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
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,
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",