1
0
This commit is contained in:
dtb
2023-11-19 20:18:20 -07:00
parent 67b50e9133
commit 407ea45346
15 changed files with 5 additions and 0 deletions

20
niceties/ifpublic Executable file
View File

@@ -0,0 +1,20 @@
#!/bin/sh
: HTTP APIs that return your public IP address [both v4 and v6] "\
https://icanhazip.com
https://ifconfig.io
http://icanhazip.com
http://ifconfig.io/
"
PUBLIC_IP_FETCH_URL="https://icanhazip.com"
PUBLIC_IP6_FETCH_URL="$PUBLIC_IP_FETCH_URL"
printf "%s / %s\n" \
"$(curl -4 --connect-timeout 5 --silent "$PUBLIC_IP_FETCH_URL")" \
"$(curl -6 --connect-timeout 5 --silent "$PUBLIC_IP6_FETCH_URL")" \
| sed -e 's/ \/ $//' \
-e 's/^ \/ //' \
-e 's/^$/[error fetching address]/'
exit 0