mirror of
https://github.com/ArchiveBox/ArchiveBox
synced 2024-11-22 04:03:06 +00: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
|
@ -129,7 +129,7 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=apt-$TARGETARCH$T
|
||||||
# 1. packaging dependencies
|
# 1. packaging dependencies
|
||||||
apt-transport-https ca-certificates apt-utils gnupg2 curl wget \
|
apt-transport-https ca-certificates apt-utils gnupg2 curl wget \
|
||||||
# 2. docker and init system dependencies
|
# 2. docker and init system dependencies
|
||||||
zlib1g-dev dumb-init gosu cron unzip grep \
|
zlib1g-dev dumb-init gosu cron unzip grep dnsutils \
|
||||||
# 3. frivolous CLI helpers to make debugging failed archiving easier
|
# 3. frivolous CLI helpers to make debugging failed archiving easier
|
||||||
# nano iputils-ping dnsutils htop procps jq yq
|
# nano iputils-ping dnsutils htop procps jq yq
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
|
@ -66,7 +66,7 @@ class BaseBinary(BaseHook, Binary):
|
||||||
symlink.unlink(missing_ok=True)
|
symlink.unlink(missing_ok=True)
|
||||||
symlink.symlink_to(binary.abspath)
|
symlink.symlink_to(binary.abspath)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
# print('[red]:caution: Failed to symlink binary into ./lib/bin folder[/red]', err)
|
# print('[red]:warning: Failed to symlink binary into ./lib/bin folder[/red]', err)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@validate_call
|
@validate_call
|
||||||
|
|
|
@ -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
|
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()
|
dns_server = result.split(';; SERVER: ', 1)[-1].split('\n')[0].split('#')[0].strip()
|
||||||
except Exception:
|
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
|
# Get DNS resolver's ISP name
|
||||||
# url = f'https://ipapi.co/{dns_server}/json/'
|
# url = f'https://ipapi.co/{dns_server}/json/'
|
||||||
|
|
Loading…
Reference in a new issue