Reorganise
This commit is contained in:
parent
339459d37a
commit
35262a9e03
1 changed files with 117 additions and 116 deletions
11
main.go
11
main.go
|
@ -96,6 +96,7 @@ func main() {
|
|||
if err != nil {
|
||||
log.Fatalf("Couldn't listen on udp4:387: %v", err)
|
||||
}
|
||||
defer ln.Close()
|
||||
log.Printf("Listening on %v", ln.LocalAddr())
|
||||
|
||||
log.Println("Press ^C or send SIGINT to stop the router gracefully")
|
||||
|
@ -144,11 +145,6 @@ func main() {
|
|||
// -------------------------------- Peers ---------------------------------
|
||||
// Wait until all peer handlers have finished before closing the port
|
||||
var handlersWG sync.WaitGroup
|
||||
defer func() {
|
||||
log.Print("Waiting for handlers to return...")
|
||||
handlersWG.Wait()
|
||||
ln.Close()
|
||||
}()
|
||||
goPeerHandler := func(p *router.Peer) {
|
||||
handlersWG.Add(1)
|
||||
go func() {
|
||||
|
@ -370,6 +366,7 @@ func main() {
|
|||
}()
|
||||
|
||||
// ----------------------------- AURP inbound -----------------------------
|
||||
go func() {
|
||||
ctx, setStatus, done := status.AddSimpleItem(ctx, "AURP inbound")
|
||||
defer done()
|
||||
setStatus("Running")
|
||||
|
@ -500,6 +497,10 @@ func main() {
|
|||
log.Printf("AURP: Got unknown packet type %v", dh.PacketType)
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
// -------------------------------- Close ---------------------------------
|
||||
handlersWG.Wait()
|
||||
}
|
||||
|
||||
// Hashable net.UDPAddr
|
||||
|
|
Loading…
Reference in a new issue