mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-02-13 11:01:50 +00:00
Interfaces can be added from wizard
This commit is contained in:
parent
531851d3c2
commit
1e4d24bdaa
2 changed files with 78 additions and 26 deletions
|
@ -18,6 +18,44 @@ function index()
|
||||||
end
|
end
|
||||||
|
|
||||||
function wizard_add()
|
function wizard_add()
|
||||||
|
local add_interface = luci.http.formvalue("add_interface") or ""
|
||||||
|
local gostatus = true
|
||||||
|
if add_interface ~= "" then
|
||||||
|
local i = 1
|
||||||
|
ucic:foreach("network", "interface", function(s)
|
||||||
|
local sectionname = s[".name"]
|
||||||
|
if sectionname:match("^wan(%d+)$") then
|
||||||
|
i = i + 1
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
local defif = ucic:get("network","wan1","ifname") or "eth0"
|
||||||
|
ucic:set("network","wan" .. i,"interface")
|
||||||
|
ucic:set("network","wan" .. i,"ifname",defif)
|
||||||
|
ucic:set("network","wan" .. i,"proto","static")
|
||||||
|
ucic:set("network","wan" .. i,"type","macvlan")
|
||||||
|
ucic:set("network","wan" .. i,"ip4table","wan")
|
||||||
|
ucic:set("network","wan" .. i,"multipath","on")
|
||||||
|
ucic:set("network","wan" .. i,"defaultroute","0")
|
||||||
|
ucic:save("network")
|
||||||
|
ucic:commit("network")
|
||||||
|
-- Dirty way to add new interface to firewall...
|
||||||
|
luci.sys.call("uci -q add_list firewall.@zone[1].network=wan" .. i)
|
||||||
|
|
||||||
|
luci.sys.call("/etc/init.d/macvlan restart >/dev/null 2>/dev/null")
|
||||||
|
gostatus = false
|
||||||
|
end
|
||||||
|
|
||||||
|
local delete_intf = luci.http.formvaluetable("delete")
|
||||||
|
if delete_intf ~= "" then
|
||||||
|
for intf, _ in pairs(delete_intf) do
|
||||||
|
ucic:delete("network",intf)
|
||||||
|
ucic:delete("network",intf .. "_dev")
|
||||||
|
ucic:save("network")
|
||||||
|
ucic:commit("network")
|
||||||
|
end
|
||||||
|
gostatus = false
|
||||||
|
end
|
||||||
|
|
||||||
local server_ip = luci.http.formvalue("server_ip")
|
local server_ip = luci.http.formvalue("server_ip")
|
||||||
|
|
||||||
-- Set ShadowSocks settings
|
-- Set ShadowSocks settings
|
||||||
|
@ -60,7 +98,11 @@ function wizard_add()
|
||||||
ucic:commit("network")
|
ucic:commit("network")
|
||||||
luci.sys.call("(env -i /bin/ubus call network reload) >/dev/null 2>/dev/null")
|
luci.sys.call("(env -i /bin/ubus call network reload) >/dev/null 2>/dev/null")
|
||||||
luci.sys.call("/etc/init.d/glorytun restart >/dev/null 2>/dev/null")
|
luci.sys.call("/etc/init.d/glorytun restart >/dev/null 2>/dev/null")
|
||||||
|
if gostatus then
|
||||||
luci.http.redirect(luci.dispatcher.build_url("admin/system/openmptcprouter/status"))
|
luci.http.redirect(luci.dispatcher.build_url("admin/system/openmptcprouter/status"))
|
||||||
|
else
|
||||||
|
luci.http.redirect(luci.dispatcher.build_url("admin/system/openmptcprouter/wizard"))
|
||||||
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
local net = require "luci.model.network".init()
|
local net = require "luci.model.network".init()
|
||||||
local ifaces = net:get_interfaces()
|
local ifaces = net:get_interfaces()
|
||||||
%>
|
%>
|
||||||
|
<script type="text/javascript" src="<%=resource%>/cbi.js"></script>
|
||||||
|
|
||||||
<% if stderr and #stderr > 0 then %><pre class="error"><%=pcdata(stderr)%></pre><% end %>
|
<% if stderr and #stderr > 0 then %><pre class="error"><%=pcdata(stderr)%></pre><% end %>
|
||||||
<form class="inline" method="post" action="<%=url('admin/system/openmptcprouter/wizard_add')%>">
|
<form class="inline" method="post" action="<%=url('admin/system/openmptcprouter/wizard_add')%>">
|
||||||
|
@ -41,7 +42,11 @@
|
||||||
local ifname = iface:name()
|
local ifname = iface:name()
|
||||||
if (ifname:match("^wan.*")) then
|
if (ifname:match("^wan.*")) then
|
||||||
%>
|
%>
|
||||||
|
<div class="cbi-section-remove right">
|
||||||
|
<input type="submit" name="delete.<%=ifname%>" value="<%:Delete%>" class="cbi-button" />
|
||||||
|
</div>
|
||||||
<h3><%=ifname%></h3>
|
<h3><%=ifname%></h3>
|
||||||
|
<fieldset class="cbi-section-node" id="cbi-openmptcprouter-<%=ifname%>">
|
||||||
<input type="hidden" name="intf.<%=ifname%>" value="<%=ifname%>" />
|
<input type="hidden" name="intf.<%=ifname%>" value="<%=ifname%>" />
|
||||||
<div class="cbi-value">
|
<div class="cbi-value">
|
||||||
<label class="cbi-value-title"><%:IPv4 address%></label>
|
<label class="cbi-value-title"><%:IPv4 address%></label>
|
||||||
|
@ -71,10 +76,15 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</fieldset>
|
||||||
<%
|
<%
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
%>
|
%>
|
||||||
|
|
||||||
|
<div class="cbi-section-create">
|
||||||
|
<input class="cbi-button cbi-button-add" type="submit" name="add_interface" value="<%:Add an interface%>" title="<%:Add an interface%>" />
|
||||||
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
<div class="cbi-page-actions">
|
<div class="cbi-page-actions">
|
||||||
|
|
Loading…
Reference in a new issue