@@ -51,8 +51,6 @@ public class NetherNetClientChannel extends NetherNetChannel {
5151
5252 private volatile ScheduledFuture <?> handshakeTimeoutTask ;
5353
54- private volatile String localUfrag ;
55-
5654 private int retryCount = 0 ;
5755
5856 /**
@@ -204,6 +202,7 @@ private void resetAndRetryHandshake() {
204202
205203 private void initWebRTC (List <NetherNetSignaling .IceServerInfo > iceServers ) {
206204 RTCConfiguration rtcConfig = new RTCConfiguration ();
205+ rtcConfig .portAllocatorConfig = this .config .getOption (NetherChannelOption .NETHER_PORT_ALLOCATOR_CONFIG );
207206 rtcConfig .bundlePolicy = RTCBundlePolicy .MAX_BUNDLE ;
208207
209208 if (iceServers != null ) {
@@ -219,24 +218,10 @@ private void initWebRTC(List<NetherNetSignaling.IceServerInfo> iceServers) {
219218 peerConnection = factory .createPeerConnection (rtcConfig , new PeerConnectionObserver () {
220219 @ Override
221220 public void onIceCandidate (RTCIceCandidate candidate ) {
222- // Wait until we have the ufrag (usually available immediately after createOffer)
223- if (localUfrag == null ) {
224- log .warn ("Generated ICE candidate before local ufrag was available. Skipping." );
225- return ;
226- }
227-
228- String sdp = candidate .sdp .trim ();
229-
230- // Format: <StandardSDP> ufrag <LocalUfrag> network-id <LocalNetworkID> network-cost 0
231- StringBuilder sb = new StringBuilder (sdp )
232- .append (" ufrag " ).append (localUfrag )
233- .append (" network-id " ).append (signaling .getLocalNetworkId ())
234- .append (" network-cost 0" );
235-
236221 try {
237222 signaling .sendSignal (
238223 targetNetworkId ,
239- NetherNetConstants .buildSignalCandidateAdd (connectionId , sb . toString () )
224+ NetherNetConstants .buildSignalCandidateAdd (connectionId , candidate . sdp )
240225 );
241226 } catch (Exception e ) {
242227 log .error ("Failed to send ICE candidate" , e );
@@ -261,29 +246,12 @@ public void onConnectionChange(RTCPeerConnectionState state) {
261246 setupDataChannels ();
262247 }
263248
264- private String extractUfrag (String sdp ) {
265- if (sdp == null ) return "" ;
266- for (String line : sdp .split ("\\ r?\\ n" )) {
267- line = line .trim ();
268- if (line .startsWith ("a=ice-ufrag:" )) {
269- return line .substring ("a=ice-ufrag:" .length ()).trim ();
270- }
271- // Some implementations might omit 'a='
272- if (line .startsWith ("ice-ufrag:" )) {
273- return line .substring ("ice-ufrag:" .length ()).trim ();
274- }
275- }
276- log .warn ("Could not find ice-ufrag in local SDP!" );
277- return "" ;
278- }
279-
280249 private void createAndSendOffer () {
281250 if (peerConnection == null ) return ;
282251 peerConnection .createOffer (new RTCOfferOptions (), new CreateSessionDescriptionObserver () {
283252 @ Override
284253 public void onSuccess (RTCSessionDescription description ) {
285254 if (peerConnection == null ) return ;
286- NetherNetClientChannel .this .localUfrag = extractUfrag (description .sdp );
287255 peerConnection .setLocalDescription (description , new SetSessionDescriptionObserver () {
288256 @ Override
289257 public void onSuccess () {
0 commit comments