mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-09 12:21:57 -04:00
fallback to localhost if detecting dnsserver fails
This commit is contained in:
parent
b36e89d086
commit
490e5ba11d
3 changed files with 7 additions and 3 deletions
|
@ -167,7 +167,11 @@ def get_isp_info(ip=None):
|
|||
result = subprocess.run(['dig', 'example.com', 'A'], capture_output=True, text=True, check=True).stdout
|
||||
dns_server = result.split(';; SERVER: ', 1)[-1].split('\n')[0].split('#')[0].strip()
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
dns_server = Path('/etc/resolv.conf').read_text().split('nameserver ', 1)[-1].split('\n')[0].strip()
|
||||
except Exception:
|
||||
dns_server = '127.0.0.1'
|
||||
print(f'[red]:warning: WARNING: Could not determine DNS server, using {dns_server}[/red]')
|
||||
|
||||
# Get DNS resolver's ISP name
|
||||
# url = f'https://ipapi.co/{dns_server}/json/'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue