4 .
/lib
/functions
/network.sh
5 .
/usr
/share
/libubox
/jshn.sh
7 MWAN3TRACK_STATUS_DIR
="/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}"
38 local pid device time_p time_n
40 network_get_device device
$1
42 if [ "${iface}" = "${iface_select}" ] || [ "${iface_select}" = "" ]; then
43 pid
="$(pgrep -f "mwan3track
$iface $device")"
44 if [ "${pid}" != "" ]; then
48 time_p
="$(cat "$MWAN3TRACK_STATUS_DIR/${iface}/TIME
")"
49 [ -z "${time_p}" ] ||
{
50 time_n
="$(date +'%s')"
54 json_add_object
"${iface}"
55 json_add_int age
"$age"
56 json_add_int
"score" "$(cat "$MWAN3TRACK_STATUS_DIR/${iface}/SCORE
")"
57 json_add_int
"lost" "$(cat "$MWAN3TRACK_STATUS_DIR/${iface}/LOST
")"
58 json_add_int
"turn" "$(cat "$MWAN3TRACK_STATUS_DIR/${iface}/TURN
")"
59 json_add_string
"status" "$(cat "$MWAN3TRACK_STATUS_DIR/${iface}/STATUS
")"
60 json_add_boolean
"running" "${running}"
61 json_add_array
"track_ip"
62 for file in $MWAN3TRACK_STATUS_DIR/${iface}/*; do
63 track
="${file#*/TRACK_}"
64 if [ "${track}" != "${file}" ]; then
66 json_add_string ip
"${track}"
67 json_add_string status
"$(cat "${file}")"
79 json_add_object
"status"
80 json_add_string
"section" "x"
81 json_add_string
"interface" "x"
91 json_get_var section section
92 json_get_var iface interface
98 json_add_object interfaces
99 config_foreach get_mwan3_status interface
"${iface}"
103 json_add_object connected
114 json_add_object interfaces
115 config_foreach get_mwan3_status interface
118 json_add_object connected