diff --git a/linux/sindan.conf.example b/linux/sindan.conf.example index 83daf4e..4626f9d 100644 --- a/linux/sindan.conf.example +++ b/linux/sindan.conf.example @@ -1,5 +1,5 @@ # SINDAN Configuration file -# version 3.0.0 +# version 3 # PID file readonly PIDFILE=/tmp/sindan.pid diff --git a/linux/sindan.sh b/linux/sindan.sh index cd447e8..88106cf 100755 --- a/linux/sindan.sh +++ b/linux/sindan.sh @@ -1,6 +1,6 @@ #!/bin/bash # sindan.sh -# version 3.0.1 +# version 3 VERSION="3.0.1" # read configuration file diff --git a/linux/sindan_func4.sh b/linux/sindan_func4.sh index aa4f035..e0c62cd 100755 --- a/linux/sindan_func4.sh +++ b/linux/sindan_func4.sh @@ -31,8 +31,8 @@ function get_tracepath() { # do_pmtud function do_pmtud() { if [ $# -ne 5 ]; then - echo "ERROR: do_pmtud " \ - "." 1>&2 + echo "ERROR: do_pmtud " \ + "." 1>&2 return 1 fi case $1 in diff --git a/linux/sindan_func5.sh b/linux/sindan_func5.sh index 62433ea..b9cde2b 100755 --- a/linux/sindan_func5.sh +++ b/linux/sindan_func5.sh @@ -51,6 +51,7 @@ function get_dnsttl() { # Get query time of the DNS request. # require do_dnslookup() data from STDIN. +# get_dnsrtt function get_dnsrtt() { sed -n 's/^;; Query time: \([0-9]*\) msec$/\1/p' return $? diff --git a/linux/sindan_func6.sh b/linux/sindan_func6.sh index 8ec6bce..2ccd6e4 100755 --- a/linux/sindan_func6.sh +++ b/linux/sindan_func6.sh @@ -142,7 +142,7 @@ function cmdset_portscan() { stat=$? fi write_json "$layer" "$ipv" "v${ver}portscan_${port}" "$result" \ - "$target" "$ps_ans" "$count" + "$target" "$ps_ans" "$count" if [ "$result" = "$SUCCESS" ]; then string="$string\n status: ok" else diff --git a/linux/sindan_funcb.sh b/linux/sindan_funcb.sh index 7f66590..6d432de 100755 --- a/linux/sindan_funcb.sh +++ b/linux/sindan_funcb.sh @@ -97,3 +97,4 @@ function write_json() { > log/sindan_"$1"_"$3"_"$7"_"$(date -u '+%s')".json return $? } + diff --git a/macos/sindan.conf.example b/macos/sindan.conf.example index dd68d54..bf48069 100644 --- a/macos/sindan.conf.example +++ b/macos/sindan.conf.example @@ -1,5 +1,5 @@ # SINDAN Configuration file -# version 3.0.0 +# version 3 # PID file readonly PIDFILE=/tmp/sindan.pid @@ -7,6 +7,9 @@ readonly PIDFILE=/tmp/sindan.pid # lock file readonly LOCKFILE_SENDLOG=/tmp/sendlog.isrunning +# airport command +readonly CMD_AIRPORT=/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport + # result parameters readonly FAIL=0 readonly SUCCESS=1 @@ -33,12 +36,8 @@ readonly EXCL_IPv6=no # IFTYPE: Wi-Fi, WWAN (for Cellular), Ethernet readonly IFTYPE=Wi-Fi -# set ssid -#readonly SSID=sindan -#readonly SSID_KEY=sindan00 - -# airport command -readonly CMD_AIRPORT=/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport +# proxy url (e.g., http://192.0.2.1:8080) +readonly PROXY_URL="" # target servers readonly PING_SRVS="8.8.8.8,203.178.139.60,1.1.1.1" diff --git a/macos/sindan.sh b/macos/sindan.sh index 866dea0..b02fcf6 100755 --- a/macos/sindan.sh +++ b/macos/sindan.sh @@ -1,6 +1,6 @@ #!/bin/bash # sindan.sh -# version 3.0.1 +# version 3 VERSION="3.0.1" # read configuration file diff --git a/macos/sindan_func3.sh b/macos/sindan_func3.sh index f9b4123..fc76a14 100755 --- a/macos/sindan_func3.sh +++ b/macos/sindan_func3.sh @@ -28,7 +28,6 @@ function get_rtt() { # Get paket loss rate of ping command. # require do_ping() data from STDIN. function get_loss() { - # require do_ping() data from STDIN. sed -n 's/^.* \([0-9.]*\)\% packet loss.*$/\1/p' return $? } diff --git a/macos/sindan_func4.sh b/macos/sindan_func4.sh index 931eb61..4b1bda3 100755 --- a/macos/sindan_func4.sh +++ b/macos/sindan_func4.sh @@ -37,10 +37,10 @@ function do_pmtud() { fi case $1 in "4" ) command="ping -t 1"; dfopt="-D"; header=28 ;; - "6" ) command="gtimeout 3 ping6"; dfopt=""; header=48 ;; + "6" ) command="gtimeout -sKILL 3 ping6"; dfopt=""; header=48 ;; * ) echo "ERROR: must be 4 or 6." 1>&2; return 9 ;; esac - if ! $command -c 1 $2 > /dev/null; then + if ! eval $command -c 1 $2 -S $5 > /dev/null; then echo 0 return 1 fi @@ -52,7 +52,7 @@ function do_pmtud() { local mid=$(( ( min + max ) / 2 )) while [ "$min" -ne "$mid" ] && [ "$max" -ne "$mid" ]; do - if eval "$command -c 1 -s $mid $dfopt $target -S $src_addr >/dev/null 2>/dev/null" + if eval $command -c 1 -s $mid $dfopt $target -S $src_addr >/dev/null 2>/dev/null then min=$mid else @@ -106,7 +106,7 @@ function cmdset_trace() { function cmdset_pmtud() { if [ $# -ne 7 ]; then echo "ERROR: cmdset_pmtud " \ - " ." 1>&2 + " ." 1>&2 return 1 fi local layer=$1 @@ -114,7 +114,7 @@ function cmdset_pmtud() { local ipv=IPv${ver} local type=$3 local target=$4 - local min_mtu=1200 + local min_mtu=56 local max_mtu=$5 local count=$6 local src_addr=$7 diff --git a/macos/sindan_func5.sh b/macos/sindan_func5.sh index fb29e95..b9cde2b 100755 --- a/macos/sindan_func5.sh +++ b/macos/sindan_func5.sh @@ -12,6 +12,12 @@ function do_dnslookup() { return 1 fi dig @"$1" "$3" "$2" +time=1 + # Dig return codes are: + # 0: Everything went well, including things like NXDOMAIN + # 1: Usage error + # 8: Couldn't open batch file + # 9: No reply from server + # 10: Internal error return $? } @@ -44,8 +50,8 @@ function get_dnsttl() { } # Get query time of the DNS request. -# get_dnsrtt # require do_dnslookup() data from STDIN. +# get_dnsrtt function get_dnsrtt() { sed -n 's/^;; Query time: \([0-9]*\) msec$/\1/p' return $? @@ -55,11 +61,11 @@ function get_dnsrtt() { # check_dns64 function check_dns64() { if [ $# -ne 1 ]; then - echo "ERROR: check_dns64 ." 1>&2 + echo "ERROR: check_dns64 ." 1>&2 return 1 fi local dns_ans - dns_ans=$(do_dnslookup "$target" AAAA ipv4only.arpa | + dns_ans=$(do_dnslookup "$1" AAAA ipv4only.arpa | get_dnsans AAAA) if [ -n "$dns_ans" ]; then echo 'yes' diff --git a/macos/sindan_func6.sh b/macos/sindan_func6.sh index a27c0f7..2ccd6e4 100755 --- a/macos/sindan_func6.sh +++ b/macos/sindan_func6.sh @@ -24,7 +24,7 @@ function do_curl() { function cmdset_http() { if [ $# -ne 5 ]; then echo "ERROR: cmdset_http " \ - " ." 1>&2 + " ." 1>&2 return 1 fi local layer=$1 @@ -105,16 +105,52 @@ function cmdset_ssh() { # Do port scan to the target server. # do_portscan function do_portscan() { - : - #TBD + if [ $# -ne 3 ]; then + echo "ERROR: do_portscan ." 1>&2 + return 1 + fi + case $1 in + "4" ) nc -zv4 -w1 "$2" "$3" 2>&1 ; return $? ;; + "6" ) nc -zv6 -w1 "$2" "$3" 2>&1 ; return $? ;; + "*" ) echo "ERROR: must be 4 or 6." 1>&2; return 9 ;; + esac } # Check the state of the port scan result to the target server. # cmdset_portscan \ # function cmdset_portscan() { - : - #TBD + if [ $# -ne 6 ]; then + echo "ERROR: cmdset_portscan " \ + " ." 1>&2 + return 1 + fi + local layer=$1 + local ver=$2 + local ipv="IPv${ver}" + local type=$3 + local target=$4 + local port=$5 + local count=$6 + local result=$FAIL + local string=" portscan to extarnal server: $target:$port by $ipv" + local ps_ans + + if ps_ans=$(do_portscan "$ver" "$target" "$port"); then + result=$SUCCESS + else + stat=$? + fi + write_json "$layer" "$ipv" "v${ver}portscan_${port}" "$result" \ + "$target" "$ps_ans" "$count" + if [ "$result" = "$SUCCESS" ]; then + string="$string\n status: ok" + else + string="$string\n status: ng ($stat)" + fi + if [ "$VERBOSE" = "yes" ]; then + echo -e "$string" + fi } # Do measure speed index to the target URL. @@ -126,7 +162,7 @@ function do_speedindex() { fi tracejson=trace-json/$(echo "$1" | sed 's/[.:/]/_/g').json - node speedindex.js "$1" ${tracejson} + node speedindex.js "$1" "$SI_TIMEOUT" ${tracejson} return $? } @@ -136,7 +172,7 @@ function do_speedindex() { function cmdset_speedindex() { if [ $# -ne 5 ]; then echo "ERROR: cmdset_speedindex " \ - " ." 1>&2 + " ." 1>&2 return 1 fi local layer=$1 @@ -145,7 +181,7 @@ function cmdset_speedindex() { local target=$4 local count=$5 local result=$FAIL - local string=" speedindex to extarnal server: $target by $ver" + local string=" speedindex to extarnal server: $target by $ver (timeout: $SI_TIMEOUT)" local speedindex_ans if speedindex_ans=$(do_speedindex ${target}); then @@ -201,7 +237,6 @@ function get_speedtest_ipv4_dl() { # Get IPv4 upload speed from the result of iNonius speedtest. # require do_speedtest() data from STDIN. function get_speedtest_ipv4_ul() { - # require do_speedtest() data from STDIN. sed -n 's/IPv4_UL://p' return $? } @@ -240,7 +275,7 @@ function get_speedtest_ipv6_ul() { function cmdset_speedtest() { if [ $# -ne 5 ]; then echo "ERROR: cmdset_speedtest " \ - " ." 1>&2 + " ." 1>&2 return 1 fi local layer=$1