mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-12 18:27:51 +08:00
🌴 Sync 2026-03-05 23:51:42
This commit is contained in:
1 parent
97c049ed0a
commit
0acff03804
14253 files changed
+3893239
No files matched your search
Executable
+14
@@ -0,0 +1,14 @@
|
||||
# Copyright (C) 2008-2014 The LuCI Team <luci@lists.subsignal.org>
|
||||
# Copyright (C) 2020-2021 Hyy2001X <https://github.com/Hyy2001X>
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
LUCI_TITLE:=LuCI support for NPS Client(NPC)
|
||||
LUCI_DEPENDS:=+npc
|
||||
LUCI_PKGARCH:=all
|
||||
PKG_VERSION:=1.3
|
||||
PKG_RELEASE:=1
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
||||
Executable
+11
@@ -0,0 +1,11 @@
|
||||
# luci-app-npc
|
||||
|
||||
## 修改内容
|
||||
|
||||
- 解除原有服务端仅 IPv4 地址的限制
|
||||
|
||||
- 添加[速度限制] [流量限制] [最大连接数] 等多个选项
|
||||
|
||||
## Based on
|
||||
|
||||
- [lede](https://github.com/coolsnowwolf/lede/tree/master/package/lean/luci-app-nps)
|
||||
Executable
+17
@@ -0,0 +1,17 @@
|
||||
module("luci.controller.npc",package.seeall)
|
||||
|
||||
function index()
|
||||
if not nixio.fs.access("/etc/config/npc") then
|
||||
return
|
||||
end
|
||||
|
||||
entry({"admin", "services", "npc"}, cbi("npc"), _("NPS Client"), 99).dependent = true
|
||||
entry({"admin", "services", "npc", "status"}, call("act_status")).leaf = true
|
||||
end
|
||||
|
||||
function act_status()
|
||||
local e = {}
|
||||
e.running = luci.sys.call("pgrep npc > /dev/null") == 0
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(e)
|
||||
end
|
||||
Executable
+50
@@ -0,0 +1,50 @@
|
||||
m = Map("npc", translate("NPS Client"), translate("Nps is a fast reverse proxy to help you expose a local server behind a NAT or firewall to the internet."))
|
||||
|
||||
m:section(SimpleSection).template = "npc/npc_status"
|
||||
|
||||
s = m:section(TypedSection,"npc")
|
||||
s.addremove = false
|
||||
s.anonymous = true
|
||||
|
||||
enable = s:option(Flag, "enable", translate("Enable"))
|
||||
enable.rmempty = false
|
||||
enable.default = "0"
|
||||
|
||||
server = s:option(Value, "server_addr", translate("Server Address"), translate("IPv4 address or Domain Name"))
|
||||
server.rmempty = false
|
||||
|
||||
port = s:option(Value, "server_port", translate("Port"))
|
||||
port.datatype = "port"
|
||||
port.default = "8024"
|
||||
port.rmempty = false
|
||||
|
||||
vkey = s:option(Value, "vkey", translate("vkey"))
|
||||
vkey.password = true
|
||||
vkey.rmempty = false
|
||||
|
||||
protocol = s:option(ListValue, "protocol", translate("Protocol Type"))
|
||||
protocol.default = "tcp"
|
||||
protocol:value("tcp", translate("TCP Protocol"))
|
||||
protocol:value("kcp", translate("KCP Protocol"))
|
||||
|
||||
max_conn = s:option(Value, "max_conn", translate("Max Connection Limit"), translate("Maximum number of connections (Not necessary)"))
|
||||
max_conn.optional = true
|
||||
max_conn.rmempty = true
|
||||
|
||||
rate_limit = s:option(Value, "rate_limit", translate("Rate Limit"), translate("Client rate limit (Not necessary)"))
|
||||
rate_limit.optional = true
|
||||
rate_limit.rmempty = true
|
||||
|
||||
flow_limit = s:option(Value, "flow_limit", translate("Flow Limit"), translate("Client flow limit (Not necessary)"))
|
||||
flow_limit.optional = true
|
||||
flow_limit.rmempty = true
|
||||
|
||||
compress = s:option(Flag, "compress", translate("Enable Compression"), translate("The contents will be compressed to speed up the traffic forwarding speed, but this will consume some additional cpu resources."))
|
||||
compress.default = "0"
|
||||
compress.rmempty = false
|
||||
|
||||
crypt = s:option(Flag, "crypt", translate("Enable Encryption"), translate("Encrypted the communication between Npc and Nps, will effectively prevent the traffic intercepted."))
|
||||
crypt.default = "0"
|
||||
crypt.rmempty = false
|
||||
|
||||
return m
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
XHR.poll(3, '<%=url([[admin]], [[services]], [[npc]], [[status]])%>', null,
|
||||
function(x, data) {
|
||||
var tb = document.getElementById('npc_status');
|
||||
if (data && tb) {
|
||||
if (data.running) {
|
||||
var links = '<em><b><font color=green>NPS Client <%:RUNNING%></font></b></em>';
|
||||
tb.innerHTML = links;
|
||||
} else {
|
||||
tb.innerHTML = '<em><b><font color=red>NPS Client <%:NOT RUNNING%></font></b></em>';
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
//]]>
|
||||
</script>
|
||||
<style>.mar-10 {margin-left: 50px; margin-right: 10px;}</style>
|
||||
<fieldset class="cbi-section">
|
||||
<p id="npc_status">
|
||||
<em><%:Collecting data...%></em>
|
||||
</p>
|
||||
</fieldset>
|
||||
Executable
+56
@@ -0,0 +1,56 @@
|
||||
msgid "NPS Client"
|
||||
msgstr "NPS 内网穿透客户端"
|
||||
|
||||
msgid "Nps is a fast reverse proxy to help you expose a local server behind a NAT or firewall to the internet."
|
||||
msgstr "NPS 是一种快速反向代理,可帮助您将 NAT 或防火墙后的本地服务器公开到 Internet"
|
||||
|
||||
msgid "IPv4 address or Domain Name"
|
||||
msgstr "服务器域名或 IPv4 地址"
|
||||
|
||||
msgid "vkey"
|
||||
msgstr "唯一验证密钥(vkey)"
|
||||
|
||||
msgid "Enable Compression"
|
||||
msgstr "压缩传输"
|
||||
|
||||
msgid "Enable Encryption"
|
||||
msgstr "加密传输"
|
||||
|
||||
msgid "The contents will be compressed to speed up the traffic forwarding speed, but this will consume some additional cpu resources."
|
||||
msgstr "启用压缩传输内容会加快流量转发速度,但是会额外消耗 CPU 资源"
|
||||
|
||||
msgid "Encrypted the communication between Npc and Nps, will effectively prevent the traffic intercepted."
|
||||
msgstr "启用加密传输客户端与服务端之间的通信内容,会有效防止流量被拦截"
|
||||
|
||||
msgid "Basic Setting"
|
||||
msgstr "基本设置"
|
||||
|
||||
msgid "Protocol Type"
|
||||
msgstr "协议类型"
|
||||
|
||||
msgid "Server Address"
|
||||
msgstr "服务端地址"
|
||||
|
||||
msgid "TCP Protocol"
|
||||
msgstr "TCP"
|
||||
|
||||
msgid "KCP Protocol"
|
||||
msgstr "KCP"
|
||||
|
||||
msgid "Max Connection Limit"
|
||||
msgstr "连接数限制"
|
||||
|
||||
msgid "Maximum number of connections (Not necessary)"
|
||||
msgstr "最大连接数限制 (可选,非必须)"
|
||||
|
||||
msgid "Rate Limit"
|
||||
msgstr "速度限制"
|
||||
|
||||
msgid "Client rate limit (Not necessary)"
|
||||
msgstr "客户端速度限制 (可选,非必须)"
|
||||
|
||||
msgid "Flow Limit"
|
||||
msgstr "流量限制"
|
||||
|
||||
msgid "Client flow limit (Not necessary)"
|
||||
msgstr "客户端流量限制 (可选,非必须)"
|
||||
Executable
+56
@@ -0,0 +1,56 @@
|
||||
msgid "NPS Client"
|
||||
msgstr "NPS 内网穿透客户端"
|
||||
|
||||
msgid "Nps is a fast reverse proxy to help you expose a local server behind a NAT or firewall to the internet."
|
||||
msgstr "NPS 是一种快速反向代理,可帮助您将 NAT 或防火墙后的本地服务器公开到 Internet"
|
||||
|
||||
msgid "IPv4 address or Domain Name"
|
||||
msgstr "服务器域名或 IPv4 地址"
|
||||
|
||||
msgid "vkey"
|
||||
msgstr "唯一验证密钥(vkey)"
|
||||
|
||||
msgid "Enable Compression"
|
||||
msgstr "压缩传输"
|
||||
|
||||
msgid "Enable Encryption"
|
||||
msgstr "加密传输"
|
||||
|
||||
msgid "The contents will be compressed to speed up the traffic forwarding speed, but this will consume some additional cpu resources."
|
||||
msgstr "启用压缩传输内容会加快流量转发速度,但是会额外消耗 CPU 资源"
|
||||
|
||||
msgid "Encrypted the communication between Npc and Nps, will effectively prevent the traffic intercepted."
|
||||
msgstr "启用加密传输客户端与服务端之间的通信内容,会有效防止流量被拦截"
|
||||
|
||||
msgid "Basic Setting"
|
||||
msgstr "基本设置"
|
||||
|
||||
msgid "Protocol Type"
|
||||
msgstr "协议类型"
|
||||
|
||||
msgid "Server Address"
|
||||
msgstr "服务端地址"
|
||||
|
||||
msgid "TCP Protocol"
|
||||
msgstr "TCP"
|
||||
|
||||
msgid "KCP Protocol"
|
||||
msgstr "KCP"
|
||||
|
||||
msgid "Max Connection Limit"
|
||||
msgstr "连接数限制"
|
||||
|
||||
msgid "Maximum number of connections (Not necessary)"
|
||||
msgstr "最大连接数限制 (可选,非必须)"
|
||||
|
||||
msgid "Rate Limit"
|
||||
msgstr "速度限制"
|
||||
|
||||
msgid "Client rate limit (Not necessary)"
|
||||
msgstr "客户端速度限制 (可选,非必须)"
|
||||
|
||||
msgid "Flow Limit"
|
||||
msgstr "流量限制"
|
||||
|
||||
msgid "Client flow limit (Not necessary)"
|
||||
msgstr "客户端流量限制 (可选,非必须)"
|
||||
Executable
+6
@@ -0,0 +1,6 @@
|
||||
|
||||
config npc
|
||||
option enable '0'
|
||||
option server_addr '1.2.3.4'
|
||||
option vkey 'abcdefg'
|
||||
|
||||
Executable
+71
@@ -0,0 +1,71 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=95
|
||||
USE_PROCD=1
|
||||
LOGGER="logger -t [NPC]"
|
||||
|
||||
npc_Path="$(command -v npc)"
|
||||
conf_Path="/tmp/etc/npc.conf"
|
||||
|
||||
start_service() {
|
||||
local basic_list="enable server_addr server_port protocol vkey max_conn rate_limit flow_limit compress crypt"
|
||||
for i in $(echo $basic_list);do
|
||||
local eval $i="$(uci_get_by_type npc 0 $i)"
|
||||
done;unset i
|
||||
|
||||
[ -s "$conf_Path" ] && rm -f $conf_Path
|
||||
echo "[common]" > $conf_Path || {
|
||||
${LOGGER} "Failed to create config,exit ..."
|
||||
exit 1
|
||||
}
|
||||
echo "server_addr=${server_addr}:${server_port}" >> $conf_Path
|
||||
echo "conn_type=${protocol}" >> $conf_Path
|
||||
echo "vkey=${vkey}" >> $conf_Path
|
||||
echo "auto_reconnection=true" >> $conf_Path
|
||||
[ -n "$max_conn" ] && echo "max_conn=${max_conn}" >> $conf_Path
|
||||
[ -n "$rate_limit" ] && echo "rate_limit=${rate_limit}" >> $conf_Path
|
||||
[ -n "$flow_limit" ] && echo "flow_limit=${flow_limit}" >> $conf_Path
|
||||
conf_write_bool compress $compress
|
||||
conf_write_bool crypt $crypt
|
||||
|
||||
if [ "$enable" = 1 ]
|
||||
then
|
||||
${LOGGER} "Starting NPS Client(NPC) ..."
|
||||
procd_open_instance
|
||||
procd_set_param command $npc_Path -config=$conf_Path
|
||||
procd_set_param respawn
|
||||
procd_set_param stdout 1
|
||||
procd_set_param stderr 1
|
||||
procd_close_instance
|
||||
else
|
||||
${LOGGER} "NPS Client(NPC) Service is now disabled ..."
|
||||
fi
|
||||
}
|
||||
|
||||
stop_service() {
|
||||
$LOGGER "Stopping NPS Client(NPC) ..."
|
||||
rm -f $conf_Path
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger "npc"
|
||||
}
|
||||
|
||||
conf_write_bool() {
|
||||
if [ "$2" == 0 ]
|
||||
then
|
||||
echo "$1=false" >> $conf_Path
|
||||
else
|
||||
echo "$1=true" >> $conf_Path
|
||||
fi
|
||||
return
|
||||
}
|
||||
|
||||
uci_get_by_type() {
|
||||
local ret=$(uci get npc.@$1[$2].$3 2>/dev/null)
|
||||
echo ${ret:=$4}
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
restart
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
[ ! -f "/usr/share/ucitrack/luci-app-npc.json" ] && {
|
||||
cat > /usr/share/ucitrack/luci-app-npc.json << EEOF
|
||||
{
|
||||
"config": "npc",
|
||||
"init": "npc"
|
||||
}
|
||||
EEOF
|
||||
}
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete ucitrack.@npc[-1]
|
||||
add ucitrack npc
|
||||
set ucitrack.@npc[-1].init=npc
|
||||
commit ucitrack
|
||||
EOF
|
||||
|
||||
rm -f /tmp/luci-indexcache
|
||||
exit 0
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"luci-app-npc": {
|
||||
"description": "Grant UCI access for luci-app-npc",
|
||||
"read": {
|
||||
"uci": [ "npc" ]
|
||||
},
|
||||
"write": {
|
||||
"uci": [ "npc" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user