4 .
/usr
/share
/libubox
/jshn.sh
6 MWAN3_STATUS_DIR
="/var/run/mwan3track"
7 MWAN3_PID_FILE
="/var/run/mwan3track"
10 IPT4
="iptables -t mangle -w"
11 IPT6
="ip6tables -t mangle -w"
13 report_connected_v4
() {
16 if [ -n "$($IPT4 -S mwan3_connected 2> /dev/null)" ]; then
17 for address
in $
($IPS list mwan3_connected_v4 |
tail -n +8); do
18 json_add_string
"" "${address}"
23 report_connected_v6
() {
26 if [ -n "$($IPT6 -S mwan3_connected 2> /dev/null)" ]; then
27 for address
in $
($IPS list mwan3_connected_v6 |
tail -n +8); do
28 json_add_string
"" "${address}"
35 local iface_select
="${2}"
39 if [ "${iface}" = "${iface_select}" ] || [ "${iface_select}" = "" ]; then
40 pid
="$(pgrep -f "mwan3track
$iface_selected")"
41 if [ "${pid}" != "" ]; then
45 json_add_object
"${iface}"
46 json_add_string
"score" "$(cat "$MWAN3_STATUS_DIR/${iface}/SCORE
")"
47 json_add_string
"lost" "$(cat "$MWAN3_STATUS_DIR/${iface}/LOST
")"
48 json_add_string
"turn" "$(cat "$MWAN3_STATUS_DIR/${iface}/TURN
")"
49 json_add_string
"status" "$(cat "$MWAN3_STATUS_DIR/${iface}/STATUS
")"
50 json_add_boolean
"running" "${running}"
51 json_add_array
"track_ip"
52 for file in $MWAN3_STATUS_DIR/${iface}/*; do
53 track
="${file#*/TRACK_}"
54 if [ "${track}" != "${file}" ]; then
56 json_add_string ip
"${track}"
57 json_add_string status
"$(cat "${file}")"
69 json_add_object
"status"
70 json_add_string
"section" "x"
71 json_add_string
"interface" "x"
81 json_get_var section section
82 json_get_var iface interface
88 json_add_object interfaces
89 config_foreach get_mwan3_status interface
"${iface}"
93 json_add_object connected
104 json_add_object interfaces
105 config_foreach get_mwan3_status interface
108 json_add_object connected