Browse Source

Merge pull request #1607 from aa65535/master

shadowsocks-libev: bump version
Steven Barth 9 years ago
parent
commit
cb755385f8

+ 4
- 4
net/shadowsocks-libev/Makefile View File

@@ -8,13 +8,13 @@
8 8
 include $(TOPDIR)/rules.mk
9 9
 
10 10
 PKG_NAME:=shadowsocks-libev
11
-PKG_VERSION:=2.2.2
11
+PKG_VERSION:=2.2.3
12 12
 PKG_RELEASE:=1
13 13
 
14 14
 PKG_SOURCE_PROTO:=git
15 15
 PKG_SOURCE_URL:=https://github.com/shadowsocks/shadowsocks-libev.git
16 16
 PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_RELEASE)
17
-PKG_SOURCE_VERSION:=4883903e657095b93f88a3a3b9a0dccdffdaa397
17
+PKG_SOURCE_VERSION:=2b1eef11973de3f7380401fd20f937e84bc2b756
18 18
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
19 19
 PKG_MAINTAINER:=Jian Chang <aa65535@live.com>
20 20
 
@@ -36,14 +36,14 @@ define Package/shadowsocks-libev/Default
36 36
 	TITLE:=Lightweight Secured Socks5 Proxy $(2)
37 37
 	URL:=https://github.com/shadowsocks/shadowsocks-libev
38 38
 	VARIANT:=$(1)
39
-	DEPENDS:=$(3) +resolveip +ipset +ip +iptables-mod-tproxy
39
+	DEPENDS:=$(3) +libpthread +ipset +ip +iptables-mod-tproxy
40 40
 endef
41 41
 
42 42
 Package/shadowsocks-libev = $(call Package/shadowsocks-libev/Default,openssl,(OpenSSL),+libopenssl)
43 43
 Package/shadowsocks-libev-polarssl = $(call Package/shadowsocks-libev/Default,polarssl,(PolarSSL),+libpolarssl)
44 44
 
45 45
 define Package/shadowsocks-libev/description
46
-Shadowsocks-libev is a lightweight secured scoks5 proxy for embedded devices and low end boxes.
46
+Shadowsocks-libev is a lightweight secured socks5 proxy for embedded devices and low end boxes.
47 47
 endef
48 48
 
49 49
 Package/shadowsocks-libev-polarssl/description = $(Package/shadowsocks-libev/description)

+ 1
- 1
net/shadowsocks-libev/files/shadowsocks-libev.config View File

@@ -8,7 +8,7 @@ config shadowsocks-libev
8 8
 	option timeout '60'
9 9
 	option encrypt_method 'rc4-md5'
10 10
 	option ignore_list '/dev/null'
11
-	option udp_relay '0'
11
+	option udp_mode '0'
12 12
 	option tunnel_enable '1'
13 13
 	option tunnel_port '5300'
14 14
 	option tunnel_forward '8.8.4.4:53'

+ 66
- 25
net/shadowsocks-libev/files/shadowsocks-libev.init View File

@@ -14,11 +14,17 @@ get_config() {
14 14
 	config_get server $1 server
15 15
 	config_get server_port $1 server_port
16 16
 	config_get local_port $1 local_port
17
-	config_get password $1 password
18 17
 	config_get timeout $1 timeout
18
+	config_get password $1 password
19 19
 	config_get encrypt_method $1 encrypt_method
20 20
 	config_get ignore_list $1 ignore_list
21
-	config_get udp_relay $1 udp_relay
21
+	config_get udp_mode $1 udp_mode
22
+	config_get udp_server $1 udp_server
23
+	config_get udp_server_port $1 udp_server_port
24
+	config_get udp_local_port $1 udp_local_port
25
+	config_get udp_timeout $1 udp_timeout
26
+	config_get udp_password $1 udp_password
27
+	config_get udp_encrypt_method $1 udp_encrypt_method
22 28
 	config_get_bool tunnel_enable $1 tunnel_enable
23 29
 	config_get tunnel_port $1 tunnel_port
24 30
 	config_get tunnel_forward $1 tunnel_forward
@@ -27,6 +33,8 @@ get_config() {
27 33
 	config_get wan_bp_ip $1 wan_bp_ip
28 34
 	config_get wan_fw_ip $1 wan_fw_ip
29 35
 	config_get ipt_ext $1 ipt_ext
36
+	: ${timeout:=60}
37
+	: ${udp_timeout:=60}
30 38
 	: ${tunnel_port:=5300}
31 39
 	: ${tunnel_forward:=8.8.4.4:53}
32 40
 }
@@ -45,6 +53,8 @@ start_rules() {
45 53
 	/usr/bin/ss-rules \
46 54
 		-s "$server" \
47 55
 		-l "$local_port" \
56
+		-S "$udp_server" \
57
+		-L "$udp_local_port" \
48 58
 		-i "$ignore_list" \
49 59
 		-a "$ac_args" \
50 60
 		-b "$wan_bp_ip" \
@@ -55,17 +65,48 @@ start_rules() {
55 65
 }
56 66
 
57 67
 start_redir() {
58
-	service_start /usr/bin/ss-redir \
59
-		-c "$CONFIG_FILE" $udp
68
+	cat <<-EOF >$CONFIG_FILE
69
+		{
70
+		    "server": "$server",
71
+		    "server_port": $server_port,
72
+		    "local_address": "0.0.0.0",
73
+		    "local_port": $local_port,
74
+		    "password": "$password",
75
+		    "timeout": $timeout,
76
+		    "method": "$encrypt_method"
77
+		}
78
+EOF
79
+	if [ "$udp_mode" = 2 ]; then
80
+		/usr/bin/ss-redir \
81
+			-c $CONFIG_FILE \
82
+			-f /var/run/ss-redir_t.pid
83
+		cat <<-EOF >$CONFIG_FILE
84
+			{
85
+			    "server": "$udp_server",
86
+			    "server_port": $udp_server_port,
87
+			    "local_address": "0.0.0.0",
88
+			    "local_port": $udp_local_port,
89
+			    "password": "$udp_password",
90
+			    "timeout": $udp_timeout,
91
+			    "method": "$udp_encrypt_method"
92
+			}
93
+EOF
94
+	fi
95
+	/usr/bin/ss-redir \
96
+		-c $CONFIG_FILE \
97
+		-f /var/run/ss-redir.pid \
98
+		$udp
60 99
 	return $?
61 100
 }
62 101
 
63 102
 start_tunnel() {
64
-	service_start /usr/bin/ss-tunnel \
65
-		-c "$CONFIG_FILE" \
66
-		-l "$tunnel_port" \
67
-		-L "$tunnel_forward" \
68
-		-u
103
+	: ${udp:="-u"}
104
+	/usr/bin/ss-tunnel \
105
+		-c $CONFIG_FILE \
106
+		-l $tunnel_port \
107
+		-L $tunnel_forward \
108
+		-f /var/run/ss-tunnel.pid \
109
+		$udp
69 110
 	return $?
70 111
 }
71 112
 
@@ -73,25 +114,26 @@ rules() {
73 114
 	config_load shadowsocks-libev
74 115
 	config_foreach get_config shadowsocks-libev
75 116
 	[ "$enable" = 1 ] || exit 0
76
-	[ "$udp_relay" = 1 ] && udp="-u"
77
-	mkdir -p $(dirname $CONFIG_FILE)
117
+	mkdir -p /var/run /var/etc
78 118
 
79 119
 	: ${server:?}
80 120
 	: ${server_port:?}
81 121
 	: ${local_port:?}
82 122
 	: ${password:?}
83 123
 	: ${encrypt_method:?}
84
-	cat <<-EOF >$CONFIG_FILE
85
-		{
86
-		    "server": "$server",
87
-		    "server_port": $server_port,
88
-		    "local_address": "0.0.0.0",
89
-		    "local_port": $local_port,
90
-		    "password": "$password",
91
-		    "timeout": $timeout,
92
-		    "method": "$encrypt_method"
93
-		}
94
-EOF
124
+	case $udp_mode in
125
+		1) udp="-u"
126
+		;;
127
+		2)
128
+			udp="-U"
129
+			: ${udp_server:?}
130
+			: ${udp_server_port:?}
131
+			: ${udp_local_port:?}
132
+			: ${udp_password:?}
133
+			: ${udp_encrypt_method:?}
134
+		;;
135
+	esac
136
+
95 137
 	start_rules
96 138
 }
97 139
 
@@ -109,7 +151,6 @@ start() {
109 151
 
110 152
 stop() {
111 153
 	/usr/bin/ss-rules -f
112
-	service_stop /usr/bin/ss-redir
113
-	service_stop /usr/bin/ss-tunnel
114
-	rm -f $CONFIG_FILE
154
+	killall -q -9 ss-redir
155
+	killall -q -9 ss-tunnel
115 156
 }

+ 25
- 9
net/shadowsocks-libev/files/ss-rules View File

@@ -16,6 +16,8 @@ usage() {
16 16
 		    -e <extra_options>      extra options for iptables
17 17
 		    -o                      apply the rules to the OUTPUT chain
18 18
 		    -u                      enable udprelay mode, TPROXY is required
19
+		    -U                      enable udprelay mode, using different IP
20
+		                            and ports for TCP and UDP
19 21
 		    -f                      flush the rules
20 22
 EOF
21 23
 }
@@ -69,7 +71,7 @@ EOF
69 71
 fw_rule() {
70 72
 	$ipt_n -N SS_SPEC_WAN_FW && \
71 73
 	$ipt_n -A SS_SPEC_WAN_FW -p tcp \
72
-		-j REDIRECT --to-ports $LOCAL_PORT 2>/dev/null || {
74
+		-j REDIRECT --to-ports $local_port 2>/dev/null || {
73 75
 		loger 3 "Can't redirect, please check the iptables."
74 76
 		exit 1
75 77
 	}
@@ -111,7 +113,7 @@ EOF
111 113
 }
112 114
 
113 115
 tp_rule() {
114
-	[ "$TPROXY" = 1 ] || return 0
116
+	[ -n "$TPROXY" ] || return 0
115 117
 	ip rule add fwmark 0x01/0x01 table 100
116 118
 	ip route add local 0.0.0.0/0 dev lo table 100
117 119
 	$ipt_m -N SS_SPEC_TPROXY
@@ -123,12 +125,18 @@ tp_rule() {
123 125
 	return $?
124 126
 }
125 127
 
126
-while getopts ":s:l:c:i:e:a:b:w:ouf" arg; do
128
+while getopts ":s:l:S:L:i:e:a:b:w:ouUf" arg; do
127 129
 	case $arg in
128 130
 		s)
129
-			SERVER=$OPTARG
131
+			server=$OPTARG
130 132
 			;;
131 133
 		l)
134
+			local_port=$OPTARG
135
+			;;
136
+		S)
137
+			SERVER=$OPTARG
138
+			;;
139
+		L)
132 140
 			LOCAL_PORT=$OPTARG
133 141
 			;;
134 142
 		i)
@@ -152,6 +160,9 @@ while getopts ":s:l:c:i:e:a:b:w:ouf" arg; do
152 160
 		u)
153 161
 			TPROXY=1
154 162
 			;;
163
+		U)
164
+			TPROXY=2
165
+			;;
155 166
 		f)
156 167
 			flush_r
157 168
 			exit 0
@@ -159,16 +170,20 @@ while getopts ":s:l:c:i:e:a:b:w:ouf" arg; do
159 170
 	esac
160 171
 done
161 172
 
162
-if [ -z "$SERVER" -o -z "$LOCAL_PORT" ]; then
173
+if [ -z "$server" -o -z "$local_port" ]; then
163 174
 	usage
164 175
 	exit 2
165 176
 fi
166 177
 
167
-SERVER=$(resolveip -t60 $SERVER)
178
+if [ "$TPROXY" = 1 ]; then
179
+	SERVER=$server
180
+	LOCAL_PORT=$local_port
181
+fi
168 182
 
169
-if [ -z "$SERVER" ]; then
170
-	loger 3 "Can't resolve the server hostname."
171
-	exit 1
183
+if [ "$TPROXY" = 2 ]; then
184
+	if [ -z "$SERVER" -o -z "$LOCAL_PORT" ]; then
185
+		loger 3 "Please use -S and -L specifies IP and port for UDP."
186
+	fi
172 187
 fi
173 188
 
174 189
 if [ -f "$IGNORE" ]; then
@@ -176,6 +191,7 @@ if [ -f "$IGNORE" ]; then
176 191
 fi
177 192
 
178 193
 IPLIST=$(cat <<-EOF | grep -E "^([0-9]{1,3}\.){3}[0-9]{1,3}"
194
+	$server
179 195
 	$SERVER
180 196
 	0.0.0.0/8
181 197
 	10.0.0.0/8