|
@@ -1017,17 +1017,17 @@ func (lhh *LightHouseHandler) resetMeta() *NebulaMeta {
|
|
return lhh.meta
|
|
return lhh.meta
|
|
}
|
|
}
|
|
|
|
|
|
-func (lhh *LightHouseHandler) HandleRequest(rAddr netip.AddrPort, fromVpnAddrs []netip.Addr, p []byte, w EncWriter) {
|
|
|
|
|
|
+func (lhh *LightHouseHandler) HandleRequest(rAddr netip.AddrPort, hostinfo *HostInfo, p []byte, w EncWriter) {
|
|
n := lhh.resetMeta()
|
|
n := lhh.resetMeta()
|
|
err := n.Unmarshal(p)
|
|
err := n.Unmarshal(p)
|
|
if err != nil {
|
|
if err != nil {
|
|
- lhh.l.WithError(err).WithField("vpnAddrs", fromVpnAddrs).WithField("udpAddr", rAddr).
|
|
|
|
|
|
+ lhh.l.WithError(err).WithField("vpnAddrs", hostinfo.vpnAddrs).WithField("udpAddr", rAddr).
|
|
Error("Failed to unmarshal lighthouse packet")
|
|
Error("Failed to unmarshal lighthouse packet")
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
if n.Details == nil {
|
|
if n.Details == nil {
|
|
- lhh.l.WithField("vpnAddrs", fromVpnAddrs).WithField("udpAddr", rAddr).
|
|
|
|
|
|
+ lhh.l.WithField("vpnAddrs", hostinfo.vpnAddrs).WithField("udpAddr", rAddr).
|
|
Error("Invalid lighthouse update")
|
|
Error("Invalid lighthouse update")
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -1036,24 +1036,24 @@ func (lhh *LightHouseHandler) HandleRequest(rAddr netip.AddrPort, fromVpnAddrs [
|
|
|
|
|
|
switch n.Type {
|
|
switch n.Type {
|
|
case NebulaMeta_HostQuery:
|
|
case NebulaMeta_HostQuery:
|
|
- lhh.handleHostQuery(n, fromVpnAddrs, rAddr, w)
|
|
|
|
|
|
+ lhh.handleHostQuery(n, hostinfo, rAddr, w)
|
|
|
|
|
|
case NebulaMeta_HostQueryReply:
|
|
case NebulaMeta_HostQueryReply:
|
|
- lhh.handleHostQueryReply(n, fromVpnAddrs)
|
|
|
|
|
|
+ lhh.handleHostQueryReply(n, hostinfo.vpnAddrs)
|
|
|
|
|
|
case NebulaMeta_HostUpdateNotification:
|
|
case NebulaMeta_HostUpdateNotification:
|
|
- lhh.handleHostUpdateNotification(n, fromVpnAddrs, w)
|
|
|
|
|
|
+ lhh.handleHostUpdateNotification(n, hostinfo, w)
|
|
|
|
|
|
case NebulaMeta_HostMovedNotification:
|
|
case NebulaMeta_HostMovedNotification:
|
|
case NebulaMeta_HostPunchNotification:
|
|
case NebulaMeta_HostPunchNotification:
|
|
- lhh.handleHostPunchNotification(n, fromVpnAddrs, w)
|
|
|
|
|
|
+ lhh.handleHostPunchNotification(n, hostinfo.vpnAddrs, w)
|
|
|
|
|
|
case NebulaMeta_HostUpdateNotificationAck:
|
|
case NebulaMeta_HostUpdateNotificationAck:
|
|
// noop
|
|
// noop
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-func (lhh *LightHouseHandler) handleHostQuery(n *NebulaMeta, fromVpnAddrs []netip.Addr, addr netip.AddrPort, w EncWriter) {
|
|
|
|
|
|
+func (lhh *LightHouseHandler) handleHostQuery(n *NebulaMeta, hostinfo *HostInfo, addr netip.AddrPort, w EncWriter) {
|
|
// Exit if we don't answer queries
|
|
// Exit if we don't answer queries
|
|
if !lhh.lh.amLighthouse {
|
|
if !lhh.lh.amLighthouse {
|
|
if lhh.l.Level >= logrus.DebugLevel {
|
|
if lhh.l.Level >= logrus.DebugLevel {
|
|
@@ -1065,7 +1065,7 @@ func (lhh *LightHouseHandler) handleHostQuery(n *NebulaMeta, fromVpnAddrs []neti
|
|
queryVpnAddr, useVersion, err := n.Details.GetVpnAddrAndVersion()
|
|
queryVpnAddr, useVersion, err := n.Details.GetVpnAddrAndVersion()
|
|
if err != nil {
|
|
if err != nil {
|
|
if lhh.l.Level >= logrus.DebugLevel {
|
|
if lhh.l.Level >= logrus.DebugLevel {
|
|
- lhh.l.WithField("from", fromVpnAddrs).WithField("details", n.Details).
|
|
|
|
|
|
+ lhh.l.WithField("from", hostinfo.vpnAddrs).WithField("details", n.Details).
|
|
Debugln("Dropping malformed HostQuery")
|
|
Debugln("Dropping malformed HostQuery")
|
|
}
|
|
}
|
|
return
|
|
return
|
|
@@ -1073,7 +1073,7 @@ func (lhh *LightHouseHandler) handleHostQuery(n *NebulaMeta, fromVpnAddrs []neti
|
|
if useVersion == cert.Version1 && queryVpnAddr.Is6() {
|
|
if useVersion == cert.Version1 && queryVpnAddr.Is6() {
|
|
// this case really shouldn't be possible to represent, but reject it anyway.
|
|
// this case really shouldn't be possible to represent, but reject it anyway.
|
|
if lhh.l.Level >= logrus.DebugLevel {
|
|
if lhh.l.Level >= logrus.DebugLevel {
|
|
- lhh.l.WithField("vpnAddrs", fromVpnAddrs).WithField("queryVpnAddr", queryVpnAddr).
|
|
|
|
|
|
+ lhh.l.WithField("vpnAddrs", hostinfo.vpnAddrs).WithField("queryVpnAddr", queryVpnAddr).
|
|
Debugln("invalid vpn addr for v1 handleHostQuery")
|
|
Debugln("invalid vpn addr for v1 handleHostQuery")
|
|
}
|
|
}
|
|
return
|
|
return
|
|
@@ -1099,14 +1099,14 @@ func (lhh *LightHouseHandler) handleHostQuery(n *NebulaMeta, fromVpnAddrs []neti
|
|
}
|
|
}
|
|
|
|
|
|
if err != nil {
|
|
if err != nil {
|
|
- lhh.l.WithError(err).WithField("vpnAddrs", fromVpnAddrs).Error("Failed to marshal lighthouse host query reply")
|
|
|
|
|
|
+ lhh.l.WithError(err).WithField("vpnAddrs", hostinfo.vpnAddrs).Error("Failed to marshal lighthouse host query reply")
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
lhh.lh.metricTx(NebulaMeta_HostQueryReply, 1)
|
|
lhh.lh.metricTx(NebulaMeta_HostQueryReply, 1)
|
|
- w.SendMessageToVpnAddr(header.LightHouse, 0, fromVpnAddrs[0], lhh.pb[:ln], lhh.nb, lhh.out[:0])
|
|
|
|
|
|
+ w.SendMessageToHostInfo(header.LightHouse, 0, hostinfo, lhh.pb[:ln], lhh.nb, lhh.out[:0])
|
|
|
|
|
|
- lhh.sendHostPunchNotification(n, fromVpnAddrs, queryVpnAddr, w)
|
|
|
|
|
|
+ lhh.sendHostPunchNotification(n, hostinfo.vpnAddrs, queryVpnAddr, w)
|
|
}
|
|
}
|
|
|
|
|
|
// sendHostPunchNotification signals the other side to punch some zero byte udp packets
|
|
// sendHostPunchNotification signals the other side to punch some zero byte udp packets
|
|
@@ -1234,7 +1234,8 @@ func (lhh *LightHouseHandler) handleHostQueryReply(n *NebulaMeta, fromVpnAddrs [
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-func (lhh *LightHouseHandler) handleHostUpdateNotification(n *NebulaMeta, fromVpnAddrs []netip.Addr, w EncWriter) {
|
|
|
|
|
|
+func (lhh *LightHouseHandler) handleHostUpdateNotification(n *NebulaMeta, hostinfo *HostInfo, w EncWriter) {
|
|
|
|
+ fromVpnAddrs := hostinfo.vpnAddrs
|
|
if !lhh.lh.amLighthouse {
|
|
if !lhh.lh.amLighthouse {
|
|
if lhh.l.Level >= logrus.DebugLevel {
|
|
if lhh.l.Level >= logrus.DebugLevel {
|
|
lhh.l.Debugln("I am not a lighthouse, do not take host updates: ", fromVpnAddrs)
|
|
lhh.l.Debugln("I am not a lighthouse, do not take host updates: ", fromVpnAddrs)
|
|
@@ -1302,7 +1303,7 @@ func (lhh *LightHouseHandler) handleHostUpdateNotification(n *NebulaMeta, fromVp
|
|
}
|
|
}
|
|
|
|
|
|
lhh.lh.metricTx(NebulaMeta_HostUpdateNotificationAck, 1)
|
|
lhh.lh.metricTx(NebulaMeta_HostUpdateNotificationAck, 1)
|
|
- w.SendMessageToVpnAddr(header.LightHouse, 0, fromVpnAddrs[0], lhh.pb[:ln], lhh.nb, lhh.out[:0])
|
|
|
|
|
|
+ w.SendMessageToHostInfo(header.LightHouse, 0, hostinfo, lhh.pb[:ln], lhh.nb, lhh.out[:0])
|
|
}
|
|
}
|
|
|
|
|
|
func (lhh *LightHouseHandler) handleHostPunchNotification(n *NebulaMeta, fromVpnAddrs []netip.Addr, w EncWriter) {
|
|
func (lhh *LightHouseHandler) handleHostPunchNotification(n *NebulaMeta, fromVpnAddrs []netip.Addr, w EncWriter) {
|