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 57c4727
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions server_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,14 @@ func (c *PacketConnConfig) validate() error {
if c.PacketConn == nil {
return errConnUnset
}
if c.RelayAddressGenerator == nil {
return errRelayAddressGeneratorUnset

if c.RelayAddressGenerator != nil {
if err := c.RelayAddressGenerator.Validate(); err != nil {
return err
}

Check warning on line 64 in server_config.go

View check run for this annotation

Codecov / codecov/patch

server_config.go#L63-L64

Added lines #L63 - L64 were not covered by tests
}

return c.RelayAddressGenerator.Validate()
return nil
}

// 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 57c4727

Please sign in to comment.