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