utils

package
v0.0.72 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExpandCIDR added in v0.0.57

func ExpandCIDR(cidr string) ([]string, error)

ExpandCIDR expands a CIDR range into individual IP addresses

func ExplodeIPsFromAddressesAndCIDR added in v0.0.57

func ExplodeIPsFromAddressesAndCIDR(ipAddresses []string, cidr *string) ([]string, error)

ExplodeIPsFromAddressesAndCIDR extracts and expands all IPs from individual IP addresses and CIDR range

func ExtractASN added in v0.0.51

func ExtractASN(whoisOutput string) []string

ExtractASN extracts ASN information from whois output

func ExtractCIDRsByCountry added in v0.0.51

func ExtractCIDRsByCountry(response *utilsfern.BgpViewResponse, countryCode string) []string

ExtractCIDRsByCountry filters CIDRs by country code from BGPView response

func GetASNCIDRs added in v0.0.51

func GetASNCIDRs(ctx context.Context, asn string) ([]string, error)

GetASNCIDRs retrieves all CIDR prefixes for a given ASN using BGPView API This is the main function called by the ASN discovery module

func GetASNCIDRsDetailed added in v0.0.51

func GetASNCIDRsDetailed(ctx context.Context, asn string) (*utilsfern.BgpViewResponse, error)

GetASNCIDRsDetailed retrieves detailed CIDR information for a given ASN Returns the full BGPView response with additional metadata

func GetASNCIDRsWithTimeout added in v0.0.51

func GetASNCIDRsWithTimeout(ctx context.Context, asn string, timeout time.Duration) ([]string, error)

GetASNCIDRsWithTimeout retrieves all CIDR prefixes for a given ASN using BGPView API with timeout

func GetASNDescription added in v0.0.51

func GetASNDescription(ctx context.Context, asn string, timeout ...time.Duration) (string, error)

GetASNDescription looks up the description for a given ASN using Cymru's asn.cymru.com zone Example query: dig +short AS23028.asn.cymru.com TXT

func GetASNInfo added in v0.0.51

func GetASNInfo(ctx context.Context, asn string) (*utilsfern.BgpViewResponse, error)

GetASNInfo retrieves comprehensive ASN information using BGPView API

func GetASNInfoWithTimeout added in v0.0.51

func GetASNInfoWithTimeout(ctx context.Context, asn string, timeout time.Duration) (*utilsfern.BgpViewResponse, error)

GetASNInfoWithTimeout retrieves comprehensive ASN information using BGPView API with timeout

func GetEntriesFromFiles

func GetEntriesFromFiles(paths []string) ([]string, error)

func GetResolver added in v0.0.32

func GetResolver(dnsServerAddress string, log svc1log.Logger) *net.Resolver

GetResolver returns a new resolver with the given DNS server address. If the DNS server address is empty, the system default resolver is used. If the DNS server address is provided, the resolver is configured to use the given DNS server address.

func IPASNLookup added in v0.0.51

func IPASNLookup(ctx context.Context, ip string) ([]string, error)

IPASNLookup performs an ASN lookup using the Cymru DNS service Returns ASN information for the given IP address using raw DNS queries Returns the first ASN if multiple ASNs are found (for backward compatibility)

func IPASNLookupDetailed added in v0.0.51

func IPASNLookupDetailed(ctx context.Context, ip string) (*utilsfern.CymruAsnResult, error)

IPASNLookupDetailed performs an ASN lookup using the Cymru DNS service Returns detailed ASN information for the given IP address using raw DNS queries Now returns ALL ASNs associated with the IP (handles multi-homed networks)

func IPASNLookupMultiple added in v0.0.57

func IPASNLookupMultiple(ctx context.Context, ip string) ([]string, error)

IPASNLookupMultiple performs an ASN lookup and returns ALL ASNs associated with an IP This is useful for detecting multi-homed networks, anycast deployments, or route hijacking Returns a slice of ASN strings, empty slice if none found

func ValidateDNSServerAddress added in v0.0.32

func ValidateDNSServerAddress(address string) error

ValidateDNSServerAddress checks if the DNS server address is in the correct format (IP:PORT or HOSTNAME:PORT)

func WhoisASN added in v0.0.51

func WhoisASN(query string) ([]string, error)

WhoisASN performs a whois lookup and extracts ASN information

func WhoisASNWithContext added in v0.0.51

func WhoisASNWithContext(ctx context.Context, query string) ([]string, error)

WhoisASNWithContext performs a whois lookup with context and extracts ASN information

Types

type BGPViewClient added in v0.0.51

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

BGPViewClient represents a client for the BGPView.io API

func NewBGPViewClient added in v0.0.51

func NewBGPViewClient() *BGPViewClient

NewBGPViewClient creates a new BGPView API client

func (*BGPViewClient) GetASNInfo added in v0.0.51

func (c *BGPViewClient) GetASNInfo(ctx context.Context, asn string) (*utilsfern.BgpViewResponse, error)

GetASNInfo retrieves basic ASN information using BGPView API This provides an alternative to Cymru DNS for ASN description lookup

func (*BGPViewClient) GetASNInfoWithTimeout added in v0.0.51

func (c *BGPViewClient) GetASNInfoWithTimeout(ctx context.Context, asn string, timeout time.Duration) (*utilsfern.BgpViewResponse, error)

GetASNInfoWithTimeout retrieves basic ASN information using BGPView API with timeout

func (*BGPViewClient) GetASNPrefixes added in v0.0.51

func (c *BGPViewClient) GetASNPrefixes(ctx context.Context, asn string) (*utilsfern.BgpViewResponse, error)

GetASNPrefixes retrieves all BGP prefixes for a given ASN

func (*BGPViewClient) GetASNPrefixesWithTimeout added in v0.0.51

func (c *BGPViewClient) GetASNPrefixesWithTimeout(ctx context.Context, asn string, timeout time.Duration) (*utilsfern.BgpViewResponse, error)

GetASNPrefixesWithTimeout retrieves all BGP prefixes for a given ASN with timeout

func (*BGPViewClient) SetTimeout added in v0.0.51

func (c *BGPViewClient) SetTimeout(timeout time.Duration) *BGPViewClient

SetTimeout sets the HTTP client timeout

func (*BGPViewClient) SetUserAgent added in v0.0.51

func (c *BGPViewClient) SetUserAgent(userAgent string) *BGPViewClient

SetUserAgent sets a custom User-Agent header

type WhoisClient added in v0.0.51

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

WhoisClient represents a whois client

func NewWhoisClient added in v0.0.51

func NewWhoisClient() *WhoisClient

NewWhoisClient creates a new whois client

func (*WhoisClient) SetServers added in v0.0.51

func (c *WhoisClient) SetServers(servers []string) *WhoisClient

SetServers sets the whois servers to use

func (*WhoisClient) SetTimeout added in v0.0.51

func (c *WhoisClient) SetTimeout(timeout time.Duration) *WhoisClient

SetTimeout sets the timeout for whois queries

func (*WhoisClient) Whois added in v0.0.51

func (c *WhoisClient) Whois(query string) (string, error)

Whois performs a whois lookup on the given domain/IP

func (*WhoisClient) WhoisWithContext added in v0.0.51

func (c *WhoisClient) WhoisWithContext(ctx context.Context, query string) (string, error)

WhoisWithContext performs a whois lookup with a custom context

func (*WhoisClient) WhoisWithContextAndServer added in v0.0.51

func (c *WhoisClient) WhoisWithContextAndServer(ctx context.Context, query string, server string) (string, error)

WhoisWithContextAndServer performs a whois lookup with a custom context and specified server

func (*WhoisClient) WhoisWithContextAndServerVerbose added in v0.0.51

func (c *WhoisClient) WhoisWithContextAndServerVerbose(ctx context.Context, query string, server string) (string, error)

WhoisWithContextAndServerVerbose performs a whois lookup with a custom context, specified server, and verbose output

func (*WhoisClient) WhoisWithServer added in v0.0.51

func (c *WhoisClient) WhoisWithServer(query string, server string) (string, error)

WhoisWithServer performs a whois lookup on the given domain/IP with a specified server

func (*WhoisClient) WhoisWithServerVerbose added in v0.0.51

func (c *WhoisClient) WhoisWithServerVerbose(query string, server string) (string, error)

WhoisWithServerVerbose performs a whois lookup on the given domain/IP with a specified server and verbose output

Jump to

Keyboard shortcuts

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