@@ -17,6 +17,7 @@ import (
1717 "github.com/pion/ice/v2/internal/fakenet"
1818 stunx "github.com/pion/ice/v2/internal/stun"
1919 "github.com/pion/logging"
20+ "github.com/pion/stun"
2021 "github.com/pion/turn/v2"
2122)
2223
@@ -376,7 +377,7 @@ func (a *Agent) gatherCandidatesSrflxMapped(ctx context.Context, networkTypes []
376377 }
377378}
378379
379- func (a * Agent ) gatherCandidatesSrflxUDPMux (ctx context.Context , urls []* URL , networkTypes []NetworkType ) { //nolint:gocognit
380+ func (a * Agent ) gatherCandidatesSrflxUDPMux (ctx context.Context , urls []* stun. URI , networkTypes []NetworkType ) { //nolint:gocognit
380381 var wg sync.WaitGroup
381382 defer wg .Wait ()
382383
@@ -393,7 +394,7 @@ func (a *Agent) gatherCandidatesSrflxUDPMux(ctx context.Context, urls []*URL, ne
393394 continue
394395 }
395396 wg .Add (1 )
396- go func (url URL , network string , localAddr * net.UDPAddr ) {
397+ go func (url stun. URI , network string , localAddr * net.UDPAddr ) {
397398 defer wg .Done ()
398399
399400 hostPort := fmt .Sprintf ("%s:%d" , url .Host , url .Port )
@@ -444,7 +445,7 @@ func (a *Agent) gatherCandidatesSrflxUDPMux(ctx context.Context, urls []*URL, ne
444445 }
445446}
446447
447- func (a * Agent ) gatherCandidatesSrflx (ctx context.Context , urls []* URL , networkTypes []NetworkType ) { //nolint:gocognit
448+ func (a * Agent ) gatherCandidatesSrflx (ctx context.Context , urls []* stun. URI , networkTypes []NetworkType ) { //nolint:gocognit
448449 var wg sync.WaitGroup
449450 defer wg .Wait ()
450451
@@ -455,7 +456,7 @@ func (a *Agent) gatherCandidatesSrflx(ctx context.Context, urls []*URL, networkT
455456
456457 for i := range urls {
457458 wg .Add (1 )
458- go func (url URL , network string ) {
459+ go func (url stun. URI , network string ) {
459460 defer wg .Done ()
460461
461462 hostPort := fmt .Sprintf ("%s:%d" , url .Host , url .Port )
@@ -518,14 +519,14 @@ func (a *Agent) gatherCandidatesSrflx(ctx context.Context, urls []*URL, networkT
518519 }
519520}
520521
521- func (a * Agent ) gatherCandidatesRelay (ctx context.Context , urls []* URL ) { //nolint:gocognit
522+ func (a * Agent ) gatherCandidatesRelay (ctx context.Context , urls []* stun. URI ) { //nolint:gocognit
522523 var wg sync.WaitGroup
523524 defer wg .Wait ()
524525
525526 network := NetworkTypeUDP4 .String ()
526527 for i := range urls {
527528 switch {
528- case urls [i ].Scheme != SchemeTypeTURN && urls [i ].Scheme != SchemeTypeTURNS :
529+ case urls [i ].Scheme != stun . SchemeTypeTURN && urls [i ].Scheme != stun . SchemeTypeTURNS :
529530 continue
530531 case urls [i ].Username == "" :
531532 a .log .Errorf ("Failed to gather relay candidates: %v" , ErrUsernameEmpty )
@@ -536,7 +537,7 @@ func (a *Agent) gatherCandidatesRelay(ctx context.Context, urls []*URL) { //noli
536537 }
537538
538539 wg .Add (1 )
539- go func (url URL ) {
540+ go func (url stun. URI ) {
540541 defer wg .Done ()
541542 turnServerAddr := fmt .Sprintf ("%s:%d" , url .Host , url .Port )
542543 var (
@@ -548,7 +549,7 @@ func (a *Agent) gatherCandidatesRelay(ctx context.Context, urls []*URL) { //noli
548549 )
549550
550551 switch {
551- case url .Proto == ProtoTypeUDP && url .Scheme == SchemeTypeTURN :
552+ case url .Proto == stun . ProtoTypeUDP && url .Scheme == stun . SchemeTypeTURN :
552553 if locConn , err = a .net .ListenPacket (network , "0.0.0.0:0" ); err != nil {
553554 a .log .Warnf ("Failed to listen %s: %v" , network , err )
554555 return
@@ -557,8 +558,8 @@ func (a *Agent) gatherCandidatesRelay(ctx context.Context, urls []*URL) { //noli
557558 relAddr = locConn .LocalAddr ().(* net.UDPAddr ).IP .String () //nolint:forcetypeassert
558559 relPort = locConn .LocalAddr ().(* net.UDPAddr ).Port //nolint:forcetypeassert
559560 relayProtocol = udp
560- case a .proxyDialer != nil && url .Proto == ProtoTypeTCP &&
561- (url .Scheme == SchemeTypeTURN || url .Scheme == SchemeTypeTURNS ):
561+ case a .proxyDialer != nil && url .Proto == stun . ProtoTypeTCP &&
562+ (url .Scheme == stun . SchemeTypeTURN || url .Scheme == stun . SchemeTypeTURNS ):
562563 conn , connectErr := a .proxyDialer .Dial (NetworkTypeTCP4 .String (), turnServerAddr )
563564 if connectErr != nil {
564565 a .log .Warnf ("Failed to dial TCP address %s via proxy dialer: %v" , turnServerAddr , connectErr )
@@ -567,14 +568,14 @@ func (a *Agent) gatherCandidatesRelay(ctx context.Context, urls []*URL) { //noli
567568
568569 relAddr = conn .LocalAddr ().(* net.TCPAddr ).IP .String () //nolint:forcetypeassert
569570 relPort = conn .LocalAddr ().(* net.TCPAddr ).Port //nolint:forcetypeassert
570- if url .Scheme == SchemeTypeTURN {
571+ if url .Scheme == stun . SchemeTypeTURN {
571572 relayProtocol = tcp
572- } else if url .Scheme == SchemeTypeTURNS {
573+ } else if url .Scheme == stun . SchemeTypeTURNS {
573574 relayProtocol = "tls"
574575 }
575576 locConn = turn .NewSTUNConn (conn )
576577
577- case url .Proto == ProtoTypeTCP && url .Scheme == SchemeTypeTURN :
578+ case url .Proto == stun . ProtoTypeTCP && url .Scheme == stun . SchemeTypeTURN :
578579 tcpAddr , connectErr := a .net .ResolveTCPAddr (NetworkTypeTCP4 .String (), turnServerAddr )
579580 if connectErr != nil {
580581 a .log .Warnf ("Failed to resolve TCP address %s: %v" , turnServerAddr , connectErr )
@@ -591,7 +592,7 @@ func (a *Agent) gatherCandidatesRelay(ctx context.Context, urls []*URL) { //noli
591592 relPort = conn .LocalAddr ().(* net.TCPAddr ).Port //nolint:forcetypeassert
592593 relayProtocol = tcp
593594 locConn = turn .NewSTUNConn (conn )
594- case url .Proto == ProtoTypeUDP && url .Scheme == SchemeTypeTURNS :
595+ case url .Proto == stun . ProtoTypeUDP && url .Scheme == stun . SchemeTypeTURNS :
595596 udpAddr , connectErr := a .net .ResolveUDPAddr (network , turnServerAddr )
596597 if connectErr != nil {
597598 a .log .Warnf ("Failed to resolve UDP address %s: %v" , turnServerAddr , connectErr )
@@ -617,7 +618,7 @@ func (a *Agent) gatherCandidatesRelay(ctx context.Context, urls []*URL) { //noli
617618 relPort = conn .LocalAddr ().(* net.UDPAddr ).Port //nolint:forcetypeassert
618619 relayProtocol = "dtls"
619620 locConn = & fakenet.PacketConn {Conn : conn }
620- case url .Proto == ProtoTypeTCP && url .Scheme == SchemeTypeTURNS :
621+ case url .Proto == stun . ProtoTypeTCP && url .Scheme == stun . SchemeTypeTURNS :
621622 tcpAddr , resolvErr := a .net .ResolveTCPAddr (NetworkTypeTCP4 .String (), turnServerAddr )
622623 if resolvErr != nil {
623624 a .log .Warnf ("Failed to resolve relay address %s: %v" , turnServerAddr , resolvErr )
0 commit comments