mirror of
https://github.com/coolsnowwolf/lede.git
synced 2025-04-18 17:33:31 +00:00
add udp server support to openvpn luci
This commit is contained in:
parent
97686ea24c
commit
30b413b43a
@ -10,7 +10,7 @@ LUCI_DEPENDS:=+openvpn-openssl +openvpn-easy-rsa +kmod-tun
|
||||
LUCI_PKGARCH:=all
|
||||
PKG_NAME:=luci-app-openvpn-server
|
||||
PKG_VERSION:=2.0
|
||||
PKG_RELEASE:=17
|
||||
PKG_RELEASE:=18
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
|
@ -11,4 +11,12 @@ function index()
|
||||
local page
|
||||
|
||||
entry({"admin", "vpn", "openvpn-server"}, cbi("openvpn-server/openvpn-server"), _("OpenVPN Server"), 80).dependent=false
|
||||
entry({"admin", "vpn", "openvpn-server","status"},call("act_status")).leaf=true
|
||||
end
|
||||
|
||||
function act_status()
|
||||
local e={}
|
||||
e.running=luci.sys.call("pgrep openvpn >/dev/null")==0
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(e)
|
||||
end
|
@ -1,9 +1,11 @@
|
||||
|
||||
--require("luci.tools.webadmin")
|
||||
|
||||
mp = Map("openvpn", "OpenVPN Server","")
|
||||
mp = Map("openvpn", "OpenVPN Server",translate("An easy config OpenVPN Server Web-UI"))
|
||||
|
||||
s = mp:section(TypedSection, "openvpn", "", translate("An easy config OpenVPN Server Web-UI"))
|
||||
mp:section(SimpleSection).template = "openvpn/openvpn_status"
|
||||
|
||||
s = mp:section(TypedSection, "openvpn")
|
||||
s.anonymous = true
|
||||
s.addremove = false
|
||||
|
||||
@ -11,6 +13,10 @@ s:tab("basic", translate("Base Setting"))
|
||||
|
||||
o = s:taboption("basic", Flag, "enabled", translate("Enable"))
|
||||
|
||||
proto = s:taboption("basic",Value,"proto", translate("Proto"))
|
||||
proto:value("tcp-server", translate("TCP Server"))
|
||||
proto:value("udp", translate("UDP Server"))
|
||||
|
||||
port = s:taboption("basic", Value, "port", translate("Port"))
|
||||
port.datatype = "range(1,65535)"
|
||||
|
||||
@ -88,44 +94,10 @@ function Download()
|
||||
luci.http.close()
|
||||
end
|
||||
|
||||
t = mp:section(Table, openvpn_process_status())
|
||||
t.anonymous = true
|
||||
|
||||
t:option(DummyValue, "status", translate("OpenVPN status"))
|
||||
|
||||
if pid == "" then
|
||||
start = t:option(Button, "_start", translate("Start"))
|
||||
start.inputstyle = "apply"
|
||||
function start.write(self, section)
|
||||
luci.util.exec("uci set openvpn.myvpn.enabled=='1' && uci commit openvpn")
|
||||
message = luci.util.exec("/etc/init.d/openvpn start 2>&1")
|
||||
luci.util.exec("sleep 2")
|
||||
luci.http.redirect(
|
||||
luci.dispatcher.build_url("admin", "vpn", "openvpn-server") .. "?message=" .. message
|
||||
)
|
||||
end
|
||||
else
|
||||
stop = t:option(Button, "_stop", translate("Stop"))
|
||||
stop.inputstyle = "reset"
|
||||
function stop.write(self, section)
|
||||
luci.util.exec("uci set openvpn.myvpn.enabled=='0' && uci commit openvpn")
|
||||
luci.util.exec("/etc/init.d/openvpn stop")
|
||||
luci.util.exec("sleep 2")
|
||||
luci.http.redirect(
|
||||
luci.dispatcher.build_url("admin", "vpn", "openvpn-server")
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
function mp.on_after_commit(self)
|
||||
os.execute("uci set firewall.openvpn.dest_port=$(uci get openvpn.myvpn.port) && uci commit firewall && /etc/init.d/firewall restart")
|
||||
os.execute("/etc/init.d/openvpn restart")
|
||||
end
|
||||
|
||||
|
||||
--local apply = luci.http.formvalue("cbi.apply")
|
||||
--if apply then
|
||||
-- os.execute("/etc/init.d/openvpn restart")
|
||||
--end
|
||||
|
||||
return mp
|
||||
|
@ -0,0 +1,22 @@
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
XHR.poll(3, '<%=url([[admin]], [[vpn]], [[openvpn-server]], [[status]])%>', null,
|
||||
function(x, data) {
|
||||
var tb = document.getElementById('openvpn_status');
|
||||
if (data && tb) {
|
||||
if (data.running) {
|
||||
var links = '<em><b><font color=green>OpenVPN Server <%:RUNNING%></font></b></em>';
|
||||
tb.innerHTML = links;
|
||||
} else {
|
||||
tb.innerHTML = '<em><b><font color=red>OpenVPN Server <%:NOT RUNNING%></font></b></em>';
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
//]]>
|
||||
</script>
|
||||
<style>.mar-10 {margin-left: 50px; margin-right: 10px;}</style>
|
||||
<fieldset class="cbi-section">
|
||||
<p id="openvpn_status">
|
||||
<em><%:Collecting data...%></em>
|
||||
</p>
|
||||
</fieldset>
|
@ -48,3 +48,6 @@ msgstr "根据路由的实际LAN IP 修改 route 192.168.0.0 255.255.255.0 和 d
|
||||
|
||||
msgid "OpenVPN status"
|
||||
msgstr "OpenVPN 服务器运行状态"
|
||||
|
||||
msgid "Proto"
|
||||
msgstr "协议"
|
||||
|
@ -12,7 +12,7 @@ uci rename firewall.@rule[-1]="openvpn"
|
||||
uci set firewall.@rule[-1].name="openvpn"
|
||||
uci set firewall.@rule[-1].target="ACCEPT"
|
||||
uci set firewall.@rule[-1].src="wan"
|
||||
uci set firewall.@rule[-1].proto="tcp"
|
||||
uci set firewall.@rule[-1].proto="tcp udp"
|
||||
uci set firewall.@rule[-1].dest_port="1194"
|
||||
|
||||
uci delete firewall.vpn
|
||||
|
Loading…
Reference in New Issue
Block a user