Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update to 20181113.0, add start script and config sample #2

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
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
PKG_MIRROR_HASH:=9c0bbfdf610d37b01ce296934a074a3a5f6c908b6d7ed8ffa72e981c8d9be3c3

PKG_LICENSE:=MIT
PKG_LICENSE_FILES:=LICENSE
Expand Down Expand Up @@ -50,6 +51,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))
9 changes: 9 additions & 0 deletions files/etc/config/udp2raw
Original file line number Diff line number Diff line change
@@ -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'
55 changes: 55 additions & 0 deletions files/etc/init.d/udp2raw
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/sh /etc/rc.common
# author: xiaofan <xfan1024@live.com>

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 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
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" --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
}

start_service() {
config_load udp2raw
config_foreach start_udp2raw client "-c"
config_foreach start_udp2raw server "-s"
}