mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-06 20:14:10 +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
@@ -0,0 +1,19 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
# Copyright (C) 2025 ImmortalWrt.org
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
LUCI_TITLE:=LuCI support for simple port forwarding via 3proxy
|
||||
LUCI_DEPENDS:=+3proxy-mod-tcppm +3proxy-mod-udppm
|
||||
|
||||
PKG_MAINTAINER:=Tianling Shen <cnsztl@immortalwrt.org>
|
||||
PKG_PROVIDES:=luci-app-socat
|
||||
|
||||
define Package/luci-app-3cat/conffiles
|
||||
/etc/config/3cat
|
||||
endef
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
||||
@@ -0,0 +1,82 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
/*
|
||||
* Copyright (C) 2025 ImmortalWrt.org
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
'require form';
|
||||
'require network';
|
||||
'require view';
|
||||
'require tools.firewall as fwtool';
|
||||
|
||||
return view.extend({
|
||||
load() {
|
||||
return Promise.all([
|
||||
network.getHostHints()
|
||||
]);
|
||||
},
|
||||
|
||||
render(data) {
|
||||
let m, s, o;
|
||||
let hosts = fwtool.transformHostHints(null, data[0]?.hosts);
|
||||
|
||||
m = new form.Map('3cat', _('3cat'),
|
||||
_('A simple TCP/UDP port forwarder via 3proxy.'));
|
||||
|
||||
s = m.section(form.GridSection, 'instance');
|
||||
s.addremove = true;
|
||||
s.sortable = true;
|
||||
s.rowcolors = true;
|
||||
s.nodescriptions = true;
|
||||
s.addbtntitle = _('Add instance');
|
||||
|
||||
o = s.option(form.Flag, 'enabled', _('Enable'));
|
||||
o.default = o.enabled;
|
||||
o.editable = true;
|
||||
o.rmempty = false;
|
||||
|
||||
o = s.option(form.Value, 'listen_addr', _('Listen address'));
|
||||
o.value('::');
|
||||
o.value('0.0.0.0');
|
||||
o.datatype = 'ipaddr';
|
||||
o.rmempty = false;
|
||||
|
||||
o = s.option(form.Value, 'listen_port', _('Listen port'));
|
||||
o.datatype = 'port';
|
||||
o.rmempty = false;
|
||||
|
||||
o = s.option(form.Value, 'dest_addr', _('Destination address'));
|
||||
if (hosts && hosts.length > 0)
|
||||
for (let i = 0; i < hosts[0].length; i++)
|
||||
o.value(hosts[0][i], hosts[1][hosts[0][i]]);
|
||||
o.datatype = 'or(hostname, ipaddr)';
|
||||
o.rmempty = false;
|
||||
|
||||
o = s.option(form.Value, 'dest_port', _('Destination port'));
|
||||
o.datatype = 'port';
|
||||
o.rmempty = false;
|
||||
|
||||
o = s.option(form.ListValue, 'protocol', _('Protocol'));
|
||||
o.value('tcp', _('TCP'));
|
||||
o.value('udp', _('UDP'));
|
||||
o.rmempty = false;
|
||||
|
||||
o = s.option(form.ListValue, 'ip_prefer', _('IP version'),
|
||||
_('If the destination address is a hostname, this option controls which IP version to use.'));
|
||||
o.value('', _('Default'));
|
||||
o.value('46', _('Prefer IPv4'));
|
||||
o.value('64', _('Prefer IPv6'));
|
||||
o.value('4', _('IPv4 only'));
|
||||
o.value('6', _('IPv6 only'));
|
||||
|
||||
o = s.option(form.Flag, 'logging', _('Logging'),
|
||||
_('Log this instance to the system log.'));
|
||||
o.editable = true;
|
||||
|
||||
o = s.option(form.Flag, 'firewall', _('Firewall'),
|
||||
_('Allow access from the Internet.'));
|
||||
o.editable = true;
|
||||
|
||||
return m.render();
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,97 @@
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=UTF-8"
|
||||
|
||||
#: applications/luci-app-3cat/htdocs/luci-static/resources/view/3cat.js:23
|
||||
#: applications/luci-app-3cat/root/usr/share/luci/menu.d/luci-app-3cat.json:3
|
||||
msgid "3cat"
|
||||
msgstr ""
|
||||
|
||||
#: applications/luci-app-3cat/htdocs/luci-static/resources/view/3cat.js:24
|
||||
msgid "A simple TCP/UDP port forwarder via 3proxy."
|
||||
msgstr ""
|
||||
|
||||
#: applications/luci-app-3cat/htdocs/luci-static/resources/view/3cat.js:31
|
||||
msgid "Add instance"
|
||||
msgstr ""
|
||||
|
||||
#: applications/luci-app-3cat/htdocs/luci-static/resources/view/3cat.js:75
|
||||
msgid "Allow access from the Internet."
|
||||
msgstr ""
|
||||
|
||||
#: applications/luci-app-3cat/htdocs/luci-static/resources/view/3cat.js:64
|
||||
msgid "Default"
|
||||
msgstr ""
|
||||
|
||||
#: applications/luci-app-3cat/htdocs/luci-static/resources/view/3cat.js:46
|
||||
msgid "Destination address"
|
||||
msgstr ""
|
||||
|
||||
#: applications/luci-app-3cat/htdocs/luci-static/resources/view/3cat.js:53
|
||||
msgid "Destination port"
|
||||
msgstr ""
|
||||
|
||||
#: applications/luci-app-3cat/htdocs/luci-static/resources/view/3cat.js:33
|
||||
msgid "Enable"
|
||||
msgstr ""
|
||||
|
||||
#: applications/luci-app-3cat/htdocs/luci-static/resources/view/3cat.js:74
|
||||
msgid "Firewall"
|
||||
msgstr ""
|
||||
|
||||
#: applications/luci-app-3cat/root/usr/share/rpcd/acl.d/luci-app-3cat.json:3
|
||||
msgid "Grant UCI access for luci-app-3cat"
|
||||
msgstr ""
|
||||
|
||||
#: applications/luci-app-3cat/htdocs/luci-static/resources/view/3cat.js:62
|
||||
msgid "IP version"
|
||||
msgstr ""
|
||||
|
||||
#: applications/luci-app-3cat/htdocs/luci-static/resources/view/3cat.js:67
|
||||
msgid "IPv4 only"
|
||||
msgstr ""
|
||||
|
||||
#: applications/luci-app-3cat/htdocs/luci-static/resources/view/3cat.js:68
|
||||
msgid "IPv6 only"
|
||||
msgstr ""
|
||||
|
||||
#: applications/luci-app-3cat/htdocs/luci-static/resources/view/3cat.js:63
|
||||
msgid ""
|
||||
"If the destination address is a hostname, this option controls which IP "
|
||||
"version to use."
|
||||
msgstr ""
|
||||
|
||||
#: applications/luci-app-3cat/htdocs/luci-static/resources/view/3cat.js:36
|
||||
msgid "Listen address"
|
||||
msgstr ""
|
||||
|
||||
#: applications/luci-app-3cat/htdocs/luci-static/resources/view/3cat.js:42
|
||||
msgid "Listen port"
|
||||
msgstr ""
|
||||
|
||||
#: applications/luci-app-3cat/htdocs/luci-static/resources/view/3cat.js:71
|
||||
msgid "Log this instance to the system log."
|
||||
msgstr ""
|
||||
|
||||
#: applications/luci-app-3cat/htdocs/luci-static/resources/view/3cat.js:70
|
||||
msgid "Logging"
|
||||
msgstr ""
|
||||
|
||||
#: applications/luci-app-3cat/htdocs/luci-static/resources/view/3cat.js:65
|
||||
msgid "Prefer IPv4"
|
||||
msgstr ""
|
||||
|
||||
#: applications/luci-app-3cat/htdocs/luci-static/resources/view/3cat.js:66
|
||||
msgid "Prefer IPv6"
|
||||
msgstr ""
|
||||
|
||||
#: applications/luci-app-3cat/htdocs/luci-static/resources/view/3cat.js:57
|
||||
msgid "Protocol"
|
||||
msgstr ""
|
||||
|
||||
#: applications/luci-app-3cat/htdocs/luci-static/resources/view/3cat.js:58
|
||||
msgid "TCP"
|
||||
msgstr ""
|
||||
|
||||
#: applications/luci-app-3cat/htdocs/luci-static/resources/view/3cat.js:59
|
||||
msgid "UDP"
|
||||
msgstr ""
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
zh_Hans
|
||||
@@ -0,0 +1,104 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Last-Translator: Automatically generated\n"
|
||||
"Language-Team: none\n"
|
||||
"Language: zh-Hans\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#: applications/luci-app-3cat/htdocs/luci-static/resources/view/3cat.js:23
|
||||
#: applications/luci-app-3cat/root/usr/share/luci/menu.d/luci-app-3cat.json:3
|
||||
msgid "3cat"
|
||||
msgstr "3cat"
|
||||
|
||||
#: applications/luci-app-3cat/htdocs/luci-static/resources/view/3cat.js:24
|
||||
msgid "A simple TCP/UDP port forwarder via 3proxy."
|
||||
msgstr "一个基于 3proxy 的简单 TCP/UDP 端口转发器。"
|
||||
|
||||
#: applications/luci-app-3cat/htdocs/luci-static/resources/view/3cat.js:31
|
||||
msgid "Add instance"
|
||||
msgstr "添加实例"
|
||||
|
||||
#: applications/luci-app-3cat/htdocs/luci-static/resources/view/3cat.js:75
|
||||
msgid "Allow access from the Internet."
|
||||
msgstr "允许来自互联网的访问。"
|
||||
|
||||
#: applications/luci-app-3cat/htdocs/luci-static/resources/view/3cat.js:64
|
||||
msgid "Default"
|
||||
msgstr "默认"
|
||||
|
||||
#: applications/luci-app-3cat/htdocs/luci-static/resources/view/3cat.js:46
|
||||
msgid "Destination address"
|
||||
msgstr "目标地址"
|
||||
|
||||
#: applications/luci-app-3cat/htdocs/luci-static/resources/view/3cat.js:53
|
||||
msgid "Destination port"
|
||||
msgstr "目标端口"
|
||||
|
||||
#: applications/luci-app-3cat/htdocs/luci-static/resources/view/3cat.js:33
|
||||
msgid "Enable"
|
||||
msgstr "启用"
|
||||
|
||||
#: applications/luci-app-3cat/htdocs/luci-static/resources/view/3cat.js:74
|
||||
msgid "Firewall"
|
||||
msgstr "防火墙"
|
||||
|
||||
#: applications/luci-app-3cat/root/usr/share/rpcd/acl.d/luci-app-3cat.json:3
|
||||
msgid "Grant UCI access for luci-app-3cat"
|
||||
msgstr "授予 luci-app-3cat 访问 UCI 配置的权限。"
|
||||
|
||||
#: applications/luci-app-3cat/htdocs/luci-static/resources/view/3cat.js:62
|
||||
msgid "IP version"
|
||||
msgstr "IP 版本"
|
||||
|
||||
#: applications/luci-app-3cat/htdocs/luci-static/resources/view/3cat.js:67
|
||||
msgid "IPv4 only"
|
||||
msgstr "仅 IPv4"
|
||||
|
||||
#: applications/luci-app-3cat/htdocs/luci-static/resources/view/3cat.js:68
|
||||
msgid "IPv6 only"
|
||||
msgstr "仅 IPv6"
|
||||
|
||||
#: applications/luci-app-3cat/htdocs/luci-static/resources/view/3cat.js:63
|
||||
msgid ""
|
||||
"If the destination address is a hostname, this option controls which IP "
|
||||
"version to use."
|
||||
msgstr "如果目标地址是主机名,此选项控制使用哪个 IP 版本。"
|
||||
|
||||
#: applications/luci-app-3cat/htdocs/luci-static/resources/view/3cat.js:36
|
||||
msgid "Listen address"
|
||||
msgstr "监听地址"
|
||||
|
||||
#: applications/luci-app-3cat/htdocs/luci-static/resources/view/3cat.js:42
|
||||
msgid "Listen port"
|
||||
msgstr "监听端口"
|
||||
|
||||
#: applications/luci-app-3cat/htdocs/luci-static/resources/view/3cat.js:71
|
||||
msgid "Log this instance to the system log."
|
||||
msgstr "将此实例记录到系统日志。"
|
||||
|
||||
#: applications/luci-app-3cat/htdocs/luci-static/resources/view/3cat.js:70
|
||||
msgid "Logging"
|
||||
msgstr "记录日志"
|
||||
|
||||
#: applications/luci-app-3cat/htdocs/luci-static/resources/view/3cat.js:65
|
||||
msgid "Prefer IPv4"
|
||||
msgstr "优先 IPv4"
|
||||
|
||||
#: applications/luci-app-3cat/htdocs/luci-static/resources/view/3cat.js:66
|
||||
msgid "Prefer IPv6"
|
||||
msgstr "优先 IPv6"
|
||||
|
||||
#: applications/luci-app-3cat/htdocs/luci-static/resources/view/3cat.js:57
|
||||
msgid "Protocol"
|
||||
msgstr "协议"
|
||||
|
||||
#: applications/luci-app-3cat/htdocs/luci-static/resources/view/3cat.js:58
|
||||
msgid "TCP"
|
||||
msgstr "TCP"
|
||||
|
||||
#: applications/luci-app-3cat/htdocs/luci-static/resources/view/3cat.js:59
|
||||
msgid "UDP"
|
||||
msgstr "UDP"
|
||||
@@ -0,0 +1,12 @@
|
||||
|
||||
config instance 'example'
|
||||
option enabled '0'
|
||||
option listen_addr '::'
|
||||
option listen_port '25'
|
||||
option dest_addr 'mail.my.provider'
|
||||
option dest_port '25'
|
||||
option protocol 'tcp'
|
||||
option ip_prefer ''
|
||||
option logging '0'
|
||||
option firewall '0'
|
||||
|
||||
Executable
+117
@@ -0,0 +1,117 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2025 ImmortalWrt.org
|
||||
|
||||
START=99
|
||||
USE_PROCD=1
|
||||
|
||||
NAME="3cat"
|
||||
PROG="/usr/bin/3proxy"
|
||||
CONF="/var/run/3cat.cfg"
|
||||
|
||||
fw_ports=""
|
||||
|
||||
validate_3cat_section() {
|
||||
uci_load_validate "$NAME" "instance" "$1" "$2" \
|
||||
'enabled:bool:0' \
|
||||
'listen_addr:or(ipaddr,hostname)' \
|
||||
'listen_port:port' \
|
||||
'dest_addr:or(ipaddr,hostname)' \
|
||||
'dest_port:port' \
|
||||
'protocol:string' \
|
||||
'ip_prefer:uinteger' \
|
||||
'logging:bool:0' \
|
||||
'firewall:bool:0'
|
||||
}
|
||||
|
||||
start_instance() {
|
||||
local section="$1"
|
||||
local seconds="0"
|
||||
|
||||
[ "$2" -eq "0" ] || { logger -p daemon.err -t "$NAME" "$section Validation failed."; return 1; }
|
||||
[ "$enabled" -eq "1" ] || return 1
|
||||
|
||||
if [ -x "$PROG" ]; then
|
||||
if [ "$logging" -eq "1" ]; then
|
||||
logging="-l"
|
||||
else
|
||||
logging=""
|
||||
fi
|
||||
[ "$firewall" -eq "1" ] && fw_ports="$fw_ports $listen_port@$protocol"
|
||||
echo "${protocol}pm $logging ${ip_prefer:+-$ip_prefer} ${listen_addr:+-i$listen_addr} $listen_port $dest_addr $dest_port" >> "$CONF"
|
||||
else
|
||||
procd_open_instance "$section"
|
||||
procd_set_param command "/usr/libexec/3proxy/${protocol}pm"
|
||||
[ "$logging" -eq "1" ] && procd_append_param command "-l@$section"
|
||||
[ -n "$ip_prefer" ] && procd_append_param command "-$ip_prefer"
|
||||
[ -n "$listen_addr" ] && procd_append_param command "-i$listen_addr"
|
||||
procd_append_param command "$listen_port"
|
||||
procd_append_param command "$dest_addr"
|
||||
procd_append_param command "$dest_port"
|
||||
|
||||
procd_set_param limits core="unlimited"
|
||||
procd_set_param limits nofile="1000000 1000000"
|
||||
procd_set_param respawn
|
||||
|
||||
if [ "$firewall" -eq "1" ]; then
|
||||
procd_open_data
|
||||
json_add_array firewall
|
||||
json_add_object ""
|
||||
json_add_string type rule
|
||||
json_add_string src "*"
|
||||
json_add_string dest_port "$listen_port"
|
||||
json_add_string proto "$protocol"
|
||||
json_add_string target ACCEPT
|
||||
json_close_object
|
||||
json_close_array
|
||||
procd_close_data
|
||||
fi
|
||||
|
||||
procd_close_instance
|
||||
fi
|
||||
}
|
||||
|
||||
start_service() {
|
||||
rm -f "$CONF"
|
||||
|
||||
config_load "$NAME"
|
||||
config_foreach validate_3cat_section "instance" start_instance
|
||||
|
||||
if [ -x "$PROG" ] && [ -s "$CONF" ]; then
|
||||
procd_open_instance
|
||||
procd_set_param command "$PROG" "$CONF"
|
||||
procd_set_param limits core="unlimited"
|
||||
procd_set_param limits nofile="1000000 1000000"
|
||||
procd_set_param respawn
|
||||
procd_set_param stdout 1
|
||||
|
||||
if [ -n "$fw_ports" ]; then
|
||||
procd_open_data
|
||||
json_add_array firewall
|
||||
for fw_port in $fw_ports; do
|
||||
json_add_object ""
|
||||
json_add_string type rule
|
||||
json_add_string src "*"
|
||||
json_add_string dest_port "${fw_port%@*}"
|
||||
json_add_string proto "${fw_port#*@}"
|
||||
json_add_string target ACCEPT
|
||||
json_close_object
|
||||
done
|
||||
json_close_array
|
||||
procd_close_data
|
||||
fi
|
||||
|
||||
procd_close_instance
|
||||
fi
|
||||
}
|
||||
|
||||
stop_service() {
|
||||
rm -f "$CONF"
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger "$NAME"
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
restart
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"admin/services/3cat": {
|
||||
"title": "3cat",
|
||||
"action": {
|
||||
"type": "view",
|
||||
"path": "3cat"
|
||||
},
|
||||
"depends": {
|
||||
"acl": [ "luci-app-3cat" ],
|
||||
"fs": { "/etc/config/3cat": "file" }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"luci-app-3cat": {
|
||||
"description": "Grant UCI access for luci-app-3cat",
|
||||
"read": {
|
||||
"uci": [ "3cat" ]
|
||||
},
|
||||
"write": {
|
||||
"uci": [ "3cat" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user