From 57c47279dde46392fcc811553ef1052928c54a3e Mon Sep 17 00:00:00 2001 From: boks1971 Date: Thu, 4 Apr 2024 12:42:25 +0530 Subject: [PATCH] Support stand alone STUN server mode 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`. --- server_config.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/server_config.go b/server_config.go index ee808fe9..eaa7a258 100644 --- a/server_config.go +++ b/server_config.go @@ -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 + } } - 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