package server import ( "errors" "time" ) var ( // ErrInvalidIP says that an IP address is malformed. The IP lookup returns // it. ErrInvalidIP = errors.New("invalid IP address") // ErrNoRoute says that the routing table has no route for an address, a // prefix or an AS. The lookups return it. ErrNoRoute = errors.New("no route found") ) // LiveRoute represents a route in the live routing table. JSON leaves out an // empty AS path, next hop or time: the routing table in memory keeps them only // for the two newest routes of each prefix and origin AS. // //nolint:tagliatelle // field names are the existing JSON API type LiveRoute struct { Prefix string `json:"prefix"` MaskLength int `json:"mask_length"` IPVersion int `json:"ip_version"` OriginASN int `json:"origin_asn"` PeerIP string `json:"peer_ip"` ASPath []int `json:"as_path,omitempty"` NextHop string `json:"next_hop,omitempty"` LastUpdated time.Time `json:"last_updated,omitzero"` } // PrefixDistribution represents the distribution of prefixes by mask length // //nolint:tagliatelle // field names are the existing JSON API type PrefixDistribution struct { MaskLength int `json:"mask_length"` Count int `json:"count"` } // IPInfo is what the IP lookup knows about the route of an address and that // route's origin AS. A field is nil, null in JSON, when its value is not known. // Every field is nil for an address with no route. // //nolint:tagliatelle // field names are the existing JSON API type IPInfo struct { // Netblock is the most specific prefix that holds the address. Netblock *string `json:"netblock"` MaskLength *int `json:"mask_length"` IPVersion *int `json:"ip_version"` NumPeers *int `json:"num_peers"` // ASN is the origin AS that the most peers carry the netblock with. ASN *int `json:"asn"` // NumOrigins and OriginASNs are how many origin ASes peers carry the // netblock with, and which, in AS number order. NumOrigins *int `json:"num_origins"` OriginASNs []int `json:"origin_asns"` // The details the database holds about the AS in ASN. ASName *string `json:"as_name"` Handle *string `json:"handle"` Description *string `json:"description"` OrgName *string `json:"org_name"` OrgID *string `json:"org_id"` Address *string `json:"address"` CountryCode *string `json:"country_code"` AbuseEmail *string `json:"abuse_email"` RIR *string `json:"rir"` // FirstSeen is when RouteWatch first saw the netblock. LastSeen is the // time of the netblock's newest kept route. FirstSeen *time.Time `json:"first_seen"` LastSeen *time.Time `json:"last_seen"` // Indicates if WHOIS data needs refresh (not serialized) NeedsWHOISRefresh bool `json:"-"` }