-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Library for IP -> ASN mapping #1
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- don't include the tsv in the repo
- ideally set up so
go generate
rebuilds the generated file - would be great if the rebuilder can re-download a new version of the database, so that
go generate
is the only command that needs to be run to update the lib.
// AsnForIPv6 returns the AS number for the given IPv6 address. | ||
// If no mapping exists for the given IP, this function will | ||
// return an empty ASN and a nil error. | ||
func (a *asnStore) AsnForIPv6(ip net.IP) (string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
string is a weird return type? Asn's are positive integers
panic(err) | ||
} | ||
} | ||
printf("package %s\n\n", pkgName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider template
, which may make this easier to read:
e.g. https://github.com/ipfs/go-datastore/blob/master/fuzz/cmd/generate/main.go#L60
- [Contribute](#contribute) | ||
- [License](#license) | ||
|
||
## Install |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
include a section on how to rebuild the DB
asn.go
Outdated
|
||
// NewAsnStore returns a `asnStore` that can be queried for the Autonomous System Numbers | ||
// for a given IP address or a multiaddress which contains an IP address. | ||
func NewAsnStore() (*asnStore, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any way to pre-generate this? This only adds 2MiB of data (not nice but not terrible), but this function takes way too long to run.
And update some deps
feat: use deferred initialization of the asnStore
Note this would also make the master branch non-empty, solve #2, and allow a simple |
ONLY supports IPv6 for now.