luci-app-wireguard: fix allowed_ip parsing 5403/head
authorlvoegl <lvoegl@tdt.de>
Fri, 1 Oct 2021 13:28:19 +0000 (15:28 +0200)
committerlvoegl <lvoegl@tdt.de>
Fri, 1 Oct 2021 13:31:38 +0000 (15:31 +0200)
Signed-off-by: lvoegl <lvoegl@tdt.de>
protocols/luci-proto-wireguard/root/usr/libexec/rpcd/luci.wireguard

index 94374b07d7f4d31e097f14bade299aec7f09ed66..ce21570cce162ae5068d4c310b3261729583676a 100755 (executable)
@@ -93,28 +93,27 @@ local methods = {
                                                        end
                                                )
 
-                                               table.insert(
-                                                       data[line[1]].peers,
-                                                       {
-                                                               name = peer_name,
-                                                               public_key = line[2],
-                                                               endpoint = line[4],
-                                                               allowed_ips = {},
-                                                               latest_handshake = line[6],
-                                                               transfer_rx = line[7],
-                                                               transfer_tx = line[8],
-                                                               persistent_keepalive = line[9]
-                                                       }
-                                               )
+                                               local peer = {
+                                                       name = peer_name,
+                                                       public_key = line[2],
+                                                       endpoint = line[4],
+                                                       allowed_ips = {},
+                                                       latest_handshake = line[6],
+                                                       transfer_rx = line[7],
+                                                       transfer_tx = line[8],
+                                                       persistent_keepalive = line[9]
+                                               }
 
                                                if not (line[4] == "(none)") then
                                                        local ipkey, ipvalue
                                                        for ipkey, ipvalue in pairs(string.split(line[5], ",")) do
                                                                if #ipvalue > 0 then
-                                                                       table.insert(data[line[1]].peers[peer_name]["allowed_ips"], ipvalue)
+                                                                       table.insert(peer["allowed_ips"], ipvalue)
                                                                end
                                                        end
                                                end
+
+                                               table.insert(data[line[1]].peers, peer)
                                        end
                                end
                        end