This commit is contained in:
jdl
2026-06-10 18:52:11 +02:00
parent bb28b8f340
commit db78964033
13 changed files with 373 additions and 62 deletions

View File

@@ -25,6 +25,7 @@ const (
type HubPeer struct {
PubKey wgtypes.Key
VPNIP netip.Addr
Name string
IsRelay bool
IsPublic bool
EndpointV4 netip.AddrPort // zero if none
@@ -47,12 +48,13 @@ type MulticastEvent struct {
// accessed only from the Run goroutine.
type App struct {
// Identity
vpnIP netip.Addr
vpnNet netip.Prefix
privKey wgtypes.Key
pubKey wgtypes.Key
isRelay bool
isPublic bool
vpnIP netip.Addr
vpnNet netip.Prefix
privKey wgtypes.Key
pubKey wgtypes.Key
isRelay bool
isPublic bool
localDomain string
// Infrastructure
dev WGDevice
@@ -76,6 +78,11 @@ type App struct {
// Run is the main event loop. It runs until SIGTERM/SIGINT.
func (a *App) Run() error {
// Establish a clean hosts section before the first poll lands, clearing
// any stale entries left by a prior run (e.g. crash, or peers removed
// while we were down).
a.updateHosts()
ticker := time.NewTicker(PingInterval)
defer ticker.Stop()
@@ -102,5 +109,6 @@ func (a *App) Run() error {
}
func (a *App) onShutdown() error {
// TODO: removeHosts() ?
return wginterface.Delete(a.dev.Name())
}