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

Feature AS inforomation lookup #10

Merged
merged 9 commits into from
Jul 18, 2022
Merged

Feature AS inforomation lookup #10

merged 9 commits into from
Jul 18, 2022

Conversation

digizeph
Copy link
Member

@digizeph digizeph commented Jul 18, 2022

New Features

monocle whois

This pull request adds a new subcommand monocle whois that allows querying AS and organization information with ASN or name text.

This function has the following features:

  • one bootstrap and offline use forever
    • 1 minute bootstrap time
  • "smart query": search based on input, 400644 -> search by ASN, bgpkit -> search by AS name
    • can always fall back for force searching by ASN or name
  • output to table and order entries by organizations' sizes
  • SQLite as storage backend, so users can always run queries directly on the database
    • The database is stored at ~/.monocle/monocle-data.sqlite3 by default
➜  ~ monocle whois --help
monocle-whois 0.0.4
ASN and organization lookup utility

USAGE:
    monocle whois [OPTIONS] <QUERY>

ARGS:
    <QUERY>    Search query, an ASN (e.g. "400644") or a name (e.g. "bgpkit")

OPTIONS:
    -a, --asn-only     Search by ASN only
    -h, --help         Print help information
    -n, --name-only    Search AS and Org name only
    -u, --update       Refresh local as2org database
    -V, --version      Print version information

Example queries:

➜  ~ monocle whois 400644
+--------+------------+------------+--------------+-------------+----------+
|  asn   |  as_name   |  org_name  |    org_id    | org_country | org_size |
+--------+------------+------------+--------------+-------------+----------+
| 400644 | BGPKIT-LLC | BGPKIT LLC | BL-1057-ARIN |     US      |    1     |
+--------+------------+------------+--------------+-------------+----------+

➜  ~ monocle whois bgpkit
+--------+------------+------------+--------------+-------------+----------+
|  asn   |  as_name   |  org_name  |    org_id    | org_country | org_size |
+--------+------------+------------+--------------+-------------+----------+
| 400644 | BGPKIT-LLC | BGPKIT LLC | BL-1057-ARIN |     US      |    1     |
+--------+------------+------------+--------------+-------------+----------+

Monocle Configration

This pull request also adds the initial support for configuring Monocle's behavior. There are two ways to pass configuration values to the function:

  1. by environment variable with prefix MONOCLE_
  2. by changing TOML configuration file at ~/.monocle/monocle.toml

Currently, we have one supported variable:

  • data_dir: the directory where the Monocle's SQLite datafile will be stored

Users can configure data_dir to ~/DATA in two ways: set environment variable MONOCLE_DATA_DIR=~/DATA or have a data_dir="~/DATA" in the ~/.monocle/monocle.toml file like below

### monocle configuration file

### directory for cached data used by monocle
data_dir="~/.monocle"

@digizeph digizeph mentioned this pull request Jul 18, 2022
3 tasks
@digizeph digizeph marked this pull request as ready for review July 18, 2022 01:21
@digizeph digizeph merged commit ab2b611 into main Jul 18, 2022
@digizeph digizeph deleted the feature-as2org branch July 18, 2022 01:21
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.

1 participant