diff --git a/respodns/db.py b/respodns/db.py index ed7aa7e..1e91cdb 100644 --- a/respodns/db.py +++ b/respodns/db.py @@ -165,6 +165,11 @@ class RespoDB: execution.completed = completed self.flush() + def all_ips(self): + assert self._conn is not None + addresses = self._conn.find(TAddress) + return [addr.str for addr in addresses] + def next_record_id(self): from storm.expr import Add, Max, Coalesce expr = Add(Coalesce(Max(TRecord.record_id), 0), 1) diff --git a/respodns/dns.py b/respodns/dns.py index d766629..7ac4dd2 100644 --- a/respodns/dns.py +++ b/respodns/dns.py @@ -265,6 +265,14 @@ async def main(db, filepaths, checks, opts: Options): async for ip in reader: await process(ip, reader.total) + if seen == 0: + # no IPs were provided. refresh all the country codes instead. + all_ips = db.all_ips() + for i, ip in enumerate(all_ips): + if opts.progress: + print(f"#{i + 1}/{len(all_ips)}: {ip}", file=stderr) + await opts.ips.put(ip) + await pooler() await syncing await opts.ips.put(None) # end of queue