lib/stun: Prevent nil deref when naming service (#7872)

This commit is contained in:
Simon Frei
2021-08-05 01:04:22 +02:00
committed by GitHub
parent 50aacdf1f0
commit e61091d240

View File

@@ -107,8 +107,14 @@ func New(cfg config.Wrapper, subscriber Subscriber, conn *net.UDPConn) (*Service
client.SetSoftwareName("") // Explicitly unset this, seems to freak some servers out.
// Return the service and the other conn to the client
name := "Stun@"
if local := conn.LocalAddr(); local != nil {
name += local.Network() + "://" + local.String()
} else {
name += "unknown"
}
s := &Service{
name: "Stun@" + conn.LocalAddr().Network() + "://" + conn.LocalAddr().String(),
name: name,
cfg: cfg,
subscriber: subscriber,