|
@@ -63,6 +63,7 @@ ERR_LOCAL_IP=0 # error counter on getting local ip
|
63
|
63
|
ERR_REG_IP=0 # error counter on getting DNS registered ip
|
64
|
64
|
ERR_SEND=0 # error counter on sending update to DNS provider
|
65
|
65
|
ERR_UPDATE=0 # error counter on different local and registered ip
|
|
66
|
+ERR_VERIFY=0 # error counter verifying proxy- and dns-servers
|
66
|
67
|
|
67
|
68
|
# format to show date information in log and luci-app-ddns default ISO 8601 format
|
68
|
69
|
DATE_FORMAT=$(uci -q get ddns.global.date_format) || DATE_FORMAT="%F %R"
|
|
@@ -122,10 +123,10 @@ start_daemon_for_all_ddns_sections()
|
122
|
123
|
local __SECTIONID=""
|
123
|
124
|
local __IFACE=""
|
124
|
125
|
|
125
|
|
- config_cb()
|
|
126
|
+ config_cb()
|
126
|
127
|
{
|
127
|
128
|
# only look for section type "service", ignore everything else
|
128
|
|
- [ "$1" == "service" ] && __SECTIONS="$__SECTIONS $2"
|
|
129
|
+ [ "$1" = "service" ] && __SECTIONS="$__SECTIONS $2"
|
129
|
130
|
}
|
130
|
131
|
config_load "ddns"
|
131
|
132
|
|
|
@@ -214,7 +215,7 @@ __urlencode() {
|
214
|
215
|
return 0
|
215
|
216
|
}
|
216
|
217
|
|
217
|
|
-# extract update_url for given DDNS Provider from
|
|
218
|
+# extract url or script for given DDNS Provider from
|
218
|
219
|
# file /usr/lib/ddns/services for IPv4 or from
|
219
|
220
|
# file /usr/lib/ddns/services_ipv6 for IPv6
|
220
|
221
|
get_service_data() {
|
|
@@ -387,25 +388,27 @@ __verify_host_port() {
|
387
|
388
|
# command error
|
388
|
389
|
[ $__ERR -gt 0 ] && {
|
389
|
390
|
verbose_echo "\n!!!!!!!!! ERROR =: BusyBox nslookup Error '$__ERR'\n$(eval $__ERRPROG)\n"
|
390
|
|
- syslog_err "DNS Resolver Error - BusyBox nslookup Error: '$__ERR'"
|
|
391
|
+ syslog_err "DNS Resolver Error - BusyBox nslookup Error '$__ERR'"
|
391
|
392
|
return 2
|
392
|
393
|
} || {
|
393
|
394
|
# we need to run twice because multi-line output needs to be directly piped to grep because
|
394
|
395
|
# pipe returns return code of last prog in pipe but we need errors from nslookup command
|
395
|
|
- __IPV4=$(eval $__RUNPROG | sed '1,2d' | grep -o "Name:\|Address.*" | grep -m 1 -o "$IPV4_REGEX")
|
396
|
|
- __IPV6=$(eval $__RUNPROG | sed '1,2d' | grep -o "Name:\|Address.*" | grep -m 1 -o "$IPV6_REGEX")
|
|
396
|
+ __IPV4=$(eval $__RUNPROG | sed -ne "3,\$ { s/^Address [0-9]*: \($IPV4_REGEX\).*$/\\1/p }")
|
|
397
|
+ __IPV6=$(eval $__RUNPROG | sed -ne "3,\$ { s/^Address [0-9]*: \($IPv6_REGEX\).*$/\\1/p }")
|
397
|
398
|
}
|
398
|
399
|
|
399
|
400
|
# check IP version if forced
|
400
|
401
|
if [ $force_ipversion -ne 0 ]; then
|
401
|
|
- [ $use_ipv6 -eq 0 -a -z "$__IPV4" ] && return 4
|
402
|
|
- [ $use_ipv6 -eq 1 -a -z "$__IPV6" ] && return 4
|
|
402
|
+ __ERR=0
|
|
403
|
+ [ $use_ipv6 -eq 0 -a -z "$__IPV4" ] && __ERR=4
|
|
404
|
+ [ $use_ipv6 -eq 1 -a -z "$__IPV6" ] && __ERR=6
|
|
405
|
+ [ $__ERR -gt 0 ] && critical_error "Invalid host: Error '4' - Force IP Version IPv$__ERR not supported"
|
403
|
406
|
fi
|
404
|
407
|
|
405
|
408
|
# verify nc command
|
406
|
409
|
# busybox nc compiled without -l option "NO OPT l!" -> critical error
|
407
|
410
|
nc --help 2>&1 | grep -iq "NO OPT l!" && \
|
408
|
|
- critical_error "Busybox nc: netcat compiled with errors"
|
|
411
|
+ critical_error "Busybox nc: netcat compiled without -l option, error 'NO OPT l!'"
|
409
|
412
|
# busybox nc compiled with extensions
|
410
|
413
|
nc --help 2>&1 | grep -q "\-w" && __NCEXT="TRUE"
|
411
|
414
|
|
|
@@ -428,7 +431,7 @@ __verify_host_port() {
|
428
|
431
|
__ERR=$?
|
429
|
432
|
[ $__ERR -eq 0 ] && return 0
|
430
|
433
|
verbose_echo "\n!!!!!!!!! ERROR =: BusyBox nc Error '$__ERR'\n$(eval $__ERRPROG)\n"
|
431
|
|
- syslog_err "host verify Error - BusyBox nc Error: '$__ERR'"
|
|
434
|
+ syslog_err "host verify Error - BusyBox nc Error '$__ERR'"
|
432
|
435
|
return 3
|
433
|
436
|
else # nc compiled without extensions (no timeout support)
|
434
|
437
|
__RUNPROG="__timeout 2 -- nc $__IP $__PORT </dev/null >/dev/null 2>&1"
|
|
@@ -437,7 +440,7 @@ __verify_host_port() {
|
437
|
440
|
__ERR=$?
|
438
|
441
|
[ $__ERR -eq 0 ] && return 0
|
439
|
442
|
verbose_echo "\n!!!!!!!!! ERROR =: BusyBox nc Error '$__ERR' (timeout)"
|
440
|
|
- syslog_err "host verify Error - BusyBox nc Error: '$__ERR' (timeout)"
|
|
443
|
+ syslog_err "host verify Error - BusyBox nc Error '$__ERR' (timeout)"
|
441
|
444
|
return 3
|
442
|
445
|
fi
|
443
|
446
|
}
|
|
@@ -454,8 +457,9 @@ verify_dns() {
|
454
|
457
|
verify_proxy() {
|
455
|
458
|
# $1 Proxy-String to verify
|
456
|
459
|
# complete entry user:password@host:port
|
|
460
|
+ # inside user and password NO '@' of ":" allowed
|
457
|
461
|
# host and port only host:port
|
458
|
|
- # host only host unsupported
|
|
462
|
+ # host only host ERROR unsupported
|
459
|
463
|
# IPv4 address instead of host 123.234.234.123
|
460
|
464
|
# IPv6 address instead of host [xxxx:....:xxxx] in square bracket
|
461
|
465
|
local __TMP __HOST __PORT
|
|
@@ -477,8 +481,8 @@ verify_proxy() {
|
477
|
481
|
__HOST=$(echo $__TMP | awk -F ":" '{print $1}')
|
478
|
482
|
__PORT=$(echo $__TMP | awk -F ":" '{print $2}')
|
479
|
483
|
fi
|
480
|
|
- # No Port detected ERROR 5
|
481
|
|
- [ -z "$__PORT" ] && return 5
|
|
484
|
+ # No Port detected
|
|
485
|
+ [ -z "$__PORT" ] && critical_error "Invalid Proxy server Error '5' - proxy port missing"
|
482
|
486
|
|
483
|
487
|
__verify_host_port "$__HOST" "$__PORT"
|
484
|
488
|
}
|