GithubHelp home page GithubHelp logo

maxmouchet / goasn Goto Github PK

View Code? Open in Web Editor NEW
6.0 3.0 2.0 2.87 MB

Fast offline lookup of IP addresses to IXP and AS numbers from RIB archives.

License: MIT License

Go 94.34% Python 2.37% Makefile 3.29%
go pyasn bgp rib mrt

goasn's Introduction

goasn

Build Status Go Report Card GoDoc

goasn provides fast lookup of IP addresses to IXP and AS numbers from RIB archives.
It supports the following sources:

It reads and store IP addresses in a radix tree (kentik/patricia) for fast lookups.

It supports multiple origin ASes in opposition to pyasn (pyasn#46).

WIP. The API is not stable

Quick Start

CLI

You can download the latest binary or build goasn by yourself.
Building meshmon requires Go 1.12+.

git clone https://github.com/maxmouchet/goasn.git
cd goasn; make
goasn download --collector route-views.amsix.routeviews.org --date 2019-08-01T08:00
goasn convert rib.20190801.0800.bz2
goasn lookup --db rib.20180801.0800.txt 8.8.8.8

Library

go get github.com/maxmouchet/goasn
asndb, _ := goasn.NewDB("rib.20180801.0800.txt")

asn, _ := asndb.LookupStr("8.8.8.8")
// => 15169

ip := net.ParseIP("1.1.1.1")
asn, _ := asndb.LookupIP(ip)
// => 13335

Performance

Constructing the radix tree is slower than pyasn, but lookups are faster.

# benchmark.go
Loading database from ipasn_20190822.dat...
Took 1.719656297s

Looking up 10000 addresses (string)
Took 3.367572ms

Looking up 10000 addresses (net.IP)
Took 1.631176ms
# benchmark.py
Loading database from ipasn_20190822.dat
Took 197.402488ms

Looking up 10000 addresses (string)
Took 9.340981ms

goasn's People

Contributors

maxmouchet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

c0c1 atlassion

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.