aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan <me@jordan.im>2022-03-25 23:10:28 -0700
committerJordan <me@jordan.im>2022-03-25 23:10:28 -0700
commit35523e3b29e68e70fd6107b4637aa1443014a6d2 (patch)
tree0820c4da33a95b664e0c24e9a81610949495853d
parent536cf7109071e0161b4ffd99070991995e4f472b (diff)
downloadasn-35523e3b29e68e70fd6107b4637aa1443014a6d2.tar.gz
asn-35523e3b29e68e70fd6107b4637aa1443014a6d2.zip
asn, readme: rm ipv6 toggle, unique netblock (prefer first)
-rw-r--r--README3
-rwxr-xr-xasn.py16
2 files changed, 7 insertions, 12 deletions
diff --git a/README b/README
index 98cb7bb..85193d2 100644
--- a/README
+++ b/README
@@ -1,12 +1,11 @@
asn: map hosts to their corresponding ASN via WHOIS
-usage: asn.py [-h] [--host HOST] [--port PORT] [--ipv6] [--update] [--populate]
+usage: asn.py [-h] [--host HOST] [--port PORT] [--update] [--populate]
optional arguments:
-h, --help show this help message and exit
--host HOST IP address to listen on
--port PORT Port to listen on
- --ipv6 Support queries for IPv6 hosts
--update Update dataset submodule and create/populate cache
--populate Create and populate cache from current dataset
diff --git a/asn.py b/asn.py
index 1b0d3ec..9d94cb2 100755
--- a/asn.py
+++ b/asn.py
@@ -17,8 +17,7 @@ log = logging.getLogger('asn')
log.setLevel(logging.DEBUG)
class Listener:
- def __init__(self, host, port, ipv6_enabled=False):
- self.ipv6_enabled = ipv6_enabled
+ def __init__(self, host, port):
self._listen(host, port)
def _listen(self, host, port):
@@ -102,10 +101,7 @@ class Listener:
if net.version == 4:
net = net.supernet(new_prefix=24)
elif net.version == 6:
- if self.ipv6_enabled:
- net = net.supernet(new_prefix=64)
- else:
- return None
+ net = net.supernet(new_prefix=64)
return net
@@ -141,6 +137,9 @@ class DB:
FOREIGN KEY(aut_num) REFERENCES asn(aut_num)
)
''')
+ self.con.execute('''
+ CREATE UNIQUE INDEX idx_net ON net(net)
+ ''')
self.con.execute('PRAGMA foreign_keys=ON')
self._get_entries()
@@ -230,9 +229,6 @@ if __name__ == '__main__':
parser.add_argument('--port', dest='port', type=int, action='store',
help='Port to listen on',
required=False)
- parser.add_argument('--ipv6', dest='ipv6_enabled', action='store_true',
- help='Support queries for IPv6 hosts',
- required=False)
parser.add_argument('--update', dest='update', action='store_true',
help='Update dataset submodule and create/populate cache',
required=False)
@@ -242,7 +238,7 @@ if __name__ == '__main__':
args = parser.parse_args()
if args.host and args.port:
- listen = Listener(args.host, args.port, args.ipv6_enabled)
+ listen = Listener(args.host, args.port)
elif args.update:
db = DB()
log.info('checking remote repository for new dataset...')