Compare commits
4 commits
9c808cbf63
...
9b4633b745
Author | SHA1 | Date | |
---|---|---|---|
9b4633b745 | |||
e31a79da90 | |||
5f32d1960d | |||
66e59320b8 |
2 changed files with 16 additions and 16 deletions
26
main.go
26
main.go
|
@ -65,13 +65,13 @@ const routingTableTemplate = `
|
||||||
<td>{{$route.LastSeenAgo}}</td>
|
<td>{{$route.LastSeenAgo}}</td>
|
||||||
<td>
|
<td>
|
||||||
{{- with $route.AURPPeer -}}
|
{{- with $route.AURPPeer -}}
|
||||||
{{.RemoteAddr}}
|
[redacted]
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{- with $route.EtherTalkPeer -}}
|
{{- with $route.EtherTalkPeer -}}
|
||||||
{{.Port.Device}} {{.PeerAddr.Network}}.{{.PeerAddr.Node}}
|
{{.Port.Device}} {{.PeerAddr.Network}}.{{.PeerAddr.Node}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{- with $route.EtherTalkDirect -}}
|
{{- with $route.EtherTalkDirect -}}
|
||||||
{{.Device}} {{.NetStart}}-{{.NetEnd}}
|
{{.Device}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -96,8 +96,8 @@ const peerTableTemplate = `
|
||||||
<tbody>
|
<tbody>
|
||||||
{{range $peer := . }}
|
{{range $peer := . }}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{$peer.ConfiguredAddr}}</td>
|
<td>[redacted]</td>
|
||||||
<td>{{$peer.RemoteAddr}}</td>
|
<td>[redacted]</td>
|
||||||
<td>{{$peer.ReceiverState}}</td>
|
<td>{{$peer.ReceiverState}}</td>
|
||||||
<td>{{$peer.SenderState}}</td>
|
<td>{{$peer.SenderState}}</td>
|
||||||
<td>{{$peer.LastHeardFromAgo}}</td>
|
<td>{{$peer.LastHeardFromAgo}}</td>
|
||||||
|
@ -152,9 +152,9 @@ func main() {
|
||||||
}
|
}
|
||||||
localDI := aurp.IPDomainIdentifier(localIP)
|
localDI := aurp.IPDomainIdentifier(localIP)
|
||||||
|
|
||||||
log.Printf("Using %v as local domain identifier", localIP)
|
// log.Printf("Using %v as local domain identifier", localIP)
|
||||||
|
|
||||||
log.Printf("EtherTalk configuration: %+v", cfg.EtherTalk)
|
// log.Printf("EtherTalk configuration: %+v", cfg.EtherTalk)
|
||||||
|
|
||||||
ln, err := net.ListenUDP("udp4", &net.UDPAddr{Port: int(cfg.ListenPort)})
|
ln, err := net.ListenUDP("udp4", &net.UDPAddr{Port: int(cfg.ListenPort)})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -256,12 +256,12 @@ func main() {
|
||||||
|
|
||||||
// ------------------------- Configured peer setup ------------------------
|
// ------------------------- Configured peer setup ------------------------
|
||||||
if cfg.PeerListURL != "" {
|
if cfg.PeerListURL != "" {
|
||||||
log.Printf("Fetching peer list from %s...", cfg.PeerListURL)
|
log.Print("Fetching peer list...")
|
||||||
existing := len(cfg.Peers)
|
existing := len(cfg.Peers)
|
||||||
func() {
|
func() {
|
||||||
resp, err := http.Get(cfg.PeerListURL)
|
resp, err := http.Get(cfg.PeerListURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Couldn't fetch peer list: %v", err)
|
log.Fatalf("Couldn't fetch peer list!")
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
@ -287,13 +287,13 @@ func main() {
|
||||||
|
|
||||||
raddr, err := net.ResolveUDPAddr("udp4", peerStr)
|
raddr, err := net.ResolveUDPAddr("udp4", peerStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("couldn't resolve UDP address, skipping: %v", err)
|
log.Print("couldn't resolve UDP address, skipping peer")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
log.Printf("resolved %q to %v", peerStr, raddr)
|
//log.Printf("resolved %q to %v", peerStr, raddr)
|
||||||
|
|
||||||
if raddr.IP.Equal(localIP) {
|
if raddr.IP.Equal(localIP) {
|
||||||
log.Printf("%v == %v == me, skipping", peerStr, raddr)
|
//log.Print("peer == me, skipping")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -380,7 +380,7 @@ func main() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("AURP: Got %T from %v (%v)", pkt, raddr, dh.SourceDI)
|
// log.Printf("AURP: Got %T from %v (%v)", pkt, raddr, dh.SourceDI)
|
||||||
|
|
||||||
// Existing peer?
|
// Existing peer?
|
||||||
ra := udpAddrFromNet(raddr)
|
ra := udpAddrFromNet(raddr)
|
||||||
|
@ -388,7 +388,7 @@ func main() {
|
||||||
pr := peers[ra]
|
pr := peers[ra]
|
||||||
if pr == nil {
|
if pr == nil {
|
||||||
if !cfg.OpenPeering {
|
if !cfg.OpenPeering {
|
||||||
log.Printf("AURP: Got packet from %v but it's not in my config and open peering is disabled; dropping the packet", raddr)
|
log.Print("AURP: Got packet but it's not in my config and open peering is disabled; dropping the packet")
|
||||||
peersMu.Unlock()
|
peersMu.Unlock()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
|
@ -295,7 +295,7 @@ func (p *AURPPeer) send(pkt aurp.Packet) (int, error) {
|
||||||
if _, err := pkt.WriteTo(&b); err != nil {
|
if _, err := pkt.WriteTo(&b); err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
log.Printf("AURP Peer: Sending %T (len %d) to %v", pkt, b.Len(), p.RemoteAddr)
|
// log.Printf("AURP Peer: Sending %T (len %d) to %v", pkt, b.Len(), p.RemoteAddr)
|
||||||
return p.UDPConn.WriteToUDP(b.Bytes(), p.RemoteAddr)
|
return p.UDPConn.WriteToUDP(b.Bytes(), p.RemoteAddr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -442,10 +442,10 @@ func (p *AURPPeer) Handle(ctx context.Context) error {
|
||||||
// In case it's a DNS name, re-resolve it before reconnecting
|
// In case it's a DNS name, re-resolve it before reconnecting
|
||||||
raddr, err := net.ResolveUDPAddr("udp4", p.ConfiguredAddr)
|
raddr, err := net.ResolveUDPAddr("udp4", p.ConfiguredAddr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("couldn't resolve UDP address, skipping: %v", err)
|
log.Print("couldn't resolve UDP address, skipping")
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
log.Printf("AURP Peer: resolved %q to %v", p.ConfiguredAddr, raddr)
|
// log.Printf("AURP Peer: resolved %q to %v", p.ConfiguredAddr, raddr)
|
||||||
p.RemoteAddr = raddr
|
p.RemoteAddr = raddr
|
||||||
|
|
||||||
p.bumpLastReconnect()
|
p.bumpLastReconnect()
|
||||||
|
|
Loading…
Reference in a new issue