@@ -50,8 +50,11 @@ func NewUDPConn(config *AllocationConfig) *UDPConn {
5050 allocation : allocation {
5151 client : config .Client ,
5252 relayedAddr : config .RelayedAddr ,
53+ serverAddr : config .ServerAddr ,
5354 readTimer : time .NewTimer (time .Duration (math .MaxInt64 )),
5455 permMap : newPermissionMap (),
56+ username : config .Username ,
57+ realm : config .Realm ,
5558 integrity : config .Integrity ,
5659 _nonce : config .Nonce ,
5760 _lifetime : config .Lifetime ,
@@ -220,7 +223,7 @@ func (c *UDPConn) WriteTo(p []byte, addr net.Addr) (int, error) { //nolint: goco
220223
221224 // Indication has no transaction (fire-and-forget)
222225
223- return c .client .WriteTo (msg .Raw , c .client . TURNServerAddr () )
226+ return c .client .WriteTo (msg .Raw , c .serverAddr )
224227 }
225228
226229 // Binding is either ready
@@ -346,8 +349,8 @@ func (a *allocation) CreatePermissions(addrs ...net.Addr) error {
346349 }
347350
348351 setters = append (setters ,
349- a .client . Username () ,
350- a .client . Realm () ,
352+ a .username ,
353+ a .realm ,
351354 a .nonce (),
352355 a .integrity ,
353356 stun .Fingerprint )
@@ -357,7 +360,7 @@ func (a *allocation) CreatePermissions(addrs ...net.Addr) error {
357360 return err
358361 }
359362
360- trRes , err := a .client .PerformTransaction (msg , a .client . TURNServerAddr () , false )
363+ trRes , err := a .client .PerformTransaction (msg , a .serverAddr , false )
361364 if err != nil {
362365 return err
363366 }
@@ -408,8 +411,8 @@ func (c *UDPConn) bind(b *binding) error {
408411 stun .NewType (stun .MethodChannelBind , stun .ClassRequest ),
409412 addr2PeerAddress (b .addr ),
410413 proto .ChannelNumber (b .number ),
411- c .client . Username () ,
412- c .client . Realm () ,
414+ c .username ,
415+ c .realm ,
413416 c .nonce (),
414417 c .integrity ,
415418 stun .Fingerprint ,
@@ -420,7 +423,7 @@ func (c *UDPConn) bind(b *binding) error {
420423 return err
421424 }
422425
423- trRes , err := c .client .PerformTransaction (msg , c .client . TURNServerAddr () , false )
426+ trRes , err := c .client .PerformTransaction (msg , c .serverAddr , false )
424427 if err != nil {
425428 c .bindingMgr .deleteByAddr (b .addr )
426429 return err
@@ -444,7 +447,7 @@ func (c *UDPConn) sendChannelData(data []byte, chNum uint16) (int, error) {
444447 Number : proto .ChannelNumber (chNum ),
445448 }
446449 chData .Encode ()
447- _ , err := c .client .WriteTo (chData .Raw , c .client . TURNServerAddr () )
450+ _ , err := c .client .WriteTo (chData .Raw , c .serverAddr )
448451 if err != nil {
449452 return 0 , err
450453 }
0 commit comments