net/portmapper: fix nil pointer dereference in Client.createMapping

The EventBus in net/portmapper.Config is still optional and Client.updates can be nil.

Updates #15772

Signed-off-by: Nick Khyl <nickk@tailscale.com>
This commit is contained in:
Nick Khyl 2025-04-23 09:35:14 -05:00 committed by chaosinthecrd
parent 65c6dfc0e5
commit b224c94683
No known key found for this signature in database
GPG Key ID: 87942E75F71EF65D

View File

@ -508,11 +508,13 @@ func (c *Client) createMapping() {
}
return
}
c.updates.Publish(Mapping{
External: mapping.External(),
Type: mapping.MappingType(),
GoodUntil: mapping.GoodUntil(),
})
if c.updates != nil {
c.updates.Publish(Mapping{
External: mapping.External(),
Type: mapping.MappingType(),
GoodUntil: mapping.GoodUntil(),
})
}
if c.onChange != nil {
go c.onChange()
}