Update ASN data
ASN data 20240123
Update embedded data
Look up ASNs. Can be used as a library or a CLI.
Comes with (possibly out of date) versions of the ASN database from APNIC embedded:
Or you can download and parse new versions yourself with asn.ParseReference
and asn.ParseMappings
.
Install the CLI:
go install go.shabbyrobe.org/asnine/cmd/asnine@latest
You can look up individual IPs like so:
asnine lookup 8.8.8.8
But it's really slow to do it this way because the data is slow to parse and I don't have a good intermediate format yet.
There's also a scan mode that works with stdin, and is most useful with a streaming pipe input:
$ </some/log jq -r .ipAddress | asnine scan -
scan
can also be used with rlwrap
to create a cheap interactive shell. You
can get rlwrap
from homebrew, apt, or where all good action toys are sold.
(NOTE: There may be a delay before the first input produces an output):
$ rlwrap -S 'ip> ' asnine scan -
ip> 8.8.8.8
{"success":true,"ip":"8.8.8.8", ...}
ip> 1.1.1.1
{"success":true,"ip":"8.8.8.8", ...}
If you're really adventurous, there's a crap linewise TCP server you can use like so:
go run asnine serve 127.0.0.1:9876
Then you can use rlwrap
, just as with scan
, from another terminal, and
it'll behave pretty much the same way:
$ rlwrap -S 'ip> ' nc 127.0.0.1 9876
This is a tool I hack on for my own amusement in an ad-hoc fashion. No stability guarantees are made, the code is not guaranteed to work, and anything may be changed, renamed or removed at any time as I see fit.
If you wish to use any of this, I strongly recommend you copy-paste pieces as-needed (including tests and license/attribution) into your own project, or fork it for your own purposes.
Bug reports are welcome, feature requests discouraged, and code contributions will not be accepted.
asnine
is Copyright Blake Williams code@shabbyrobe.org 2023. It is licensed
under a 3-clause BSD license.