asn

package
v0.0.0-...-704fb84 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 22, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const AddressMappingsURL = "https://thyme.apnic.net/current/data-raw-table"
View Source
const ReferenceURL = "https://thyme.apnic.net/current/data-used-autnums"

Variables

This section is empty.

Functions

This section is empty.

Types

type ASN

type ASN struct {
	ID         ID
	Name       string
	Country    string
	Allocation Allocation
}

func (ASN) Valid

func (a ASN) Valid() bool

type Allocation

type Allocation string
const (
	Unassigned  Allocation = "unassigned"
	Unallocated Allocation = "unallocated"
	Reserved    Allocation = "reserved"
	Allocated   Allocation = "allocated"
)

type ID

type ID string

type Mapper

type Mapper struct {
	SourceName string
	Reference  Reference
	// contains filtered or unexported fields
}

func DefaultMapper

func DefaultMapper() Mapper

func DefaultMapperWithReference

func DefaultMapperWithReference(ref Reference, flags ParseMapperFlags) (Mapper, error)

func ParseMapper

func ParseMapper(
	sourceName string,
	rdr io.Reader,
	refs Reference,
	flags ParseMapperFlags,
) (Mapper, error)

func (Mapper) ByIP

func (m Mapper) ByIP(ip net.IP) (mappings []Mapping, err error)

func (Mapper) ByIPString

func (m Mapper) ByIPString(s string) (mappings []Mapping, err error)

func (Mapper) ByNetIPAddr

func (m Mapper) ByNetIPAddr(ip netip.Addr) (mappings []Mapping, err error)

func (Mapper) FirstByIP

func (m Mapper) FirstByIP(ip net.IP) (mapping *Mapping, err error)

func (Mapper) FirstByIPString

func (m Mapper) FirstByIPString(s string) (mapping *Mapping, err error)

func (Mapper) FirstByNetIPAddr

func (m Mapper) FirstByNetIPAddr(ip netip.Addr) (mapping *Mapping, err error)

func (Mapper) MaybeFirstByIP

func (m Mapper) MaybeFirstByIP(ip net.IP) (mapping *Mapping, err error)

func (Mapper) MaybeFirstByIPString

func (m Mapper) MaybeFirstByIPString(s string) (mapping *Mapping, err error)

func (Mapper) MaybeFirstByNetIPAddr

func (m Mapper) MaybeFirstByNetIPAddr(ip netip.Addr) (mapping *Mapping, err error)

type MapperBuilder

type MapperBuilder struct {
	// contains filtered or unexported fields
}

func NewMapperBuilder

func NewMapperBuilder(sourceName string) MapperBuilder

func (MapperBuilder) AddNetwork

func (mb MapperBuilder) AddNetwork(network *net.IPNet, asn ASN) error

func (MapperBuilder) Mappings

func (mb MapperBuilder) Mappings() Mapper

type Mapping

type Mapping struct {
	Net *net.IPNet

	// The data may be bad, so this may be missing. Check it with Valid() even
	// if you get a mapping back.
	ASN ASN
}

func (Mapping) Network

func (m Mapping) Network() net.IPNet

func (Mapping) Valid

func (m Mapping) Valid() bool

type ParseMapperFlags

type ParseMapperFlags int
const (
	IgnoreMissingASN ParseMapperFlags = 1 << iota
	DropMissingASN
)

type Reference

type Reference struct {
	SourceName string
	ASNs       map[ID]ASN
}

func DefaultReference

func DefaultReference() Reference

func ParseReference

func ParseReference(sourceName string, rdr io.Reader) (Reference, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL