Skip to content

Commit

Permalink
Support stand alone STUN server mode
Browse files Browse the repository at this point in the history
Running in stand alone STUN server does not start
due to packet conn config requiring relay address config
during validation.

To enable that mode, bypass validation if relay address config
in packet conn config is nil.

Note that it is still validated in `ListenerConfig`.
  • Loading branch information
boks1971 committed Apr 4, 2024
1 parent 40c468b commit ce7c722
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions server_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,12 @@ func (c *PacketConnConfig) validate() error {
if c.PacketConn == nil {
return errConnUnset
}
if c.RelayAddressGenerator == nil {
return errRelayAddressGeneratorUnset

if c.RelayAddressGenerator != nil {
return c.RelayAddressGenerator.Validate()

Check warning on line 62 in server_config.go

View check run for this annotation

Codecov / codecov/patch

server_config.go#L61-L62

Added lines #L61 - L62 were not covered by tests
}

return c.RelayAddressGenerator.Validate()
return nil

Check warning on line 65 in server_config.go

View check run for this annotation

Codecov / codecov/patch

server_config.go#L65

Added line #L65 was not covered by tests
}

// ListenerConfig is a single net.Listener to accept connections on. This will be used for TCP, TLS and DTLS listeners
Expand Down

0 comments on commit ce7c722

Please sign in to comment.