Skip to content

Commit

Permalink
web-static-ip: migrate to roles
Browse files Browse the repository at this point in the history
we're just treating other as lan and uplink as wan

see #22
  • Loading branch information
mkg20001 committed Mar 20, 2022
1 parent efbe3bf commit 2006092
Showing 1 changed file with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@ local uci = require("simple-uci").cursor()
local wireless = require 'gluon.wireless'
local ip = require 'luci.ip'
local site = require 'gluon.site'
local sysconfig = require 'gluon.sysconfig'
local util = require 'gluon.util'

local mesh_interfaces = util.get_role_interfaces(uci, 'mesh')
local uplink_interfaces = util.get_role_interfaces(uci, 'uplink')

local mesh_interfaces_uplink = {}
local mesh_interfaces_other = {}
for _, iface in ipairs(mesh_interfaces) do
if util.contains(uplink_interfaces, iface) then
table.insert(mesh_interfaces_uplink, iface)
else
table.insert(mesh_interfaces_other, iface)
end
end

local f = Form(translate("Static IPs"))

Expand Down Expand Up @@ -121,11 +136,10 @@ if pcall(function() require 'gluon.mesh-vpn' end) then
end

local wan_mesh = not uci:get_bool('network', 'mesh_wan', 'disabled')
intf_setting('mesh_wan', 'Mesh on WAN', wan_mesh)
intf_setting('mesh_uplink', 'Mesh on WAN', #mesh_interfaces_uplink)

if uci:get('network', 'mesh_lan', 'proto') then
local lan_mesh = not uci:get_bool('network', 'mesh_lan', 'disabled')
intf_setting('mesh_lan', 'Mesh on LAN', lan_mesh)
if sysconfig.lan_ifname then
intf_setting('mesh_other', 'Mesh on LAN', #mesh_interfaces_other)
end

function f:write()
Expand Down

0 comments on commit 2006092

Please sign in to comment.