more route table data

This commit is contained in:
Josh Deprez 2024-04-26 13:22:48 +10:00
parent cee10fac06
commit 60183999af
No known key found for this signature in database
3 changed files with 11 additions and 3 deletions

10
main.go
View file

@ -18,6 +18,7 @@ package main
import (
"bufio"
"cmp"
"context"
"errors"
"flag"
@ -31,6 +32,7 @@ import (
"os/signal"
"regexp"
"runtime/debug"
"slices"
"strings"
"sync"
"time"
@ -52,6 +54,7 @@ const routingTableTemplate = `
<th>Extended?</th>
<th>Distance</th>
<th>Last seen<th>
<th>Port</th>
</tr></thead>
<tbody>
{{range $route := . }}
@ -60,6 +63,7 @@ const routingTableTemplate = `
<td>{{if $route.Extended}}{{else}}{{end}}</td>
<td>{{$route.Distance}}</td>
<td>{{$route.LastSeenAgo}}</td>
<td>{{if $route.Peer}}{{$route.Peer.RemoteAddr}}{{else}}-{{end}}</td>
</tr>
{{end}}
</tbody>
@ -165,7 +169,11 @@ func main() {
// -------------------------------- Tables --------------------------------
routes := router.NewRoutingTable()
_, done := status.AddItem(ctx, "Routing table", routingTableTemplate, func(context.Context) (any, error) {
return routes.Dump(), nil
rs := routes.Dump()
slices.SortFunc(rs, func(ra, rb router.Route) int {
return cmp.Compare(ra.NetStart, rb.NetStart)
})
return rs, nil
})
defer done()

View file

@ -387,7 +387,7 @@ func (p *Peer) Handle(ctx context.Context) error {
ddp.Network(nt.RangeStart),
ddp.Network(nt.RangeEnd),
p,
nt.Distance,
nt.Distance+1,
)
}

View file

@ -226,7 +226,7 @@ func (m *RTMPMachine) dataPackets(myAddr ddp.Addr) []*rtmp.DataPacket {
Extended: rt.Extended,
RangeStart: rt.NetStart,
RangeEnd: rt.NetEnd,
Distance: rt.Distance + 1,
Distance: rt.Distance,
})
}
// "The first tuple in RTMP Data packets sent on extended