mirror of
https://github.com/sileht/bird-lg.git
synced 2024-11-25 08:14:42 +01:00
Add support for configuring the DNS-based ASN → name mapping service.
This commit is contained in:
parent
ca7eb2b9ac
commit
2418d13d07
3
lg.cfg
3
lg.cfg
|
@ -23,4 +23,7 @@ AS_NUMBER = {
|
||||||
|
|
||||||
#WHOIS_SERVER = "whois.foo.bar"
|
#WHOIS_SERVER = "whois.foo.bar"
|
||||||
|
|
||||||
|
# DNS zone to query for ASN -> name mapping
|
||||||
|
ASN_ZONE = "asn.cymru.com"
|
||||||
|
|
||||||
SESSION_KEY = '\xd77\xf9\xfa\xc2\xb5\xcd\x85)`+H\x9d\xeeW\\%\xbe/\xbaT\x89\xe8\xa7'
|
SESSION_KEY = '\xd77\xf9\xfa\xc2\xb5\xcd\x85)`+H\x9d\xeeW\\%\xbe/\xbaT\x89\xe8\xa7'
|
||||||
|
|
8
lg.py
8
lg.py
|
@ -29,7 +29,7 @@ from urllib import quote, unquote
|
||||||
import json
|
import json
|
||||||
import random
|
import random
|
||||||
|
|
||||||
from toolbox import mask_is_valid, ipv6_is_valid, ipv4_is_valid, resolve, save_cache_pickle, load_cache_pickle, get_asn_from_as, unescape
|
from toolbox import mask_is_valid, ipv6_is_valid, ipv4_is_valid, resolve, save_cache_pickle, load_cache_pickle, unescape
|
||||||
#from xml.sax.saxutils import escape
|
#from xml.sax.saxutils import escape
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,6 +46,12 @@ file_handler.setLevel(getattr(logging, app.config["LOG_LEVEL"].upper()))
|
||||||
app.logger.addHandler(file_handler)
|
app.logger.addHandler(file_handler)
|
||||||
|
|
||||||
|
|
||||||
|
def get_asn_from_as(n):
|
||||||
|
asn_zone = app.config.get("ASN_ZONE", "asn.cymru.com")
|
||||||
|
data = resolve("AS%s.%s" % (n, asn_zone) ,"TXT").replace("'","").replace('"','')
|
||||||
|
return [ field.strip() for field in data.split("|") ]
|
||||||
|
|
||||||
|
|
||||||
def add_links(text):
|
def add_links(text):
|
||||||
"""Browser a string and replace ipv4, ipv6, as number, with a
|
"""Browser a string and replace ipv4, ipv6, as number, with a
|
||||||
whois link """
|
whois link """
|
||||||
|
|
|
@ -27,10 +27,6 @@ import xml.parsers.expat
|
||||||
def resolve(n, q):
|
def resolve(n, q):
|
||||||
return str(resolver.query(n,q)[0])
|
return str(resolver.query(n,q)[0])
|
||||||
|
|
||||||
def get_asn_from_as(n):
|
|
||||||
data = resolve("AS%s.asn.cymru.com" % n ,"TXT").replace("'","").replace('"','')
|
|
||||||
return [ field.strip() for field in data.split("|") ]
|
|
||||||
|
|
||||||
def mask_is_valid(n):
|
def mask_is_valid(n):
|
||||||
if not n:
|
if not n:
|
||||||
return True
|
return True
|
||||||
|
|
Loading…
Reference in a new issue