Skip to content
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

Merged
merged 9 commits into from
Sep 18, 2020
Merged

Library for IP -> ASN mapping #1

merged 9 commits into from
Sep 18, 2020

Conversation

aarshkshah1992
Copy link
Contributor

ONLY supports IPv6 for now.

Copy link
Contributor

@willscott willscott left a 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) {
Copy link
Contributor

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)
Copy link
Contributor

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
Copy link
Contributor

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) {
Copy link
Member

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.

@jtacoma
Copy link

jtacoma commented Sep 6, 2020

Note this would also make the master branch non-empty, solve #2, and allow a simple go get package/that/depends/on/this to get a non-empty go-libp2p-asn-util.

@aschmahmann aschmahmann merged commit dfb290b into master Sep 18, 2020
@aschmahmann aschmahmann mentioned this pull request Dec 1, 2021
80 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants