From cff6a81aad346dffc38ef69d5cb6f8b79bfaa904 Mon Sep 17 00:00:00 2001 From: xiaofan Date: Tue, 4 Jun 2019 03:14:22 +0800 Subject: [PATCH 1/4] update to 20181113.0, add start script and config sample --- Makefile | 8 ++++++-- files/etc/config/udp2raw | 9 +++++++++ files/etc/init.d/udp2raw | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 files/etc/config/udp2raw create mode 100644 files/etc/init.d/udp2raw diff --git a/Makefile b/Makefile index fd8037c..224ae29 100644 --- a/Makefile +++ b/Makefile @@ -8,12 +8,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=udp2raw-tunnel -PKG_VERSION:=20180428.0 +PKG_VERSION:=20181113.0 PKG_RELEASE:=1 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL:=https://github.com/wangyu-/udp2raw-tunnel.git -PKG_SOURCE_VERSION:=2c2d897bc2140dbe77cea99f92942425632088e6 +PKG_SOURCE_VERSION:=0137dba1fd421ed1a61e7e913039833751e0446e PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.xz @@ -50,6 +50,10 @@ endef define Package/udp2raw-tunnel/install $(INSTALL_DIR) $(1)/usr/bin $(INSTALL_BIN) $(PKG_BUILD_DIR)/udp2raw_cross $(1)/usr/bin/udp2raw + $(INSTALL_DIR) $(1)/etc/config + $(INSTALL_DATA) ./files/etc/config/udp2raw $(1)/etc/config/udp2raw + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) ./files/etc/init.d/udp2raw $(1)/etc/init.d/udp2raw endef $(eval $(call BuildPackage,udp2raw-tunnel)) diff --git a/files/etc/config/udp2raw b/files/etc/config/udp2raw new file mode 100644 index 0000000..c6434b6 --- /dev/null +++ b/files/etc/config/udp2raw @@ -0,0 +1,9 @@ +config client udp2raw_sample + option localaddr '127.0.0.1:1000' + option remoteaddr '8.8.8.8:1000' + option mode 'faketcp' + option key 'your_password' + option cipher 'xor' + option auth 'md5' + option iptables '1' + option disabled '1' diff --git a/files/etc/init.d/udp2raw b/files/etc/init.d/udp2raw new file mode 100644 index 0000000..75ea166 --- /dev/null +++ b/files/etc/init.d/udp2raw @@ -0,0 +1,40 @@ +#!/bin/sh /etc/rc.common +# author: xiaofan + +START=80 +USE_PROCD=1 +bin="/usr/bin/udp2raw" + +start_udp2raw() { + local cfg="$1" + local first_opt="$2" + local localaddr remoteaddr mode key cipher auth disabled + + config_get_bool disabled $cfg disabled + [ "$disabled" = 1 ] && return + config_get localaddr $cfg localaddr + config_get remoteaddr $cfg remoteaddr + config_get mode $cfg mode + config_get key $cfg key + config_get cipher $cfg cipher + config_get auth $cfg auth + config_get_bool iptables $cfg iptables + + procd_open_instance + procd_set_param command "$bin" + procd_append_param command "$first_opt" + [ -n "$localaddr" ] && procd_append_param command -l "$localaddr" + [ -n "$remoteaddr" ] && procd_append_param command -r "$remoteaddr" + [ -n "$mode" ] && procd_append_param command --raw-mode "$mode" + [ -n "$key" ] && procd_append_param command -k "$key" + [ -n "$cipher" ] && procd_append_param command --cipher-mode "$cipher" + [ -n "$auth" ] && procd_append_param command --auth-mode "$auth" + [ -n "$iptables" ] && procd_append_param command -a --keep-rule + procd_close_instance +} + +start_service() { + config_load udp2raw + config_foreach start_udp2raw client "-c" + config_foreach start_udp2raw server "-s" +} From 53ecee9eb795a009029ab072fc718e04d47843ff Mon Sep 17 00:00:00 2001 From: xiaofan Date: Fri, 26 Jul 2019 18:24:28 +0800 Subject: [PATCH 2/4] use temporary configure file instead of command arguments --- files/etc/init.d/udp2raw | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/files/etc/init.d/udp2raw b/files/etc/init.d/udp2raw index 75ea166..fccb8a2 100644 --- a/files/etc/init.d/udp2raw +++ b/files/etc/init.d/udp2raw @@ -4,14 +4,29 @@ START=80 USE_PROCD=1 bin="/usr/bin/udp2raw" +confdir="/var/etc/udp2raw" + +confpath="" +conf_make(){ + mkdir -p "$confdir" + confpath="$confdir/$1.conf" + echo "# this conf generate by udp2raw.$1" >"$confpath" +} +conf_append(){ + echo "$*" >>"$confpath" +} start_udp2raw() { local cfg="$1" local first_opt="$2" + local confdir confpath local localaddr remoteaddr mode key cipher auth disabled config_get_bool disabled $cfg disabled [ "$disabled" = 1 ] && return + + conf_make "$cfg" + config_get localaddr $cfg localaddr config_get remoteaddr $cfg remoteaddr config_get mode $cfg mode @@ -21,15 +36,15 @@ start_udp2raw() { config_get_bool iptables $cfg iptables procd_open_instance - procd_set_param command "$bin" - procd_append_param command "$first_opt" - [ -n "$localaddr" ] && procd_append_param command -l "$localaddr" - [ -n "$remoteaddr" ] && procd_append_param command -r "$remoteaddr" - [ -n "$mode" ] && procd_append_param command --raw-mode "$mode" - [ -n "$key" ] && procd_append_param command -k "$key" - [ -n "$cipher" ] && procd_append_param command --cipher-mode "$cipher" - [ -n "$auth" ] && procd_append_param command --auth-mode "$auth" - [ -n "$iptables" ] && procd_append_param command -a --keep-rule + procd_set_param command "$bin" --conf-file "$confpath" + conf_append "$first_opt" + [ -n "$localaddr" ] && conf_append -l "$localaddr" + [ -n "$remoteaddr" ] && conf_append -r "$remoteaddr" + [ -n "$mode" ] && conf_append --raw-mode "$mode" + [ -n "$key" ] && conf_append -k "$key" + [ -n "$cipher" ] && conf_append --cipher-mode "$cipher" + [ -n "$auth" ] && conf_append --auth-mode "$auth" + [ -n "$iptables" ] && conf_append -a --keep-rule procd_close_instance } From 1356993530106e0a4aef25cb6c6b6b1784b10639 Mon Sep 17 00:00:00 2001 From: xiaofan Date: Sat, 27 Jul 2019 13:38:22 +0800 Subject: [PATCH 3/4] fix redundant local variables --- files/etc/init.d/udp2raw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/etc/init.d/udp2raw b/files/etc/init.d/udp2raw index fccb8a2..6c38ffb 100644 --- a/files/etc/init.d/udp2raw +++ b/files/etc/init.d/udp2raw @@ -19,7 +19,7 @@ conf_append(){ start_udp2raw() { local cfg="$1" local first_opt="$2" - local confdir confpath + local confpath local localaddr remoteaddr mode key cipher auth disabled config_get_bool disabled $cfg disabled From acb758d02b2bc204148e838533c41089e3c27fc1 Mon Sep 17 00:00:00 2001 From: xfan1024 Date: Wed, 2 Feb 2022 03:34:11 +0000 Subject: [PATCH 4/4] add PKG_MIRROR_HASH Signed-off-by: xfan1024 --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 224ae29..39193fe 100644 --- a/Makefile +++ b/Makefile @@ -16,6 +16,7 @@ PKG_SOURCE_URL:=https://github.com/wangyu-/udp2raw-tunnel.git PKG_SOURCE_VERSION:=0137dba1fd421ed1a61e7e913039833751e0446e PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.xz +PKG_MIRROR_HASH:=9c0bbfdf610d37b01ce296934a074a3a5f6c908b6d7ed8ffa72e981c8d9be3c3 PKG_LICENSE:=MIT PKG_LICENSE_FILES:=LICENSE