mirror of
https://github.com/hykilpikonna/hyfetch.git
synced 2026-03-21 17:24:51 -05:00
[+] Use cloudflare for public IP field (#416)
* Update neofetch * [F] Fix drill cloudflare and add fallback --------- Co-authored-by: Azalea <22280294+hykilpikonna@users.noreply.github.com>
This commit is contained in:
parent
0c9e4db742
commit
455f0382e7
10
neofetch
10
neofetch
|
|
@ -5300,6 +5300,16 @@ get_local_ip() {
|
|||
}
|
||||
|
||||
get_public_ip() {
|
||||
if [[ -z "$public_ip_host" ]] && type -p dig >/dev/null; then
|
||||
public_ip="$(dig +time=1 +tries=1 +short TXT ch whoami.cloudflare @1.1.1.1 | tr -d '"')"
|
||||
[[ "$public_ip" =~ ^\; ]] && unset public_ip
|
||||
fi
|
||||
|
||||
if [[ -z "$public_ip_host" ]] && [[ -z "$public_ip" ]] && type -p drill >/dev/null; then
|
||||
public_ip="$(drill whoami.cloudflare TXT CH @1.1.1.1 | awk '/^whoami\./ && $3 == "CH" {print $5}' | tr -d '"')"
|
||||
fi
|
||||
|
||||
# Fallback
|
||||
if [[ -z "$public_ip_host" ]] && type -p dig >/dev/null; then
|
||||
public_ip="$(dig +time=1 +tries=1 +short myip.opendns.com @resolver1.opendns.com)"
|
||||
[[ "$public_ip" =~ ^\; ]] && unset public_ip
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user