Documentation
¶
Index ¶
- Constants
- func AddrToUint32(addr netip.Addr) uint32
- func OpenGzipFile(path string) (io.ReadCloser, error)
- func ParseOrganisations(r io.Reader) (map[string]Organisation, error)
- func PrefixToRange(prefix netip.Prefix) (start, end uint32, err error)
- func Uint32ToAddr(ip uint32) netip.Addr
- type Database
- func (d *Database) Close() error
- func (d *Database) GetMetadata() (*Metadata, error)
- func (d *Database) GetOrganisation(orgID string) (*Organisation, error)
- func (d *Database) IterateRanges(fn func(Inetnum) error) error
- func (d *Database) LookupIP(ip netip.Addr) (*Match, error)
- func (d *Database) LookupPrefix(prefix netip.Prefix) (*Match, error)
- func (d *Database) NewIterator() iterator.Iterator
- type Error
- type FetchResult
- type Fetcher
- type Inetnum
- type Match
- type Metadata
- type Organisation
Constants ¶
const ( // DefaultBaseURL is the RIPE FTP base URL for split dumps DefaultBaseURL = "https://ftp.ripe.net/ripe/dbase/split" // Dump file names InetnumFile = "ripe.db.inetnum.gz" OrganisationFile = "ripe.db.organisation.gz" )
Variables ¶
This section is empty.
Functions ¶
func AddrToUint32 ¶
AddrToUint32 converts netip.Addr to uint32 (big-endian)
func OpenGzipFile ¶
func OpenGzipFile(path string) (io.ReadCloser, error)
OpenGzipFile opens a gzipped file and returns a reader
func ParseOrganisations ¶
func ParseOrganisations(r io.Reader) (map[string]Organisation, error)
ParseOrganisations parses RIPE organisation objects from a reader
func PrefixToRange ¶
PrefixToRange converts a CIDR prefix to inclusive [start, end] uint32 range
func Uint32ToAddr ¶
Uint32ToAddr converts a uint32 to netip.Addr (big-endian)
Types ¶
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
Database manages the RIPE bulk data index
func BuildDatabase ¶
func BuildDatabase(path string, inetnums []Inetnum, orgs map[string]Organisation) (*Database, error)
BuildDatabase creates a new RIPE bulk database from parsed data
func OpenDatabase ¶
OpenDatabase opens an existing RIPE bulk database with default cache size
func OpenDatabaseWithCache ¶
OpenDatabaseWithCache opens with custom cache size (in bytes)
func (*Database) GetMetadata ¶
GetMetadata retrieves database metadata
func (*Database) GetOrganisation ¶
func (d *Database) GetOrganisation(orgID string) (*Organisation, error)
GetOrganisation retrieves an organisation by ID
func (*Database) IterateRanges ¶
IterateRanges iterates over all inetnum ranges
func (*Database) LookupPrefix ¶
LookupPrefix finds the most specific inetnum that fully covers a prefix
func (*Database) NewIterator ¶
NewIterator creates a new range iterator for advanced use cases
type FetchResult ¶
type FetchResult struct {
FilePath string // Local path to the downloaded file
LastModified time.Time // Last-Modified header from server
Size int64 // File size in bytes
Cached bool // True if file was already cached (not downloaded)
}
FetchResult contains the result of a fetch operation
type Fetcher ¶
type Fetcher struct {
// contains filtered or unexported fields
}
Fetcher handles downloading RIPE split dumps
func NewFetcher ¶
NewFetcher creates a new RIPE dump fetcher
type Inetnum ¶
type Inetnum struct {
Start uint32 // Start IP (big-endian uint32)
End uint32 // End IP (big-endian uint32, inclusive)
OrgID string // Organisation ID (e.g., "ORG-EA123-RIPE")
Status string // Status (e.g., ASSIGNED-PA, SUB-ALLOCATED-PA, ALLOCATED-PA, LEGACY)
Country string // Country code (2-letter ISO, may be empty)
Netname string // Network name
Descr string // Description (often contains organization name)
Remarks []string // Remarks (for extracting organization info when OrgID is missing)
}
Inetnum represents an IPv4 range from RIPE inetnum object
type Match ¶
type Match struct {
Start netip.Addr // Start IP of the matching inetnum
End netip.Addr // End IP of the matching inetnum
Prefix netip.Prefix // Original query prefix
OrgID string // Organisation ID
OrgName string // Organisation name (resolved from OrgID)
OrgType string // Organisation type
Status string // RIPE status
Country string // Country code
Netname string // Network name
MatchedAt time.Time // When this lookup was performed
FullyCovered bool // True if inetnum fully covers the query prefix
}
Match represents the result of a prefix lookup
type Metadata ¶
type Metadata struct {
SchemaVersion int // Database schema version
BuildTime time.Time // When the database was built
InetnumCount int64 // Number of inetnum objects indexed
OrgCount int64 // Number of organisation objects indexed
InetnumSerial string // RIPE serial/version of inetnum dump
OrganisationSerial string // RIPE serial/version of organisation dump
SourceURL string // Base URL where dumps were fetched from
}
Metadata stores build information
type Organisation ¶
type Organisation struct {
OrgID string // Primary key (e.g., "ORG-EA123-RIPE")
OrgName string // Human-readable name
OrgType string // RIR, LIR, OTHER, etc.
}
Organisation represents a RIPE organisation object