- local data = { }
-
- local wg_ifaces = luci.sys.exec("wg show interfaces")
- for key, name in pairs(string.split(wg_ifaces, "\n")) do
- if not is_valid(name) then break end
- name = strip(name)
- local public_key = luci.sys.exec("wg show \"" .. name .. "\" public-key")
- local listening_port = luci.sys.exec("wg show \"" .. name .. "\" listen-port")
-
- local peers = { }
- local wg_peers = luci.sys.exec("wg show \"" .. name .. "\" peers")
- for key, public_key in pairs(string.split(wg_peers, "\n")) do
- if not is_valid(public_key) then break end
- peer_add(peers, public_key)
- end
-
- local wg_endpoints = luci.sys.exec("wg show \"" .. name .. "\" endpoints")
- for key, endpoint in pairs(string.split(wg_endpoints, "\n")) do
- if not is_valid(endpoint) then break end
- local ln = string.split(strip(endpoint), "\t")
- peer_set_endpoint(peers, ln[1], strip(ln[2]))
- end
-
- local wg_allowed_ips = luci.sys.exec("wg show \"" .. name .. "\" allowed-ips")
- for key, allowed_ips in pairs(string.split(wg_allowed_ips, "\n")) do
- if not is_valid(allowed_ips) then break end
- local ln = string.split(strip(allowed_ips), "\t", 2)
- peer_set_allowed_ips(peers, ln[1], strip(ln[2]))
- end
-
- local wg_persistent_keepalives = luci.sys.exec("wg show \"" .. name .. "\" persistent-keepalive")
- for key, persistent_keepalive in pairs(string.split(wg_persistent_keepalives, "\n")) do
- if not is_valid(persistent_keepalive) then break end
- local ln = string.split(strip(persistent_keepalive), "\t")
- peer_set_persistent_keepalive(peers, strip(ln[1]), strip(ln[2]))
- end
-
- local wg_latest_handshakes = luci.sys.exec("wg show \"" .. name .. "\" latest-handshakes")
- for key, latest_handshake in pairs(string.split(wg_latest_handshakes, "\n")) do
- if not is_valid(latest_handshake) then break end
- local ln = string.split(strip(latest_handshake), "\t")
- peer_set_latest_handshake(peers, strip(ln[1]), tonumber(ln[2]))
- end
-
- local wg_transfers = luci.sys.exec("wg show \"" .. name .. "\" transfer")
- for key, transfer in pairs(string.split(wg_transfers, "\n")) do
- if not is_valid(transfer) then break end
- local ln = string.split(strip(transfer), "\t")
- peer_set_transfer(peers, ln[1], strip(ln[2]), strip(ln[3]))
- end
-
- table.insert(data, {
- name = name,
- public_key = strip(public_key),
- listening_port = tonumber(strip(listening_port)),
- peers = peers
- })
- end
-