mirror of
https://github.com/openwrt/luci.git
synced 2026-04-15 10:51:51 +00:00
treewide: move templates and libraries not used by the core to luci-compat
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
@@ -1,49 +0,0 @@
|
||||
-- Copyright 2018 Florian Eckert <fe@dev.tdt.de>
|
||||
-- Licensed to the public under the Apache License 2.0.
|
||||
|
||||
local netmod = luci.model.network
|
||||
local interface = luci.model.network.interface
|
||||
|
||||
local proto = netmod:register_protocol("3g")
|
||||
|
||||
function proto.get_i18n(self)
|
||||
return luci.i18n.translate("UMTS/GPRS/EV-DO")
|
||||
end
|
||||
|
||||
function proto.ifname(self)
|
||||
return "3g-" .. self.sid
|
||||
end
|
||||
|
||||
function proto.get_interface(self)
|
||||
return interface(self:ifname(), self)
|
||||
end
|
||||
|
||||
function proto.is_installed(self)
|
||||
return nixio.fs.access("/lib/netifd/proto/3g.sh")
|
||||
end
|
||||
|
||||
function proto.opkg_package(self)
|
||||
return "comgt"
|
||||
end
|
||||
|
||||
function proto.is_floating(self)
|
||||
return true
|
||||
end
|
||||
|
||||
function proto.is_virtual(self)
|
||||
return true
|
||||
end
|
||||
|
||||
function proto.get_interfaces(self)
|
||||
return nil
|
||||
end
|
||||
|
||||
function proto.contains_interface(self, ifc)
|
||||
if self:is_floating() then
|
||||
return (netmod:ifnameof(ifc) == self:ifname())
|
||||
else
|
||||
return netmod.protocol.contains_interface(self, ifc)
|
||||
end
|
||||
end
|
||||
|
||||
netmod:register_pattern_virtual("^3g%-%w")
|
||||
@@ -1,16 +0,0 @@
|
||||
-- Copyright 2014 Steven Barth <steven@midlink.org>
|
||||
-- Licensed to the public under the Apache License 2.0.
|
||||
|
||||
local proto = luci.model.network:register_protocol("hnet")
|
||||
|
||||
function proto.get_i18n(self)
|
||||
return luci.i18n.translate("Automatic Homenet (HNCP)")
|
||||
end
|
||||
|
||||
function proto.is_installed(self)
|
||||
return nixio.fs.access("/lib/netifd/proto/hnet.sh")
|
||||
end
|
||||
|
||||
function proto.opkg_package(self)
|
||||
return "hnet-full"
|
||||
end
|
||||
@@ -1,40 +0,0 @@
|
||||
-- Copyright 2016 Roger Pueyo Centelles <roger.pueyo@guifi.net>
|
||||
-- Licensed to the public under the Apache License 2.0.
|
||||
|
||||
local netmod = luci.model.network
|
||||
local interface = luci.model.network.interface
|
||||
local proto = netmod:register_protocol("ipip")
|
||||
|
||||
function proto.get_i18n(self)
|
||||
return luci.i18n.translate("IPv4-in-IPv4 (RFC2003)")
|
||||
end
|
||||
|
||||
function proto.ifname(self)
|
||||
return "ipip-" .. self.sid
|
||||
end
|
||||
|
||||
function proto.opkg_package(self)
|
||||
return "ipip"
|
||||
end
|
||||
|
||||
function proto.is_installed(self)
|
||||
return nixio.fs.access("/lib/netifd/proto/ipip.sh")
|
||||
end
|
||||
|
||||
function proto.is_floating(self)
|
||||
return true
|
||||
end
|
||||
|
||||
function proto.is_virtual(self)
|
||||
return true
|
||||
end
|
||||
|
||||
function proto.get_interfaces(self)
|
||||
return nil
|
||||
end
|
||||
|
||||
function proto.contains_interface(self, ifc)
|
||||
return (netmod:ifnameof(ifc) == self:ifname())
|
||||
end
|
||||
|
||||
netmod:register_pattern_virtual("^ipip%-%w")
|
||||
@@ -1,64 +0,0 @@
|
||||
-- Copyright 2011 Jo-Philipp Wich <jow@openwrt.org>
|
||||
-- Copyright 2013 Steven Barth <steven@midlink.org>
|
||||
-- Licensed to the public under the Apache License 2.0.
|
||||
|
||||
local netmod = luci.model.network
|
||||
|
||||
local _, p
|
||||
for _, p in ipairs({"dslite", "map", "464xlat"}) do
|
||||
|
||||
local proto = netmod:register_protocol(p)
|
||||
|
||||
function proto.get_i18n(self)
|
||||
if p == "dslite" then
|
||||
return luci.i18n.translate("Dual-Stack Lite (RFC6333)")
|
||||
elseif p == "map" then
|
||||
return luci.i18n.translate("MAP / LW4over6")
|
||||
elseif p == "464xlat" then
|
||||
return luci.i18n.translate("464XLAT (CLAT)")
|
||||
end
|
||||
end
|
||||
|
||||
function proto.ifname(self)
|
||||
return p .. "-" .. self.sid
|
||||
end
|
||||
|
||||
function proto.opkg_package(self)
|
||||
if p == "dslite" then
|
||||
return "ds-lite"
|
||||
elseif p == "map" then
|
||||
return "map-t"
|
||||
elseif p == "464xlat" then
|
||||
return "464xlat"
|
||||
end
|
||||
end
|
||||
|
||||
function proto.is_installed(self)
|
||||
return nixio.fs.access("/lib/netifd/proto/" .. p .. ".sh")
|
||||
end
|
||||
|
||||
function proto.is_floating(self)
|
||||
return true
|
||||
end
|
||||
|
||||
function proto.is_virtual(self)
|
||||
return true
|
||||
end
|
||||
|
||||
function proto.get_interfaces(self)
|
||||
return nil
|
||||
end
|
||||
|
||||
function proto.contains_interface(self, ifc)
|
||||
return (netmod:ifnameof(ifc) == self:ifname())
|
||||
end
|
||||
end
|
||||
|
||||
netmod:register_pattern_virtual("^464%-%w")
|
||||
netmod:register_pattern_virtual("^ds%-%w")
|
||||
netmod:register_pattern_virtual("^map%-%w")
|
||||
|
||||
netmod:register_error_code("AFTR_DNS_FAIL", luci.i18n.translate("Unable to resolve AFTR host name"))
|
||||
netmod:register_error_code("INVALID_MAP_RULE", luci.i18n.translate("MAP rule is invalid"))
|
||||
netmod:register_error_code("NO_MATCHING_PD", luci.i18n.translate("No matching prefix delegation"))
|
||||
netmod:register_error_code("UNSUPPORTED_TYPE", luci.i18n.translate("Unsupported MAP type"))
|
||||
@@ -1,50 +0,0 @@
|
||||
-- Copyright 2011 Jo-Philipp Wich <jow@openwrt.org>
|
||||
-- Licensed to the public under the Apache License 2.0.
|
||||
|
||||
local netmod = luci.model.network
|
||||
|
||||
local _, p
|
||||
for _, p in ipairs({"6in4", "6to4", "6rd"}) do
|
||||
|
||||
local proto = netmod:register_protocol(p)
|
||||
|
||||
function proto.get_i18n(self)
|
||||
if p == "6in4" then
|
||||
return luci.i18n.translate("IPv6-in-IPv4 (RFC4213)")
|
||||
elseif p == "6to4" then
|
||||
return luci.i18n.translate("IPv6-over-IPv4 (6to4)")
|
||||
elseif p == "6rd" then
|
||||
return luci.i18n.translate("IPv6-over-IPv4 (6rd)")
|
||||
end
|
||||
end
|
||||
|
||||
function proto.ifname(self)
|
||||
return p .. "-" .. self.sid
|
||||
end
|
||||
|
||||
function proto.opkg_package(self)
|
||||
return p
|
||||
end
|
||||
|
||||
function proto.is_installed(self)
|
||||
return nixio.fs.access("/lib/netifd/proto/" .. p .. ".sh")
|
||||
end
|
||||
|
||||
function proto.is_floating(self)
|
||||
return true
|
||||
end
|
||||
|
||||
function proto.is_virtual(self)
|
||||
return true
|
||||
end
|
||||
|
||||
function proto.get_interfaces(self)
|
||||
return nil
|
||||
end
|
||||
|
||||
function proto.contains_interface(self, ifc)
|
||||
return (netmod:ifnameof(ifc) == self:ifname())
|
||||
end
|
||||
|
||||
netmod:register_pattern_virtual("^%s%%-%%w" % p)
|
||||
end
|
||||
@@ -1,16 +0,0 @@
|
||||
-- Copyright 2013 Jo-Philipp Wich <jow@openwrt.org>
|
||||
-- Licensed to the public under the Apache License 2.0.
|
||||
|
||||
local proto = luci.model.network:register_protocol("dhcpv6")
|
||||
|
||||
function proto.get_i18n(self)
|
||||
return luci.i18n.translate("DHCPv6 client")
|
||||
end
|
||||
|
||||
function proto.is_installed(self)
|
||||
return nixio.fs.access("/lib/netifd/proto/dhcpv6.sh")
|
||||
end
|
||||
|
||||
function proto.opkg_package(self)
|
||||
return "odhcp6c"
|
||||
end
|
||||
@@ -1,55 +0,0 @@
|
||||
-- Copyright 2016 David Thornley <david.thornley@touchstargroup.com>
|
||||
-- Licensed to the public under the Apache License 2.0.
|
||||
|
||||
local netmod = luci.model.network
|
||||
local interface = luci.model.network.interface
|
||||
local proto = netmod:register_protocol("modemmanager")
|
||||
|
||||
function proto.get_i18n(self)
|
||||
return luci.i18n.translate("Mobile Data")
|
||||
end
|
||||
|
||||
function proto.ifname(self)
|
||||
local base = netmod._M.protocol
|
||||
local ifname = base.ifname(self) -- call base class "protocol.ifname(self)"
|
||||
|
||||
-- Note: ifname might be nil if the adapter could not be determined through ubus (default name to qmi-wan in this case)
|
||||
if ifname == nil then
|
||||
ifname = "modemmanager-" .. self.sid
|
||||
end
|
||||
return ifname
|
||||
end
|
||||
|
||||
function proto.get_interface(self)
|
||||
return interface(self:ifname(), self)
|
||||
end
|
||||
|
||||
function proto.opkg_package(self)
|
||||
return "modemmanager"
|
||||
end
|
||||
|
||||
function proto.is_installed(self)
|
||||
return nixio.fs.access("/lib/netifd/proto/modemmanager.sh")
|
||||
end
|
||||
|
||||
function proto.is_floating(self)
|
||||
return true
|
||||
end
|
||||
|
||||
function proto.is_virtual(self)
|
||||
return true
|
||||
end
|
||||
|
||||
function proto.get_interfaces(self)
|
||||
return nil
|
||||
end
|
||||
|
||||
function proto.contains_interface(self, ifc)
|
||||
return (netmod:ifnameof(ifc) == self:ifname())
|
||||
end
|
||||
|
||||
netmod:register_pattern_virtual("^mobiledata%-%w")
|
||||
|
||||
netmod:register_error_code("CALL_FAILED", luci.i18n.translate("Call failed"))
|
||||
netmod:register_error_code("NO_CID", luci.i18n.translate("Unable to obtain client ID"))
|
||||
netmod:register_error_code("PLMN_FAILED", luci.i18n.translate("Setting PLMN failed"))
|
||||
@@ -1,69 +0,0 @@
|
||||
--[[
|
||||
LuCI - Network model - NCM protocol extension
|
||||
|
||||
Copyright 2015 Cezary Jackiewicz <cezary.jackiewicz@gmail.com>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
]]--
|
||||
|
||||
local netmod = luci.model.network
|
||||
|
||||
local proto = netmod:register_protocol("ncm")
|
||||
local interface = luci.model.network.interface
|
||||
|
||||
function proto.get_i18n(self)
|
||||
return luci.i18n.translate("NCM")
|
||||
end
|
||||
|
||||
function proto.opkg_package(self)
|
||||
return "comgt-ncm"
|
||||
end
|
||||
|
||||
function proto.is_installed(self)
|
||||
return nixio.fs.access("/lib/netifd/proto/ncm.sh")
|
||||
end
|
||||
|
||||
function proto.is_floating(self)
|
||||
return true
|
||||
end
|
||||
|
||||
function proto.is_virtual(self)
|
||||
return true
|
||||
end
|
||||
|
||||
function proto.get_interface(self)
|
||||
local _ifname=netmod.protocol.ifname(self)
|
||||
if not _ifname then
|
||||
_ifname = "wan"
|
||||
end
|
||||
return interface(_ifname, self)
|
||||
end
|
||||
|
||||
function proto.get_interfaces(self)
|
||||
return nil
|
||||
end
|
||||
|
||||
function proto.contains_interface(self, ifc)
|
||||
return (netmod:ifnameof(ifc) == self:ifname())
|
||||
end
|
||||
|
||||
netmod:register_pattern_virtual("^ncm%-%w")
|
||||
|
||||
netmod:register_error_code("CONFIGURE_FAILED", luci.i18n.translate("Configuration failed"))
|
||||
netmod:register_error_code("DISCONNECT_FAILED", luci.i18n.translate("Disconnection attempt failed"))
|
||||
netmod:register_error_code("FINALIZE_FAILED", luci.i18n.translate("Finalizing failed"))
|
||||
netmod:register_error_code("GETINFO_FAILED", luci.i18n.translate("Modem information query failed"))
|
||||
netmod:register_error_code("INITIALIZE_FAILED", luci.i18n.translate("Initialization failure"))
|
||||
netmod:register_error_code("SETMODE_FAILED", luci.i18n.translate("Setting operation mode failed"))
|
||||
netmod:register_error_code("UNSUPPORTED_MODEM", luci.i18n.translate("Unsupported modem"))
|
||||
@@ -1,45 +0,0 @@
|
||||
-- Copyright 2012 David Woodhouse
|
||||
-- Licensed to the public under the Apache License 2.0.
|
||||
|
||||
local netmod = luci.model.network
|
||||
local interface = luci.model.network.interface
|
||||
local proto = netmod:register_protocol("openconnect")
|
||||
|
||||
function proto.get_i18n(self)
|
||||
return luci.i18n.translate("OpenConnect (CISCO AnyConnect)")
|
||||
end
|
||||
|
||||
function proto.ifname(self)
|
||||
return "vpn-" .. self.sid
|
||||
end
|
||||
|
||||
function proto.get_interface(self)
|
||||
return interface(self:ifname(), self)
|
||||
end
|
||||
|
||||
function proto.opkg_package(self)
|
||||
return "openconnect"
|
||||
end
|
||||
|
||||
function proto.is_installed(self)
|
||||
return nixio.fs.access("/lib/netifd/proto/openconnect.sh")
|
||||
end
|
||||
|
||||
function proto.is_floating(self)
|
||||
return true
|
||||
end
|
||||
|
||||
function proto.is_virtual(self)
|
||||
return true
|
||||
end
|
||||
|
||||
function proto.get_interfaces(self)
|
||||
return nil
|
||||
end
|
||||
|
||||
function proto.contains_interface(self, ifc)
|
||||
return (netmod:ifnameof(ifc) == self:ifname())
|
||||
|
||||
end
|
||||
|
||||
netmod:register_pattern_virtual("^vpn%-%w")
|
||||
@@ -1,82 +0,0 @@
|
||||
-- Copyright 2011 Jo-Philipp Wich <jow@openwrt.org>
|
||||
-- Licensed to the public under the Apache License 2.0.
|
||||
|
||||
local netmod = luci.model.network
|
||||
|
||||
local _, p
|
||||
for _, p in ipairs({"ppp", "pptp", "pppoe", "pppoa", "l2tp"}) do
|
||||
|
||||
local proto = netmod:register_protocol(p)
|
||||
|
||||
function proto.get_i18n(self)
|
||||
if p == "ppp" then
|
||||
return luci.i18n.translate("PPP")
|
||||
elseif p == "pptp" then
|
||||
return luci.i18n.translate("PPtP")
|
||||
elseif p == "pppoe" then
|
||||
return luci.i18n.translate("PPPoE")
|
||||
elseif p == "pppoa" then
|
||||
return luci.i18n.translate("PPPoATM")
|
||||
elseif p == "l2tp" then
|
||||
return luci.i18n.translate("L2TP")
|
||||
end
|
||||
end
|
||||
|
||||
function proto.ifname(self)
|
||||
return p .. "-" .. self.sid
|
||||
end
|
||||
|
||||
function proto.opkg_package(self)
|
||||
if p == "ppp" then
|
||||
return p
|
||||
elseif p == "pptp" then
|
||||
return "ppp-mod-pptp"
|
||||
elseif p == "pppoe" then
|
||||
return "ppp-mod-pppoe"
|
||||
elseif p == "pppoa" then
|
||||
return "ppp-mod-pppoa"
|
||||
elseif p == "l2tp" then
|
||||
return "xl2tpd"
|
||||
end
|
||||
end
|
||||
|
||||
function proto.is_installed(self)
|
||||
if p == "pppoa" then
|
||||
return (nixio.fs.glob("/usr/lib/pppd/*/pppoatm.so")() ~= nil)
|
||||
elseif p == "pppoe" then
|
||||
return (nixio.fs.glob("/usr/lib/pppd/*/rp-pppoe.so")() ~= nil)
|
||||
elseif p == "pptp" then
|
||||
return (nixio.fs.glob("/usr/lib/pppd/*/pptp.so")() ~= nil)
|
||||
elseif p == "l2tp" then
|
||||
return nixio.fs.access("/lib/netifd/proto/l2tp.sh")
|
||||
else
|
||||
return nixio.fs.access("/lib/netifd/proto/ppp.sh")
|
||||
end
|
||||
end
|
||||
|
||||
function proto.is_floating(self)
|
||||
return (p ~= "pppoe")
|
||||
end
|
||||
|
||||
function proto.is_virtual(self)
|
||||
return true
|
||||
end
|
||||
|
||||
function proto.get_interfaces(self)
|
||||
if self:is_floating() then
|
||||
return nil
|
||||
else
|
||||
return netmod.protocol.get_interfaces(self)
|
||||
end
|
||||
end
|
||||
|
||||
function proto.contains_interface(self, ifc)
|
||||
if self:is_floating() then
|
||||
return (netmod:ifnameof(ifc) == self:ifname())
|
||||
else
|
||||
return netmod.protocol.contains_interface(self, ifc)
|
||||
end
|
||||
end
|
||||
|
||||
netmod:register_pattern_virtual("^%s%%-%%w" % p)
|
||||
end
|
||||
@@ -1,40 +0,0 @@
|
||||
-- Copyright 2018 Florian Eckert <fe@dev.tdt.de>
|
||||
-- Licensed to the public under the Apache License 2.0.
|
||||
|
||||
local netmod = luci.model.network
|
||||
|
||||
local proto = netmod:register_protocol("pppossh")
|
||||
|
||||
function proto.get_i18n(self)
|
||||
return luci.i18n.translate("PPPoSSH")
|
||||
end
|
||||
|
||||
function proto.ifname(self)
|
||||
return "pppossh-" .. self.sid
|
||||
end
|
||||
|
||||
function proto.opkg_package(self)
|
||||
return "pppossh"
|
||||
end
|
||||
|
||||
function proto.is_installed(self)
|
||||
return nixio.fs.access("/lib/netifd/proto/pppossh.sh")
|
||||
end
|
||||
|
||||
function proto.is_floating(self)
|
||||
return true
|
||||
end
|
||||
|
||||
function proto.is_virtual(self)
|
||||
return true
|
||||
end
|
||||
|
||||
function proto.get_interfaces(self)
|
||||
return nil
|
||||
end
|
||||
|
||||
function proto.contains_interface(self, ifc)
|
||||
return (netmod:ifnameof(ifc) == self:ifname())
|
||||
end
|
||||
|
||||
netmod:register_pattern_virtual("^pppossh%-%w")
|
||||
@@ -1,55 +0,0 @@
|
||||
-- Copyright 2016 David Thornley <david.thornley@touchstargroup.com>
|
||||
-- Licensed to the public under the Apache License 2.0.
|
||||
|
||||
local netmod = luci.model.network
|
||||
local interface = luci.model.network.interface
|
||||
local proto = netmod:register_protocol("qmi")
|
||||
|
||||
function proto.get_i18n(self)
|
||||
return luci.i18n.translate("QMI Cellular")
|
||||
end
|
||||
|
||||
function proto.ifname(self)
|
||||
local base = netmod._M.protocol
|
||||
local ifname = base.ifname(self) -- call base class "protocol.ifname(self)"
|
||||
|
||||
-- Note: ifname might be nil if the adapter could not be determined through ubus (default name to qmi-wan in this case)
|
||||
if ifname == nil then
|
||||
ifname = "qmi-" .. self.sid
|
||||
end
|
||||
return ifname
|
||||
end
|
||||
|
||||
function proto.get_interface(self)
|
||||
return interface(self:ifname(), self)
|
||||
end
|
||||
|
||||
function proto.opkg_package(self)
|
||||
return "uqmi"
|
||||
end
|
||||
|
||||
function proto.is_installed(self)
|
||||
return nixio.fs.access("/lib/netifd/proto/qmi.sh")
|
||||
end
|
||||
|
||||
function proto.is_floating(self)
|
||||
return true
|
||||
end
|
||||
|
||||
function proto.is_virtual(self)
|
||||
return true
|
||||
end
|
||||
|
||||
function proto.get_interfaces(self)
|
||||
return nil
|
||||
end
|
||||
|
||||
function proto.contains_interface(self, ifc)
|
||||
return (netmod:ifnameof(ifc) == self:ifname())
|
||||
end
|
||||
|
||||
netmod:register_pattern_virtual("^qmi%-%w")
|
||||
|
||||
netmod:register_error_code("CALL_FAILED", luci.i18n.translate("Call failed"))
|
||||
netmod:register_error_code("NO_CID", luci.i18n.translate("Unable to obtain client ID"))
|
||||
netmod:register_error_code("PLMN_FAILED", luci.i18n.translate("Setting PLMN failed"))
|
||||
@@ -1,158 +0,0 @@
|
||||
-- Copyright 2011 Jo-Philipp Wich <jow@openwrt.org>
|
||||
-- Licensed to the public under the Apache License 2.0.
|
||||
|
||||
local netmod = luci.model.network
|
||||
local device = luci.util.class(netmod.interface)
|
||||
|
||||
netmod:register_pattern_virtual("^relay%-%w")
|
||||
|
||||
local proto = netmod:register_protocol("relay")
|
||||
|
||||
function proto.get_i18n(self)
|
||||
return luci.i18n.translate("Relay bridge")
|
||||
end
|
||||
|
||||
function proto.ifname(self)
|
||||
return "relay-" .. self.sid
|
||||
end
|
||||
|
||||
function proto.opkg_package(self)
|
||||
return "relayd"
|
||||
end
|
||||
|
||||
function proto.is_installed(self)
|
||||
return nixio.fs.access("/etc/init.d/relayd")
|
||||
end
|
||||
|
||||
function proto.is_floating(self)
|
||||
return true
|
||||
end
|
||||
|
||||
function proto.is_virtual(self)
|
||||
return true
|
||||
end
|
||||
|
||||
function proto.is_up(self)
|
||||
local iface = self:get_interface()
|
||||
return iface and iface:is_up() or false
|
||||
end
|
||||
|
||||
function proto.get_interface(self)
|
||||
return device(self.sid, self)
|
||||
end
|
||||
|
||||
function proto.get_interfaces(self)
|
||||
if not self.ifaces then
|
||||
local ifs = { }
|
||||
local _, net, dev
|
||||
|
||||
for net in luci.util.imatch(self:_get("network")) do
|
||||
net = netmod:get_network(net)
|
||||
if net then
|
||||
dev = net:get_interface()
|
||||
if dev then
|
||||
ifs[dev:name()] = dev
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for dev in luci.util.imatch(self:_get("ifname")) do
|
||||
dev = netmod:get_interface(dev)
|
||||
if dev then
|
||||
ifs[dev:name()] = dev
|
||||
end
|
||||
end
|
||||
|
||||
self.ifaces = { }
|
||||
|
||||
for _, dev in luci.util.kspairs(ifs) do
|
||||
self.ifaces[#self.ifaces+1] = dev
|
||||
end
|
||||
end
|
||||
|
||||
return self.ifaces
|
||||
end
|
||||
|
||||
function proto.uptime(self)
|
||||
local net
|
||||
local upt = 0
|
||||
for net in luci.util.imatch(self:_get("network")) do
|
||||
net = netmod:get_network(net)
|
||||
if net then
|
||||
upt = math.max(upt, net:uptime())
|
||||
end
|
||||
end
|
||||
return upt
|
||||
end
|
||||
|
||||
function proto.errors(self)
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
function device.__init__(self, ifname, network)
|
||||
self.ifname = ifname
|
||||
self.network = network
|
||||
end
|
||||
|
||||
function device.type(self)
|
||||
return "tunnel"
|
||||
end
|
||||
|
||||
function device.is_up(self)
|
||||
if self.network then
|
||||
local _, dev
|
||||
for _, dev in ipairs(self.network:get_interfaces()) do
|
||||
if not dev:is_up() then
|
||||
return false
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function device._stat(self, what)
|
||||
local v = 0
|
||||
if self.network then
|
||||
local _, dev
|
||||
for _, dev in ipairs(self.network:get_interfaces()) do
|
||||
v = v + dev[what](dev)
|
||||
end
|
||||
end
|
||||
return v
|
||||
end
|
||||
|
||||
function device.rx_bytes(self) return self:_stat("rx_bytes") end
|
||||
function device.tx_bytes(self) return self:_stat("tx_bytes") end
|
||||
function device.rx_packets(self) return self:_stat("rx_packets") end
|
||||
function device.tx_packets(self) return self:_stat("tx_packets") end
|
||||
|
||||
function device.mac(self)
|
||||
if self.network then
|
||||
local _, dev
|
||||
for _, dev in ipairs(self.network:get_interfaces()) do
|
||||
return dev:mac()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function device.ipaddrs(self)
|
||||
local addrs = { }
|
||||
if self.network then
|
||||
addrs[1] = luci.ip.IPv4(self.network:_get("ipaddr"))
|
||||
end
|
||||
return addrs
|
||||
end
|
||||
|
||||
function device.ip6addrs(self)
|
||||
return { }
|
||||
end
|
||||
|
||||
function device.shortname(self)
|
||||
return "%s %q" % { luci.i18n.translate("Relay"), self.ifname }
|
||||
end
|
||||
|
||||
function device.get_type_i18n(self)
|
||||
return luci.i18n.translate("Relay Bridge")
|
||||
end
|
||||
@@ -1,46 +0,0 @@
|
||||
-- Copyright 2015 Daniel Dickinson <openwrt@daniel.thecshore.com>
|
||||
-- Licensed to the public under the Apache License 2.0.
|
||||
|
||||
local netmod = luci.model.network
|
||||
local interface = luci.model.network.interface
|
||||
local proto = netmod:register_protocol("vpnc")
|
||||
|
||||
function proto.get_i18n(self)
|
||||
return luci.i18n.translate("VPNC (CISCO 3000 (and others) VPN)")
|
||||
end
|
||||
|
||||
function proto.ifname(self)
|
||||
return "vpn-" .. self.sid
|
||||
end
|
||||
|
||||
function proto.get_interface(self)
|
||||
return interface(self:ifname(), self)
|
||||
end
|
||||
|
||||
function proto.opkg_package(self)
|
||||
return "vpnc"
|
||||
end
|
||||
|
||||
function proto.is_installed(self)
|
||||
return nixio.fs.access("/lib/netifd/proto/vpnc.sh")
|
||||
end
|
||||
|
||||
function proto.is_floating(self)
|
||||
return true
|
||||
end
|
||||
|
||||
function proto.is_virtual(self)
|
||||
return true
|
||||
end
|
||||
|
||||
function proto.get_interfaces(self)
|
||||
return nil
|
||||
end
|
||||
|
||||
function proto.contains_interface(self, ifc)
|
||||
return (netmod:ifnameof(ifc) == self:ifname())
|
||||
|
||||
end
|
||||
|
||||
netmod:register_pattern_virtual("^vpn%-%w")
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
-- Copyright 2016 Dan Luedtke <mail@danrl.com>
|
||||
-- Licensed to the public under the Apache License 2.0.
|
||||
|
||||
local netmod = luci.model.network
|
||||
local interface = luci.model.network.interface
|
||||
local proto = netmod:register_protocol("wireguard")
|
||||
|
||||
function proto.get_i18n(self)
|
||||
return luci.i18n.translate("WireGuard VPN")
|
||||
end
|
||||
|
||||
function proto.ifname(self)
|
||||
return self.sid
|
||||
end
|
||||
|
||||
function proto.get_interface(self)
|
||||
return interface(self:ifname(), self)
|
||||
end
|
||||
|
||||
function proto.opkg_package(self)
|
||||
return "wireguard-tools"
|
||||
end
|
||||
|
||||
function proto.is_installed(self)
|
||||
return nixio.fs.access("/lib/netifd/proto/wireguard.sh")
|
||||
end
|
||||
|
||||
function proto.is_floating(self)
|
||||
return true
|
||||
end
|
||||
|
||||
function proto.is_virtual(self)
|
||||
return true
|
||||
end
|
||||
|
||||
function proto.get_interfaces(self)
|
||||
return nil
|
||||
end
|
||||
|
||||
function proto.contains_interface(self, ifc)
|
||||
return (netmod:ifnameof(ifc) == self:ifname())
|
||||
end
|
||||
Reference in New Issue
Block a user