@@ -53,6 +53,26 @@ policy_json_array() {
5353 printf ' ]'
5454}
5555
56+ policy_active_ifaces_json () {
57+ local raw item
58+ local -a items=()
59+
60+ raw=" $( policy_read_state_value " active_ifaces" || true) "
61+ if [[ -z " ${raw} " ]]; then
62+ printf ' []'
63+ return 0
64+ fi
65+
66+ IFS=' ,' read -r -a items <<< " ${raw}"
67+ for item in " ${items[@]} " ; do
68+ [[ -n " ${item} " ]] || continue
69+ policy_json_array " ${items[@]} "
70+ return 0
71+ done
72+
73+ printf ' []'
74+ }
75+
5676policy_write_state () {
5777 local status=" ${1:? missing status} "
5878 local last_event=" ${2:- } "
@@ -206,14 +226,14 @@ policy_monitor_loop() {
206226 pending_event=" ${line} "
207227 pending_ts=" $( timestamp_utc) "
208228 case " ${line} " in
209- * inet* |* inet6 * | * address* |* Deleted* ) refresh_requested=" true" ;;
229+ * inet* |* address* |* Deleted* ) refresh_requested=" true" ;;
210230 esac
211231
212232 while IFS= read -r -t " ${BOX_POLICY_DEBOUNCE_SECONDS} " next_line < & " ${POLICY_EVENTS[0]} " ; do
213233 pending_event=" ${next_line} "
214234 pending_ts=" $( timestamp_utc) "
215235 case " ${next_line} " in
216- * inet* |* inet6 * | * address* |* Deleted* ) refresh_requested=" true" ;;
236+ * inet* |* address* |* Deleted* ) refresh_requested=" true" ;;
217237 esac
218238 marker_state=" $( if policy_disable_marker_present; then printf ' present' ; else printf ' absent' ; fi) "
219239 if [[ " ${marker_state} " != " ${previous_marker_state} " ]]; then
@@ -346,7 +366,7 @@ policy_status_json() {
346366 " $( json_pair " applied_state" " $( policy_read_state_value " applied_state" || printf ' unchanged' ) " ) " \
347367 " $( json_pair " proxy_mode" " ${BOX_POLICY_PROXY_MODE} " ) " \
348368 " $( json_num_pair " debounce_seconds" " ${BOX_POLICY_DEBOUNCE_SECONDS} " ) " \
349- " \" active_ifaces\" :$( policy_json_array $( tr ' , ' ' ' <<< " $(policy_read_state_value " active_ifaces " || true) " ) ) " \
369+ " \" active_ifaces\" :$( policy_active_ifaces_json ) " \
350370 " $( json_bool_pair " wifi_connected" " $( policy_read_state_value " wifi_connected" || printf ' false' ) " ) " \
351371 " $( json_pair " ssid" " $( policy_read_state_value " ssid" || true) " ) " \
352372 " $( json_pair " bssid" " $( policy_read_state_value " bssid" || true) " ) " \
0 commit comments