Skip to content

brunoerg/asmapy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

64 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Asmapy - Asmap | Bitcoin Core

CLI to download dumps, convert dump files to human-readable ones, compare two files, and other stuff. Some codes presented here were originally written in sipa/asmap.

Installing and running

$ pip install -r requirements.txt
$ ./asmapy.py -h
usage: asmapy.py [-h] {diff,download,to-human-readable,to-binary,to-mapping} ...

Tool for performing various operations on texual and binary asmap files.

options:
  -h, --help            show this help message and exit

valid subcommands:
  {diff,download,to-human-readable,to-binary,to-mapping}
    diff                compute the difference between two asmap files
    download            download dumps
    to-human-readable   convert dump files to human-readable dumps (getting unique originating ASN for this prefix)
    to-binary           convert human-readable dump into binary asmap file
    to-mapping          convert (sets of) human-readable dumps into a text file with iprange->asn mappings

1. Downloading dumps

You can get dumps from a specific date (YYYYMMDD).

$ ./asmapy.py download 20220202

2. Converting dump files to human-readable

After downloading the dumps, they will be available in a folder (e.g. data-20220202), and you can use that directory in the following command to convert them to a human-readable format:

$ ./asmapy.py to-human-readable -p data-20220202

You can also pass more than one folder, this can be useful to combine data from different dates, e.g:

$ ./asmapy.py to-human-readable -p data-20220202 data-20221212

Use --allasn to fetch all ASN for every prefix instead of unique originating one.

Use --singleoutput to combine all dumps into one file.

3. Converting human-readable dumps into a text file with iprange->asn mappings

After converting the dumps using to-human-readable --singleoutput, you're gonna have one file with all dumps, it means we can have duplicated stuff. For this reason, you can use the following command to convert them into a text file with iprange->asn mappings.

$ ./asmapy.py to-mapping path/to/file

4. Converting a file to binary

$ ./asmapy.py to-binary path/to/file

Comparing two files

$ ./asmapy.py diff path/to/file1 path/to/file2

Optional flags:

  • --ignore-unassigned to ignore unassigned ranges in the first input (useful when second input is filled).
  • --unified to get output diff in unified format.
  • -ips= Path to file with ips. It will print the ASNs related to that ips which has changed

About

Asmap stuff for Bitcoin Core

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages