mirror of
https://github.com/wangyu-/udp2raw.git
synced 2025-01-19 14:29:34 +08:00
update 3rd party
This commit is contained in:
parent
7fe8321082
commit
b0613e5b9b
23
third-party/luci-app-udp2raw/Makefile
vendored
23
third-party/luci-app-udp2raw/Makefile
vendored
@ -9,17 +9,15 @@ include $(TOPDIR)/rules.mk
|
|||||||
|
|
||||||
PKG_NAME:=luci-app-udp2raw
|
PKG_NAME:=luci-app-udp2raw
|
||||||
PKG_VERSION:=1.0.0
|
PKG_VERSION:=1.0.0
|
||||||
PKG_RELEASE:=1
|
PKG_RELEASE:=2
|
||||||
|
|
||||||
PKG_LICENSE:=GPLv3
|
PKG_LICENSE:=GPLv3
|
||||||
PKG_LICENSE_FILES:=LICENSE
|
PKG_LICENSE_FILES:=LICENSE
|
||||||
PKG_MAINTAINER:=Jian Chang <aa65535@live.com>
|
PKG_MAINTAINER:=Jian Chang <aa65535@live.com>
|
||||||
|
|
||||||
PKG_BUILD_PARALLEL:=1
|
|
||||||
|
|
||||||
include $(INCLUDE_DIR)/package.mk
|
include $(INCLUDE_DIR)/package.mk
|
||||||
|
|
||||||
define Package/luci-app-udp2raw
|
define Package/$(PKG_NAME)
|
||||||
SECTION:=luci
|
SECTION:=luci
|
||||||
CATEGORY:=LuCI
|
CATEGORY:=LuCI
|
||||||
SUBMENU:=3. Applications
|
SUBMENU:=3. Applications
|
||||||
@ -28,7 +26,7 @@ define Package/luci-app-udp2raw
|
|||||||
DEPENDS:=+udp2raw-tunnel
|
DEPENDS:=+udp2raw-tunnel
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define Package/luci-app-udp2raw/description
|
define Package/$(PKG_NAME)/description
|
||||||
LuCI Support for udp2raw-tunnel.
|
LuCI Support for udp2raw-tunnel.
|
||||||
endef
|
endef
|
||||||
|
|
||||||
@ -43,28 +41,27 @@ endef
|
|||||||
define Build/Compile
|
define Build/Compile
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define Package/luci-app-udp2raw/postinst
|
define Package/$(PKG_NAME)/postinst
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
if [ -z "$${IPKG_INSTROOT}" ]; then
|
if [ -z "$${IPKG_INSTROOT}" ]; then
|
||||||
( . /etc/uci-defaults/luci-udp2raw ) && rm -f /etc/uci-defaults/luci-udp2raw
|
( . /etc/uci-defaults/luci-udp2raw ) && rm -f /etc/uci-defaults/luci-udp2raw
|
||||||
rm -rf /tmp/luci-indexcache /tmp/luci-modulecache
|
|
||||||
fi
|
fi
|
||||||
exit 0
|
exit 0
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define Package/luci-app-udp2raw/conffiles
|
define Package/$(PKG_NAME)/conffiles
|
||||||
/etc/config/udp2raw
|
/etc/config/udp2raw
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define Package/luci-app-udp2raw/install
|
define Package/$(PKG_NAME)/install
|
||||||
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/i18n
|
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/i18n
|
||||||
$(INSTALL_DATA) $(PKG_BUILD_DIR)/udp2raw.*.lmo $(1)/usr/lib/lua/luci/i18n/
|
$(INSTALL_DATA) $(PKG_BUILD_DIR)/udp2raw.*.lmo $(1)/usr/lib/lua/luci/i18n/
|
||||||
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/controller
|
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/controller
|
||||||
$(INSTALL_DATA) ./files/luci/controller/*.lua $(1)/usr/lib/lua/luci/controller/
|
$(INSTALL_DATA) ./files/luci/controller/*.lua $(1)/usr/lib/lua/luci/controller/
|
||||||
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/model/cbi/udp2raw
|
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/model/cbi/udp2raw
|
||||||
$(INSTALL_DATA) ./files/luci/model/cbi/udp2raw/*.lua $(1)/usr/lib/lua/luci/model/cbi/udp2raw/
|
$(INSTALL_DATA) ./files/luci/model/cbi/udp2raw/*.lua $(1)/usr/lib/lua/luci/model/cbi/udp2raw/
|
||||||
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/view
|
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/view/udp2raw
|
||||||
$(INSTALL_DATA) ./files/luci/view/*.htm $(1)/usr/lib/lua/luci/view/
|
$(INSTALL_DATA) ./files/luci/view/udp2raw/*.htm $(1)/usr/lib/lua/luci/view/udp2raw/
|
||||||
$(INSTALL_DIR) $(1)/etc/config
|
$(INSTALL_DIR) $(1)/etc/config
|
||||||
$(INSTALL_CONF) ./files/root/etc/config/udp2raw $(1)/etc/config/udp2raw
|
$(INSTALL_CONF) ./files/root/etc/config/udp2raw $(1)/etc/config/udp2raw
|
||||||
$(INSTALL_DIR) $(1)/etc/init.d
|
$(INSTALL_DIR) $(1)/etc/init.d
|
||||||
@ -73,4 +70,4 @@ define Package/luci-app-udp2raw/install
|
|||||||
$(INSTALL_BIN) ./files/root/etc/uci-defaults/luci-udp2raw $(1)/etc/uci-defaults/luci-udp2raw
|
$(INSTALL_BIN) ./files/root/etc/uci-defaults/luci-udp2raw $(1)/etc/uci-defaults/luci-udp2raw
|
||||||
endef
|
endef
|
||||||
|
|
||||||
$(eval $(call BuildPackage,luci-app-udp2raw))
|
$(eval $(call BuildPackage,$(PKG_NAME)))
|
||||||
|
Binary file not shown.
@ -77,7 +77,7 @@ msgid "Cipher Mode"
|
|||||||
msgstr "加密方式"
|
msgstr "加密方式"
|
||||||
|
|
||||||
msgid "Auth Mode"
|
msgid "Auth Mode"
|
||||||
msgstr "认证方式"
|
msgstr "验证方式"
|
||||||
|
|
||||||
msgid "Auto Rule"
|
msgid "Auto Rule"
|
||||||
msgstr "自动规则"
|
msgstr "自动规则"
|
||||||
@ -89,7 +89,7 @@ msgid "Keep Rule"
|
|||||||
msgstr "保持规则"
|
msgstr "保持规则"
|
||||||
|
|
||||||
msgid "Monitor iptables and auto re-add if necessary."
|
msgid "Monitor iptables and auto re-add if necessary."
|
||||||
msgstr "监视 iptables 并在必要时重新添加规则。"
|
msgstr "定期检查 iptables 并在必要时重新添加规则。"
|
||||||
|
|
||||||
msgid "seq Mode"
|
msgid "seq Mode"
|
||||||
msgstr "seq 模式"
|
msgstr "seq 模式"
|
||||||
|
@ -18,13 +18,14 @@ uci:foreach("udp2raw", "servers", function(s)
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
m = Map("udp2raw", "%s - %s" %{translate("udp2raw-tunnel"), translate("Settings")})
|
m = Map("udp2raw", "%s - %s" %{translate("udp2raw-tunnel"), translate("Settings")})
|
||||||
m:append(Template("udp2raw_status"))
|
m:append(Template("udp2raw/status"))
|
||||||
|
|
||||||
s = m:section(NamedSection, "general", "general", translate("General Settings"))
|
s = m:section(NamedSection, "general", "general", translate("General Settings"))
|
||||||
s.anonymous = true
|
s.anonymous = true
|
||||||
s.addremove = false
|
s.addremove = false
|
||||||
|
|
||||||
o = s:option(ListValue, "server", translate("Server"))
|
o = s:option(DynamicList, "server", translate("Server"))
|
||||||
|
o.template = "udp2raw/dynamiclist"
|
||||||
o:value("nil", translate("Disable"))
|
o:value("nil", translate("Disable"))
|
||||||
for _, s in ipairs(servers) do o:value(s.name, s.alias) end
|
for _, s in ipairs(servers) do o:value(s.name, s.alias) end
|
||||||
o.default = "nil"
|
o.default = "nil"
|
||||||
|
98
third-party/luci-app-udp2raw/files/luci/view/udp2raw/dynamiclist.htm
vendored
Normal file
98
third-party/luci-app-udp2raw/files/luci/view/udp2raw/dynamiclist.htm
vendored
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
<%#
|
||||||
|
Copyright (C) 2017 Jian Chang <aa65535@live.com>
|
||||||
|
Licensed to the public under the GNU General Public License v3.
|
||||||
|
-%>
|
||||||
|
|
||||||
|
<%+cbi/valueheader%>
|
||||||
|
|
||||||
|
<%-
|
||||||
|
local values = self:formvalue(section)
|
||||||
|
if not values then
|
||||||
|
values = self:cfgvalue(section) or {self.default}
|
||||||
|
end
|
||||||
|
|
||||||
|
local function serialize_json(x, cb)
|
||||||
|
local rv, push = nil, cb
|
||||||
|
if not push then
|
||||||
|
rv = { }
|
||||||
|
push = function(tok) rv[#rv+1] = tok end
|
||||||
|
end
|
||||||
|
|
||||||
|
if x == nil then
|
||||||
|
push("null")
|
||||||
|
elseif type(x) == "table" then
|
||||||
|
push("[")
|
||||||
|
for k = 1, #x do
|
||||||
|
if k > 1 then
|
||||||
|
push(",")
|
||||||
|
end
|
||||||
|
serialize_json(x[k], push)
|
||||||
|
end
|
||||||
|
push("]")
|
||||||
|
else
|
||||||
|
push('"%s"' % tostring(x):gsub('["%z\1-\31\\]',
|
||||||
|
function(c) return '\\u%04x' % c:byte(1) end))
|
||||||
|
end
|
||||||
|
|
||||||
|
if not cb then
|
||||||
|
return table.concat(rv, "")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-%>
|
||||||
|
|
||||||
|
<div<%=attr("id", cbid .. ".value.field")%>></div>
|
||||||
|
<script type="text/javascript">//<![CDATA[
|
||||||
|
(function() {
|
||||||
|
var values = <%=serialize_json(values)%>;
|
||||||
|
var keylist = <%=serialize_json(self.keylist)%>;
|
||||||
|
var vallist = <%=serialize_json(self.vallist)%>;
|
||||||
|
var parent = document.getElementById("<%=cbid%>.value.field");
|
||||||
|
|
||||||
|
var dynamiclist_cbi_init = function() {
|
||||||
|
while (parent.firstChild) {
|
||||||
|
parent.removeChild(parent.firstChild);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var i = 0; i < values.length; i++) {
|
||||||
|
var sel = document.createElement("select");
|
||||||
|
sel.id = "<%=cbid%>." + (i + 1);
|
||||||
|
sel.name = "<%=cbid%>";
|
||||||
|
sel.index = i;
|
||||||
|
sel.className = "cbi-input-select";
|
||||||
|
sel.onchange = function() {
|
||||||
|
values[this.index] = this.value;
|
||||||
|
};
|
||||||
|
parent.appendChild(sel);
|
||||||
|
|
||||||
|
for (var j = 0; j < keylist.length; j++) {
|
||||||
|
var opt = document.createElement("option");
|
||||||
|
opt.value = keylist[j];
|
||||||
|
if (opt.value == values[i]) {
|
||||||
|
opt.selected = "selected";
|
||||||
|
}
|
||||||
|
opt.appendChild(document.createTextNode(vallist[j]));
|
||||||
|
sel.appendChild(opt);
|
||||||
|
}
|
||||||
|
|
||||||
|
var btn = document.createElement('img');
|
||||||
|
btn.src = "<%=resource%>" + ((i + 1) < values.length ? "/cbi/remove.gif" : "/cbi/add.gif");
|
||||||
|
btn.index = i;
|
||||||
|
btn.className = 'cbi-image-button';
|
||||||
|
btn.onclick = function() {
|
||||||
|
if (this.src.indexOf('remove') > -1) {
|
||||||
|
values.splice(this.index, 1);
|
||||||
|
} else {
|
||||||
|
values.push("<%=self.default%>");
|
||||||
|
}
|
||||||
|
dynamiclist_cbi_init();
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
parent.appendChild(btn);
|
||||||
|
parent.appendChild(document.createElement('br'));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
dynamiclist_cbi_init();
|
||||||
|
}());
|
||||||
|
//]]></script>
|
||||||
|
|
||||||
|
<%+cbi/valuefooter%>
|
39
third-party/luci-app-udp2raw/files/luci/view/udp2raw/status.htm
vendored
Normal file
39
third-party/luci-app-udp2raw/files/luci/view/udp2raw/status.htm
vendored
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
<%
|
||||||
|
local function get_udp2raw_version(name)
|
||||||
|
local info = luci.util.split(luci.sys.exec("%s -h 2>/dev/null" %{name}), "\n")
|
||||||
|
local version = string.match(info[2], "git version:(%w+)")
|
||||||
|
local build = string.match(info[2], "build date:(.+)")
|
||||||
|
return info[1] == "udp2raw-tunnel" and version or "", info[1] == "udp2raw-tunnel" and build or ""
|
||||||
|
end
|
||||||
|
|
||||||
|
local udp2raw_version, udp2raw_build = get_udp2raw_version("udp2raw")
|
||||||
|
-%>
|
||||||
|
|
||||||
|
<fieldset class="cbi-section">
|
||||||
|
<legend><%:Running Status%></legend>
|
||||||
|
<table width="100%" cellspacing="10" id="_udp2raw_status_table">
|
||||||
|
<tr>
|
||||||
|
<td width="33%"><%:Binary Version%></td>
|
||||||
|
<td>
|
||||||
|
<% if udp2raw_version == "" then -%>
|
||||||
|
<em><%:Invalid Binary File.%></em>
|
||||||
|
<% else -%>
|
||||||
|
<%=pcdata(udp2raw_version)%>
|
||||||
|
<%- end %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<% if udp2raw_build ~= "" then -%>
|
||||||
|
<tr><td width="33%"><%:Build Time%></td><td><%=pcdata(udp2raw_build)%></td></tr>
|
||||||
|
<% end -%>
|
||||||
|
<tr><td width="33%"><%:Running Status%></td><td id="_udp2raw_status"><em><%:Collecting data...%></em></td></tr>
|
||||||
|
</table>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<script type="text/javascript">//<![CDATA[
|
||||||
|
var udp2raw_status = document.getElementById('_udp2raw_status');
|
||||||
|
XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "services", "udp2raw", "status")%>', null, function(x, status) {
|
||||||
|
if ( x && x.status == 200 ) {
|
||||||
|
udp2raw_status.innerHTML = status.running ? '<%:RUNNING%>' : '<%:NOT RUNNING%>';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//]]></script>
|
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
config general 'general'
|
config general 'general'
|
||||||
option server 'nil'
|
list server 'nil'
|
||||||
option daemon_user 'root'
|
option daemon_user 'root'
|
||||||
|
|
||||||
config servers 'default'
|
config servers 'default'
|
||||||
|
@ -1,51 +1,56 @@
|
|||||||
#!/bin/sh /etc/rc.common
|
#!/bin/sh /etc/rc.common
|
||||||
|
|
||||||
START=88
|
START=88
|
||||||
|
STOP=15
|
||||||
USE_PROCD=1
|
USE_PROCD=1
|
||||||
|
|
||||||
UDP2RAW=udp2raw
|
NAME=udp2raw
|
||||||
|
|
||||||
_log() {
|
_log() {
|
||||||
local level="$1"
|
logger -p "daemon.$1" -t "$NAME" "$2"
|
||||||
local msg="$2"
|
|
||||||
|
|
||||||
logger -p "daemon.${level}" -t "$UDP2RAW" "$msg"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gen_client_config_file() {
|
has_valid_server() {
|
||||||
|
local server
|
||||||
|
for server in $@; do
|
||||||
|
[ "$(uci_get $NAME $server)" = "servers" ] && return 0
|
||||||
|
done
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
create_config() {
|
||||||
local config_file="$1"
|
local config_file="$1"
|
||||||
echo "# auto-generated config file from /etc/config/udp2raw" > $config_file
|
echo "# auto-generated config file from /etc/config/udp2raw" > $config_file
|
||||||
|
|
||||||
echo "-c" >> $config_file
|
echo "-c" >> $config_file
|
||||||
echo "-l ${listen_addr}:${listen_port}" >> $config_file && _log "info" "listening on: ${listen_addr}:${listen_port}"
|
echo "-l ${listen_addr:=127.0.0.1}:${listen_port:=2080}" >> $config_file && _log "info" "listening on: ${listen_addr}:${listen_port}"
|
||||||
echo "-r ${server_addr}:${server_port}" >> $config_file && _log "info" "remote address: ${server_addr}:${server_port}"
|
echo "-r ${server_addr}:${server_port:=8080}" >> $config_file
|
||||||
|
|
||||||
[ -n "$raw_mode" ] && echo "--raw-mode ${raw_mode}" >> $config_file && _log "info" "raw-mode: ${raw_mode}"
|
[ -n "$raw_mode" ] && echo "--raw-mode ${raw_mode}" >> $config_file && _log "info" "raw-mode: ${raw_mode}"
|
||||||
[ -n "$key" ] && echo "--key ${key}" >> $config_file
|
[ -n "$key" ] && echo "--key ${key}" >> $config_file
|
||||||
[ -n "$cipher_mode" ] && echo "--cipher-mode ${cipher_mode}" >> $config_file && _log "info" "cipher-mode: ${cipher_mode}"
|
[ -n "$cipher_mode" ] && echo "--cipher-mode ${cipher_mode}" >> $config_file
|
||||||
[ -n "$auth_mode" ] && echo "--auth-mode ${auth_mode}" >> $config_file && _log "info" "auth-mode: ${auth_mode}"
|
[ -n "$auth_mode" ] && echo "--auth-mode ${auth_mode}" >> $config_file
|
||||||
|
|
||||||
[ "$auto_rule" -ne 0 ] && echo "--auto-rule" >> $config_file && _log "info" "auto-rule: true"
|
[ $auto_rule -eq 1 ] && echo "--auto-rule" >> $config_file
|
||||||
[ "$auto_rule" -ne 0 -a "$keep_rule" -ne 0 ] && echo "--keep-rule" >> $config_file && _log "info" "keep-rule: true"
|
[ $auto_rule -eq 1 -a $keep_rule -eq 1 ] && echo "--keep-rule" >> $config_file
|
||||||
|
|
||||||
[ -n "$seq_mode" ] && echo "--seq-mode ${seq_mode}" >> $config_file && _log "info" "seq-mode: ${seq_mode}"
|
[ -n "$seq_mode" ] && echo "--seq-mode ${seq_mode}" >> $config_file
|
||||||
[ -n "$lower_level" ] && echo "--lower-level ${lower_level}" >> $config_file && _log "info" "lower-level: ${lower_level}"
|
[ -n "$lower_level" ] && echo "--lower-level ${lower_level}" >> $config_file
|
||||||
[ -n "$source_ip" ] && echo "--source-ip ${source_ip}" >> $config_file
|
[ -n "$source_ip" ] && echo "--source-ip ${source_ip}" >> $config_file
|
||||||
[ -n "$source_port" ] && echo "--source-port ${source_port}" >> $config_file
|
[ -n "$source_port" ] && echo "--source-port ${source_port}" >> $config_file
|
||||||
|
|
||||||
[ -n "$log_level" ] && echo "--log-level ${log_level}" >> $config_file
|
[ -n "$log_level" ] && echo "--log-level ${log_level}" >> $config_file
|
||||||
echo "--disable-color" >> $config_file
|
echo "--disable-color" >> $config_file
|
||||||
_log "info" "running from ${daemon_user} user"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
validate_config_section() {
|
validate_config_section() {
|
||||||
uci_validate_section "$UDP2RAW" general "$1" \
|
uci_validate_section "$NAME" general "$1" \
|
||||||
'server:uciname' \
|
'server:uciname' \
|
||||||
'daemon_user:string:root'
|
'daemon_user:string:root'
|
||||||
}
|
}
|
||||||
|
|
||||||
validate_server_section() {
|
validate_server_section() {
|
||||||
uci_validate_section "$UDP2RAW" servers "$1" \
|
uci_validate_section "$NAME" servers "$1" \
|
||||||
'server_addr:host' \
|
'server_addr:host' \
|
||||||
'server_port:port:8080' \
|
'server_port:port:8080' \
|
||||||
'listen_addr:ipaddr:127.0.0.1' \
|
'listen_addr:ipaddr:127.0.0.1' \
|
||||||
@ -63,59 +68,49 @@ validate_server_section() {
|
|||||||
'log_level:range(0,6)'
|
'log_level:range(0,6)'
|
||||||
}
|
}
|
||||||
|
|
||||||
start_udp2raw_instance() {
|
start_instance() {
|
||||||
local section="$1"
|
local server="$1"
|
||||||
|
|
||||||
if ! validate_config_section "$section" ; then
|
if [ -z "$server" -o "$server" == "nil" ]; then
|
||||||
_log "err" "Config validate failed."
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$server" ] || [ "$server" = "nil" ]; then
|
|
||||||
return 0
|
return 0
|
||||||
elif ! validate_server_section "$server"; then
|
elif ! validate_server_section "$server"; then
|
||||||
_log "err" "Server config validation failed."
|
_log "err" "Server config validation failed."
|
||||||
return 1
|
return 1
|
||||||
elif [ -z "$server_addr" ]; then
|
fi
|
||||||
|
|
||||||
|
/sbin/validate_data "ipaddr" "$server_addr" >/dev/null 2>&1
|
||||||
|
[ $? -ne 0 ] && server_addr=$(nslookup "$server_addr" | \
|
||||||
|
sed -n 's/^Address[[:space:]]*[0-9]*:[[:space:]]*\(\([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}\)$/\1/p')
|
||||||
|
if [ -z "$server_addr" ]; then
|
||||||
_log "err" "Server address validation failed."
|
_log "err" "Server address validation failed."
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
is_ipv6_address() {
|
|
||||||
echo "$1" | grep -q ":"
|
|
||||||
}
|
|
||||||
|
|
||||||
is_ipv6_address "$server_addr" && server_addr="[${server_addr}]"
|
|
||||||
is_ipv6_address "$listen_addr" && listen_addr="[${listen_addr}]"
|
|
||||||
|
|
||||||
_log "notice" "udp2raw-tunnel start."
|
|
||||||
[ -d /var/etc ] || mkdir -p /var/etc
|
[ -d /var/etc ] || mkdir -p /var/etc
|
||||||
local config_file=/var/etc/${UDP2RAW}.${server}.conf
|
local config_file="/var/etc/${NAME}.${server}.conf"
|
||||||
|
create_config "$config_file" || return 1
|
||||||
if ! ( gen_client_config_file "$config_file" ); then
|
|
||||||
_log "err" "Can't create config file".
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
procd_open_instance
|
procd_open_instance
|
||||||
procd_set_param command /usr/bin/udp2raw
|
procd_set_param command /usr/bin/udp2raw
|
||||||
procd_append_param command --conf-file "$config_file"
|
procd_append_param command --conf-file "$config_file"
|
||||||
procd_set_param respawn
|
procd_set_param respawn
|
||||||
procd_set_param file "$config_file"
|
procd_set_param file "$config_file"
|
||||||
procd_set_param user "$daemon_user"
|
[ -n "$daemon_user" ] && procd_set_param user "$daemon_user" && _log "info" "running from ${daemon_user} user"
|
||||||
procd_set_param pidfile /var/run/${UDP2RAW}.${server}.pid
|
procd_set_param pidfile "/var/run/${NAME}.${server}.pid"
|
||||||
procd_close_instance
|
procd_close_instance
|
||||||
}
|
}
|
||||||
|
|
||||||
service_triggers() {
|
service_triggers() {
|
||||||
procd_add_reload_trigger "$UDP2RAW"
|
procd_add_reload_trigger "$NAME"
|
||||||
}
|
}
|
||||||
|
|
||||||
start_service() {
|
start_service() {
|
||||||
config_load "$UDP2RAW"
|
if ! validate_config_section "general" ; then
|
||||||
config_foreach start_udp2raw_instance "general"
|
_log "err" "Config validate failed."
|
||||||
}
|
return 1
|
||||||
|
fi
|
||||||
stop_service() {
|
has_valid_server $server || return 1
|
||||||
_log "notice" "udp2raw-tunnel stop."
|
for srv in $server; do
|
||||||
|
start_instance $srv
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
130
third-party/luci-app-udp2raw/files/root/etc/init.d/udp2raw.init
vendored
Normal file
130
third-party/luci-app-udp2raw/files/root/etc/init.d/udp2raw.init
vendored
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
#!/bin/sh /etc/rc.common
|
||||||
|
|
||||||
|
START=88
|
||||||
|
STOP=15
|
||||||
|
|
||||||
|
NAME=udp2raw
|
||||||
|
|
||||||
|
_log() {
|
||||||
|
logger -p "daemon.$1" -t "$NAME" "$2"
|
||||||
|
}
|
||||||
|
|
||||||
|
has_valid_server() {
|
||||||
|
local server
|
||||||
|
for server in $@; do
|
||||||
|
[ "$(uci_get $NAME $server)" = "servers" ] && return 0
|
||||||
|
done
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
create_config() {
|
||||||
|
local config_file="$1"
|
||||||
|
echo "# auto-generated config file from /etc/config/udp2raw" > $config_file
|
||||||
|
|
||||||
|
echo "-c" >> $config_file
|
||||||
|
echo "-l ${listen_addr:=127.0.0.1}:${listen_port:=2080}" >> $config_file
|
||||||
|
echo "-r ${server_addr}:${server_port:=8080}" >> $config_file
|
||||||
|
|
||||||
|
[ -n "$raw_mode" ] && echo "--raw-mode ${raw_mode}" >> $config_file
|
||||||
|
[ -n "$key" ] && echo "--key ${key}" >> $config_file
|
||||||
|
[ -n "$cipher_mode" ] && echo "--cipher-mode ${cipher_mode}" >> $config_file
|
||||||
|
[ -n "$auth_mode" ] && echo "--auth-mode ${auth_mode}" >> $config_file
|
||||||
|
|
||||||
|
[ $auto_rule -eq 1 ] && echo "--auto-rule" >> $config_file
|
||||||
|
[ $auto_rule -eq 1 -a $keep_rule -eq 1 ] && echo "--keep-rule" >> $config_file
|
||||||
|
|
||||||
|
[ -n "$seq_mode" ] && echo "--seq-mode ${seq_mode}" >> $config_file
|
||||||
|
[ -n "$lower_level" ] && echo "--lower-level ${lower_level}" >> $config_file
|
||||||
|
[ -n "$source_ip" ] && echo "--source-ip ${source_ip}" >> $config_file
|
||||||
|
[ -n "$source_port" ] && echo "--source-port ${source_port}" >> $config_file
|
||||||
|
|
||||||
|
[ -n "$log_level" ] && echo "--log-level ${log_level}" >> $config_file
|
||||||
|
echo "--disable-color" >> $config_file
|
||||||
|
}
|
||||||
|
|
||||||
|
validate_config_section() {
|
||||||
|
local ret=$(/sbin/validate_data "$NAME" general "$1" \
|
||||||
|
'server:uciname' \
|
||||||
|
'daemon_user:string:root' \
|
||||||
|
2> /dev/null)
|
||||||
|
[ $? -ne 0 ] && return 1
|
||||||
|
eval "$ret"
|
||||||
|
}
|
||||||
|
|
||||||
|
validate_server_section() {
|
||||||
|
local ret=$(/sbin/validate_data "$NAME" servers "$1" \
|
||||||
|
'server_addr:host' \
|
||||||
|
'server_port:port:8080' \
|
||||||
|
'listen_addr:ipaddr:127.0.0.1' \
|
||||||
|
'listen_port:port:2080' \
|
||||||
|
'raw_mode:or("faketcp", "udp", "icmp"):faketcp' \
|
||||||
|
'key:string' \
|
||||||
|
'cipher_mode:or("aes128cbc", "xor", "none"):aes128cbc' \
|
||||||
|
'auth_mode:or("md5", "crc32", "simple", "none"):md5' \
|
||||||
|
'auto_rule:bool:1' \
|
||||||
|
'keep_rule:bool:0' \
|
||||||
|
'seq_mode:range(0,4)' \
|
||||||
|
'lower_level:string' \
|
||||||
|
'source_ip:ipaddr' \
|
||||||
|
'source_port:port' \
|
||||||
|
'log_level:range(0,6)' \
|
||||||
|
2> /dev/null)
|
||||||
|
[ $? -ne 0 ] && return 1
|
||||||
|
eval "$ret"
|
||||||
|
}
|
||||||
|
|
||||||
|
start_instance() {
|
||||||
|
local server="$1"
|
||||||
|
|
||||||
|
if [ -z "$server" -o "$server" == "nil" ]; then
|
||||||
|
return 0
|
||||||
|
elif ! validate_server_section "$server"; then
|
||||||
|
_log "err" "Server config validation failed."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
/sbin/validate_data "ipaddr" "$server_addr" >/dev/null 2>&1
|
||||||
|
[ $? -ne 0 ] && server_addr=$(nslookup "$server_addr" | \
|
||||||
|
sed -n 's/^Address[[:space:]]*[0-9]*:[[:space:]]*\(\([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}\)$/\1/p')
|
||||||
|
if [ -z "$server_addr" ]; then
|
||||||
|
_log "err" "Server address validation failed."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
[ -d /var/etc ] || mkdir -p /var/etc
|
||||||
|
local config_file="/var/etc/${NAME}.${server}.conf"
|
||||||
|
create_config "$config_file" || return 1
|
||||||
|
[ -d "/var/log/${NAME}" ] || mkdir -p "/var/log/${NAME}"
|
||||||
|
|
||||||
|
/usr/bin/udp2raw --conf-file "$config_file" >> "/var/log/${NAME}/${NAME}.${server}.log" &
|
||||||
|
echo $! > "/var/run/${NAME}.${server}.pid"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
start() {
|
||||||
|
pgrep "/usr/bin/${NAME}" >/dev/null 2>&1 && return
|
||||||
|
|
||||||
|
if ! validate_config_section "general" ; then
|
||||||
|
_log "err" "Config validate failed."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
has_valid_server $server || return 1
|
||||||
|
for srv in $server; do
|
||||||
|
start_instance $srv
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
stop() {
|
||||||
|
local pids=$(pgrep "/usr/bin/${NAME}" 2> /dev/null)
|
||||||
|
[ $? -ne 0 ] && return
|
||||||
|
for pid in $pids; do
|
||||||
|
kill $pid >/dev/null 2>&1
|
||||||
|
done
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
restart() {
|
||||||
|
stop
|
||||||
|
sleep 1
|
||||||
|
start
|
||||||
|
}
|
@ -8,11 +8,9 @@ uci -q batch <<-EOF >/dev/null
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
general=$(uci -q get udp2raw.@general[-1])
|
general=$(uci -q get udp2raw.@general[-1])
|
||||||
|
|
||||||
if [ -z "$general" ]; then
|
if [ -z "$general" ]; then
|
||||||
uci -q add udp2raw general
|
uci -q add udp2raw general
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ."$general" != ."general" ]; then
|
if [ ."$general" != ."general" ]; then
|
||||||
uci -q batch <<-EOF >/dev/null
|
uci -q batch <<-EOF >/dev/null
|
||||||
rename udp2raw.@general[-1]="general"
|
rename udp2raw.@general[-1]="general"
|
||||||
|
BIN
third-party/luci-app-udp2raw/luci-app-udp2raw1.jpg
vendored
BIN
third-party/luci-app-udp2raw/luci-app-udp2raw1.jpg
vendored
Binary file not shown.
Before Width: | Height: | Size: 85 KiB After Width: | Height: | Size: 77 KiB |
BIN
third-party/luci-app-udp2raw/luci-app-udp2raw2.jpg
vendored
BIN
third-party/luci-app-udp2raw/luci-app-udp2raw2.jpg
vendored
Binary file not shown.
Before Width: | Height: | Size: 89 KiB After Width: | Height: | Size: 88 KiB |
BIN
third-party/luci-app-udp2raw/luci-app-udp2raw3.jpg
vendored
BIN
third-party/luci-app-udp2raw/luci-app-udp2raw3.jpg
vendored
Binary file not shown.
Before Width: | Height: | Size: 149 KiB After Width: | Height: | Size: 132 KiB |
17
third-party/udp2raw-openwrt-makefile/Makefile
vendored
17
third-party/udp2raw-openwrt-makefile/Makefile
vendored
@ -9,13 +9,13 @@ include $(TOPDIR)/rules.mk
|
|||||||
|
|
||||||
PKG_NAME:=udp2raw-tunnel
|
PKG_NAME:=udp2raw-tunnel
|
||||||
PKG_VERSION:=20171125.0
|
PKG_VERSION:=20171125.0
|
||||||
PKG_RELEASE:=1
|
PKG_RELEASE:=2
|
||||||
|
|
||||||
PKG_SOURCE_PROTO:=git
|
PKG_SOURCE_PROTO:=git
|
||||||
PKG_SOURCE_URL:=https://github.com/wangyu-/udp2raw-tunnel.git
|
PKG_SOURCE_URL:=https://github.com/wangyu-/udp2raw-tunnel.git
|
||||||
PKG_SOURCE_VERSION:=b35edf74865275cdc970384681a1a076d3a8d0e1
|
PKG_SOURCE_VERSION:=19b4d456365ea5d44e2fa6e7447e59061f14ef51
|
||||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
|
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.xz
|
||||||
|
|
||||||
PKG_LICENSE:=MIT
|
PKG_LICENSE:=MIT
|
||||||
PKG_LICENSE_FILES:=LICENSE
|
PKG_LICENSE_FILES:=LICENSE
|
||||||
@ -40,12 +40,11 @@ endef
|
|||||||
|
|
||||||
MAKE_FLAGS += cross2
|
MAKE_FLAGS += cross2
|
||||||
|
|
||||||
define Build/Prepare
|
define Build/Configure
|
||||||
$(PKG_UNPACK)
|
$(call Build/Configure/Default)
|
||||||
sed -i 's/cc_cross=.*/cc_cross=$(TARGET_CXX)/g' $(PKG_BUILD_DIR)/makefile
|
$(SED) 's/cc_cross[[:space:]]*=.*/cc_cross=$(TARGET_CXX)/' \
|
||||||
sed -i '/\*gitversion/d' $(PKG_BUILD_DIR)/makefile
|
-e 's/\\".*shell git rev-parse HEAD.*\\"/\\"$(PKG_SOURCE_VERSION)\\"/' \
|
||||||
echo 'const char *gitversion = "$(PKG_SOURCE_VERSION)";' > $(PKG_BUILD_DIR)/git_version.h
|
$(PKG_BUILD_DIR)/makefile
|
||||||
$(Build/Patch)
|
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define Package/udp2raw-tunnel/install
|
define Package/udp2raw-tunnel/install
|
||||||
|
Loading…
x
Reference in New Issue
Block a user