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 and address space 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 was merged in pull request #196.
This commit is contained in:
1 parent
e68be8254a
commit
281d162e27
23 files changed
+2240
-6
No files matched your search
@@ -223,6 +223,35 @@ func (m *mockStore) GetAS(_ context.Context, asn int) (*database.ASN, bool, erro
|
||||
return &database.ASN{ASN: asn}, false, nil
|
||||
}
|
||||
|
||||
// GetLastSeenASes returns copies of the stored ASes last seen most recently
|
||||
// and longest ago, or neither when none is stored.
|
||||
func (m *mockStore) GetLastSeenASes(
|
||||
_ context.Context,
|
||||
) (*database.ASN, *database.ASN, error) {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
|
||||
var newest, oldest *database.ASN
|
||||
|
||||
for _, asn := range m.ASNs {
|
||||
if newest == nil || asn.LastSeen.After(newest.LastSeen) {
|
||||
newest = asn
|
||||
}
|
||||
|
||||
if oldest == nil || asn.LastSeen.Before(oldest.LastSeen) {
|
||||
oldest = asn
|
||||
}
|
||||
}
|
||||
|
||||
if newest == nil {
|
||||
return nil, nil, nil
|
||||
}
|
||||
|
||||
newestCopy, oldestCopy := *newest, *oldest
|
||||
|
||||
return &newestCopy, &oldestCopy, nil
|
||||
}
|
||||
|
||||
// GetASWHOIS returns the stored AS, or only its number when none is stored.
|
||||
func (m *mockStore) GetASWHOIS(ctx context.Context, asn int) (*database.ASN, error) {
|
||||
asnInfo, _, err := m.GetAS(ctx, asn)
|
||||
@@ -605,12 +634,15 @@ func TestShutdownReturnsByItsDeadlineWhileAWriteIsBlocked(t *testing.T) {
|
||||
cfg := &config.Config{Port: port}
|
||||
s := streamer.New(log, metrics.New())
|
||||
|
||||
// A started server reads its routing table in the background, so it
|
||||
// needs one.
|
||||
rw := New(Dependencies{
|
||||
DB: store,
|
||||
Streamer: s,
|
||||
Server: server.New(store, nil, s, log, cfg),
|
||||
Logger: log,
|
||||
Config: cfg,
|
||||
Server: server.New(store, routetable.New(routetable.Params{}), s, log,
|
||||
cfg),
|
||||
Logger: log,
|
||||
Config: cfg,
|
||||
})
|
||||
|
||||
err := rw.server.Start(t.Context())
|
||||
|
||||
Reference in new issue
Block a user