net/mwan3: enhance ipset status generation
authorFlorian Eckert <redacted>
Mon, 15 Oct 2018 06:58:57 +0000 (08:58 +0200)
committerFlorian Eckert <redacted>
Tue, 23 Oct 2018 12:47:10 +0000 (14:47 +0200)
This change should optimize and speed up the status output generation.

Signed-off-by: Florian Eckert <redacted>
net/mwan3/files/lib/mwan3/mwan3.sh
net/mwan3/files/usr/libexec/rpcd/mwan3

index e7a865b43a343f525bea61e6d89dd4b9f8a26b05..8c8f23523325221a6991c7ed29c72eb2a4570aaa 100644 (file)
@@ -1092,9 +1092,7 @@ mwan3_report_connected_v4()
        local address
 
        if [ -n "$($IPT4 -S mwan3_connected 2> /dev/null)" ]; then
-               for address in $($IPS list mwan3_connected_v4 | egrep '[0-9]{1,3}(\.[0-9]{1,3}){3}'); do
-                       echo " $address"
-               done
+               $IPS -o save list mwan3_connected_v4 | grep add | cut -d " " -f 3
        fi
 }
 
@@ -1103,9 +1101,7 @@ mwan3_report_connected_v6()
        local address
 
        if [ -n "$($IPT6 -S mwan3_connected 2> /dev/null)" ]; then
-               for address in $($IPS list mwan3_connected_v6 | egrep '([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])'); do
-                       echo " $address"
-               done
+               $IPS -o save list mwan3_connected_v6 | grep add | cut -d " " -f 3
        fi
 }
 
index a9b31f222f4bed95cdad66e06a3d0f703f93b1a6..dc4eeb6df6b2a51e1b27a93a68f69f2b1cf82825 100755 (executable)
@@ -15,7 +15,7 @@ report_connected_v4() {
        local address
 
        if [ -n "$($IPT4 -S mwan3_connected 2> /dev/null)" ]; then
-               for address in $($IPS list mwan3_connected_v4 | tail -n +8); do
+               for address in $($IPS -o save list mwan3_connected_v4 | grep add | cut -d " " -f 3); do
                        json_add_string "" "${address}"
                done
        fi
@@ -25,7 +25,7 @@ report_connected_v6() {
        local address
 
        if [ -n "$($IPT6 -S mwan3_connected 2> /dev/null)" ]; then
-               for address in $($IPS list mwan3_connected_v6 | tail -n +8); do
+               for address in $($IPS -o save list mwan3_connected_v6 | grep add | cut -d " " -f 3); do
                        json_add_string "" "${address}"
                done
        fi
git clone https://git.99rst.org/PROJECT