mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-04 01:43:56 +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
+15
@@ -0,0 +1,15 @@
|
||||
# Copyright (C) 2020-2024 Hyy2001X <https://github.com/Hyy2001X>
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-natter2
|
||||
PKG_VERSION:=1.0
|
||||
PKG_RELEASE:=1
|
||||
|
||||
LUCI_TITLE:=LuCI Support for Natter v2.2.1
|
||||
LUCI_PKGARCH:=all
|
||||
LUCI_DEPENDS:=+natter2
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
||||
Executable
+3
@@ -0,0 +1,3 @@
|
||||
# luci-app-natter2
|
||||
|
||||
项目地址: https://github.com/MikeWang000000/Natter
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
module("luci.controller.natter2",package.seeall)
|
||||
|
||||
function index()
|
||||
if not nixio.fs.access("/etc/config/natter2")then
|
||||
return
|
||||
end
|
||||
entry({"admin","network","natter2"},alias("admin","network","natter2","base"),_("Natter v2"),99).dependent=true
|
||||
entry({"admin","network","natter2","base"},cbi("natter2/base"),_("Base Settings"),10).leaf=true
|
||||
entry({"admin","network","natter2","instances"},cbi("natter2/instances")).leaf=true
|
||||
entry({"admin","network","natter2","log"},form("natter2/log"),_("Log"),20).leaf=true
|
||||
entry({"admin","network","natter2","print_log"},call("print_log")).leaf=true
|
||||
entry({"admin","network","natter2","del_log"},call("del_log")).leaf=true
|
||||
end
|
||||
|
||||
function print_log()
|
||||
luci.http.write(luci.sys.exec("sh /usr/share/luci-app-natter2/log.sh print"))
|
||||
end
|
||||
|
||||
function del_log()
|
||||
luci.http.write(luci.sys.exec("sh /usr/share/luci-app-natter2/log.sh del"))
|
||||
end
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
m = Map("natter2", translate("Natter v2"),
|
||||
translate("Expose your port behind full-cone NAT to the Internet")
|
||||
.. [[<br /><br /><a href="https://github.com/MikeWang000000/Natter">]]
|
||||
.. translate("Project")
|
||||
.. [[</a>]]
|
||||
)
|
||||
|
||||
s = m:section(TypedSection, "base")
|
||||
s.addremove = false
|
||||
s.anonymous = true
|
||||
|
||||
local function check_file(e)
|
||||
return luci.sys.exec('ls "%s" 2> /dev/null' % e) ~= "" and true or false
|
||||
end
|
||||
|
||||
enable = s:option(Flag, "enable", translate("Enable"))
|
||||
enable.default = 0
|
||||
|
||||
if check_file("/tmp/natter2_nat_type") then
|
||||
natter_nat_type_tcp = luci.sys.exec ("grep TCP /tmp/natter2_nat_type")
|
||||
natter_nat_type_udp = luci.sys.exec ("grep UDP /tmp/natter2_nat_type")
|
||||
nat_check = s:option (Button, "nat_check", translate("Check NAT Status"), translate("") .. "<br><br>" .. natter_nat_type_tcp .. "<br><br>" .. natter_nat_type_udp)
|
||||
else
|
||||
nat_check = s:option (Button, "nat_check", translate("Check NAT Status"), translate("Tips")
|
||||
.. [[<br />]] .. translate("After clicking Exec button, please wait for the luci to refresh"))
|
||||
end
|
||||
|
||||
nat_check.inputtitle = translate("Exec")
|
||||
nat_check.write = function()
|
||||
luci.sys.call ("sh /usr/share/luci-app-natter2/nat-check.sh")
|
||||
luci.http.redirect(luci.dispatcher.build_url("admin", "network", "natter2", "base"))
|
||||
end
|
||||
|
||||
tmp_path = s:option(Value, "tmp_path", translate("Tmp Path"))
|
||||
tmp_path.default = "/tmp/natter2"
|
||||
tmp_path.placeholder = "/tmp/natter2"
|
||||
tmp_path.rmempty = false
|
||||
|
||||
s = m:section(TypedSection, "instances", translate("Instances"), translate("Setting up multiple instances"))
|
||||
s.anonymous = true
|
||||
s.addremove = true
|
||||
s.template = "cbi/tblsection"
|
||||
s.extedit = luci.dispatcher.build_url("admin", "network", "natter2", "instances", "%s")
|
||||
function s.create(...)
|
||||
local e=TypedSection.create(...)
|
||||
if e then
|
||||
luci.http.redirect(s.extedit%e)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
enable_instance = s:option(Flag, "enable_instance", translate("Enable"))
|
||||
enable_instance.default = 1
|
||||
enable_instance.width = "5%"
|
||||
|
||||
remark = s:option(DummyValue,"remark",translate("Remark"))
|
||||
remark.width = "5%"
|
||||
|
||||
protocol = s:option(DummyValue,"protocol",translate("Protocol"))
|
||||
remark.width = "5%"
|
||||
|
||||
tmp_public_port = s:option(DummyValue, "tmp_public_port", translate("Public Port"))
|
||||
remark.width = "5%"
|
||||
|
||||
target_address = s:option(DummyValue, "target_address", translate("Target Address"))
|
||||
remark.width = "5%"
|
||||
|
||||
target_port = s:option(DummyValue, "target_port", translate("Target Port"))
|
||||
remark.width = "5%"
|
||||
|
||||
notify_path = s:option(DummyValue, "notify_path", translate("Notify Script Path"))
|
||||
remark.width = "5%"
|
||||
|
||||
return m
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
m = Map("natter2", translate("Instances Settings"),
|
||||
translate("")
|
||||
.. [[<a href="https://github.com/MikeWang000000/Natter/blob/master/docs/usage.md">]]
|
||||
.. translate("Instructions")
|
||||
.. [[</a>]])
|
||||
m.redirect = luci.dispatcher.build_url("admin", "network", "natter2")
|
||||
|
||||
s = m:section(NamedSection, arg[1], "instances", "")
|
||||
s.addremove = false
|
||||
s.dynamic = false
|
||||
|
||||
local function check_binary(e)
|
||||
return luci.sys.exec('which "%s" 2> /dev/null' % e) ~= "" and true or false
|
||||
end
|
||||
|
||||
enable_instance = s:option(Flag, "enable_instance", translate("Enable"))
|
||||
|
||||
local e = luci.sys.exec("cut -d '-' -f1 /proc/sys/kernel/random/uuid 2> /dev/null")
|
||||
id = s:option(Value, "id", translate("ID"))
|
||||
id.default = e
|
||||
|
||||
remark = s:option(Value, "remark", translate("Remark"))
|
||||
remark.rmempty=false
|
||||
|
||||
protocol = s:option(ListValue, "protocol", translate("Protocol"))
|
||||
protocol:value('tcp', translate("TCP"))
|
||||
protocol:value('udp', translate("UDP"))
|
||||
protocol.default = 'tcp'
|
||||
|
||||
enable_stun_server = s:option(Flag, "enable_stun_server", translate("Enable Stun Server"), translate("Using customized STUN server"))
|
||||
stun_server = s:option(DynamicList, "stun_server", translate("STUN Server"))
|
||||
stun_server.rmempty = true
|
||||
stun_server:depends({enable_stun_server = "1"})
|
||||
|
||||
enable_keepalive_server = s:option(Flag, "enable_keepalive_server", translate("Enable Keepalive Server"), translate("Using customized Keepalive server"))
|
||||
keepalive_server = s:option(Value, "keepalive_server", translate("Keepalive Server"))
|
||||
keepalive_server.rmempty = true
|
||||
keepalive_server:depends({enable_keepalive_server = "1"})
|
||||
|
||||
interval = s:option(Value, "interval", translate("Interval (Seconds)"), translate("The number of seconds between keepalive"))
|
||||
interval.default = 15
|
||||
interval.datatype = "uinteger"
|
||||
enable_upnp_service = s:option(Flag, "enable_upnp_service", translate("Enable UPnP Service"),
|
||||
translate("Using UPnP to map ports on your device"))
|
||||
|
||||
enable_binding = s:option(Flag, "enable_binding", translate("Enable Binding Options"), translate("Usually there is no need to enable binding"))
|
||||
enable_binding.rmempty = true
|
||||
binding_interface = s:option(Value, "binding_interface", translate("Binding Interface"))
|
||||
binding_interface.rmempty = true
|
||||
binding_interface.default = '0.0.0.0'
|
||||
binding_interface:depends({enable_binding = "1"})
|
||||
|
||||
binding_port = s:option(Value, "binding_port", translate("Binding Port"))
|
||||
binding_port.rmempty = true
|
||||
binding_port.default = '0'
|
||||
binding_port:depends({enable_binding = "1"})
|
||||
|
||||
enable_forwarding = s:option(Flag, "enable_forwarding", translate("Enable Forwarding Options"), translate("Forwarding to internal devices"))
|
||||
|
||||
forwarding_method = s:option(ListValue, "forwarding_method", translate("Forwarding Method"),
|
||||
translate("")
|
||||
.. [[<a href="https://github.com/MikeWang000000/Natter/blob/master/docs/forward.md">]]
|
||||
.. translate("Instructions for forwarding method")
|
||||
.. [[</a>]])
|
||||
forwarding_method:value('socket', translate("socket (Not Recommended)"))
|
||||
if check_binary("iptables") then
|
||||
forwarding_method:value('iptables', translate("iptables (Recommended)"))
|
||||
end
|
||||
if check_binary("nft") then
|
||||
forwarding_method:value('nftables', translate("nftables (Recommended)"))
|
||||
end
|
||||
if check_binary("socat") then
|
||||
forwarding_method:value('socat', translate("socat"))
|
||||
end
|
||||
if check_binary("gost") then
|
||||
forwarding_method:value('gost', translate("gost"))
|
||||
end
|
||||
forwarding_method.default = 'socket'
|
||||
forwarding_method:depends({enable_forwarding = "1"})
|
||||
|
||||
target_address = s:option(Value, "target_address", translate("Target Address"))
|
||||
target_address.datatype = "ipmask4"
|
||||
luci.sys.net.ipv4_hints(
|
||||
function(ip, name)
|
||||
target_address:value(ip, "%s (%s)" %{ ip, name })
|
||||
end)
|
||||
target_address:depends({enable_forwarding = "1"})
|
||||
|
||||
target_port = s:option(Value, "target_port", translate("Target Port"))
|
||||
target_port.datatype = "port"
|
||||
target_port:depends({enable_forwarding = "1"})
|
||||
|
||||
enable_forwarding_retry = s:option(Flag, "enable_forwarding_retry", translate("Enable Forwarding Retry"), translate("Retry until the target port is open"))
|
||||
enable_forwarding_retry:depends({enable_forwarding = "1"})
|
||||
enable_forwarding_retry.default = 1
|
||||
enable_forwarding_retry.rmempty = false
|
||||
|
||||
enable_quit = s:option(Flag, "enable_quit", translate("Enable Quit"), translate("Exit immediately when the mapping address changes"))
|
||||
enable_quit.default = "0"
|
||||
|
||||
delay = s:option(Value,"delay", translate("Start delay (Seconds)"), translate("Time to wait before starting this instance"))
|
||||
delay.default = 0
|
||||
delay.datatype = "uinteger"
|
||||
delay.rmempty = false
|
||||
|
||||
log_level = s:option(ListValue, "log_level", translate("Log Level"))
|
||||
log_level:value('normal', translate("Normal"))
|
||||
log_level:value('verbose', translate("Verbose"))
|
||||
|
||||
enable_notify = s:option(Flag,"enable_notify", translate("Enable Notify Script"))
|
||||
enable_notify.rmempty = false
|
||||
notify_path = s:option(Value, "notify_path", translate("Notify Script Path"),
|
||||
translate("")
|
||||
.. [[<a href="https://github.com/MikeWang000000/Natter/blob/master/docs/script.md">]]
|
||||
.. translate("Instructions for using the notification script")
|
||||
.. [[</a>]])
|
||||
notify_path.rmempty = true
|
||||
notify_path.default = "/usr/share/luci-app-natter2/notify-example.sh"
|
||||
notify_path:depends({enable_notify = "1"})
|
||||
|
||||
return m
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
log = SimpleForm("natter2")
|
||||
log.reset = false
|
||||
log.submit = false
|
||||
log:append(Template("natter2/natter_log"))
|
||||
|
||||
return log
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
function del_log(btn) {
|
||||
XHR.get('<%=luci.dispatcher.build_url("admin/network/natter2/del_log")%>', null,
|
||||
function(x, data) {
|
||||
if(x && x.status == 200) {
|
||||
var log_textarea = document.getElementById('log_textarea');
|
||||
log_textarea.innerHTML = "";
|
||||
log_textarea.scrollTop = log_textarea.scrollHeight;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
XHR.poll(5, '<%=luci.dispatcher.build_url("admin/network/natter2/print_log")%>', null,
|
||||
function(x, data) {
|
||||
if(x && x.status == 200) {
|
||||
var log_textarea = document.getElementById('log_textarea');
|
||||
log_textarea.innerHTML = x.responseText;
|
||||
log_textarea.scrollTop = log_textarea.scrollHeight;
|
||||
}
|
||||
}
|
||||
);
|
||||
//]]>
|
||||
</script>
|
||||
|
||||
<fieldset class="cbi-section" id="_log_fieldset" >
|
||||
<input class="cbi-button cbi-input-remove" type="button" onclick="del_log()" value="<%:Delete Logs%>" />
|
||||
<textarea id="log_textarea" class="cbi-input-textarea" style="width: 100%;margin-top: 10px;" data-update="change" rows="30" wrap="off" readonly="readonly"></textarea>
|
||||
</fieldset>
|
||||
Executable
+155
@@ -0,0 +1,155 @@
|
||||
msgid "Natter v2"
|
||||
msgstr "Natter v2 测试版"
|
||||
|
||||
msgid "Base Settings"
|
||||
msgstr "基础设置"
|
||||
|
||||
msgid "Log"
|
||||
msgstr "日志"
|
||||
|
||||
msgid "Expose your port behind full-cone NAT to the Internet"
|
||||
msgstr "将 FullCone NAT (NAT 1) 后的端口,打洞暴露至互联网"
|
||||
|
||||
msgid "Project"
|
||||
msgstr "项目地址"
|
||||
|
||||
msgid "Enable"
|
||||
msgstr "启用"
|
||||
|
||||
msgid "Check NAT Status"
|
||||
msgstr "NAT 类型检测"
|
||||
|
||||
msgid "Proxy programs may affect NAT types"
|
||||
msgstr "代理程序可能会影响 NAT 类型"
|
||||
|
||||
msgid "Tmp Path"
|
||||
msgstr "临时路径"
|
||||
|
||||
msgid "Instances"
|
||||
msgstr "实例"
|
||||
|
||||
msgid "Setting up multiple instances"
|
||||
msgstr "设置多个实例"
|
||||
|
||||
msgid "Remark"
|
||||
msgstr "备注"
|
||||
|
||||
msgid "Public Port"
|
||||
msgstr "公开端口"
|
||||
|
||||
msgid "Target Address"
|
||||
msgstr "目标地址"
|
||||
|
||||
msgid "Target Port"
|
||||
msgstr "目标端口"
|
||||
|
||||
msgid "Notify Script Path"
|
||||
msgstr "通知脚本路径"
|
||||
|
||||
msgid "Enable Stun Server"
|
||||
msgstr "自定义 STUN 服务器"
|
||||
|
||||
msgid "STUN Server"
|
||||
msgstr "STUN 服务器"
|
||||
|
||||
msgid "Enable Keepalive Server"
|
||||
msgstr "自定义保活服务器"
|
||||
|
||||
msgid "Keepalive Server"
|
||||
msgstr "保活服务器"
|
||||
|
||||
msgid "Interval (Seconds)"
|
||||
msgstr "保活间隔(秒)"
|
||||
|
||||
msgid "The number of seconds between keepalive"
|
||||
msgstr "每次保活的间隔秒数"
|
||||
|
||||
msgid "Enable Binding Options"
|
||||
msgstr "启用绑定"
|
||||
|
||||
msgid "Binding Interface"
|
||||
msgstr "绑定接口"
|
||||
|
||||
msgid "Binding Port"
|
||||
msgstr "绑定端口"
|
||||
|
||||
msgid "Enable Forwarding Options"
|
||||
msgstr "启用转发"
|
||||
|
||||
msgid "Forwarding to internal devices"
|
||||
msgstr "转发至内部设备"
|
||||
|
||||
msgid "Forwarding Method"
|
||||
msgstr "转发方式"
|
||||
|
||||
msgid "Instructions for forwarding method"
|
||||
msgstr "转发方式说明"
|
||||
|
||||
msgid "socket (Not Recommended)"
|
||||
msgstr "Socket(内置, 不推荐)"
|
||||
|
||||
msgid "iptables (Recommended)"
|
||||
msgstr "iptables(防火墙, 推荐)"
|
||||
|
||||
msgid "nftables (Recommended)"
|
||||
msgstr "nftables(防火墙, 推荐)"
|
||||
|
||||
msgid "Target Address"
|
||||
msgstr "目标地址"
|
||||
|
||||
msgid "Target Port"
|
||||
msgstr "目标端口"
|
||||
|
||||
msgid "Enable Forwarding Retry"
|
||||
msgstr "自动重试"
|
||||
|
||||
msgid "Retry until the target port is open"
|
||||
msgstr "重试直至目标端口开放"
|
||||
|
||||
msgid "Enable Quit"
|
||||
msgstr "自动退出"
|
||||
|
||||
msgid "Exit immediately when the mapping address changes"
|
||||
msgstr "映射地址改变时立即退出"
|
||||
|
||||
msgid "Time to wait before starting this instance"
|
||||
msgstr "启动该实例前等待的时间"
|
||||
|
||||
msgid "Enable Notify Script"
|
||||
msgstr "启用通知脚本"
|
||||
|
||||
msgid "Instructions for using the notification script"
|
||||
msgstr "通知脚本说明"
|
||||
|
||||
msgid "Start delay (Seconds)"
|
||||
msgstr "启动延时(秒)"
|
||||
|
||||
msgid "Log Level"
|
||||
msgstr "日志级别"
|
||||
|
||||
msgid "Normal"
|
||||
msgstr "正常"
|
||||
|
||||
msgid "Verbose"
|
||||
msgstr "详细"
|
||||
|
||||
msgid "Instructions"
|
||||
msgstr "使用说明"
|
||||
|
||||
msgid "Using customized STUN server"
|
||||
msgstr "使用自定义的 STUN 服务器"
|
||||
|
||||
msgid "Using customized Keepalive server"
|
||||
msgstr "使用自定义的保活服务器"
|
||||
|
||||
msgid "Tips"
|
||||
msgstr "提示"
|
||||
|
||||
msgid "After clicking Exec button, please wait for the luci to refresh"
|
||||
msgstr "点击执行后,请耐心等待页面自动刷新"
|
||||
|
||||
msgid "Enable UPnP Service"
|
||||
msgstr "启用 UPnP 服务"
|
||||
|
||||
msgid "Enable UPnP Service"
|
||||
msgstr "使用 UPnP 映射设备上的端口"
|
||||
Executable
+155
@@ -0,0 +1,155 @@
|
||||
msgid "Natter v2"
|
||||
msgstr "Natter v2 测试版"
|
||||
|
||||
msgid "Base Settings"
|
||||
msgstr "基础设置"
|
||||
|
||||
msgid "Log"
|
||||
msgstr "日志"
|
||||
|
||||
msgid "Expose your port behind full-cone NAT to the Internet"
|
||||
msgstr "将 FullCone NAT (NAT 1) 后的端口,打洞暴露至互联网"
|
||||
|
||||
msgid "Project"
|
||||
msgstr "项目地址"
|
||||
|
||||
msgid "Enable"
|
||||
msgstr "启用"
|
||||
|
||||
msgid "Check NAT Status"
|
||||
msgstr "NAT 类型检测"
|
||||
|
||||
msgid "Proxy programs may affect NAT types"
|
||||
msgstr "代理程序可能会影响 NAT 类型"
|
||||
|
||||
msgid "Tmp Path"
|
||||
msgstr "临时路径"
|
||||
|
||||
msgid "Instances"
|
||||
msgstr "实例"
|
||||
|
||||
msgid "Setting up multiple instances"
|
||||
msgstr "设置多个实例"
|
||||
|
||||
msgid "Remark"
|
||||
msgstr "备注"
|
||||
|
||||
msgid "Public Port"
|
||||
msgstr "公开端口"
|
||||
|
||||
msgid "Target Address"
|
||||
msgstr "目标地址"
|
||||
|
||||
msgid "Target Port"
|
||||
msgstr "目标端口"
|
||||
|
||||
msgid "Notify Script Path"
|
||||
msgstr "通知脚本路径"
|
||||
|
||||
msgid "Enable Stun Server"
|
||||
msgstr "自定义 STUN 服务器"
|
||||
|
||||
msgid "STUN Server"
|
||||
msgstr "STUN 服务器"
|
||||
|
||||
msgid "Enable Keepalive Server"
|
||||
msgstr "自定义保活服务器"
|
||||
|
||||
msgid "Keepalive Server"
|
||||
msgstr "保活服务器"
|
||||
|
||||
msgid "Interval (Seconds)"
|
||||
msgstr "保活间隔(秒)"
|
||||
|
||||
msgid "The number of seconds between keepalive"
|
||||
msgstr "每次保活的间隔秒数"
|
||||
|
||||
msgid "Enable Binding Options"
|
||||
msgstr "启用绑定"
|
||||
|
||||
msgid "Binding Interface"
|
||||
msgstr "绑定接口"
|
||||
|
||||
msgid "Binding Port"
|
||||
msgstr "绑定端口"
|
||||
|
||||
msgid "Enable Forwarding Options"
|
||||
msgstr "启用转发"
|
||||
|
||||
msgid "Forwarding to internal devices"
|
||||
msgstr "转发至内部设备"
|
||||
|
||||
msgid "Forwarding Method"
|
||||
msgstr "转发方式"
|
||||
|
||||
msgid "Instructions for forwarding method"
|
||||
msgstr "转发方式说明"
|
||||
|
||||
msgid "socket (Not Recommended)"
|
||||
msgstr "Socket(内置, 不推荐)"
|
||||
|
||||
msgid "iptables (Recommended)"
|
||||
msgstr "iptables(防火墙, 推荐)"
|
||||
|
||||
msgid "nftables (Recommended)"
|
||||
msgstr "nftables(防火墙, 推荐)"
|
||||
|
||||
msgid "Target Address"
|
||||
msgstr "目标地址"
|
||||
|
||||
msgid "Target Port"
|
||||
msgstr "目标端口"
|
||||
|
||||
msgid "Enable Forwarding Retry"
|
||||
msgstr "自动重试"
|
||||
|
||||
msgid "Retry until the target port is open"
|
||||
msgstr "重试直至目标端口开放"
|
||||
|
||||
msgid "Enable Quit"
|
||||
msgstr "自动退出"
|
||||
|
||||
msgid "Exit immediately when the mapping address changes"
|
||||
msgstr "映射地址改变时立即退出"
|
||||
|
||||
msgid "Time to wait before starting this instance"
|
||||
msgstr "启动该实例前等待的时间"
|
||||
|
||||
msgid "Enable Notify Script"
|
||||
msgstr "启用通知脚本"
|
||||
|
||||
msgid "Instructions for using the notification script"
|
||||
msgstr "通知脚本说明"
|
||||
|
||||
msgid "Start delay (Seconds)"
|
||||
msgstr "启动延时(秒)"
|
||||
|
||||
msgid "Log Level"
|
||||
msgstr "日志级别"
|
||||
|
||||
msgid "Normal"
|
||||
msgstr "正常"
|
||||
|
||||
msgid "Verbose"
|
||||
msgstr "详细"
|
||||
|
||||
msgid "Instructions"
|
||||
msgstr "使用说明"
|
||||
|
||||
msgid "Using customized STUN server"
|
||||
msgstr "使用自定义的 STUN 服务器"
|
||||
|
||||
msgid "Using customized Keepalive server"
|
||||
msgstr "使用自定义的保活服务器"
|
||||
|
||||
msgid "Tips"
|
||||
msgstr "提示"
|
||||
|
||||
msgid "After clicking Exec button, please wait for the luci to refresh"
|
||||
msgstr "点击执行后,请耐心等待页面自动刷新"
|
||||
|
||||
msgid "Enable UPnP Service"
|
||||
msgstr "启用 UPnP 服务"
|
||||
|
||||
msgid "Enable UPnP Service"
|
||||
msgstr "使用 UPnP 映射设备上的端口"
|
||||
Executable
+4
@@ -0,0 +1,4 @@
|
||||
|
||||
config base
|
||||
option tmp_path '/tmp/natter2'
|
||||
option enable '0'
|
||||
Executable
+111
@@ -0,0 +1,111 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
USE_PROCD=1
|
||||
START=98
|
||||
script_path="/usr/share/natter2/natter.py"
|
||||
|
||||
start_service() {
|
||||
local basic_list="enable tmp_path"
|
||||
local instance_list="enable_instance id remark protocol enable_stun_server \
|
||||
stun_server enable_keepalive_server keepalive_server \
|
||||
interval enable_bonding bonding_interface bonding_port \
|
||||
enable_forwarding forwarding_method target_address target_port \
|
||||
enable_forwarding_retry enable_quit delay log_level enable_notify \
|
||||
notify_path enable_upnp_service"
|
||||
|
||||
for i in $basic_list; do
|
||||
local eval $i="$(uci_get_by_type base 0 $i)"
|
||||
done ; unset i
|
||||
|
||||
if [ "$enable" == 1 ]; then
|
||||
mkdir -p ${tmp_path}
|
||||
mkdir -p /var/etc/natter2
|
||||
|
||||
for u in $(seq 0 $(($(uci show natter2 2> /dev/null | grep -E '@instances\[[0-9]\]+=instances' | wc -l) - 1)))
|
||||
do
|
||||
for i in $instance_list; do
|
||||
local eval $i="$(uci_get_by_type instances $u $i)"
|
||||
done ; unset i
|
||||
|
||||
[ "$enable_instance" != 1 ] && continue
|
||||
script_command=""
|
||||
|
||||
[ "$protocol" == udp ] && script_command="$script_command -u"
|
||||
|
||||
if [ "$enable_stun_server" == 1 ]; then
|
||||
for i in $stun_server; do
|
||||
script_command="$script_command -s $i"
|
||||
done ; unset i
|
||||
fi
|
||||
|
||||
[ "$enable_keepalive_server" == 1 ] && script_command="$script_command -h $keepalive_server"
|
||||
[ "$interval" ] && script_command="$script_command -k $interval"
|
||||
[ "$enable_upnp_service" == 1 ] && script_command="$script_command -U"
|
||||
|
||||
if [ "$enable_bonding" == 1 ]; then
|
||||
[ "$bonding_interface" ] && script_command="$script_command -i $bonding_interface"
|
||||
[ "$bonding_port" ] && script_command="$script_command -b $bonding_port"
|
||||
fi
|
||||
|
||||
if [ "$enable_forwarding" == 1 ]; then
|
||||
[ "$forwarding_method" ] && script_command="$script_command -m $forwarding_method"
|
||||
[ "$target_address" ] && script_command="$script_command -t $target_address"
|
||||
[ "$target_port" ] && script_command="$script_command -p $target_port"
|
||||
[ "$enable_forwarding_retry" == 1 ] && script_command="$script_command -r"
|
||||
fi
|
||||
|
||||
[ "$enable_quit" == 1 ] && script_command="$script_command -q"
|
||||
[ "$log_level" == "verbose" ] && script_command="$script_command -v"
|
||||
|
||||
if [ "$enable_notify" == 1 ]; then
|
||||
echo "$notify_path" > /var/etc/natter2/${id}-notify
|
||||
var_file=/var/etc/natter2/${id}-${u}-1
|
||||
else
|
||||
var_file=/var/etc/natter2/${id}-${u}-0
|
||||
fi
|
||||
|
||||
cp -a /usr/share/luci-app-natter2/notify-base.sh $var_file
|
||||
chmod +x $var_file
|
||||
|
||||
procd_open_instance "natter2_${id}"
|
||||
procd_set_param command $(command -v python) "$script_path" $script_command -e $var_file
|
||||
|
||||
procd_set_param stdout 1
|
||||
procd_set_param stderr 1
|
||||
|
||||
[ -n "$delay" ] && procd_set_param delay "$delay"
|
||||
procd_set_param respawn
|
||||
|
||||
procd_close_instance
|
||||
|
||||
for i in $instance_list; do
|
||||
unset $(echo $i)
|
||||
done ; unset i
|
||||
unset script_command
|
||||
done ; unset u
|
||||
else
|
||||
stop_service
|
||||
fi
|
||||
}
|
||||
|
||||
stop_service() {
|
||||
rm -rf "/var/etc/natter2" 2> /dev/null
|
||||
for u in $(seq 0 $(($(uci show natter2 2> /dev/null | grep -E '@instances\[[0-9]\]+=instances' | wc -l) - 1)))
|
||||
do
|
||||
uci set natter2.@instances[$u].tmp_public_port=""
|
||||
uci commit natter2
|
||||
done
|
||||
rm -f /tmp/natter2_nat_type
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger "natter2"
|
||||
}
|
||||
|
||||
uci_get_by_type() {
|
||||
local ret=$(uci get natter2.@$1[$2].$3 2>/dev/null)
|
||||
echo ${ret:=$4}
|
||||
}
|
||||
reload_service() {
|
||||
restart
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
[ ! -f "/usr/share/ucitrack/luci-app-natter2.json" ] && {
|
||||
cat > /usr/share/ucitrack/luci-app-natter2.json << EEOF
|
||||
{
|
||||
"config": "natter2",
|
||||
"init": "natter2"
|
||||
}
|
||||
EEOF
|
||||
}
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete ucitrack.@natter2[-1]
|
||||
add ucitrack natter2
|
||||
set ucitrack.@natter2[-1].init=natter2
|
||||
commit ucitrack
|
||||
EOF
|
||||
|
||||
exit 0
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
|
||||
log_path=$(uci get natter2.@base[0].tmp_path 2> /dev/null)
|
||||
|
||||
for i in $(ls -1 ${log_path} | grep natter2 | grep .log)
|
||||
do
|
||||
case $1 in
|
||||
print)
|
||||
echo -e "\n======> $i <======"
|
||||
tail -n 30 ${log_path}/$i 2> /dev/null
|
||||
echo -e "======> END of $i <======"
|
||||
;;
|
||||
del)
|
||||
echo > ${log_path}/$i
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
exit 0
|
||||
@@ -0,0 +1,39 @@
|
||||
#!/bin/sh
|
||||
|
||||
script_file='/usr/share/natter2/natter-check/natter-check.py'
|
||||
natter2_nat_type_file="/tmp/natter2_nat_type"
|
||||
tmp_natter2_nat_type_file="/tmp/tmp_natter2_nat_type"
|
||||
|
||||
rm -f $natter2_nat_type_file
|
||||
rm -f $tmp_natter2_nat_type_file
|
||||
|
||||
$(which python) $script_file | egrep 'Checking TCP|Checking UDP' > $tmp_natter2_nat_type_file
|
||||
TCP=$(awk -F '[:]+' '/TCP/{print $2}' $tmp_natter2_nat_type_file | sed 's/\[//g;s/\]//g')
|
||||
UDP=$(awk -F '[:]+' '/UDP/{print $2}' $tmp_natter2_nat_type_file | sed 's/\[//g;s/\]//g')
|
||||
|
||||
[ ! "$TCP" ] && TCP="未知"
|
||||
[ ! "$UDP" ] && UDP="未知"
|
||||
|
||||
function NAT_Type() {
|
||||
case $1 in
|
||||
0)
|
||||
echo "Public Network"
|
||||
;;
|
||||
1)
|
||||
echo "Full Cone"
|
||||
;;
|
||||
2)
|
||||
echo "Restricted Cone"
|
||||
;;
|
||||
3)
|
||||
echo "Port Restricted Cone"
|
||||
;;
|
||||
4)
|
||||
echo "Symmetric"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
echo "TCP: NAT $TCP | $(NAT_Type $TCP)" > $natter2_nat_type_file
|
||||
echo "UDP: NAT $UDP | $(NAT_Type $UDP)" >> $natter2_nat_type_file
|
||||
|
||||
rm -f $tmp_natter2_nat_type_file
|
||||
@@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
|
||||
protocol="$1"; private_ip="$2"; private_port="$3"; public_ip="$4"; public_port="$5"
|
||||
|
||||
script_name=$(basename $0)
|
||||
script_path=$(dirname $0)
|
||||
instance_id=$(echo $script_name | cut -d '-' -f1)
|
||||
instance_num=$(echo $script_name | cut -d '-' -f2)
|
||||
instance_isnotify=$(echo $script_name | cut -d '-' -f3)
|
||||
|
||||
# echo script_path:$script_path
|
||||
# echo script_name:$script_name
|
||||
# echo instance_id:$instance_id
|
||||
# echo instance_num:$instance_num
|
||||
# echo instance_isnotify:$instance_isnotify
|
||||
|
||||
uci set natter2.@instances[$instance_num].tmp_public_port="$public_port"
|
||||
uci commit natter2
|
||||
|
||||
if [ "$instance_isnotify" == 1 ]
|
||||
then
|
||||
notify_path=$(cat $script_path/${instance_id}-notify)
|
||||
if [ -f "${notify_path}" ]
|
||||
then
|
||||
chmod +x ${notify_path}
|
||||
${notify_path} $1 $2 $3 $4 $5
|
||||
fi
|
||||
fi
|
||||
@@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
# 参数序号 参数说明 参数格式
|
||||
# 1 传输层协议 tcp, udp 二者之一
|
||||
# 2 内部 IP 点分十进制 IPv4 地址
|
||||
# 3 内部端口 1 - 65535 的整数
|
||||
# 4 外部 IP 点分十进制 IPv4 地址
|
||||
# 5 外部端口 1 - 65535 的整数
|
||||
|
||||
protocol="$1"; private_ip="$2"; private_port="$3"; public_ip="$4"; public_port="$5"
|
||||
|
||||
echo $1 $2 $3 $4 $5
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"luci-app-natter2": {
|
||||
"description": "Grant UCI access for luci-app-natter2",
|
||||
"read": {
|
||||
"uci": [ "natter2" ]
|
||||
},
|
||||
"write": {
|
||||
"uci": [ "natter2" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user