Skip to content

Commit 03498a0

Browse files
authored
Make nebula advertise its dynamic port to lighthouses (slackhq#653)
1 parent 312a01d commit 03498a0

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

lighthouse.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,15 @@ func NewLightHouseFromConfig(l *logrus.Logger, c *config.C, myVpnNet *net.IPNet,
7878
return nil, util.NewContextualError("lighthouse.am_lighthouse enabled on node but no port number is set in config", nil, nil)
7979
}
8080

81+
// If port is dynamic, discover it
82+
if nebulaPort == 0 && pc != nil {
83+
uPort, err := pc.LocalAddr()
84+
if err != nil {
85+
return nil, util.NewContextualError("Failed to get listening port", nil, err)
86+
}
87+
nebulaPort = uint32(uPort.Port)
88+
}
89+
8190
ones, _ := myVpnNet.Mask.Size()
8291
h := LightHouse{
8392
amLighthouse: amLighthouse,

main.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,6 @@ func Main(c *config.C, configTest bool, buildVersion string, logger *logrus.Logg
158158
}
159159
udpServer.ReloadConfig(c)
160160
udpConns[i] = udpServer
161-
162-
// If port is dynamic, discover it
163-
if port == 0 {
164-
uPort, err := udpServer.LocalAddr()
165-
if err != nil {
166-
return nil, util.NewContextualError("Failed to get listening port", nil, err)
167-
}
168-
port = int(uPort.Port)
169-
}
170161
}
171162
}
172163

0 commit comments

Comments
 (0)