Documentation
¶
Overview ¶
Package catalog provides protocol-neutral PeeringDB catalog queries and data.
Index ¶
- Variables
- type CampusDetail
- type CampusFacilityRow
- type CarrierDetail
- type CarrierFacilityRow
- type CompareCampus
- type CompareCampusFacility
- type CompareData
- type CompareFacPresence
- type CompareFacility
- type CompareIXP
- type CompareIXPresence
- type CompareInput
- type CompareNetwork
- type CompareService
- type ContactRow
- type FacCarrierRow
- type FacIXRow
- type FacNetworkRow
- type FacilityDetail
- type IXDetail
- type IXFacilityRow
- type IXParticipantRow
- type IXPrefixRow
- type NetworkDetail
- type NetworkFacRow
- type NetworkIXLanRow
- type OrgCampusRow
- type OrgCarrierRow
- type OrgDetail
- type OrgFacilityRow
- type OrgIXRow
- type OrgNetworkRow
- type SearchHit
- type SearchService
- type SearchTypeInput
- type SearchTypeResult
- type Service
- func (s *Service) Campus(ctx context.Context, id int) (CampusDetail, error)
- func (s *Service) Carrier(ctx context.Context, id int) (CarrierDetail, error)
- func (s *Service) Facility(ctx context.Context, id int) (FacilityDetail, error)
- func (s *Service) IX(ctx context.Context, id int) (IXDetail, error)
- func (s *Service) Network(ctx context.Context, asn int) (NetworkDetail, error)
- func (s *Service) Organization(ctx context.Context, id int) (OrgDetail, error)
- type TypeResult
Constants ¶
This section is empty.
Variables ¶
var ErrUnknownSearchType = errors.New("unknown search type")
ErrUnknownSearchType is returned by SearchType when the type slug is not a recognized searchable entity type.
Functions ¶
This section is empty.
Types ¶
type CampusDetail ¶
type CampusDetail struct {
// ID is the campus's PeeringDB identifier.
ID int
// Name is the campus's display name.
Name string
// NameLong is the campus's long-form name.
NameLong string
// AKA is the "also known as" alias.
AKA string
// Website is the campus's website URL.
Website string
// OrgName is the name of the parent organization.
OrgName string
// OrgID is the parent organization's PeeringDB ID.
OrgID int
// City is the campus's city.
City string
// State is the campus's state or province.
State string
// Country is the campus's country code.
Country string
// Zipcode is the postal code.
Zipcode string
// Notes contains freeform notes.
Notes string
// Status is the record status.
Status string
// FacCount is the count of facilities (requires query).
FacCount int
// Facilities holds eager-loaded facility rows for terminal/JSON rendering. Nil for web UI requests.
Facilities []CampusFacilityRow `json:"facilities,omitempty"`
}
CampusDetail holds display data for a campus detail page.
type CampusFacilityRow ¶
type CampusFacilityRow struct {
// FacName is the facility name.
FacName string
// FacID is the facility's PeeringDB ID for cross-linking.
FacID int
// City is the facility's city.
City string
// Country is the facility's country code.
Country string
// Latitude is the facility's geographic latitude. Zero means no data.
Latitude float64
// Longitude is the facility's geographic longitude. Zero means no data.
Longitude float64
}
CampusFacilityRow holds display data for a campus's facility row.
type CarrierDetail ¶
type CarrierDetail struct {
// ID is the carrier's PeeringDB identifier.
ID int
// Name is the carrier's display name.
Name string
// NameLong is the carrier's long-form name.
NameLong string
// AKA is the "also known as" alias.
AKA string
// Website is the carrier's website URL.
Website string
// OrgName is the name of the parent organization.
OrgName string
// OrgID is the parent organization's PeeringDB ID.
OrgID int
// Notes contains freeform notes.
Notes string
// Status is the record status.
Status string
// FacCount is the pre-computed count of facilities.
FacCount int
// Facilities holds eager-loaded facility rows for terminal/JSON rendering. Nil for web UI requests.
Facilities []CarrierFacilityRow `json:"facilities,omitempty"`
}
CarrierDetail holds display data for a carrier detail page.
type CarrierFacilityRow ¶
type CarrierFacilityRow struct {
// FacName is the facility name.
FacName string
// FacID is the facility's PeeringDB ID for cross-linking.
FacID int
// Latitude is the facility's geographic latitude. Zero means no data.
Latitude float64
// Longitude is the facility's geographic longitude. Zero means no data.
Longitude float64
}
CarrierFacilityRow holds display data for a carrier's facility row.
type CompareCampus ¶
type CompareCampus struct {
// CampusID is the campus's PeeringDB ID for cross-linking.
CampusID int
// CampusName is the campus display name.
CampusName string
SharedFacilities []CompareCampusFacility
}
CompareCampus holds comparison data for a shared campus.
type CompareCampusFacility ¶
type CompareCampusFacility struct {
// FacID is the facility's PeeringDB ID for cross-linking.
FacID int
// FacName is the facility display name.
FacName string
}
CompareCampusFacility holds a facility within a shared campus.
type CompareData ¶
type CompareData struct {
// NetA is the first network's summary info.
NetA CompareNetwork
// NetB is the second network's summary info.
NetB CompareNetwork
SharedIXPs []CompareIXP
SharedFacilities []CompareFacility
SharedCampuses []CompareCampus
// AllIXPs lists all IXPs for both networks with a shared flag (for full view).
AllIXPs []CompareIXP
// AllFacilities lists all facilities for both networks with shared flag (for full view).
AllFacilities []CompareFacility
// ViewMode is "shared" (default) or "full".
ViewMode string
}
CompareData holds the full comparison result for template rendering.
type CompareFacPresence ¶
type CompareFacPresence struct {
// LocalASN is the local ASN used at this facility.
LocalASN int
}
CompareFacPresence holds one network's presence details at a facility.
type CompareFacility ¶
type CompareFacility struct {
// FacID is the facility's PeeringDB ID for cross-linking.
FacID int
// FacName is the facility display name.
FacName string
// City is the facility's city.
City string
// Country is the facility's country code.
Country string
// Latitude is the facility's geographic latitude. Zero means no data.
Latitude float64
// Longitude is the facility's geographic longitude. Zero means no data.
Longitude float64
Shared bool
// NetA holds network A's presence info (nil if not present).
NetA *CompareFacPresence
// NetB holds network B's presence info (nil if not present).
NetB *CompareFacPresence
}
CompareFacility holds comparison data for a single facility.
type CompareIXP ¶
type CompareIXP struct {
// IXID is the exchange's PeeringDB ID for cross-linking.
IXID int
// IXName is the exchange display name.
IXName string
Shared bool
// NetA holds network A's presence details (nil if not present).
NetA *CompareIXPresence
// NetB holds network B's presence details (nil if not present).
NetB *CompareIXPresence
}
CompareIXP holds comparison data for a single IXP showing both networks' presence info.
type CompareIXPresence ¶
type CompareIXPresence struct {
// Speed is the port speed in Mbps.
Speed int
// IPAddr4 is the IPv4 peering address.
IPAddr4 string
// IPAddr6 is the IPv6 peering address.
IPAddr6 string
// IsRSPeer indicates route server peering.
IsRSPeer bool
// Operational indicates whether the connection is operational.
Operational bool
}
CompareIXPresence holds one network's presence details at an IXP.
type CompareInput ¶
type CompareInput struct {
// ASN1 is the first network's Autonomous System Number.
ASN1 int
// ASN2 is the second network's Autonomous System Number.
ASN2 int
// ViewMode is "shared" (default) or "full".
ViewMode string
}
CompareInput holds the parameters for a network comparison.
type CompareNetwork ¶
type CompareNetwork struct {
// ASN is the Autonomous System Number.
ASN int
// Name is the network's display name.
Name string
// ID is the network's PeeringDB internal identifier.
ID int
}
CompareNetwork holds summary info for one side of the comparison.
type CompareService ¶
type CompareService struct {
// contains filtered or unexported fields
}
CompareService compares two networks' presences across IXPs, facilities, and campuses.
func NewCompareService ¶
func NewCompareService(client *ent.Client) *CompareService
NewCompareService creates a CompareService backed by the given ent client.
func (*CompareService) Compare ¶
func (s *CompareService) Compare(ctx context.Context, input CompareInput) (*CompareData, error)
Compare loads both networks' presences and computes set intersections to find shared IXPs, facilities, and campuses.
type ContactRow ¶
type ContactRow struct {
// Name is the contact's name.
Name string
// Role is the contact's role (e.g. "NOC", "Policy").
Role string
// Email is the contact's email address.
Email string
// Phone is the contact's phone number.
Phone string
// URL is the contact's URL.
URL string
}
ContactRow holds display data for a network contact (poc) row.
type FacCarrierRow ¶
type FacCarrierRow struct {
// CarrierName is the carrier name.
CarrierName string
// CarrierID is the carrier's PeeringDB ID for cross-linking.
CarrierID int
}
FacCarrierRow holds display data for a facility's carrier row.
type FacIXRow ¶
type FacIXRow struct {
// IXName is the exchange name.
IXName string
// IXID is the exchange's PeeringDB ID for cross-linking.
IXID int
}
FacIXRow holds display data for a facility's IXP row.
type FacNetworkRow ¶
type FacNetworkRow struct {
// NetName is the network's name.
NetName string
// ASN is the network's Autonomous System Number.
ASN int
// City is the facility network's city (from NetworkFacility computed field).
City string
// Country is the facility network's country code (from NetworkFacility computed field).
Country string
}
FacNetworkRow holds display data for a facility's network row.
type FacilityDetail ¶
type FacilityDetail struct {
// ID is the facility's PeeringDB identifier.
ID int
// Name is the facility's display name.
Name string
// NameLong is the facility's long-form name.
NameLong string
// AKA is the "also known as" alias.
AKA string
// Website is the facility's website URL.
Website string
// OrgName is the name of the parent organization.
OrgName string
// OrgID is the parent organization's PeeringDB ID.
OrgID int
// CampusName is the name of the parent campus, if any.
CampusName string
// CampusID is the parent campus's PeeringDB ID.
CampusID int
// Address1 is the primary street address.
Address1 string
// Address2 is the secondary address line.
Address2 string
// City is the facility's city.
City string
// State is the facility's state or province.
State string
// Country is the facility's country code.
Country string
// Zipcode is the postal code.
Zipcode string
// RegionContinent is the facility's region/continent.
RegionContinent string
// CLLI is the CLLI code.
CLLI string
// Notes contains freeform notes.
Notes string
// Status is the record status.
Status string
// NetCount is the pre-computed count of networks present.
NetCount int
// IXCount is the pre-computed count of IXPs present.
IXCount int
// CarrierCount is the pre-computed count of carriers.
CarrierCount int
// Latitude is the facility's geographic latitude. Zero means no data.
Latitude float64
// Longitude is the facility's geographic longitude. Zero means no data.
Longitude float64
// Networks holds eager-loaded network rows for terminal/JSON rendering. Nil for web UI requests.
Networks []FacNetworkRow `json:"networks,omitempty"`
// IXPs holds eager-loaded IXP rows for terminal/JSON rendering. Nil for web UI requests.
IXPs []FacIXRow `json:"ixps,omitempty"`
// Carriers holds eager-loaded carrier rows for terminal/JSON rendering. Nil for web UI requests.
Carriers []FacCarrierRow `json:"carriers,omitempty"`
}
FacilityDetail holds display data for a facility detail page.
type IXDetail ¶
type IXDetail struct {
// ID is the IXP's PeeringDB identifier.
ID int
// Name is the IXP's display name.
Name string
// NameLong is the IXP's long-form name.
NameLong string
// AKA is the "also known as" alias.
AKA string
// Website is the IXP's website URL.
Website string
// OrgName is the name of the parent organization.
OrgName string
// OrgID is the parent organization's PeeringDB ID.
OrgID int
// City is the IXP's city.
City string
// Country is the IXP's country code.
Country string
// RegionContinent is the IXP's region/continent.
RegionContinent string
// Media is the exchange media type.
Media string
// ProtoUnicast indicates unicast support.
ProtoUnicast bool
// ProtoMulticast indicates multicast support.
ProtoMulticast bool
// ProtoIPv6 indicates IPv6 support.
ProtoIPv6 bool
// Notes contains freeform notes.
Notes string
// Status is the record status.
Status string
// NetCount is the pre-computed count of network participants.
NetCount int
// FacCount is the pre-computed count of facilities.
FacCount int
// PrefixCount is the count of peering LAN prefixes (requires IxLan traversal).
PrefixCount int
// AggregateBW is the total bandwidth in Mbps across all participants (for header display).
AggregateBW int
// Participants holds eager-loaded participant rows for terminal/JSON rendering. Nil for web UI requests.
Participants []IXParticipantRow `json:"participants,omitempty"`
// Facilities holds eager-loaded facility rows for terminal/JSON rendering. Nil for web UI requests.
Facilities []IXFacilityRow `json:"facilities,omitempty"`
// Prefixes holds eager-loaded prefix rows for terminal/JSON rendering. Nil for web UI requests.
Prefixes []IXPrefixRow `json:"prefixes,omitempty"`
}
IXDetail holds display data for an IXP detail page.
type IXFacilityRow ¶
type IXFacilityRow struct {
// FacName is the facility name.
FacName string
// FacID is the facility's PeeringDB ID for cross-linking.
FacID int
// City is the facility's city.
City string
// Country is the facility's country code.
Country string
// Latitude is the facility's geographic latitude. Zero means no data.
Latitude float64
// Longitude is the facility's geographic longitude. Zero means no data.
Longitude float64
}
IXFacilityRow holds display data for an IXP facility row.
type IXParticipantRow ¶
type IXParticipantRow struct {
// NetName is the participant network's name.
NetName string
// ASN is the participant's Autonomous System Number.
ASN int
// Speed is the port speed in Mbps.
Speed int
// IPAddr4 is the IPv4 peering address.
IPAddr4 string
// IPAddr6 is the IPv6 peering address.
IPAddr6 string
// IsRSPeer indicates route server peering.
IsRSPeer bool
}
IXParticipantRow holds display data for an IXP participant row.
type IXPrefixRow ¶
type IXPrefixRow struct {
// Prefix is the peering LAN prefix.
Prefix string
// Protocol is the address family ("IPv4" or "IPv6").
Protocol string
// InDFZ indicates whether the prefix is in the default-free zone.
InDFZ bool
}
IXPrefixRow holds display data for an IXP prefix row.
type NetworkDetail ¶
type NetworkDetail struct {
// ID is the network's PeeringDB internal identifier.
ID int
// ASN is the Autonomous System Number.
ASN int
// Name is the network's display name.
Name string
// NameLong is the network's long-form name.
NameLong string
// AKA is the "also known as" alias.
AKA string
// Website is the network's website URL.
Website string
// OrgName is the name of the parent organization.
OrgName string
// OrgID is the parent organization's PeeringDB ID.
OrgID int
// IRRAsSet is the IRR AS-SET identifier.
IRRAsSet string
// InfoType is the network type classification.
InfoType string
// InfoScope is the geographic scope.
InfoScope string
// InfoTraffic is the traffic level.
InfoTraffic string
// InfoRatio is the traffic ratio.
InfoRatio string
// InfoUnicast indicates unicast support.
InfoUnicast bool
// InfoMulticast indicates multicast support.
InfoMulticast bool
// InfoIPv6 indicates IPv6 support.
InfoIPv6 bool
// InfoPrefixes4 is the IPv4 prefix count.
InfoPrefixes4 int
// InfoPrefixes6 is the IPv6 prefix count.
InfoPrefixes6 int
// LookingGlass is the looking glass URL.
LookingGlass string
// RouteServer is the route server URL.
RouteServer string
// PolicyGeneral is the general peering policy.
PolicyGeneral string
// PolicyURL is the peering policy URL.
PolicyURL string
// Notes contains freeform notes.
Notes string
// Status is the record status.
Status string
// IXCount is the pre-computed count of IX presences.
IXCount int
// FacCount is the pre-computed count of facility presences.
FacCount int
// PocCount is the count of contacts (requires query).
PocCount int
// AggregateBW is the total bandwidth in Mbps across all IX presences (for header display).
AggregateBW int
// IXPresences holds eager-loaded IX presence rows for terminal/JSON rendering.
// Nil for web UI requests that lazy-load via htmx fragments.
IXPresences []NetworkIXLanRow `json:"ixPresences,omitempty"`
// FacPresences holds eager-loaded facility presence rows for terminal/JSON rendering.
// Nil for web UI requests that lazy-load via htmx fragments.
FacPresences []NetworkFacRow `json:"facPresences,omitempty"`
}
NetworkDetail holds display data for a network detail page.
type NetworkFacRow ¶
type NetworkFacRow struct {
// FacName is the facility name.
FacName string
// FacID is the facility's PeeringDB ID for cross-linking.
FacID int
// LocalASN is the local ASN at this facility.
LocalASN int
// City is the facility's city.
City string
// Country is the facility's country code.
Country string
// Latitude is the facility's geographic latitude. Zero means no data.
Latitude float64
// Longitude is the facility's geographic longitude. Zero means no data.
Longitude float64
}
NetworkFacRow holds display data for a network's facility presence row.
type NetworkIXLanRow ¶
type NetworkIXLanRow struct {
// IXName is the exchange name.
IXName string
// IXID is the exchange's PeeringDB ID for cross-linking.
IXID int
// Speed is the port speed in Mbps.
Speed int
// IPAddr4 is the IPv4 peering address.
IPAddr4 string
// IPAddr6 is the IPv6 peering address.
IPAddr6 string
// IsRSPeer indicates route server peering.
IsRSPeer bool
}
NetworkIXLanRow holds display data for a network's IX presence row.
type OrgCampusRow ¶
type OrgCampusRow struct {
// CampusName is the campus name.
CampusName string
// CampusID is the campus's PeeringDB ID for cross-linking.
CampusID int
}
OrgCampusRow holds display data for an org's campus row.
type OrgCarrierRow ¶
type OrgCarrierRow struct {
// CarrierName is the carrier name.
CarrierName string
// CarrierID is the carrier's PeeringDB ID for cross-linking.
CarrierID int
}
OrgCarrierRow holds display data for an org's carrier row.
type OrgDetail ¶
type OrgDetail struct {
// ID is the organization's PeeringDB identifier.
ID int
// Name is the organization's display name.
Name string
// NameLong is the organization's long-form name.
NameLong string
// AKA is the "also known as" alias.
AKA string
// Website is the organization's website URL.
Website string
// Address1 is the primary street address.
Address1 string
// Address2 is the secondary address line.
Address2 string
// City is the organization's city.
City string
// State is the organization's state or province.
State string
// Country is the organization's country code.
Country string
// Zipcode is the postal code.
Zipcode string
// Notes contains freeform notes.
Notes string
// Status is the record status.
Status string
// NetCount is the pre-computed count of networks.
NetCount int
// FacCount is the pre-computed count of facilities.
FacCount int
// IXCount is the count of IXPs (requires query).
IXCount int
// CampusCount is the count of campuses (requires query).
CampusCount int
// CarrierCount is the count of carriers (requires query).
CarrierCount int
// Networks holds eager-loaded network rows for terminal/JSON rendering. Nil for web UI requests.
Networks []OrgNetworkRow `json:"networks,omitempty"`
// IXPs holds eager-loaded IXP rows for terminal/JSON rendering. Nil for web UI requests.
IXPs []OrgIXRow `json:"ixps,omitempty"`
// Facs holds eager-loaded facility rows for terminal/JSON rendering. Nil for web UI requests.
Facs []OrgFacilityRow `json:"facilities,omitempty"`
// Campuses holds eager-loaded campus rows for terminal/JSON rendering. Nil for web UI requests.
Campuses []OrgCampusRow `json:"campuses,omitempty"`
// Carriers holds eager-loaded carrier rows for terminal/JSON rendering. Nil for web UI requests.
Carriers []OrgCarrierRow `json:"carriers,omitempty"`
}
OrgDetail holds display data for an organization detail page.
type OrgFacilityRow ¶
type OrgFacilityRow struct {
// FacName is the facility name.
FacName string
// FacID is the facility's PeeringDB ID for cross-linking.
FacID int
// City is the facility's city.
City string
// Country is the facility's country code.
Country string
// Latitude is the facility's geographic latitude. Zero means no data.
Latitude float64
// Longitude is the facility's geographic longitude. Zero means no data.
Longitude float64
}
OrgFacilityRow holds display data for an org's facility row.
type OrgIXRow ¶
type OrgIXRow struct {
// IXName is the exchange name.
IXName string
// IXID is the exchange's PeeringDB ID for cross-linking.
IXID int
}
OrgIXRow holds display data for an org's IXP row.
type OrgNetworkRow ¶
type OrgNetworkRow struct {
// NetName is the network's name.
NetName string
// ASN is the network's Autonomous System Number.
ASN int
}
OrgNetworkRow holds display data for an org's network row.
type SearchHit ¶
type SearchHit struct {
// ID is the entity's database identifier.
ID int
// Name is the entity's display name.
Name string
// Country is the ISO 3166-1 alpha-2 code; empty if not available.
Country string
// City is the city name; empty if not available.
City string
// ASN is the AS number; 0 if not applicable (non-network entity).
ASN int
}
SearchHit represents a single protocol-neutral catalog search result.
type SearchService ¶
type SearchService struct {
// contains filtered or unexported fields
}
SearchService provides search across all 6 PeeringDB entity types.
func NewSearchService ¶
func NewSearchService(client *ent.Client) *SearchService
NewSearchService creates a SearchService backed by the given ent client.
func (*SearchService) Search ¶
func (s *SearchService) Search(ctx context.Context, query string) ([]TypeResult, error)
Search queries all 6 entity types in parallel for the given search term. Returns only types with matches, sorted in canonical type order. Queries under 2 characters (after trimming) return an empty slice.
func (*SearchService) SearchType ¶
func (s *SearchService) SearchType(ctx context.Context, in SearchTypeInput) (SearchTypeResult, error)
SearchType returns one page of matches for a single entity type, backing the "view all" results page. It returns ErrUnknownSearchType when the slug is not a recognized searchable type; queries under 2 characters yield an empty page.
type SearchTypeInput ¶
type SearchTypeInput struct {
// Query is the raw search term.
Query string
// TypeSlug selects the entity type (e.g. "net", "fac").
TypeSlug string
// Offset is the number of leading matches to skip (>= 0).
Offset int
// Limit is the page size; values < 1 default to pageSize.
Limit int
}
SearchTypeInput parameterizes a single-type paginated search for the "view all" results page. The context is passed separately to SearchType.
type SearchTypeResult ¶
type SearchTypeResult struct {
// TypeName is the human-readable plural name (e.g. "Networks").
TypeName string
// TypeSlug is the short identifier used in URLs (e.g. "net").
TypeSlug string
// Hits holds this page's matching entities.
Hits []SearchHit
// HasMore indicates whether matches exist beyond this page.
HasMore bool
// Total is the exact number of matches across all pages.
Total int
}
SearchTypeResult holds one page of results for a single entity type.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service queries catalog entity details.
func NewService ¶
NewService creates a catalog detail service backed by client.
func (*Service) Campus ¶
Campus fetches a campus by ID and its related catalog data. It returns errors compatible with ent.IsNotFound.
func (*Service) Carrier ¶
Carrier fetches a carrier by ID and its related catalog data. It returns errors compatible with ent.IsNotFound.
func (*Service) Facility ¶
Facility fetches a facility by ID and its related catalog data. It returns errors compatible with ent.IsNotFound.
func (*Service) IX ¶
IX fetches an internet exchange by ID and its related catalog data. It returns errors compatible with ent.IsNotFound.
type TypeResult ¶
type TypeResult struct {
// TypeName is the human-readable plural name (e.g. "Networks", "IXPs").
TypeName string
// TypeSlug is the short identifier used in URLs (e.g. "net", "ix").
TypeSlug string
// Results holds up to displayLimit matching entities.
Results []SearchHit
// HasMore indicates whether additional matches exist beyond the displayed results.
HasMore bool
// Total is the exact number of matches across all pages. It equals
// len(Results) when HasMore is false; when HasMore is true it is the full
// count (so the "view all" link can show the real total).
Total int
}
TypeResult groups search hits for a single entity type.