X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=src%2Fpython%2Flocation-importer.in;h=eb4a303b80aa0d375f3184e893f2cf8981a154ed;hb=b904896a954206e3862c9b9a67f4379113198361;hp=ea6d48527c8139760e38c6ee6c407c6cd8376009;hpb=f476cdfd464fff8415e0711e4b8212342c3ae3f7;p=people%2Fms%2Flibloc.git diff --git a/src/python/location-importer.in b/src/python/location-importer.in index ea6d485..eb4a303 100644 --- a/src/python/location-importer.in +++ b/src/python/location-importer.in @@ -70,6 +70,7 @@ class CLI(object): write.add_argument("--vendor", nargs="?", help=_("Sets the vendor")) write.add_argument("--description", nargs="?", help=_("Sets a description")) write.add_argument("--license", nargs="?", help=_("Sets the license")) + write.add_argument("--version", type=int, help=_("Database Format Version")) # Update WHOIS update_whois = subparsers.add_parser("update-whois", help=_("Update WHOIS Information")) @@ -155,6 +156,7 @@ class CLI(object): CREATE TABLE IF NOT EXISTS autnum_overrides( number bigint NOT NULL, name text, + country text, is_anonymous_proxy boolean DEFAULT FALSE, is_satellite_provider boolean DEFAULT FALSE, is_anycast boolean DEFAULT FALSE @@ -221,7 +223,21 @@ class CLI(object): DISTINCT ON (announcements.network) announcements.network AS network, announcements.autnum AS autnum, - networks.country AS country, + + -- Country + COALESCE( + ( + SELECT country FROM network_overrides overrides + WHERE announcements.network <<= overrides.network + ORDER BY masklen(overrides.network) DESC + LIMIT 1 + ), + ( + SELECT country FROM autnum_overrides overrides + WHERE announcements.autnum = overrides.number + ), + networks.country + ) AS country, -- Must be part of returned values for ORDER BY clause masklen(networks.network) AS sort, @@ -448,7 +464,6 @@ class CLI(object): server = ns.server[0] # Pre-compile regular expression for routes - #route = re.compile(b"^\*>?\s[\si]?([^\s]+)[.\s]*?(\d+)\si$", re.MULTILINE) route = re.compile(b"^\*[\s\>]i([^\s]+).+?(\d+)\si\r\n", re.MULTILINE|re.DOTALL) with telnetlib.Telnet(server) as t: @@ -457,8 +472,10 @@ class CLI(object): # t.set_debuglevel(10) # Wait for console greeting - greeting = t.read_until(b"> ") - log.debug(greeting.decode()) + greeting = t.read_until(b"> ", timeout=30) + if not greeting: + log.error("Could not get a console prompt") + return 1 # Disable pagination t.write(b"terminal length 0\n") @@ -626,12 +643,15 @@ class CLI(object): INSERT INTO autnum_overrides( number, name, + country, is_anonymous_proxy, is_satellite_provider, is_anycast - ) VALUES(%s, %s, %s, %s, %s) + ) VALUES(%s, %s, %s, %s, %s, %s) ON CONFLICT DO NOTHING""", - autnum, block.get("name"), + autnum, + block.get("name"), + block.get("country"), block.get("is-anonymous-proxy") == "yes", block.get("is-satellite-provider") == "yes", block.get("is-anycast") == "yes",