WIP
This commit is contained in:
20
peer/app.go
20
peer/app.go
@@ -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())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user