Add route age information to IP lookup API
- Add last_updated timestamp and age fields to ASInfo - Include route's last_updated time from live_routes table - Calculate and display age as human-readable duration - Update both IPv4 and IPv6 queries to fetch timestamp - Fix error handling to return 400 for invalid IPs
This commit is contained in:
@@ -4,6 +4,7 @@ package server
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"net/http"
|
||||
"os"
|
||||
"runtime"
|
||||
@@ -439,7 +440,13 @@ func (s *Server) handleIPLookup() http.HandlerFunc {
|
||||
// Look up AS information for the IP
|
||||
asInfo, err := s.db.GetASInfoForIP(ip)
|
||||
if err != nil {
|
||||
writeJSONError(w, http.StatusNotFound, err.Error())
|
||||
// Check if it's an invalid IP error
|
||||
if errors.Is(err, database.ErrInvalidIP) {
|
||||
writeJSONError(w, http.StatusBadRequest, err.Error())
|
||||
} else {
|
||||
// All other errors (including ErrNoRoute) are 404
|
||||
writeJSONError(w, http.StatusNotFound, err.Error())
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user