mirror of
https://github.com/kenzok8/small-package
synced 2025-01-05 11:36:47 +08:00
update 2024-07-22 00:22:21
This commit is contained in:
parent
7394169366
commit
f127b06e08
@ -3,7 +3,7 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-openvpn-client
|
||||
PKG_VERSION:=20211229
|
||||
PKG_VERSION:=20240721
|
||||
PKG_RELEASE:=1
|
||||
|
||||
LUCI_TITLE:=LuCI support for OpenVPN Client
|
||||
|
@ -4,6 +4,11 @@ m = Map("luci-app-openvpn-client", translate("Client List"))
|
||||
m.apply_on_parse = true
|
||||
m.redirect = d.build_url("admin", "vpn", "openvpn-client")
|
||||
|
||||
m.on_apply = function(self)
|
||||
luci.sys.call("/etc/init.d/luci-app-openvpn-client start %s" % arg[1])
|
||||
luci.http.redirect( self.redirect )
|
||||
end
|
||||
|
||||
s = m:section(NamedSection, arg[1], "clients", "")
|
||||
s.addremove = false
|
||||
s.anonymous = true
|
||||
@ -41,6 +46,10 @@ o.rmempty = false
|
||||
o = s:option(DynamicList, "routes", translate("Static Routes"))
|
||||
o.placeholder = "192.168.10.0/24"
|
||||
|
||||
o = s:option(Flag, "allow_access", translate("Allow server access"))
|
||||
o.default = "1"
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(ListValue, "auth", translate("Auth"))
|
||||
o:value("", translate("None"))
|
||||
o:value("user_pass", translate("User/Pass"))
|
||||
|
@ -46,6 +46,9 @@ msgstr "不拉取路由"
|
||||
msgid "Static Routes"
|
||||
msgstr "静态路由"
|
||||
|
||||
msgid "Allow server access"
|
||||
msgstr "允许服务端访问"
|
||||
|
||||
msgid "Auth"
|
||||
msgstr "身份认证"
|
||||
|
||||
|
@ -97,6 +97,10 @@ start_instance() {
|
||||
_proxy="socks-proxy ${c_p_server} ${c_p_port} ${_proxy_auth}"
|
||||
fi
|
||||
}
|
||||
|
||||
local c_allow_access_action="ACCEPT"
|
||||
local c_allow_access=$(uci -q get ${CONFIG}.${cfgid}.allow_access || echo "1")
|
||||
[ "${c_allow_access}" = "0" ] && c_allow_access_action="DROP"
|
||||
|
||||
echo "#!/bin/sh" > ${TMP_OVPN_PATH}/${cfgid}/up.sh
|
||||
echo "#!/bin/sh" > ${TMP_OVPN_PATH}/${cfgid}/down.sh
|
||||
@ -124,6 +128,7 @@ start_instance() {
|
||||
#允许服务端配置静态路由表访问内网
|
||||
iptables -t nat -I POSTROUTING -s \$(cat ${TMP_OVPN_PATH}/${cfgid}/network)/\$(cat ${TMP_OVPN_PATH}/${cfgid}/mask) -m comment --comment "${c_dev}" -j MASQUERADE
|
||||
iptables -t nat -I POSTROUTING -o ${c_dev} -m comment --comment "${c_dev}" -j MASQUERADE
|
||||
iptables -I INPUT -s \$(cat ${TMP_OVPN_PATH}/${cfgid}/network)/\$(cat ${TMP_OVPN_PATH}/${cfgid}/mask) -m comment --comment "${c_dev}" -j ${c_allow_access_action}
|
||||
iptables -I FORWARD -i ${c_dev} -m comment --comment "${c_dev}" -j ACCEPT
|
||||
iptables -I FORWARD -o ${c_dev} -m comment --comment "${c_dev}" -j ACCEPT
|
||||
EOF
|
||||
@ -135,6 +140,7 @@ start_instance() {
|
||||
\$1 -w -D \$2 \$index 2>/dev/null
|
||||
done
|
||||
}
|
||||
ipt_del "iptables" "INPUT"
|
||||
ipt_del "iptables" "FORWARD"
|
||||
ipt_del "iptables -t nat" "POSTROUTING"
|
||||
EOF
|
||||
|
@ -1,7 +1,3 @@
|
||||
<%
|
||||
local ipkg = require "luci.model.ipkg"
|
||||
-%>
|
||||
|
||||
<div class="cbi-value">
|
||||
<label class="cbi-value-title"><%:Status%></label>
|
||||
<div class="cbi-value-field" id="run_status" style="font-weight: bold;"><%:Collecting data...%></div>
|
||||
@ -11,16 +7,11 @@ local ipkg = require "luci.model.ipkg"
|
||||
//<![CDATA[
|
||||
var run_status = document.getElementById('run_status');
|
||||
var style = run_status.getAttribute("style");
|
||||
<% if ipkg.installed("python3") then %>
|
||||
XHR.poll(2, '<%=luci.dispatcher.build_url("admin", "vpn", "ssr_mudb_server", "status")%>', null,
|
||||
function(x, result) {
|
||||
run_status.setAttribute("style", result.status ? style + "color: green;" : style + "color: red;");
|
||||
run_status.innerHTML = result.status ? '<%=translate("RUNNING")%>' : '<%=translate("NOT RUNNING")%>';
|
||||
}
|
||||
)
|
||||
<% else %>
|
||||
run_status.setAttribute("style", style + "color: red;");
|
||||
run_status.innerHTML = '<%=translate("NOT INSTALLED")%><br><%=translate("please Install the python3")%><br>opkg update && opkg install python3</font></b>';
|
||||
<% end %>
|
||||
XHR.poll(2, '<%=luci.dispatcher.build_url("admin", "vpn", "ssr_mudb_server", "status")%>', null,
|
||||
function(x, result) {
|
||||
run_status.setAttribute("style", result.status ? style + "color: green;" : style + "color: red;");
|
||||
run_status.innerHTML = result.status ? '<%=translate("RUNNING")%>' : '<%=translate("NOT RUNNING")%>';
|
||||
}
|
||||
)
|
||||
//]]>
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user