|
12 | 12 | # │ (Launch the script without parameters or visit the project's homepage for usage info)│ |
13 | 13 | # ╰──────────────────────────────────────────────────────────────────────────────────────╯ |
14 | 14 |
|
15 | | -ASN_VERSION="0.79.0" |
| 15 | +ASN_VERSION="0.80.0" |
16 | 16 | ASN_LOGFILE="$HOME/asndebug.log" |
17 | 17 |
|
18 | 18 | # ╭──────────────────╮ |
@@ -1039,8 +1039,12 @@ TraceASPath(){ |
1039 | 1039 | BoxHeader "$headermsg" |
1040 | 1040 | # check if we're trying to trace an IPv6 from an IPv4-only box |
1041 | 1041 | echo "$host_to_trace" | grep -q ':' && is_ipv6=true || is_ipv6=false |
1042 | | - if [ "$is_ipv6" = true ] && [ "$HAVE_IPV6" = false ]; then |
1043 | | - PrintErrorAndExit "Error: cannot trace an IPv6 from this IPv4-only host!" |
| 1042 | + if [ "$is_ipv6" = true ]; then |
| 1043 | + if [ "$FORCE_IPV4" = true ]; then |
| 1044 | + PrintErrorAndExit "Error: cannot trace an IPv6 when FORCE_IPV4=true (hint: check .asnrc or don't pass the -4 option)" |
| 1045 | + elif [ "$HAVE_IPV6" = false ]; then |
| 1046 | + PrintErrorAndExit "Error: cannot trace an IPv6 from this IPv4-only host!" |
| 1047 | + fi |
1044 | 1048 | fi |
1045 | 1049 | echo "" |
1046 | 1050 | StatusbarMessage "Collecting trace data to ${bluebg}${host_to_trace}${lightgreybg}" |
@@ -3028,8 +3032,9 @@ AsnServerListener(){ |
3028 | 3032 | # Handle all non-GCP cases |
3029 | 3033 | # prepare the bookmarklet URL and the appropriate notation for the server's bind address:port |
3030 | 3034 | if [ "$ASN_SRV_BINDADDR" = "0.0.0.0" ]; then |
| 3035 | + FORCE_IPV4=true |
3031 | 3036 | # discover our IPv4 WAN IP if we already determined we're on an IPv6-capable host but the user wants to bind to 0.0.0.0 |
3032 | | - [[ "$HAVE_IPV6" = true ]] && WhatIsMyIP "true" |
| 3037 | + [[ "$HAVE_IPV6" = true ]] && WhatIsMyIP |
3033 | 3038 | if grep -q ':' <<<"$local_wanip"; then |
3034 | 3039 | INTERNAL_ASNSERVER_ADDRESS="[$local_wanip]:$ASN_SRV_BINDPORT" |
3035 | 3040 | else |
@@ -3167,8 +3172,8 @@ StatusbarMessage() { # invoke without parameters to delete the status bar messag |
3167 | 3172 | } |
3168 | 3173 |
|
3169 | 3174 | WhatIsMyIP() { |
3170 | | - # if an argument was passed, force IPv4 lookup (and skip "only check once" check) |
3171 | | - if [ -n "$1" ]; then |
| 3175 | + # if FORCE_IPV4=true, force IPv4 lookup (and skip "only check once" check) |
| 3176 | + if [ "$FORCE_IPV4" = true ]; then |
3172 | 3177 | local_wanip=$(docurl -m10 -s -4 "https://ifconfig.co") |
3173 | 3178 | else |
3174 | 3179 | # only lookup local WAN IP once |
@@ -3432,6 +3437,7 @@ CheckPrerequisites() { |
3432 | 3437 | DebugPrint "${dim}${white}$token: ${green}✓ OK${white}" |
3433 | 3438 | fi |
3434 | 3439 | done |
| 3440 | + [[ "$FORCE_IPV4" = true ]] && DebugPrint "${dim}${white}Forcing IPv4-only connectivity (FORCE_IPV4=true)" |
3435 | 3441 | fi |
3436 | 3442 | fi |
3437 | 3443 | CoreutilsFixup |
@@ -4131,6 +4137,7 @@ peeringdb_ipv6_dataset="" |
4131 | 4137 | [[ -r "/etc/services" ]] && WELL_KNOWN_PORTS=$(cat /etc/services) || WELL_KNOWN_PORTS="" |
4132 | 4138 |
|
4133 | 4139 | # default options (configurable via $HOME/.asnrc) |
| 4140 | +FORCE_IPV4=false |
4134 | 4141 | MTR_TRACING=true |
4135 | 4142 | ADDITIONAL_INETNUM_LOOKUP=true |
4136 | 4143 | DETAILED_TRACE=false |
@@ -4210,7 +4217,7 @@ json_resultcount=0 |
4210 | 4217 | # in this mode, getopts sets optchar to: |
4211 | 4218 | # '?' -> unknown option |
4212 | 4219 | # ':' -> missing mandatory parameter to the option |
4213 | | -optspec=":hvmljJsgn:t:d:o:a:c:u:" |
| 4220 | +optspec=":hvmljJsg4n:t:d:o:a:c:u:" |
4214 | 4221 |
|
4215 | 4222 | FORCE_ORGSEARCH=false |
4216 | 4223 | SUGGEST_SEARCH=false |
@@ -4295,6 +4302,11 @@ while getopts "$optspec" optchar; do { |
4295 | 4302 | #shellcheck disable=SC2218 |
4296 | 4303 | GetFullParamsFromCurrentPosition "$@" |
4297 | 4304 | ;; |
| 4305 | + "4") |
| 4306 | + FORCE_IPV4=true |
| 4307 | + #shellcheck disable=SC2218 |
| 4308 | + GetFullParamsFromCurrentPosition "$@" |
| 4309 | + ;; |
4298 | 4310 | "m") |
4299 | 4311 | MONOCHROME_MODE=true |
4300 | 4312 | ;; |
|
0 commit comments