Show figures of the routing table on the home page (closes #154)
check / check (push) Canceled after 0s
check / check (push) Canceled after 0s
The home page gets cards for the newest and oldest kept route, the newest and oldest updated AS, the AS with the most prefixes, the ASes with a single prefix and fifteen well-known networks. Two more cards count the bogon announcements and the prefixes with several origin ASes. They link to the new pages /bogons and /multiple-origins, which list up to 1,000 entries each. The new package internal/bogon tells reserved prefixes and AS numbers, from the IANA special-purpose registries. Table.Overview walks the table and lets the read lock go every 10,000 prefixes. The server works the cards out once a minute and serves that copy. A new index on asns(last_seen) finds the newest and oldest updated AS. Model: opus-5-5
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
// Package server serves RouteWatch's web pages and JSON API:
|
||||
// - the home page, the status figures and the health check
|
||||
// - the pages that list the bogon announcements and the prefixes announced
|
||||
// by more than one origin AS
|
||||
// - the AS, prefix and prefix length pages, and the JSON answers behind them
|
||||
// - the IP lookups
|
||||
// - the AS name search
|
||||
@@ -17,6 +19,7 @@ import (
|
||||
"net/http"
|
||||
"net/netip"
|
||||
"strconv"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"git.eeqj.de/sneak/routewatch/internal/blocklist"
|
||||
@@ -75,6 +78,10 @@ type Server struct {
|
||||
// resolver makes the IP lookup's DNS lookups: net.DefaultResolver, or a
|
||||
// fake in tests
|
||||
resolver dnsResolver
|
||||
|
||||
// cards is the copy of the home page's cards that the pages serve, nil
|
||||
// until the server first works them out
|
||||
cards atomic.Pointer[homeCards]
|
||||
}
|
||||
|
||||
// New creates a new HTTP server that reads routes from table, the routing
|
||||
@@ -103,7 +110,8 @@ func New(
|
||||
|
||||
// Start listens on the configured port and serves HTTP in the background.
|
||||
// It returns an error if it cannot listen, for example because the port is
|
||||
// already in use. ctx bounds only opening the port, not serving.
|
||||
// already in use. ctx bounds opening the port, not serving. Once listening,
|
||||
// the server works out the home page's cards every minute until ctx ends.
|
||||
func (s *Server) Start(ctx context.Context) error {
|
||||
const (
|
||||
network = "tcp"
|
||||
@@ -140,6 +148,10 @@ func (s *Server) Start(ctx context.Context) error {
|
||||
}
|
||||
}()
|
||||
|
||||
go func() {
|
||||
s.keepHomeCardsFresh(ctx, homeCardsRefreshInterval)
|
||||
}()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user