From 3a657b8ab585f6e0fef5c9128dc84c5a008a6969 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Wed, 18 Dec 2019 21:32:48 +0100 Subject: luci-mod-network: replace controller address check action with cgi-io script This change removes the last bit of Lua code from luci-mod-network. Signed-off-by: Jo-Philipp Wich --- .../luasrc/controller/admin/network.lua | 68 ---------------------- 1 file changed, 68 deletions(-) delete mode 100644 modules/luci-mod-network/luasrc/controller/admin/network.lua (limited to 'modules/luci-mod-network/luasrc') diff --git a/modules/luci-mod-network/luasrc/controller/admin/network.lua b/modules/luci-mod-network/luasrc/controller/admin/network.lua deleted file mode 100644 index 109c59f2a7..0000000000 --- a/modules/luci-mod-network/luasrc/controller/admin/network.lua +++ /dev/null @@ -1,68 +0,0 @@ --- Copyright 2008 Steven Barth --- Copyright 2011-2018 Jo-Philipp Wich --- Licensed to the public under the Apache License 2.0. - -module("luci.controller.admin.network", package.seeall) - -local function addr2dev(addr, src) - local ip = require "luci.ip" - local route = ip.route(addr, src) - if not src and route and route.src then - route = ip.route(addr, route.src:string()) - end - return route and route.dev -end - -function remote_addr() - local uci = require "luci.model.uci" - local peer = luci.http.getenv("REMOTE_ADDR") - local serv = luci.http.getenv("SERVER_ADDR") - local device = addr2dev(peer, serv) - local ifaces = luci.util.ubus("network.interface", "dump") - local indevs = {} - local inifs = {} - - local result = { - remote_addr = peer, - server_addr = serv, - inbound_devices = {}, - inbound_interfaces = {} - } - - if type(ifaces) == "table" and type(ifaces.interface) == "table" then - for _, iface in ipairs(ifaces.interface) do - if type(iface) == "table" then - if iface.device == device or iface.l3_device == device then - inifs[iface.interface] = true - indevs[device] = true - end - - local peeraddr = uci:get("network", iface.interface, "peeraddr") - for _, ai in ipairs(peeraddr and nixio.getaddrinfo(peeraddr) or {}) do - local peerdev = addr2dev(ai.address) - if peerdev then - for _, iface in ipairs(ifaces.interface) do - if type(iface) == "table" and - (iface.device == peerdev or iface.l3_device == peerdev) - then - inifs[iface.interface] = true - indevs[peerdev] = true - end - end - end - end - end - end - end - - for k in pairs(inifs) do - result.inbound_interfaces[#result.inbound_interfaces + 1] = k - end - - for k in pairs(indevs) do - result.inbound_devices[#result.inbound_devices + 1] = k - end - - luci.http.prepare_content("application/json") - luci.http.write_json(result) -end -- cgit v1.2.3