@ -8,348 +8,311 @@ function index()
return
end
entry ( { " admin " , " network " , " mwan3 " } ,
alias ( " admin " , " network " , " mwan3 " , " overview " ) ,
entry ( { " admin " , " network " , " mwan " } ,
alias ( " admin " , " network " , " mwan " , " overview " ) ,
_ ( " Load Balancing " ) , 600 )
entry ( { " admin " , " network " , " mwan3 " , " overview " } ,
alias ( " admin " , " network " , " mwan3 " , " overview " , " over_iface " ) ,
entry ( { " admin " , " network " , " mwan " , " overview " } ,
alias ( " admin " , " network " , " mwan " , " overview " , " overview _inter face " ) ,
_ ( " Overview " ) , 10 )
entry ( { " admin " , " network " , " mwan3 " , " overview " , " over_iface " } ,
template ( " mwan3 /mwan3_ over_interface " ) )
entry ( { " admin " , " network " , " mwan3 " , " overview " , " iface_status " } ,
call ( " mwan3_iface_s tatus" ) )
entry ( { " admin " , " network " , " mwan3 " , " overview " , " over_detail " } ,
template ( " mwan3 /mwan3_ over_detail " ) )
entry ( { " admin " , " network " , " mwan3 " , " overview " , " detail_status " } ,
call ( " mwan3_detail_s tatus" ) )
entry ( { " admin " , " network " , " mwan3 " , " configuration " } ,
alias ( " admin " , " network " , " mwan3 " , " configuration " , " interface " ) ,
entry ( { " admin " , " network " , " mwan " , " overview " , " overview _inter face " } ,
template ( " mwan/overview _interface " ) )
entry ( { " admin " , " network " , " mwan " , " overview " , " inter face_status " } ,
call ( " interfaceS tatus" ) )
entry ( { " admin " , " network " , " mwan " , " overview " , " overview _detailed " } ,
template ( " mwan/overview _detailed " ) )
entry ( { " admin " , " network " , " mwan " , " overview " , " detailed _status " } ,
call ( " detailedS tatus" ) )
entry ( { " admin " , " network " , " mwan " , " configuration " } ,
alias ( " admin " , " network " , " mwan " , " configuration " , " interface " ) ,
_ ( " Configuration " ) , 20 )
entry ( { " admin " , " network " , " mwan3 " , " configuration " , " interface " } ,
arcombine ( cbi ( " mwan3 /mwan3_ interface " ) , cbi ( " mwan3 /mwan3_ interfaceconfig " ) ) ,
entry ( { " admin " , " network " , " mwan " , " configuration " , " interface " } ,
arcombine ( cbi ( " mwan/interface " ) , cbi ( " mwan/interfaceconfig " ) ) ,
_ ( " Interfaces " ) , 10 ) . leaf = true
entry ( { " admin " , " network " , " mwan3 " , " configuration " , " member " } ,
arcombine ( cbi ( " mwan3 /mwan3_ member " ) , cbi ( " mwan3 /mwan3_ memberconfig " ) ) ,
entry ( { " admin " , " network " , " mwan " , " configuration " , " member " } ,
arcombine ( cbi ( " mwan/member " ) , cbi ( " mwan/memberconfig " ) ) ,
_ ( " Members " ) , 20 ) . leaf = true
entry ( { " admin " , " network " , " mwan3 " , " configuration " , " policy " } ,
arcombine ( cbi ( " mwan3 /mwan3_ policy " ) , cbi ( " mwan3 /mwan3_ policyconfig " ) ) ,
entry ( { " admin " , " network " , " mwan " , " configuration " , " policy " } ,
arcombine ( cbi ( " mwan/policy " ) , cbi ( " mwan/policyconfig " ) ) ,
_ ( " Policies " ) , 30 ) . leaf = true
entry ( { " admin " , " network " , " mwan3 " , " configuration " , " rule " } ,
arcombine ( cbi ( " mwan3 /mwan3_ rule " ) , cbi ( " mwan3 /mwan3_ ruleconfig " ) ) ,
entry ( { " admin " , " network " , " mwan " , " configuration " , " rule " } ,
arcombine ( cbi ( " mwan/rule " ) , cbi ( " mwan/ruleconfig " ) ) ,
_ ( " Rules " ) , 40 ) . leaf = true
entry ( { " admin " , " network " , " mwan3 " , " advanced " } ,
alias ( " admin " , " network " , " mwan3 " , " advanced " , " hotplug " ) ,
entry ( { " admin " , " network " , " mwan " , " advanced " } ,
alias ( " admin " , " network " , " mwan " , " advanced " , " hotplugscript " ) ,
_ ( " Advanced " ) , 100 )
entry ( { " admin " , " network " , " mwan3 " , " advanced " , " hotplug " } ,
form ( " mwan3 /mwan3_ adv_hotplug " ) )
entry ( { " admin " , " network " , " mwan3 " , " advanced " , " mwan3 " } ,
form ( " mwan3/mwan3_adv_mwan3 " ) )
entry ( { " admin " , " network " , " mwan3 " , " advanced " , " network " } ,
form ( " mwan3 /mwan3_ adv_network " ) )
entry ( { " admin " , " network " , " mwan3 " , " advanced " , " diag " } ,
template ( " mwan3 /mwan3_ adv_diagnostics " ) )
entry ( { " admin " , " network " , " mwan3 " , " advanced " , " diag_display " } ,
call ( " mwan3_diag_d ata" ) , nil ) . leaf = true
entry ( { " admin " , " network " , " mwan3 " , " advanced " , " tshoot " } ,
template ( " mwan3 /mwan3_ adv_troubleshoot " ) )
entry ( { " admin " , " network " , " mwan3 " , " advanced " , " tshoot_display " } ,
call ( " mwan3_tshoot_d ata" ) )
entry ( { " admin " , " network " , " mwan " , " advanced " , " hotplugscript " } ,
form ( " mwan/advanced _hotplugscript " ) )
entry ( { " admin " , " network " , " mwan " , " advanced " , " mwanconfig " } ,
form ( " mwan/advanced_mwanconfig " ) )
entry ( { " admin " , " network " , " mwan " , " advanced " , " networkconfig " } ,
form ( " mwan/advanced _networkconfig " ) )
entry ( { " admin " , " network " , " mwan " , " advanced " , " diagnostics " } ,
template ( " mwan/advanced _diagnostics " ) )
entry ( { " admin " , " network " , " mwan " , " advanced " , " diagnostics _display " } ,
call ( " diagnosticsD ata" ) , nil ) . leaf = true
entry ( { " admin " , " network " , " mwan " , " advanced " , " trouble shooting " } ,
template ( " mwan/advanced _troubleshooting " ) )
entry ( { " admin " , " network " , " mwan " , " advanced " , " trouble shooting _display " } ,
call ( " troubleshootingD ata" ) )
end
function mwan3_get_iface_status ( rulenum , ifn ame)
if ut.trim ( sys.exec ( " uci get -p /var/state mwan3. " .. ifn ame .. " .enabled " ) ) == " 1 " then
if ut.trim ( sys.exec ( " ip route list table " .. rulenum ) ) ~= " " then
if ut.trim ( sys.exec ( " uci get -p /var/state mwan3. " .. ifn ame .. " .track_ip " ) ) ~= " " then
return " on "
function getInterfaceStatus ( ruleNumber , interfaceN ame)
if ut.trim ( sys.exec ( " uci get -p /var/state mwan3. " .. interfaceN ame .. " .enabled " ) ) == " 1 " then
if ut.trim ( sys.exec ( " ip route list table " .. ruleNumber ) ) ~= " " then
if ut.trim ( sys.exec ( " uci get -p /var/state mwan3. " .. interfaceN ame .. " .track_ip " ) ) ~= " " then
return " online "
else
return " nm "
return " notMonitored "
end
else
return " off "
return " offline "
end
else
return " ne "
return " notEnabl ed "
end
end
function mwan3_get_ifac e( )
local rulenum , str = 0 , " "
function getInterfaceNam e( )
local ruleNumber , status = 0 , " "
uci.cursor ( ) : foreach ( " mwan3 " , " interface " ,
function ( section )
rulenum = rulenum + 1
str = str .. section [ " .name " ] .. " [ " .. mwan3_get_iface_status ( rulenum , section [ " .name " ] ) .. " ] "
ruleNumber = ruleNumber + 1
status = status .. section [ " .name " ] .. " [ " .. getInterfaceStatus ( ruleNumber , section [ " .name " ] ) .. " ] "
end
)
return str
return status
end
function mwan3_iface_s tatus( )
function interfaceS tatus( )
local ntm = require " luci.model.network " . init ( )
local rv = { }
local mArray = { }
-- overview status
local statstr = mwan3_get_ifac e ( )
if statstr ~= " " then
rv .wans = { }
local statusString = getInterfaceNam e ( )
if statu sS tring ~= " " then
mArray .wans = { }
wansid = { }
for wanname , ifstat in string.gfind ( statstr , " ([^%[]+)%[([^%]]+)%] " ) do
local wanifn ame = ut.trim ( sys.exec ( " uci get -p /var/state network. " .. wann ame .. " .ifname " ) )
if wanifn ame == " " then
wanifn ame = " X "
for wanName , interfaceState in string.gfind ( statu sS tring , " ([^%[]+)%[([^%]]+)%] " ) do
local wanInterfaceN ame = ut.trim ( sys.exec ( " uci get -p /var/state network. " .. wanN ame .. " .ifname " ) )
if wanInterfaceN ame == " " then
wanInterfaceN ame = " X "
end
local wanl ink = ntm : get_interface ( wanifn ame )
wanlink = wanlink and wanl ink : get_network ( )
wanlink = wanlink and wanl ink : adminlink ( ) or " # "
wansid [ wann ame ] = # rv .wans + 1
rv .wans[ wansid [ wann ame ] ] = { name = wann ame , link = wanl ink , ifname = wanifn ame , status = ifstat }
local wanDeviceL ink = ntm : get_interface ( wanInterfaceN ame )
wanDeviceLink = wanDeviceLink and wanDeviceL ink : get_network ( )
wanDeviceLink = wanDeviceLink and wanDeviceL ink : adminlink ( ) or " # "
wansid [ wanN ame ] = # mArray .wans + 1
mArray .wans[ wansid [ wanN ame ] ] = { name = wanN ame , link = wanDeviceL ink , ifname = wanInterfaceN ame , status = interfaceState }
end
end
-- overview status log
local mwlg = ut.trim ( sys.exec ( " logread | grep mwan3 | tail -n 50 | sed 'x;1!H;$!d;x' " ) )
if mwlg ~= " " then
rv.mwan3log = { }
mwlog = { }
mwlog [ mwlg ] = # rv.mwan3log + 1
rv.mwan3log [ mwlog [ mwlg ] ] = { mwanlog = mwlg }
local mwanLog = ut.trim ( sys.exec ( " logread | grep mwan3 | tail -n 50 | sed 'x;1!H;$!d;x' " ) )
if mwanLog ~= " " then
mArray.mwanlog = { mwanLog }
end
luci.http . prepare_content ( " application/json " )
luci.http . write_json ( rv )
luci.http . write_json ( mArray )
end
function mwan3_detail_s tatus( )
local rv = { }
function detailedS tatus( )
local mArray = { }
-- detailed mwan3 status
local dst = ut.trim ( sys.exec ( " mwan3 status " ) )
if dst ~= " " then
rv.mwan3dst = { }
dstat = { }
dstat [ dst ] = # rv.mwan3dst + 1
rv.mwan3dst [ dstat [ dst ] ] = { detailstat = dst }
-- detailed mwan status
local detailStatusInfo = ut.trim ( sys.exec ( " /usr/sbin/mwan3 status " ) )
if detailStatusInfo ~= " " then
mArray.mwandetail = { detailStatusInfo }
end
luci.http . prepare_content ( " application/json " )
luci.http . write_json ( rv )
luci.http . write_json ( mArray )
end
function mwan3_diag_d ata( iface , tool , alt )
function get_ifnum ( )
local num = 0
function diagnosticsD ata( inter face , tool , task )
function getInterfaceNumber ( )
local number = 0
uci.cursor ( ) : foreach ( " mwan3 " , " interface " ,
function ( section )
num = num + 1
if section [ " .name " ] == iface then
if num = num
number = number + 1
if section [ " .name " ] == inter face then
interfaceN umber = number
end
end
)
end
local rv = { }
local mArray = { }
local res = " "
local results = " "
if tool == " service " then
os.execute ( " mwan3 " .. alt )
if alt == " restart " then
res = " MWAN3 restarted "
elseif alt == " stop " then
res = " MWAN3 stopped "
os.execute ( " /usr/sbin/ mwan3 " .. task )
if task == " restart " then
results = " MWAN3 restarted "
elseif task == " stop " then
results = " MWAN3 stopped "
else
res = " MWAN3 started "
results = " MWAN3 started "
end
else
local ifdev = ut.trim ( sys.exec ( " uci get -p /var/state network. " .. iface .. " .ifname " ) )
if ifdev ~= " " then
local interfaceDevice = ut.trim ( sys.exec ( " uci get -p /var/state network. " .. inter face .. " .ifname " ) )
if interfaceDevice ~= " " then
if tool == " ping " then
local gateway = ut.trim ( sys.exec ( " route -n | awk '{ if ($8 == \" " .. ifdev .. " \" && $1 == \" 0.0.0.0 \" && $3 == \" 0.0.0.0 \" ) print $2 }' " ) )
local gateway = ut.trim ( sys.exec ( " route -n | awk '{if ($8 == \" " .. interfaceDevice .. " \" && $1 == \" 0.0.0.0 \" && $3 == \" 0.0.0.0 \" ) print $2}' " ) )
if gateway ~= " " then
if alt == " gateway " then
local cm d = " ping -c 3 -W 2 -I " .. ifdev .. " " .. gateway
res = cm d .. " \n \n " .. sys.exec ( cm d)
if task == " gateway " then
local pingComman d = " ping -c 3 -W 2 -I " .. interfaceDevice .. " " .. gateway
results = pingComman d .. " \n \n " .. sys.exec ( pingComman d)
else
local s tr = ut.trim ( sys.exec ( " uci get -p /var/state mwan3. " .. iface .. " .track_ip " ) )
if s tr ~= " " then
for z in s tr: gmatch ( " [^ ]+ " ) do
local cm d = " ping -c 3 -W 2 -I " .. ifdev .. " " .. z
res = res .. cm d .. " \n \n " .. sys.exec ( cm d) .. " \n \n "
local tracked = ut.trim ( sys.exec ( " uci get -p /var/state mwan3. " .. inter face .. " .track_ip " ) )
if tracked ~= " " then
for z in tracked : gmatch ( " [^ ]+ " ) do
local pingComman d = " ping -c 3 -W 2 -I " .. interfaceDevice .. " " .. z
results = results .. pingComman d .. " \n \n " .. sys.exec ( pingComman d) .. " \n \n "
end
else
res = " No tracking IP addresses configured on " .. iface
results = " No tracking IP addresses configured on " .. inter face
end
end
else
res = " No default gateway for " .. iface .. " found. Default route does not exist or is configured incorrectly "
results = " No default gateway for " .. inter face .. " found. Default route does not exist or is configured incorrectly "
end
elseif tool == " rulechk " then
get_ifnum ( )
local rule1 = sys.exec ( " ip rule | grep $(echo $(( " .. if num .. " + 1000))) " )
local rule2 = sys.exec ( " ip rule | grep $(echo $(( " .. if num .. " + 2000))) " )
getInterfaceNumber ( )
local rule1 = sys.exec ( " ip rule | grep $(echo $(( " .. interfaceN umber .. " + 1000))) " )
local rule2 = sys.exec ( " ip rule | grep $(echo $(( " .. interfaceN umber .. " + 2000))) " )
if rule1 ~= " " and rule2 ~= " " then
res = " All required interface IP rules found: \n \n " .. rule1 .. rule2
results = " All required interface IP rules found: \n \n " .. rule1 .. rule2
elseif rule1 ~= " " or rule2 ~= " " then
res = " Missing 1 of the 2 required interface IP rules \n \n \n Rules found: \n \n " .. rule1 .. rule2
results = " Missing 1 of the 2 required interface IP rules \n \n \n Rules found: \n \n " .. rule1 .. rule2
else
res = " Missing both of the required interface IP rules "
results = " Missing both of the required interface IP rules "
end
elseif tool == " routechk " then
get_ifnum ( )
local table = sys.exec ( " ip route list table " .. if num )
if table ~= " " then
res = " Interface routing table " .. if num .. " was found: \n \n " .. table
getInterfaceNumber ( )
local rou teT able = sys.exec ( " ip route list table " .. interfaceN umber )
if rou teT able ~= " " then
results = " Interface routing table " .. interfaceN umber .. " was found: \n \n " .. rou teT able
else
res = " Missing required interface routing table " .. if num
results = " Missing required interface routing table " .. interfaceN umber
end
elseif tool == " hotplug " then
if alt == " ifup " then
os.execute ( " mwan3 ifup " .. iface )
res = " Hotplug ifup sent to interface " .. iface .. " ... "
if task == " ifup " then
os.execute ( " /usr/sbin/ mwan3 ifup " .. inter face )
results = " Hotplug ifup sent to interface " .. inter face .. " ... "
else
os.execute ( " mwan3 ifdown " .. iface )
res = " Hotplug ifdown sent to interface " .. iface .. " ... "
os.execute ( " /usr/sbin/ mwan3 ifdown " .. inter face )
results = " Hotplug ifdown sent to interface " .. inter face .. " ... "
end
end
else
res = " Unable to perform diagnostic tests on " .. iface .. " . There is no physical or virtual device associated with this interface "
results = " Unable to perform diagnostic tests on " .. inter face .. " . There is no physical or virtual device associated with this interface "
end
end
if res ~= " " then
res = ut.trim ( res )
rv.diagres = { }
dres = { }
dres [ res ] = # rv.diagres + 1
rv.diagres [ dres [ res ] ] = { diagresult = res }
if results ~= " " then
results = ut.trim ( results )
mArray.diagnostics = { results }
end
luci.http . prepare_content ( " application/json " )
luci.http . write_json ( rv )
luci.http . write_json ( mArray )
end
function mwan3_tshoot_d ata( )
local rv = { }
function troubleshootingD ata( )
local mArray = { }
-- software versions
local wrtr elease = ut.trim ( luci.version . distversion )
if wrtr elease ~= " " then
wrtr elease = " OpenWrt - " .. wrtr elease
local wrtR elease = ut.trim ( luci.version . distversion )
if wrtR elease ~= " " then
wrtR elease = " OpenWrt - " .. wrtR elease
else
wrtr elease = " OpenWrt - unknown "
wrtR elease = " OpenWrt - unknown "
end
local lucir elease = ut.trim ( luci.version . luciversion )
if lucir elease ~= " " then
lucir elease = " \n LuCI - " .. lucir elease
local luciR elease = ut.trim ( luci.version . luciversion )
if luciR elease ~= " " then
luciR elease = " \n LuCI - " .. luciR elease
else
lucir elease = " \n LuCI - unknown "
luciR elease = " \n LuCI - unknown "
end
local mwan3v ersion = ut.trim ( sys.exec ( " opkg info mwan3 | grep Version | awk '{ print $2 }' " ) )
if mwan3v ersion ~= " " then
mwan3v ersion = " \n \n mwan3 - " .. mwan3v ersion
local mwanV ersion = ut.trim ( sys.exec ( " opkg info mwan3 | grep Version | awk '{print $2}' " ) )
if mwanV ersion ~= " " then
mwanV ersion = " \n \n mwan3 - " .. mwanV ersion
else
mwan3v ersion = " \n mwan3 - unknown "
mwanV ersion = " \n \n mwan3 - unknown "
end
local mwan3lv ersion = ut.trim ( sys.exec ( " opkg info luci-app-mwan3 | grep Version | awk '{ print $2 }' " ) )
if mwan3lv ersion ~= " " then
mwan3lv ersion = " \n mwan3-luci - " .. mwan3lv ersion
local mwanLuciV ersion = ut.trim ( sys.exec ( " opkg info luci-app-mwan3 | grep Version | awk '{print $2}' " ) )
if mwanLuciV ersion ~= " " then
mwanLuciV ersion = " \n mwan3-luci - " .. mwanLuciV ersion
else
mwan3lv ersion = " \n mwan3-luci - unknown "
mwanLuciV ersion = " \n mwan3-luci - unknown "
end
local softrev = wrtrelease .. lucirelease .. mwan3version .. mwan3lversion
rv.mw3ver = { }
mwv = { }
mwv [ softrev ] = # rv.mw3ver + 1
rv.mw3ver [ mwv [ softrev ] ] = { mwan3v = softrev }
-- mwan3 config
local mwcg = ut.trim ( sys.exec ( " cat /etc/config/mwan3 " ) )
if mwcg == " " then
mwcg = " No data found "
mArray.versions = { wrtRelease .. luciRelease .. mwanVersion .. mwanLuciVersion }
-- mwan config
local mwanConfig = ut.trim ( sys.exec ( " cat /etc/config/mwan3 " ) )
if mwanConfig == " " then
mwanConfig = " No data found "
end
rv.mwan3config = { }
mwan3cfg = { }
mwan3cfg [ mwcg ] = # rv.mwan3config + 1
rv.mwan3config [ mwan3cfg [ mwcg ] ] = { mwn3cfg = mwcg }
mArray.mwanconfig = { mwanConfig }
-- network config
local netc g = ut.trim ( sys.exec ( " cat /etc/config/network | sed -e 's/.*username.*/ USERNAME HIDDEN/' -e 's/.*password.*/ PASSWORD HIDDEN/' " ) )
if netc g == " " then
netc g = " No data found "
local networkConfig = ut.trim ( sys.exec ( " cat /etc/config/network | sed -e 's/.*username.*/ USERNAME HIDDEN/' -e 's/.*password.*/ PASSWORD HIDDEN/' " ) )
if networkConfi g == " " then
networkConfi g = " No data found "
end
rv.netconfig = { }
ncfg = { }
ncfg [ netcg ] = # rv.netconfig + 1
rv.netconfig [ ncfg [ netcg ] ] = { netcfg = netcg }
mArray.netconfig = { networkConfig }
-- ifconfig
local ifcg = ut.trim ( sys.exec ( " ifconfig " ) )
if ifcg == " " then
ifcg = " No data found "
local ifconfig = ut.trim ( sys.exec ( " ifconfig " ) )
if ifconfi g == " " then
ifconfi g = " No data found "
end
rv.ifconfig = { }
icfg = { }
icfg [ ifcg ] = # rv.ifconfig + 1
rv.ifconfig [ icfg [ ifcg ] ] = { ifcfg = ifcg }
mArray.ifconfig = { ifconfig }
-- route -n
local routes how = ut.trim ( sys.exec ( " route -n " ) )
if routes how == " " then
routes how = " No data found "
local routeShow = ut.trim ( sys.exec ( " route -n " ) )
if routeS how == " " then
routeS how = " No data found "
end
rv.rtshow = { }
rshw = { }
rshw [ routeshow ] = # rv.rtshow + 1
rv.rtshow [ rshw [ routeshow ] ] = { iprtshow = routeshow }
mArray.routeshow = { routeShow }
-- ip rule show
local ipr = ut.trim ( sys.exec ( " ip rule show " ) )
if ipr == " " then
ipr = " No data found "
local ipRuleShow = ut.trim ( sys.exec ( " ip rule show " ) )
if ipRuleShow == " " then
ipRuleShow = " No data found "
end
rv.iprule = { }
ipruleid = { }
ipruleid [ ipr ] = # rv.iprule + 1
rv.iprule [ ipruleid [ ipr ] ] = { rule = ipr }
mArray.iprule = { ipRuleShow }
-- ip route list table 1-250
local routelisting , rlstr = ut.trim ( sys.exec ( " ip rule | sed 's/://g' | awk '$1>=2001 && $1<=2250' | awk '{ print $NF }' " ) ) , " "
if routelisting ~= " " then
for line in routelisting : gmatch ( " [^ \r \n ]+ " ) do
rlstr = rlstr .. line .. " \n " .. sys.exec ( " ip route list table " .. line )
local routeList , routeString = ut.trim ( sys.exec ( " ip rule | sed 's/://g' | awk '$1>=2001 && $1<=2250' | awk '{print $NF}' " ) ) , " "
if routeList ~= " " then
for line in routeList : gmatch ( " [^ \r \n ]+ " ) do
routeString = routeString .. line .. " \n " .. sys.exec ( " ip route list table " .. line )
end
rlstr = ut.trim ( rlstr )
routeString = ut.trim ( routeString )
else
rlstr = " No data found "
routeString = " No data found "
end
rv.routelist = { }
rtlist = { }
rtlist [ rlstr ] = # rv.routelist + 1
rv.routelist [ rtlist [ rlstr ] ] = { iprtlist = rlstr }
mArray.routelist = { routeString }
-- default firewall output policy
local defo ut = ut.trim ( sys.exec ( " uci get -p /var/state firewall.@defaults[0].output " ) )
if defo ut == " " then
defo ut = " No data found "
local firewallOut = ut.trim ( sys.exec ( " uci get -p /var/state firewall.@defaults[0].output " ) )
if firewallO ut == " " then
firewallO ut = " No data found "
end
rv.fidef = { }
fwdf = { }
fwdf [ defout ] = # rv.fidef + 1
rv.fidef [ fwdf [ defout ] ] = { firedef = defout }
mArray.firewallout = { firewallOut }
-- iptables
local iptbl = ut.trim ( sys.exec ( " iptables -L -t mangle -v -n " ) )
if iptbl == " " then
iptbl = " No data found "
local iptables = ut.trim ( sys.exec ( " iptables -L -t mangle -v -n " ) )
if ipta bles == " " then
ipta bles = " No data found "
end
rv.iptables = { }
tables = { }
tables [ iptbl ] = # rv.iptables + 1
rv.iptables [ tables [ iptbl ] ] = { iptbls = iptbl }
mArray.iptables = { iptables }
luci.http . prepare_content ( " application/json " )
luci.http . write_json ( rv )
luci.http . write_json ( mArray )
end