<%- local ntm = require "luci.model.network".init() local fwm = require "luci.model.firewall".init() local b=luci.sys.exec("a=` cat /etc/config/network | grep \"config interface 'pptp\" | wc -l` ; b=1 ; while [ $b -le $a ] ; do c=`uci show network.pptp$b | wc -l` ; echo $c $b ;if [ $c -eq 5 ]; then uci delete network.pptp$b ; uci commit ;fi; b=$((b+1)) ; done") local b=luci.sys.exec("a=` cat /etc/config/network | grep \"config interface 'l2tp\" | wc -l` ; b=1 ; while [ $b -le $a ] ; do c=`uci show network.l2tp$b | wc -l` ; echo $c $b ;if [ $c -eq 4 ]; then uci delete network.l2tp$b ; uci commit ;fi; b=$((b+1)) ; done") local b=luci.sys.exec("a=` cat /etc/config/network | grep \"config interface 'gre\" | wc -l` ; b=1 ; while [ $b -le $a ] ; do c=`uci show network.gre$b | wc -l` ; echo $c $b ;if [ $c -eq 2 ]; then uci delete network.gre$b ; uci commit ;fi; b=$((b+1)) ; done") local net local ifaces = { } local netlist = { } for _, net in ipairs(ntm:get_networks()) do if net:name() ~= "loopback" then local z = fwm:get_zone_by_network(net:name()) ifaces[#ifaces+1] = net:name() netlist[#netlist+1] = { net:name(), z and z:name() or "-", z } end end table.sort(netlist, function(a, b) if a[2] ~= b[2] then return a[2] < b[2] else return a[1] < b[1] end end) -%>
<% local c = "#C47441" l2tp= {"L2TP1" , "L2TP2", "L2TP3" , "L2TP4", "L2TP5" } local vpn={} cnt=1 vpn[cnt] = "IPSEC" cnt=cnt+1 vpn[cnt]="aa" for i=1,tonumber(cnt) do if vpn[i] == "IPSEC" then local a = luci.sys.exec("cat /etc/config/ipsec | grep config | wc -l") local updown ={ } local c = "#C47441" local ipsec = { } for i=1,tonumber(a) do dupi=luci.sys.exec("cat /etc/config/ipsec | grep config | awk '{print$3}' | grep -o [0-9] | head -%q | tail -1 " % i) ipsecval="IPSEC"..tonumber(dupi) conncd=luci.sys.exec("uci get ipsec.%q.conn | tr -d '\n'" % tostring(ipsecval)) conncd1="a=`uci get ipsec."..tostring(ipsecval)..".proto |tr -d '\n' ` && if [ $a == ipsec_c_to_g ]; then echo 1; else echo 0 ;fi" proto=luci.sys.exec("uci get ipsec.%q.proto | tr -d '\n'" % tostring(ipsecval)) val=luci.sys.exec(conncd1) %> <%end%> <%else for i, net in ipairs(netlist) do local z = net[3] local c = "#C47441" local t = z and translate("Part of zone %q" % z:name()) or translate("No zone assigned") repeat cmp_if=net[1] if net[1]:upper()=="IPSEC" or cmp_ipsec=="ipsec" or net[1]:upper()=="LAN" or net[1]:upper()=="WAN" or net[1]:upper()=="WWAN" or net[1]:upper()=="CELLULAR" or net[1]:upper()=="CELLDHCP" or net[1]:upper()=="3G" or net[1]:upper()=="CELLCONF" then break end if cmp_if:match("l2tp") then val="L2TP_SETTING" end if cmp_if:match("gre") then val="GRE_SETTING" end if cmp_if:match("pptp") then val="PPTP_SETTING" end if cmp_if:match("openvpn") then val="OPENVPN" end %> <% until true %> <% end %> <%end%> <%end%>
<%:VPN%> <%:Status%> <%:Actions%>
<%=ipsecval%>

<%=conncd%> ( <%=proto%> )
>Collecting Data.. <%if tonumber(val) < 1 then %> <%else%> <%end%>
<%=net[1]:upper()%>

<% if val=="OPENVPN" then %> <%=luci.sys.exec("a=`uci show openvpn | grep %q | awk -F. '{print$2}'` && uci get openvpn.$a.profile" % net[1]:lower())%> (<%=luci.sys.exec("uci get network.%q.ifname" % net[1]:lower())%>) <% else %> <%=luci.sys.exec("uci get network.%q.ifname" % net[1]:lower())%> <% end %>
<%:Collecting data...%>