Browse Source

ipt2socks replaces redsocks2

Mattraks 4 years ago
parent
commit
ce9f571a47

+ 1 - 1
luci-app-ssr-plus/luasrc/view/shadowsocksr/ssrurl.htm

@@ -361,8 +361,8 @@ function import_ssr_url(btn, urlname, sid) {
 			document.getElementsByName('cbid.shadowsocksr.' + sid + '.vless_encryption')[0].value = queryParam.encryption || "none";
 			if (queryParam.security == "tls") {
 				document.getElementsByName('cbid.shadowsocksr.' + sid + '.tls')[0].checked = true;
-				document.getElementsByName('cbid.shadowsocksr.' + sid + '.tls_host')[0].value = queryParam.sni || serverPart[0];
 				document.getElementsByName('cbid.shadowsocksr.' + sid + '.tls')[0].dispatchEvent(event);
+				document.getElementsByName('cbid.shadowsocksr.' + sid + '.tls_host')[0].value = queryParam.sni || serverPart[0];
 			}
 			switch (queryParam.type) {
 			case "ws":

+ 33 - 10
luci-app-ssr-plus/root/etc/init.d/shadowsocksr

@@ -292,6 +292,7 @@ gen_config_file() { #server1 type2 code3 local_port4 socks_port5 threads5
 			lua /usr/share/shadowsocksr/gen_config.lua $1 client $4 >$config_file
 			;;
 		3)
+			lua /usr/share/shadowsocksr/gen_config.lua $1 nat $4 >$config_file
 			lua /usr/share/shadowsocksr/gen_config.lua $1 client $tmp_port >$shunt_dns_config_file
 			;;
 		4)
@@ -305,6 +306,7 @@ gen_config_file() { #server1 type2 code3 local_port4 socks_port5 threads5
 			lua /usr/share/shadowsocksr/gen_config.lua $1 nat $4 >$config_file
 			;;
 		3)
+			lua /usr/share/shadowsocksr/gen_config.lua $1 nat $4 >$config_file
 			lua /usr/share/shadowsocksr/gen_config.lua $1 client $tmp_port >$shunt_dns_config_file
 			;;
 		4)
@@ -372,8 +374,12 @@ start_udp() {
 		ARG_UDP=""
 		;;
 	socks5)
-		gen_config_file $UDP_RELAY_SERVER $type 2 $tmp_udp_port
-		ln_start_bin $(first_type redsocks2) redsocks2 -c $udp_config_file
+		if [ "$(uci_get_by_name $UDP_RELAY_SERVER auth_enable 0)" == "1" ]; then
+			local auth="-a $(uci_get_by_name $UDP_RELAY_SERVER username) -k $(uci_get_by_name $UDP_RELAY_SERVER password)"
+		fi
+		ln_start_bin $(first_type ipt2socks) ipt2socks $udp_config_file -U -4 -s $(uci_get_by_name $UDP_RELAY_SERVER server) -p $(uci_get_by_name $UDP_RELAY_SERVER server_port) -l $tmp_udp_port $auth
+		#gen_config_file $UDP_RELAY_SERVER $type 2 $tmp_udp_port
+		#ln_start_bin $(first_type redsocks2) redsocks2 -c $udp_config_file
 		echolog "UDP TPROXY Relay:Socks5 REDIRECT/TPROXY Started!"
 		;;
 	tun)
@@ -389,7 +395,6 @@ start_shunt() {
 	case "$type" in
 	ss | ssr)
 		gen_config_file $SHUNT_SERVER $type 3 $tmp_shunt_port
-		#gen_config_file $SHUNT_SERVER $type 3 $tmp_local_port
 		ln_start_bin $(first_type ${type}-redir) ${type}-redir -c $shunt_config_file
 		if [ -n "$tmp_local_port" ]; then
 			local tmp_port=$tmp_local_port
@@ -436,6 +441,22 @@ start_shunt() {
 		echolog "shunt:$($(first_type "naive") --version 2>&1 | head -1) Started!"
 		redir_udp=0
 		;;
+	socks5)
+		if [ "$(uci_get_by_name $SHUNT_SERVER auth_enable 0)" == "1" ]; then
+			local auth="-a $(uci_get_by_name $SHUNT_SERVER username) -k $(uci_get_by_name $SHUNT_SERVER password)"
+		fi
+		ln_start_bin $(first_type ipt2socks) ipt2socks $shunt_config_file -R -4 -s $(uci_get_by_name $SHUNT_SERVER server) -p $(uci_get_by_name $SHUNT_SERVER server_port) -l $tmp_shunt_port $auth
+		#gen_config_file $SHUNT_SERVER $type 3 $tmp_shunt_port
+		#ln_start_bin $(first_type redsocks2) redsocks2 -c $shunt_config_file
+		if [ -n "$tmp_local_port" ]; then
+			local tmp_port=$tmp_local_port
+		else
+			local tmp_port=$tmp_shunt_local_port
+			ln_start_bin $(first_type microsocks) microsocks -i 127.0.0.1 -p $tmp_port shunt-dns-ssr-plus
+		fi
+		ln_start_bin $(first_type dns2socks) dns2socks 127.0.0.1:$tmp_port 8.8.8.8:53 127.0.0.1:$tmp_shunt_dns_port -q
+		echolog "shunt:$type REDIRECT/TPROXY Started!"
+		;;
 	*)
 		gen_config_file $SHUNT_SERVER $type 3 $tmp_shunt_port
 		ln_start_bin $(first_type redsocks2) redsocks2 -c $shunt_config_file
@@ -532,7 +553,7 @@ Start_Run() {
 	trojan | trojan-go)
 		gen_config_file $GLOBAL_SERVER $type 1 $tcp_port
 		ln_start_bin $(first_type trojan-go trojan) $type --config $tcp_config_file
-		echolog "Main node:$($(first_type $type) --version 2>&1 | head -1) Started!"
+		echolog "Main node:$($(first_type trojan-go trojan) --version 2>&1 | head -1) Started!"
 		;;
 	naiveproxy)
 		gen_config_file $GLOBAL_SERVER $type 1 $tcp_port
@@ -540,10 +561,14 @@ Start_Run() {
 		echolog "Main node:$($(first_type naive) --version 2>&1 | head -1) , $threads Threads Started!"
 		;;
 	socks5)
-		gen_config_file $GLOBAL_SERVER $type 1 $tcp_port
-		for i in $(seq 1 $threads); do
-			ln_start_bin $(first_type redsocks2) redsocks2 -c $tcp_config_file
-		done
+		if [ "$(uci_get_by_name $GLOBAL_SERVER auth_enable 0)" == "1" ]; then
+			local auth="-a $(uci_get_by_name $GLOBAL_SERVER username) -k $(uci_get_by_name $GLOBAL_SERVER password)"
+		fi
+		ln_start_bin $(first_type ipt2socks) ipt2socks $tcp_config_file -R -4 -j $threads -s $(uci_get_by_name $GLOBAL_SERVER server) -p $(uci_get_by_name $GLOBAL_SERVER server_port) -l $tcp_port $auth
+		#gen_config_file $GLOBAL_SERVER $type 1 $tcp_port
+		#for i in $(seq 1 $threads); do
+		#	ln_start_bin $(first_type redsocks2) redsocks2 -c $tcp_config_file
+		#done
 		echolog "Main node:Socks5 REDIRECT/TPROXY $threads Threads Started!"
 		;;
 	tun)
@@ -747,7 +772,6 @@ start_rules() {
 		w | W | b | B) local ac_ips="$lan_ac_mode$lan_ac_ips" ;;
 		esac
 	fi
-	#deal gfw firewall rule
 	gfwmode() {
 		case "$(uci_get_by_type global run_mode)" in
 		gfw) echo "-g" ;;
@@ -848,7 +872,6 @@ stop() {
 	ps -w | grep -v "grep" | grep ssr-monitor | awk '{print $1}' | xargs kill -9 >/dev/null 2>&1 &
 	ps -w | grep -v "grep" | grep "sleep 0000" | awk '{print $1}' | xargs kill -9 >/dev/null 2>&1 &
 	ps -w | grep -v "grep" | grep "$TMP_PATH" | awk '{print $1}' | xargs kill -9 >/dev/null 2>&1 &
-	#killall -q -9 ss-redir ss-local obfs-local ssr-redir ssr-local ssr-server v2ray v2ray-plugin xray trojan naive microsocks ipt2socks dns2socks redsocks2 pdnsd
 	killall -q -9 v2ray-plugin obfs-local
 	rm -f /var/lock/ssr-monitor.lock
 	if [ -f "/var/dnsmasq.d/dnsmasq-ssrplus.conf" ]; then