mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-02-13 02:51:50 +00:00
Add advanced settings to luci app openmptcprouter
This commit is contained in:
parent
467fd3553e
commit
1c77b7965b
3 changed files with 58 additions and 1 deletions
|
@ -13,12 +13,15 @@ function index()
|
||||||
entry({"admin", "system", "openmptcprouter", "wizard_add"}, post("wizard_add"))
|
entry({"admin", "system", "openmptcprouter", "wizard_add"}, post("wizard_add"))
|
||||||
entry({"admin", "system", "openmptcprouter", "status"}, template("openmptcprouter/wanstatus"), _("Status"), 2).leaf = true
|
entry({"admin", "system", "openmptcprouter", "status"}, template("openmptcprouter/wanstatus"), _("Status"), 2).leaf = true
|
||||||
entry({"admin", "system", "openmptcprouter", "interfaces_status"}, call("interfaces_status")).leaf = true
|
entry({"admin", "system", "openmptcprouter", "interfaces_status"}, call("interfaces_status")).leaf = true
|
||||||
|
entry({"admin", "system", "openmptcprouter", "settings"}, template("openmptcprouter/settings"), _("Advanced Settings"), 3).leaf = true
|
||||||
|
entry({"admin", "system", "openmptcprouter", "settings_add"}, post("settings_add")).leaf = true
|
||||||
end
|
end
|
||||||
|
|
||||||
function wizard_add()
|
function wizard_add()
|
||||||
local server_ip = luci.http.formvalue("server_ip")
|
local server_ip = luci.http.formvalue("server_ip")
|
||||||
|
|
||||||
|
-- Set ShadowSocks settings
|
||||||
local shadowsocks_key = luci.http.formvalue("shadowsocks_key")
|
local shadowsocks_key = luci.http.formvalue("shadowsocks_key")
|
||||||
local glorytun_key = luci.http.formvalue("glorytun_key")
|
|
||||||
if shadowsocks_key ~= "" then
|
if shadowsocks_key ~= "" then
|
||||||
ucic:set("shadowsocks-libev","sss0","server",server_ip)
|
ucic:set("shadowsocks-libev","sss0","server",server_ip)
|
||||||
ucic:set("shadowsocks-libev","sss0","key",shadowsocks_key)
|
ucic:set("shadowsocks-libev","sss0","key",shadowsocks_key)
|
||||||
|
@ -28,6 +31,9 @@ function wizard_add()
|
||||||
ucic:save("shadowsocks-libev")
|
ucic:save("shadowsocks-libev")
|
||||||
ucic:commit("shadowsocks-libev")
|
ucic:commit("shadowsocks-libev")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Set Glorytun TCP settings
|
||||||
|
local glorytun_key = luci.http.formvalue("glorytun_key")
|
||||||
if glorytun_key ~= "" then
|
if glorytun_key ~= "" then
|
||||||
ucic:set("glorytun","vpn","host",server_ip)
|
ucic:set("glorytun","vpn","host",server_ip)
|
||||||
ucic:set("glorytun","vpn","port","65001")
|
ucic:set("glorytun","vpn","port","65001")
|
||||||
|
@ -40,6 +46,7 @@ function wizard_add()
|
||||||
ucic:commit("glorytun")
|
ucic:commit("glorytun")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Set interfaces settings
|
||||||
local interfaces = luci.http.formvaluetable("intf")
|
local interfaces = luci.http.formvaluetable("intf")
|
||||||
for intf, _ in pairs(interfaces) do
|
for intf, _ in pairs(interfaces) do
|
||||||
local ipaddr = luci.http.formvalue("cbid.network.%s.ipaddr" % intf)
|
local ipaddr = luci.http.formvalue("cbid.network.%s.ipaddr" % intf)
|
||||||
|
@ -57,6 +64,25 @@ function wizard_add()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function settings_add()
|
||||||
|
-- Set tcp_keepalive_time
|
||||||
|
local tcp_keepalive_time = luci.http.formvalue("tcp_keepalive_time")
|
||||||
|
luci.sys.exec("sysctl -w net.ipv4.tcp_keepalive_time=%s" % tcp_keepalive_time)
|
||||||
|
luci.sys.exec("sed -i 's:^net.ipv4.tcp_keepalive_time = [0-9]*:net.ipv4.tcp_keepalive_time=%s:' /etc/sysctl.d/zzz_openmptcprouter.conf" % tcp_keepalive_time)
|
||||||
|
|
||||||
|
-- Disable IPv6
|
||||||
|
local disable_ipv6 = luci.http.formvalue("disable_ipv6") or 0
|
||||||
|
luci.sys.exec("sysctl -w net.ipv6.conf.all.disable_ipv6=%s" % disable_ipv6)
|
||||||
|
luci.sys.exec("sed -i 's:^net.ipv6.conf.all.disable_ipv6 = [0-9]*:net.ipv6.conf.all.disable_ipv6=%s:' /etc/sysctl.d/zzz_openmptcprouter.conf" % disable_ipv6)
|
||||||
|
ucic:set("firewall",ucic:get_first("firewall","defaults"),"disable_ipv6",disable_ipv6)
|
||||||
|
ucic:save("firewall")
|
||||||
|
ucic:commit("firewall")
|
||||||
|
|
||||||
|
-- Done, redirect
|
||||||
|
luci.http.redirect(luci.dispatcher.build_url("admin/system/openmptcprouter/settings"))
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
-- This function come from OverTheBox by OVH with very small changes
|
-- This function come from OverTheBox by OVH with very small changes
|
||||||
function interfaces_status()
|
function interfaces_status()
|
||||||
local ut = require "luci.util"
|
local ut = require "luci.util"
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
<%+header%>
|
||||||
|
|
||||||
|
<% if stderr and #stderr > 0 then %><pre class="error"><%=pcdata(stderr)%></pre><% end %>
|
||||||
|
<form class="inline" method="post" action="<%=url('admin/system/openmptcprouter/settings_add')%>">
|
||||||
|
<div class="cbi-map">
|
||||||
|
<h2 name="content"><%:Advanced Settings%></h2>
|
||||||
|
<fieldset class="cbi-section" id="networks">
|
||||||
|
<legend><%:Networks settings%></legend>
|
||||||
|
<div class="cbi-section-descr"></div>
|
||||||
|
<div class="cbi-value">
|
||||||
|
<label class="cbi-value-title"><%:IPv4 TCP Keepalive time%></label>
|
||||||
|
<div class="cbi-value-field">
|
||||||
|
<input type="text" name="tcp_keepalive_time" class="cbi-input-text" value="<%=tonumber((luci.sys.exec("sysctl net.ipv4.tcp_keepalive_time")):match(" %d+"))%>">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="cbi-value">
|
||||||
|
<label class="cbi-value-title"><%:Disable IPv6%></label>
|
||||||
|
<div class="cbi-value-field">
|
||||||
|
<input type="checkbox" name="disable_ipv6" class="cbi-input-checkbox" value="1" <% if tonumber((luci.sys.exec("sysctl net.ipv6.conf.all.disable_ipv6")):match(" %d+")) == 1 %>checked<% end %>>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
</div>
|
||||||
|
<div class="cbi-page-actions">
|
||||||
|
<input type="hidden" name="token" value="<%=token%>" />
|
||||||
|
<button class="btn" type="submit">Submit</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<%+footer%>
|
|
@ -0,0 +1,2 @@
|
||||||
|
net.ipv4.tcp_keepalive_time = 1200
|
||||||
|
net.ipv6.conf.all.disable_ipv6 = 0
|
Loading…
Reference in a new issue