Compare commits

...

2 commits

Author SHA1 Message Date
6e97109946
Redact list source 2024-05-08 15:41:39 +10:00
67daa8a4ae
Remove IP addresses from logs and status page 2024-05-08 15:33:42 +10:00
2 changed files with 17 additions and 17 deletions

26
main.go
View file

@ -65,13 +65,13 @@ const routingTableTemplate = `
<td>{{$route.LastSeenAgo}}</td>
<td>
{{- with $route.AURPPeer -}}
{{.RemoteAddr}}
[redacted]
{{- end -}}
{{- with $route.EtherTalkPeer -}}
{{.Port.Device}} {{.PeerAddr.Network}}.{{.PeerAddr.Node}}
{{- end -}}
{{- with $route.EtherTalkDirect -}}
{{.Device}} {{.NetStart}}-{{.NetEnd}}
{{.Device}}
{{- end -}}
</td>
</tr>
@ -91,8 +91,8 @@ const peerTableTemplate = `
<tbody>
{{range $peer := . }}
<tr>
<td>{{$peer.ConfiguredAddr}}</td>
<td>{{$peer.RemoteAddr}}</td>
<td>[redacted]</td>
<td>[redacted]</td>
<td>{{$peer.ReceiverState}}</td>
<td>{{$peer.SenderState}}</td>
</tr>
@ -142,9 +142,9 @@ func main() {
}
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)})
if err != nil {
@ -246,12 +246,12 @@ func main() {
// ------------------------- Configured peer setup ------------------------
if cfg.PeerListURL != "" {
log.Printf("Fetching peer list from %s...", cfg.PeerListURL)
log.Print("Fetching peer list...")
existing := len(cfg.Peers)
func() {
resp, err := http.Get(cfg.PeerListURL)
if err != nil {
log.Fatalf("Couldn't fetch peer list: %v", err)
log.Fatalf("Couldn't fetch peer list!")
}
defer resp.Body.Close()
@ -277,13 +277,13 @@ func main() {
raddr, err := net.ResolveUDPAddr("udp4", peerStr)
if err != nil {
log.Printf("couldn't resolve UDP address, skipping: %v", err)
log.Print("couldn't resolve UDP address, skipping peer")
continue
}
log.Printf("resolved %q to %v", peerStr, raddr)
//log.Printf("resolved %q to %v", peerStr, raddr)
if raddr.IP.Equal(localIP) {
log.Printf("%v == %v == me, skipping", peerStr, raddr)
//log.Print("peer == me, skipping")
continue
}
@ -381,7 +381,7 @@ func main() {
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?
ra := udpAddrFromNet(raddr)
@ -389,7 +389,7 @@ func main() {
pr := peers[ra]
if pr == nil {
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()
continue
}

View file

@ -165,7 +165,7 @@ func (p *AURPPeer) Send(pkt aurp.Packet) (int, error) {
if _, err := pkt.WriteTo(&b); err != nil {
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)
}
@ -284,7 +284,7 @@ func (p *AURPPeer) Handle(ctx context.Context) error {
// send a null RI-Upd to check if the sender is also unconnected
if p.sstate == SenderConnected && time.Since(lastSend) > sendRetryTimer {
if sendRetries >= sendRetryLimit {
log.Printf("AURP Peer: Send retry limit reached while probing sender connect, closing connection")
log.Print("AURP Peer: Send retry limit reached while probing sender connect, closing connection")
}
sendRetries++
lastSend = time.Now()
@ -309,10 +309,10 @@ func (p *AURPPeer) Handle(ctx context.Context) error {
// In case it's a DNS name, re-resolve it before reconnecting
raddr, err := net.ResolveUDPAddr("udp4", p.ConfiguredAddr)
if err != nil {
log.Printf("couldn't resolve UDP address, skipping: %v", err)
log.Print("couldn't resolve UDP address, skipping")
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
lastReconnect = time.Now()