asnutil

package module
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: MIT Imports: 6 Imported by: 21

README

go-libp2p-asn-util

A library to lookup the ASN(Autonomous System Number) for an IP address. It uses the IPv6 to ASN database downloaded from https://iptoasn.com/. Supports ONLY IPv6 addresses for now.

Table of Contents

Install

go get github.com/libp2p/go-libp2p-asn-util

Usage

import (
    asn "github.com/libp2p/go-libp2p-asn-util"
)

func main() {
   store, err := asn.NewAsnStore()
   
   asNumber,err := store.AsnForIP(net.ParseIP("2a03:2880:f003:c07:face:b00c::2"))
 }

Contribute

Feel free to join in. All welcome. Open an issue!

This repository falls under the IPFS Code of Conduct.

License

MIT


Documentation

Overview

Package asnutil provides a mapping lookup for IPv6 ASNs.

Index

Constants

This section is empty.

Variables

View Source
var Store backwardCompat

Deprecated: use AsnForIPv6 or AsnForIPv6Network, they do not allocate.

Functions

func AsnForIPv6 added in v0.4.0

func AsnForIPv6(ip net.IP) (asn uint32)

AsnForIPv6 returns the AS number for the given IPv6 address. If no mapping exists for the given network, this function will return a zero ASN number.

func AsnForIPv6Network added in v0.4.0

func AsnForIPv6Network(network uint64) (asn uint32)

AsnForIPv6Network returns the AS number for the given IPv6 network. If no mapping exists for the given network, this function will return a zero ASN number. network is the first 64 bits of the ip address interpreted as big endian.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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