- Added new live_routes table with mask_length column for tracking CIDR prefix lengths - Updated PrefixHandler to maintain live routing table with additions and deletions - Added route expiration functionality (5 minute timeout) to in-memory routing table - Added prefix distribution stats showing count of prefixes by mask length - Added IPv4/IPv6 prefix distribution cards to status page - Updated database interface with UpsertLiveRoute, DeleteLiveRoute, and GetPrefixDistribution - Set all handler queue depths to 50000 for consistency - Doubled DBHandler batch size to 32000 for better throughput - Fixed withdrawal handling to delete routes when origin ASN is available
51 lines
1.3 KiB
Go
51 lines
1.3 KiB
Go
package database
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
// Stats contains database statistics
|
|
type Stats struct {
|
|
ASNs int
|
|
Prefixes int
|
|
IPv4Prefixes int
|
|
IPv6Prefixes int
|
|
Peerings int
|
|
FileSizeBytes int64
|
|
LiveRoutes int
|
|
IPv4PrefixDistribution []PrefixDistribution
|
|
IPv6PrefixDistribution []PrefixDistribution
|
|
}
|
|
|
|
// Store defines the interface for database operations
|
|
type Store interface {
|
|
// ASN operations
|
|
GetOrCreateASN(number int, timestamp time.Time) (*ASN, error)
|
|
|
|
// Prefix operations
|
|
GetOrCreatePrefix(prefix string, timestamp time.Time) (*Prefix, error)
|
|
|
|
// Announcement operations
|
|
RecordAnnouncement(announcement *Announcement) error
|
|
|
|
// Peering operations
|
|
RecordPeering(fromASNID, toASNID string, timestamp time.Time) error
|
|
|
|
// Statistics
|
|
GetStats() (Stats, error)
|
|
|
|
// Peer operations
|
|
UpdatePeer(peerIP string, peerASN int, messageType string, timestamp time.Time) error
|
|
|
|
// Live route operations
|
|
UpsertLiveRoute(route *LiveRoute) error
|
|
DeleteLiveRoute(prefix string, originASN int, peerIP string) error
|
|
GetPrefixDistribution() (ipv4 []PrefixDistribution, ipv6 []PrefixDistribution, err error)
|
|
|
|
// Lifecycle
|
|
Close() error
|
|
}
|
|
|
|
// Ensure Database implements Store
|
|
var _ Store = (*Database)(nil)
|