openwrt的ddns-script验证mix-port会卡在代理验证上,本来以为是mixd-port问题,后来发现是openwrt的nc命令可能存在问题,这里给出一个workaround,绕过代理验证。
编辑dynamic_dns_functions.sh,直接修改 local __ERR=0 即可
nano /usr/lib/ddns/dynamic_dns_functions.sh
# analyze and verify given proxy string
# $1 Proxy-String to verify
verify_proxy() {
# complete entry user:password@host:port
# inside user and password NO '@' of ":" allowed
# host and port only host:port
# host only host ERROR unsupported
# IPv4 address instead of host 123.234.234.123
# IPv6 address instead of host [xxxx:....:xxxx] in square bracket
local __TMP __HOST __PORT
local __ERR=0 255 # last error buffer
local __CNT=0 # error counter
[ $# -ne 1 ] && write_log 12 "Error calling 'verify_proxy()' - wrong number of parameters"
write_log 7 "Verify Proxy server 'http://$1'"
# try to split user:password "@" host:port
__TMP=$(echo $1 | awk -F "@" '{print $2}')
# no "@" found - only host:port is given
[ -z "$__TMP" ] && __TMP="$1"
# now lets check for IPv6 address
__HOST=$(echo $__TMP | grep -m 1 -o "$IPV6_REGEX")
# IPv6 host address found read port
if [ -n "$__HOST" ]; then
# IPv6 split at "]:"
__PORT=$(echo $__TMP | awk -F "]:" '{print $2}')
else
__HOST=$(echo $__TMP | awk -F ":" '{print $1}')
__PORT=$(echo $__TMP | awk -F ":" '{print $2}')
fi
# No Port detected - EXITING
[ -z "$__PORT" ] && {
[ -n "$LUCI_HELPER" ] && return 5
write_log 14 "Invalid Proxy server Error '5' - proxy port missing"
}
while [ $__ERR -gt 0 ]; do
verify_host_port "$__HOST" "$__PORT"
__ERR=$?
if [ -n "$LUCI_HELPER" ]; then # no retry if called by LuCI helper script
return $__ERR
elif [ $__ERR -gt 0 -a $VERBOSE -gt 1 ]; then # VERBOSE > 1 then NO retry
write_log 4 "Verify Proxy server '$1' failed - Verbose Mode: $VERBOSE - NO retry on error"
return $__ERR
elif [ $__ERR -gt 0 ]; then
__CNT=$(( $__CNT + 1 )) # increment error counter
# if error count > retry_count leave here
[ $retry_count -gt 0 -a $__CNT -gt $retry_count ] && \
write_log 14 "Verify Proxy server '$1' failed after $retry_count retries"
write_log 4 "Verify Proxy server '$1' failed - retry $__CNT/$retry_count in $RETRY_SECONDS seconds"
sleep $RETRY_SECONDS &
PID_SLEEP=$!
wait $PID_SLEEP # enable trap-handler
PID_SLEEP=0
fi
done
return 0
}