6-public now excludes fc* addresses,

cloudflare will use grepcidr if available to ensure public ip,
git *-all scripts now sort their output,
and a few other minor tweaks.
This commit is contained in:
2024-05-30 13:20:43 -04:00
parent aee3350271
commit 54b6c8479b
8 changed files with 46 additions and 6 deletions
+1 -1
View File
@@ -4,7 +4,7 @@
# keep trying until we get a result
# device info
address=$(ip -6 addr list scope global | grep -v " fd" | sed -n 's/.*inet6 \([0-9a-f:]\+\).*/\1/p' | head -n 1)
address=$(ip -6 addr list scope global | grep -v " fc" | grep -v " fd" | sed -n 's/.*inet6 \([0-9a-f:]\+\).*/\1/p' | head -n 1)
# dig
if [[ -z "$address" ]] && [[ -n $(command -v "dig") ]]; then
+36
View File
@@ -12,6 +12,10 @@ print_usage() {
echo "Usage: [token=<token-config-override>] [zone=<zone-config-override>] [prefix=<filter-prefix-override>] $0 [-q] [-f 'query-filters'] ('content' | 'regex-replace' 'regex-find')"
}
# known private ranges
local4='192.168.0.0/16 172.16.0.0/12 10.0.0.0/8'
local6='fc00::/7 fe80::/10'
# handle all arguments provided
while getopts 'f:qt' flag; do
case "$flag" in
@@ -69,6 +73,14 @@ fi
if [[ "$content" = *'<a>'* ]]; then
ipv4=$("$scriptRoot/4-public-ip.sh")
content=$(echo "$content" | sed "s/<a>/$ipv4/g")
# check if address is actually public
if [[ -n $(command -v "grepcidr") ]]; then
if [[ -z $(echo "$ipv4" | grepcidr -v "$local4") ]]; then
echo "IPv4 lookup failed, stopping"
exit 2
fi
fi
fi
# limit 1
@@ -77,12 +89,28 @@ if [[ "$content" = *'<a:'* ]]; then
domain=$(echo "$content" | grep -oP '(?<=\<a:)[^>]+(?=\>)')
ipv4=$(dig +short A "$domain" | head -n 1)
content=$(echo "$content" | sed "s/<a:$domain>/$ipv4/g")
# check if address is actually public
if [[ -n $(command -v "grepcidr") ]]; then
if [[ -z $(echo "$ipv4" | grepcidr -v "$local4") ]]; then
echo "IPv4 lookup for '$domain' failed, stopping"
exit 2
fi
fi
fi
# "<aaaa>" becomes current public ipv6
if [[ "$content" = *'<aaaa>'* ]]; then
ipv6=$("$scriptRoot/6-public-ip.sh")
content=$(echo "$content" | sed "s/<aaaa>/$ipv6/g")
# check if address is actually public
if [[ -n $(command -v "grepcidr") ]]; then
if [[ -z $(echo "$ipv6" | grepcidr -v "$local6") ]]; then
echo "IPv6 lookup failed, stopping"
exit 2
fi
fi
fi
# limit 1
@@ -91,6 +119,14 @@ if [[ "$content" = *'<aaaa:'* ]]; then
domain=$(echo "$content" | grep -oP '(?<=\<aaaa:)[^>]+(?=\>)')
ipv6=$(dig +short AAAA "$domain" | head -n 1)
content=$(echo "$content" | sed "s/<aaaa:$domain>/$ipv6/g")
# check if address is actually public
if [[ -n $(command -v "grepcidr") ]]; then
if [[ -z $(echo "$ipv6" | grepcidr -v "$local6") ]]; then
echo "IPv6 lookup for '$domain' failed, stopping"
exit 2
fi
fi
fi
# --- update regex ---
+1 -1
View File
@@ -48,5 +48,5 @@ function process_git_fetch () {
# and call process_git_fetch on each location that was found.
# we then work on the folder that contained the ".git" folder.
find "$followLinks" "$@" -type d -name ".git" $checkHidden | while read -r file; do process_git_fetch "$file"; done
find "$followLinks" "$@" -type d -name ".git" $checkHidden | sort | while read -r file; do process_git_fetch "$file"; done
+1 -1
View File
@@ -48,5 +48,5 @@ function process_git_list () {
# and call process_git_list on each location that was found.
# we then work on the folder that contained the ".git" folder.
find "$followLinks" "$@" -type d -name ".git" $checkHidden | while read -r file; do process_git_list "$file"; done
find "$followLinks" "$@" -type d -name ".git" $checkHidden | sort | while read -r file; do process_git_list "$file"; done
+1 -1
View File
@@ -5,7 +5,7 @@ PubkeyAuthentication yes
PermitRootLogin no
PasswordAuthentication no
ChallengeResponseAuthentication no
UsePAM no
UsePAM yes
LogLevel VERBOSE
X11Forwarding yes
+4
View File
@@ -57,3 +57,7 @@ highlight GitGutterDelete cterm=reverse ctermfg=1 ctermbg=none gui=reverse gui
" style vim-airline
let g:airline_theme='light'
" style context
let g:context_ellipsis_char='•'
let g:context_border_char='═'
+1 -1
View File
@@ -48,5 +48,5 @@ function process_git_pull () {
# and call process_git_pull on each location that was found.
# we then work on the folder that contained the ".git" folder.
find "$followLinks" "$@" -type d -name ".git" $checkHidden | while read -r file; do process_git_pull "$file"; done
find "$followLinks" "$@" -type d -name ".git" $checkHidden | sort | while read -r file; do process_git_pull "$file"; done
+1 -1
View File
@@ -97,5 +97,5 @@ function process_git_status () {
# and call process_git_list on each location that was found.
# we then work on the folder that contained the ".git" folder.
find "$followLinks" "$@" -type d -name ".git" $checkHidden | while read -r file; do process_git_status "$file"; done
find "$followLinks" "$@" -type d -name ".git" $checkHidden | sort | while read -r file; do process_git_status "$file"; done