|
|
@ -9,24 +9,34 @@ find_iface_address() |
|
|
|
local ipaddr="$2" |
|
|
|
local ipaddr="$2" |
|
|
|
local prefix="$3" |
|
|
|
local prefix="$3" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local idx=1 |
|
|
|
local tmp="$(ubus call network.interface."$iface" status 2>/dev/null)" |
|
|
|
local tmp="$(ubus call network.interface."$iface" status 2>/dev/null)" |
|
|
|
|
|
|
|
|
|
|
|
json_load "${tmp:-{}}" |
|
|
|
json_load "${tmp:-{}}" |
|
|
|
json_get_type tmp address |
|
|
|
json_get_type tmp address |
|
|
|
|
|
|
|
|
|
|
|
if [ "$tmp" = array ]; then |
|
|
|
if [ "$tmp" = array ]; then |
|
|
|
|
|
|
|
|
|
|
|
json_select address |
|
|
|
json_select address |
|
|
|
json_get_type tmp 1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if [ "$tmp" = object ]; then |
|
|
|
while true; do |
|
|
|
|
|
|
|
json_get_type tmp $idx |
|
|
|
|
|
|
|
[ "$tmp" = object ] || break |
|
|
|
|
|
|
|
|
|
|
|
json_select 1 |
|
|
|
json_select $((idx++)) |
|
|
|
[ -n "$ipaddr" ] && json_get_var "$ipaddr" address |
|
|
|
json_get_var tmp address |
|
|
|
[ -n "$prefix" ] && json_get_var "$prefix" mask |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case "$tmp" in |
|
|
|
|
|
|
|
*:*) json_select .. ;; |
|
|
|
|
|
|
|
*) |
|
|
|
|
|
|
|
[ -n "$ipaddr" ] && json_get_var $ipaddr address |
|
|
|
|
|
|
|
[ -n "$prefix" ] && json_get_var $prefix mask |
|
|
|
|
|
|
|
return 0 |
|
|
|
|
|
|
|
;; |
|
|
|
|
|
|
|
esac |
|
|
|
|
|
|
|
done |
|
|
|
fi |
|
|
|
fi |
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
return 1 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if [ "$ACTION" = "add" ] && [ "$INTERFACE" = "wan" ]; then |
|
|
|
if [ "$ACTION" = "add" ] && [ "$INTERFACE" = "wan" ]; then |
|
|
|