mirror of
https://github.com/fosrl/olm.git
synced 2026-02-08 05:56:41 +00:00
Remove exit nodes from HPing if peers are removed
This commit is contained in:
2
go.mod
2
go.mod
@@ -75,3 +75,5 @@ require (
|
|||||||
google.golang.org/protobuf v1.36.8 // indirect
|
google.golang.org/protobuf v1.36.8 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
)
|
)
|
||||||
|
|
||||||
|
replace github.com/fosrl/newt => ../newt
|
||||||
|
|||||||
11
olm/olm.go
11
olm/olm.go
@@ -566,6 +566,14 @@ func StartTunnel(config TunnelConfig) {
|
|||||||
return
|
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
|
// Remove successful
|
||||||
logger.Info("Successfully removed peer for site %d", removeData.SiteId)
|
logger.Info("Successfully removed peer for site %d", removeData.SiteId)
|
||||||
})
|
})
|
||||||
@@ -798,10 +806,12 @@ func StartTunnel(config TunnelConfig) {
|
|||||||
relayPort = 21820 // default relay port
|
relayPort = 21820 // default relay port
|
||||||
}
|
}
|
||||||
|
|
||||||
|
siteId := handshakeData.SiteId
|
||||||
exitNode := holepunch.ExitNode{
|
exitNode := holepunch.ExitNode{
|
||||||
Endpoint: handshakeData.ExitNode.Endpoint,
|
Endpoint: handshakeData.ExitNode.Endpoint,
|
||||||
RelayPort: relayPort,
|
RelayPort: relayPort,
|
||||||
PublicKey: handshakeData.ExitNode.PublicKey,
|
PublicKey: handshakeData.ExitNode.PublicKey,
|
||||||
|
SiteIds: []int{siteId},
|
||||||
}
|
}
|
||||||
|
|
||||||
added := holePunchManager.AddExitNode(exitNode)
|
added := holePunchManager.AddExitNode(exitNode)
|
||||||
@@ -894,6 +904,7 @@ func StartTunnel(config TunnelConfig) {
|
|||||||
Endpoint: node.Endpoint,
|
Endpoint: node.Endpoint,
|
||||||
RelayPort: relayPort,
|
RelayPort: relayPort,
|
||||||
PublicKey: node.PublicKey,
|
PublicKey: node.PublicKey,
|
||||||
|
SiteIds: node.SiteIds,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ type ExitNode struct {
|
|||||||
Endpoint string `json:"endpoint"`
|
Endpoint string `json:"endpoint"`
|
||||||
RelayPort uint16 `json:"relayPort"`
|
RelayPort uint16 `json:"relayPort"`
|
||||||
PublicKey string `json:"publicKey"`
|
PublicKey string `json:"publicKey"`
|
||||||
|
SiteIds []int `json:"siteIds"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type WSMessage struct {
|
type WSMessage struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user