Remove exit nodes from HPing if peers are removed

This commit is contained in:
Owen
2025-12-18 15:04:20 -05:00
parent de18c0cc6d
commit a4365988eb
3 changed files with 14 additions and 0 deletions

2
go.mod
View File

@@ -75,3 +75,5 @@ require (
google.golang.org/protobuf v1.36.8 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
replace github.com/fosrl/newt => ../newt

View File

@@ -566,6 +566,14 @@ func StartTunnel(config TunnelConfig) {
return
}
// Remove any exit nodes associated with this peer from hole punching
if holePunchManager != nil {
removed := holePunchManager.RemoveExitNodesByPeer(removeData.SiteId)
if removed > 0 {
logger.Info("Removed %d exit nodes associated with peer %d from hole punch rotation", removed, removeData.SiteId)
}
}
// Remove successful
logger.Info("Successfully removed peer for site %d", removeData.SiteId)
})
@@ -798,10 +806,12 @@ func StartTunnel(config TunnelConfig) {
relayPort = 21820 // default relay port
}
siteId := handshakeData.SiteId
exitNode := holepunch.ExitNode{
Endpoint: handshakeData.ExitNode.Endpoint,
RelayPort: relayPort,
PublicKey: handshakeData.ExitNode.PublicKey,
SiteIds: []int{siteId},
}
added := holePunchManager.AddExitNode(exitNode)
@@ -894,6 +904,7 @@ func StartTunnel(config TunnelConfig) {
Endpoint: node.Endpoint,
RelayPort: relayPort,
PublicKey: node.PublicKey,
SiteIds: node.SiteIds,
}
}

View File

@@ -50,6 +50,7 @@ type ExitNode struct {
Endpoint string `json:"endpoint"`
RelayPort uint16 `json:"relayPort"`
PublicKey string `json:"publicKey"`
SiteIds []int `json:"siteIds"`
}
type WSMessage struct {