Initial commit: RouteWatch BGP stream monitor

- Connects to RIPE RIS Live stream to receive real-time BGP updates
- Stores BGP data in SQLite database:
  - ASNs with first/last seen timestamps
  - Prefixes with IPv4/IPv6 classification
  - BGP announcements and withdrawals
  - AS-to-AS peering relationships from AS paths
  - Live routing table tracking active routes
- HTTP server with statistics endpoints
- Metrics tracking with go-metrics
- Custom JSON unmarshaling to handle nested AS sets in paths
- Dependency injection with uber/fx
- Pure Go implementation (no CGO)
- Includes streamdumper utility for debugging raw messages
This commit is contained in:
sneak committed 2025-07-27 21:18:57 +02:00
commit 92f7527cc5
24 files changed
+3587

No files matched your search

+45
View File
@@ -0,0 +1,45 @@
package routewatch
import (
"git.eeqj.de/sneak/routewatch/internal/ristypes"
"log/slog"
)
// SimpleHandler is a basic implementation of streamer.MessageHandler
type SimpleHandler struct {
logger *slog.Logger
messageTypes []string
callback func(*ristypes.RISMessage)
}
// NewSimpleHandler creates a handler that accepts specific message types
func NewSimpleHandler(logger *slog.Logger, messageTypes []string, callback func(*ristypes.RISMessage)) *SimpleHandler {
return &SimpleHandler{
logger: logger,
messageTypes: messageTypes,
callback: callback,
}
}
// WantsMessage returns true if this handler wants to process messages of the given type
func (h *SimpleHandler) WantsMessage(messageType string) bool {
// If no specific types are set, accept all messages
if len(h.messageTypes) == 0 {
return true
}
for _, t := range h.messageTypes {
if t == messageType {
return true
}
}
return false
}
// HandleMessage processes a RIS message
func (h *SimpleHandler) HandleMessage(msg *ristypes.RISMessage) {
if h.callback != nil {
h.callback(msg)
}
}