Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions gather.go
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,8 @@
relAddr string
relPort int
relayProtocol string

omitTurnServerAddr bool
)

switch {
Expand Down Expand Up @@ -721,6 +723,11 @@
}
locConn = turn.NewSTUNConn(conn)

// We don't need to resolve address of the turn server, since we are using
// proxy dialer.
if _, err = a.net.ResolveUDPAddr("udp4", turnServerAddr); err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't we always omit the TURN Server Addr now?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the proxy case, the TURN address is only used only for debug logging. So maybe completely skipping it is too much? Some might find having the address in the logs useful for debugging. What do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it would be possible to make this happen internally in the TURN package? Otherwise every user of the package has to do this check.

I think we should remove it personally. It confused me, and I imagine people in the future won't understand the purpose (and delete or modify)

Copy link
Author

@amanakin amanakin Apr 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only viable approach I can see on the turn library side is to add IgnoreTURNResolveError flag to this configuration struct: https://github.com/pion/turn/blob/master/client.go#L39

And it breaks the minimalism of the config, unfortunately :(

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Sean-Der Sorry for the delay.
We can try to do something like that pion/turn#455 on the TURN package.
And then in the ICE package we will just propagate IgnoreTURNResolveErrors=true in case of a proxy connection.

WDYT?

omitTurnServerAddr = true
}

Check warning on line 730 in gather.go

View check run for this annotation

Codecov / codecov/patch

gather.go#L729-L730

Added lines #L729 - L730 were not covered by tests
case url.Proto == stun.ProtoTypeTCP && url.Scheme == stun.SchemeTypeTURN:
tcpAddr, connectErr := a.net.ResolveTCPAddr(NetworkTypeTCP4.String(), turnServerAddr)
if connectErr != nil {
Expand Down Expand Up @@ -815,14 +822,18 @@
return
}

client, err := turn.NewClient(&turn.ClientConfig{
TURNServerAddr: turnServerAddr,
Conn: locConn,
Username: url.Username,
Password: url.Password,
LoggerFactory: a.loggerFactory,
Net: a.net,
})
clientCfg := &turn.ClientConfig{
Conn: locConn,
Username: url.Username,
Password: url.Password,
LoggerFactory: a.loggerFactory,
Net: a.net,
}
if !omitTurnServerAddr {
clientCfg.TURNServerAddr = turnServerAddr
}

client, err := turn.NewClient(clientCfg)
if err != nil {
closeConnAndLog(locConn, a.log, "failed to create new TURN client %s %s", turnServerAddr, err)

Expand Down
Loading