Mattraks 4 лет назад
Родитель
Сommit
12579eb5cd

+ 4 - 25
luci-app-ssr-plus/Makefile

@@ -1,8 +1,8 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=luci-app-ssr-plus
-PKG_VERSION:=182
-PKG_RELEASE:=10
+PKG_VERSION:=183
+PKG_RELEASE:=1
 
 define Package/$(PKG_NAME)/conffiles
 /etc/config/shadowsocksr
@@ -17,14 +17,6 @@ config PACKAGE_$(PKG_NAME)_INCLUDE_Shadowsocks
 config PACKAGE_$(PKG_NAME)_INCLUDE_V2ray_plugin
 	bool "Include Shadowsocks V2ray Plugin"
 	default n
-	
-config PACKAGE_$(PKG_NAME)_INCLUDE_Xray
-	bool "Include Xray"
-	default y if i386||x86_64||arm||aarch64
-
-config PACKAGE_$(PKG_NAME)_INCLUDE_Trojan
-	bool "Include Trojan"
-	default n if i386||x86_64||arm||aarch64
 
 config PACKAGE_$(PKG_NAME)_INCLUDE_Redsocks2
 	bool "Include Redsocks2"
@@ -35,14 +27,6 @@ config PACKAGE_$(PKG_NAME)_INCLUDE_NaiveProxy
 	depends on !(arc||armeb||mips||mips64||powerpc)
 	default n
 
-config PACKAGE_$(PKG_NAME)_INCLUDE_V2ray
-	bool "Include V2ray"
-	default n
-
-config PACKAGE_$(PKG_NAME)_INCLUDE_Trojan-go
-	bool "Include Trojan-go"
-	default y if i386||x86_64||arm||aarch64
-
 config PACKAGE_$(PKG_NAME)_INCLUDE_Kcptun
 	bool "Include Kcptun"
 	default n
@@ -54,17 +38,12 @@ endef
 
 LUCI_TITLE:=SS/SSR/V2Ray/Trojan/NaiveProxy/Socks5/Tun LuCI interface
 LUCI_PKGARCH:=all
-LUCI_DEPENDS:=+shadowsocksr-libev-alt +ipset +ip-full +iptables-mod-tproxy +dnsmasq-full +coreutils +coreutils-base64 +pdnsd-alt +wget-ssl +lua +libuci-lua \
-	+microsocks +dns2socks +shadowsocksr-libev-ssr-local +tcping +resolveip\
+LUCI_DEPENDS:=+xray +shadowsocksr-libev-alt +ipset +ip-full +iptables-mod-tproxy +dnsmasq-full +coreutils +coreutils-base64 +pdnsd-alt +wget-ssl +lua +libuci-lua \
+	+microsocks +dns2socks +shadowsocksr-libev-ssr-local +tcping +resolveip +ipt2socks-alt \
 	+PACKAGE_$(PKG_NAME)_INCLUDE_Shadowsocks:shadowsocks-libev-ss-local \
 	+PACKAGE_$(PKG_NAME)_INCLUDE_Shadowsocks:shadowsocks-libev-ss-redir \
 	+PACKAGE_$(PKG_NAME)_INCLUDE_Shadowsocks:simple-obfs \
 	+PACKAGE_$(PKG_NAME)_INCLUDE_V2ray_plugin:v2ray-plugin \
-	+PACKAGE_$(PKG_NAME)_INCLUDE_V2ray:v2ray \
-	+PACKAGE_$(PKG_NAME)_INCLUDE_Xray:xray \
-	+PACKAGE_$(PKG_NAME)_INCLUDE_Trojan:trojan \
-	+PACKAGE_$(PKG_NAME)_INCLUDE_Trojan-go:trojan-go \
-	+PACKAGE_$(PKG_NAME)_INCLUDE_Trojan:ipt2socks \
 	+PACKAGE_$(PKG_NAME)_INCLUDE_NaiveProxy:naiveproxy \
 	+PACKAGE_$(PKG_NAME)_INCLUDE_Redsocks2:redsocks2 \
 	+PACKAGE_$(PKG_NAME)_INCLUDE_Kcptun:kcptun-client \

+ 34 - 19
luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/client-config.lua

@@ -66,11 +66,21 @@ local encrypt_methods_ss = {
 }
 
 local encrypt_methods_v2ray_ss = {
--- aead
-"aes-128-gcm",
-"aes-256-gcm",
-"chacha20-ietf-poly1305",
-"none"
+	-- xray_ss
+	"none",
+	"plain",
+	"aes-128-cfb",
+	"aes-256-cfb",
+	"chacha20",
+	"chacha20-ietf",
+	-- aead
+	"aes-128-gcm",
+	"aes-256-gcm",
+	"chacha20-poly1305",
+	"chacha20-ietf-poly1305",
+	"aead_aes_128_gcm",
+	"aead_aes_256_gcm",
+	"aead_chacha20_poly1305"
 }
 
 local protocol = {
@@ -142,7 +152,7 @@ end
 if is_finded("xray") or is_finded("v2ray") then
 	o:value("v2ray", translate("V2Ray/XRay"))
 end
-if is_finded("trojan")then
+if is_finded("trojan") then
 	o:value("trojan", translate("Trojan"))
 end
 if is_finded("trojan-go") then
@@ -152,10 +162,13 @@ end
 if is_finded("naive") then
 	o:value("naiveproxy", translate("NaiveProxy"))
 end
-if is_finded("redsocks2") then
+if is_finded("ipt2socks-alt") or is_finded("ipt2socks") then
 	o:value("socks5", translate("Socks5"))
+end
+if is_finded("redsocks2") then
 	o:value("tun", translate("Network Tunnel"))
 end
+
 o.description = translate("Using incorrect encryption mothod may causes service fail to start")
 
 o = s:option(Value, "alias", translate("Alias(optional)"))
@@ -170,12 +183,12 @@ o:depends("type", "tun")
 o.description = translate("Redirect traffic to this network interface")
 
 o = s:option(ListValue, "v2ray_protocol", translate("V2Ray/XRay protocol"))
-o:value("vmess", translate("Vmess"))
+o:value("vmess", translate("VMess"))
 o:value("vless", translate("VLESS"))
-o:value("http", translate("HTTP"))
-o:value("socks", translate("Socks"))
-o:value("shadowsocks", translate("Shadowsocks"))
 o:value("trojan", translate("Trojan"))
+o:value("shadowsocks", translate("Shadowsocks"))
+o:value("socks", translate("Socks"))
+o:value("http", translate("HTTP"))
 o:depends("type", "v2ray")
 
 o = s:option(Value, "server", translate("Server Address"))
@@ -243,7 +256,9 @@ o.rmempty = true
 o:depends("type", "ss")
 
 o = s:option(ListValue, "encrypt_method_v2ray_ss", translate("Encrypt Method"))
-for _, v in ipairs(encrypt_methods_v2ray_ss) do o:value(v) end
+for _, v in ipairs(encrypt_methods_v2ray_ss) do
+	o:value(v)
+end
 o.rmempty = true
 o:depends({type = "v2ray", v2ray_protocol = "shadowsocks"})
 
@@ -502,13 +517,13 @@ o:depends("type", "trojan-go")
 
 -- XTLS
 if is_finded("xray") then
-o = s:option(Flag, "xtls", translate("XTLS"))
-o.rmempty = true
-o.default = "0"
-o:depends({type = "v2ray", v2ray_protocol = "vless", transport = "tcp", tls = false})
-o:depends({type = "v2ray", v2ray_protocol = "vless", transport = "kcp", tls = false})
-o:depends({type = "v2ray", v2ray_protocol = "trojan", transport = "tcp", tls = false})
-o:depends({type = "v2ray", v2ray_protocol = "trojan", transport = "kcp", tls = false})
+	o = s:option(Flag, "xtls", translate("XTLS"))
+	o.rmempty = true
+	o.default = "0"
+	o:depends({type = "v2ray", v2ray_protocol = "vless", transport = "tcp", tls = false})
+	o:depends({type = "v2ray", v2ray_protocol = "vless", transport = "kcp", tls = false})
+	o:depends({type = "v2ray", v2ray_protocol = "trojan", transport = "tcp", tls = false})
+	o:depends({type = "v2ray", v2ray_protocol = "trojan", transport = "kcp", tls = false})
 end
 
 -- Flow

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

@@ -196,8 +196,10 @@ function import_ssr_url(btn, urlname, sid) {
 				url0 = ssu[1]
 			}
 			var sstr = url0;
-			document.getElementsByName('cbid.shadowsocksr.' + sid + '.type')[0].value = ssu[0];
+			document.getElementsByName('cbid.shadowsocksr.' + sid + '.type')[0].value = "v2ray";
 			document.getElementsByName('cbid.shadowsocksr.' + sid + '.type')[0].dispatchEvent(event);
+			document.getElementsByName('cbid.shadowsocksr.' + sid + '.v2ray_protocol')[0].value = "trojan";
+			document.getElementsByName('cbid.shadowsocksr.' + sid + '.v2ray_protocol')[0].dispatchEvent(event);
 			var team = sstr.split('@');
 			var password = team[0]
 			var serverPart = team[1].split(':');		

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

@@ -359,7 +359,7 @@ start_udp() {
 	trojan) #client
 		gen_config_file $UDP_RELAY_SERVER $type 2 $tmp_udp_local_port
 		ln_start_bin $(first_type trojan-go trojan) $type --config $udp_config_file
-		ln_start_bin $(first_type ipt2socks) ipt2socks -U -b 0.0.0.0 -4 -s 127.0.0.1 -p $tmp_udp_local_port -l $tmp_udp_port
+		ln_start_bin $(first_type ipt2socks-alt ipt2socks) ipt2socks -U -b 0.0.0.0 -4 -s 127.0.0.1 -p $tmp_udp_local_port -l $tmp_udp_port
 		echolog "UDP TPROXY Relay:$($(first_type trojan-go trojan) --version 2>&1 | head -1) Started!"
 		;;
 	trojan-go)
@@ -376,7 +376,7 @@ start_udp() {
 		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-alt) ipt2socks-alt $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
+		ln_start_bin $(first_type ipt2socks-alt 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!"
@@ -444,7 +444,7 @@ start_shunt() {
 		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-alt) ipt2socks-alt $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
+		ln_start_bin $(first_type ipt2socks-alt 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
@@ -563,7 +563,7 @@ Start_Run() {
 		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-alt) ipt2socks-alt $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
+		ln_start_bin $(first_type ipt2socks-alt 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

+ 1 - 0
luci-app-ssr-plus/root/etc/uci-defaults/luci-ssr-plus

@@ -28,5 +28,6 @@ if [ ! -s "/etc/config/shadowsocksr" ]; then
 fi
 sed -i "s/option type 'vmess'"/"option type 'v2ray'\n\toption v2ray_protocol 'vmess'/g" /etc/config/shadowsocksr
 sed -i "s/option type 'vless'"/"option type 'v2ray'\n\toption v2ray_protocol 'vless'/g" /etc/config/shadowsocksr
+sed -i "s/option type 'trojan'"/"option type 'v2ray'\n\toption v2ray_protocol 'trojan'/g" /etc/config/shadowsocksr
 rm -rf /tmp/luci-modulecache /tmp/luci-indexcache
 exit 0

+ 137 - 70
luci-app-ssr-plus/root/usr/share/shadowsocksr/gen_config.lua

@@ -1,4 +1,4 @@
-local ucursor = require "luci.model.uci".cursor()
+local ucursor = require"luci.model.uci".cursor()
 local json = require "luci.jsonc"
 local server_section = arg[1]
 local proto = arg[2]
@@ -6,8 +6,7 @@ local local_port = arg[3] or "0"
 local socks_port = arg[4] or "0"
 local server = ucursor:get_all("shadowsocksr", server_section)
 local outbound_settings = nil
-if (server.v2ray_protocol == "vmess" or server.v2ray_protocol == "vless" or not server.v2ray_protocol)
-then
+function vmess_vless()
 	outbound_settings = {
 		vnext = {
 			{
@@ -19,15 +18,14 @@ then
 						alterId = (server.v2ray_protocol == "vmess" or not server.v2ray_protocol) and tonumber(server.alter_id) or nil,
 						security = (server.v2ray_protocol == "vmess" or not server.v2ray_protocol) and server.security or nil,
 						encryption = (server.v2ray_protocol == "vless") and server.vless_encryption or nil,
-						flow = (server.xtls == '1') and (server.vless_flow and server.vless_flow or "xtls-rprx-splice") or nil,
+						flow = (server.xtls == '1') and (server.vless_flow and server.vless_flow or "xtls-rprx-splice") or nil
 					}
 				}
 			}
 		}
 	}
-
-elseif (server.v2ray_protocol == "trojan" or server.v2ray_protocol == "shadowsocks")
-then
+end
+function trojan_shadowsocks()
 	outbound_settings = {
 		servers = {
 			{
@@ -35,28 +33,64 @@ then
 				port = tonumber(server.server_port),
 				password = server.password,
 				method = (server.v2ray_protocol == "shadowsocks") and server.encrypt_method_v2ray_ss or nil,
-				flow = (server.v2ray_protocol == "trojan") and (server.xtls == '1') and (server.vless_flow and server.vless_flow or "xtls-rprx-splice") or nil,
+				flow = (server.v2ray_protocol == "trojan") and (server.xtls == '1') and (server.vless_flow and server.vless_flow or "xtls-rprx-splice") or nil
 			}
 		}
 	}
-
-elseif (server.v2ray_protocol == "socks" or server.v2ray_protocol == "http")
-then
+end
+function socks_http()
 	outbound_settings = {
+		--
 		servers = {
 			{
+				--
 				address = server.server,
 				port = tonumber(server.server_port),
 				users = (server.auth_enable == "1") and {
 					{
+						--
 						user = server.username,
-						pass = server.password,
+						pass = server.password
 					}
-				} or nil,
+				} or nil
 			}
 		}
 	}
 end
+local outbound = {}
+function outbound:new(o)
+	o = o or {}
+	setmetatable(o, self)
+	self.__index = self
+	return o
+end
+function outbound:handleIndex(index)
+	local switch = {
+		vmess = function()
+			vmess_vless()
+		end,
+		vless = function()
+			vmess_vless()
+		end,
+		trojan = function()
+			trojan_shadowsocks()
+		end,
+		shadowsocks = function()
+			trojan_shadowsocks()
+		end,
+		socks = function()
+			socks_http()
+		end,
+		http = function()
+			socks_http()
+		end
+	}
+	if switch[index] then
+		switch[index]()
+	end
+end
+local settings = outbound:new()
+settings:handleIndex(server.v2ray_protocol)
 local Xray = {
 	log = {
 		-- error = "/var/ssrplus.log",
@@ -64,6 +98,7 @@ local Xray = {
 	},
 	-- 传入连接
 	inbound = (local_port ~= "0") and {
+		-- listening
 		port = tonumber(local_port),
 		protocol = "dokodemo-door",
 		settings = {network = proto, followRedirect = true},
@@ -72,6 +107,7 @@ local Xray = {
 	-- 开启 socks 代理
 	inboundDetour = (proto:find("tcp") and socks_port ~= "0") and {
 		{
+			-- socks
 			protocol = "socks",
 			port = tonumber(socks_port),
 			settings = {auth = "noauth", udp = true}
@@ -83,20 +119,24 @@ local Xray = {
 		settings = outbound_settings,
 		-- 底层传输配置
 		streamSettings = {
-			network = server.transport,
-			security = (server.xtls == '1') and "xtls" or (server.tls == '1') and "tls" or "none",
+			network = server.transport or "tcp",
+			security = (server.xtls == '1') and "xtls" or (server.tls == '1') and "tls" or nil,
 			tlsSettings = (server.tls == '1' and (server.insecure == "1" or server.tls_host)) and {
+				-- tls
 				allowInsecure = (server.insecure == "1") and true or nil,
 				serverName = server.tls_host
 			} or nil,
 			xtlsSettings = (server.xtls == '1' and (server.insecure == "1" or server.tls_host)) and {
+				-- xtls
 				allowInsecure = (server.insecure == "1") and true or nil,
 				serverName = server.tls_host
 			} or nil,
 			tcpSettings = (server.transport == "tcp" and server.tcp_guise == "http") and {
+				-- tcp
 				header = {
 					type = server.tcp_guise,
 					request = {
+						-- request
 						path = {server.http_path} or {"/"},
 						headers = {Host = {server.http_host} or {}}
 					}
@@ -114,28 +154,34 @@ local Xray = {
 				seed = server.seed or nil
 			} or nil,
 			wsSettings = (server.transport == "ws") and (server.ws_path or server.ws_host or server.tls_host) and {
+				-- ws
 				path = server.ws_path,
 				headers = (server.ws_host or server.tls_host) and {
+					-- headers
 					Host = server.ws_host or server.tls_host
 				} or nil
 			} or nil,
 			httpSettings = (server.transport == "h2") and {
+				-- h2
 				path = server.h2_path or "",
 				host = {server.h2_host} or nil
 			} or nil,
 			quicSettings = (server.transport == "quic") and {
+				-- quic
 				security = server.quic_security,
 				key = server.quic_key,
 				header = {type = server.quic_guise}
 			} or nil
 		},
 		mux = (server.mux == "1" and server.xtls ~= "1") and {
+			-- mux
 			enabled = true,
 			concurrency = tonumber(server.concurrency)
 		} or nil
 	} or nil
 }
-local cipher = "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA:AES128-SHA:AES256-SHA:DES-CBC3-SHA"
+local cipher =
+				"ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA:AES128-SHA:AES256-SHA:DES-CBC3-SHA"
 local cipher13 = "TLS_AES_128_GCM_SHA256:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_256_GCM_SHA384"
 local trojan = {
 	log_level = 3,
@@ -161,12 +207,14 @@ local trojan = {
 		session_ticket = (server.tls_sessionTicket == "1") and true or false
 	},
 	udp_timeout = 60,
-    mux = (server.mux == "1") and {
-        enabled = true,
-        concurrency = tonumber(server.concurrency),
-        idle_timeout = 60,
-        } or nil,
+	mux = (server.mux == "1") and {
+		-- mux
+		enabled = true,
+		concurrency = tonumber(server.concurrency),
+		idle_timeout = 60
+	} or nil,
 	tcp = {
+		-- tcp
 		no_delay = true,
 		keep_alive = true,
 		reuse_port = true,
@@ -190,55 +238,74 @@ local ss = {
 	fast_open = (server.fast_open == "1") and true or false,
 	reuse_port = true
 }
-if server.type == "ss" then
-	if server.plugin and server.plugin ~= "none" then
-		ss.plugin = server.plugin
-		ss.plugin_opts = server.plugin_opts or nil
-	end
-	print(json.stringify(ss, 1))
+local config = {}
+function config:new(o)
+	o = o or {}
+	setmetatable(o, self)
+	self.__index = self
+	return o
 end
-if server.type == "ssr" then
-	ss.protocol = server.protocol
-	ss.protocol_param = server.protocol_param
-	ss.method = server.encrypt_method
-	ss.obfs = server.obfs
-	ss.obfs_param = server.obfs_param
-	print(json.stringify(ss, 1))
-end
-if server.type == "v2ray" then
-	print(json.stringify(Xray, 1))
-end
-if server.type == "trojan" then
-	print(json.stringify(trojan, 1))
-end
-if server.type == "trojan-go" then
-    trojan.ssl.cipher = server.fingerprint == nil and cipher or (server.fingerprint == "disable" and cipher13 .. ":" .. cipher or "")
-    trojan.ssl.cipher_tls13 = server.fingerprint == nil and cipher13 or nil
-    trojan.ssl.fingerprint = (server.fingerprint ~= nil and server.fingerprint ~= "disable" ) and server.fingerprint or ""
-    trojan.ssl.alpn = server.trojan_transport == 'ws' and {} or {"h2", "http/1.1"}
-	if server.tls ~= "1" and server.trojan_transport == "original" then
-		trojan.ssl = nil
-		trojan.transport_plugin = server.trojan_transport == "original" and {
-			enabled = server.plugin_type ~= nil,
-			type = server.plugin_type or "plaintext",
-			command = server.plugin_type ~= "plaintext" and server.plugin_cmd or nil,
-			option = server.plugin_type ~= "plaintext" and server.plugin_option or nil,
-			arg = server.plugin_type ~= "plaintext" and { server.plugin_arg } or nil,
-			env = {}
-		} or nil	
+function config:handleIndex(index)
+	local switch = {
+		ss = function()
+			if server.plugin and server.plugin ~= "none" then
+				ss.plugin = server.plugin
+				ss.plugin_opts = server.plugin_opts or nil
+			end
+			print(json.stringify(ss, 1))
+		end,
+		ssr = function()
+			ss.protocol = server.protocol
+			ss.protocol_param = server.protocol_param
+			ss.method = server.encrypt_method
+			ss.obfs = server.obfs
+			ss.obfs_param = server.obfs_param
+			print(json.stringify(ss, 1))
+		end,
+		v2ray = function()
+			print(json.stringify(Xray, 1))
+		end,
+		trojan = function()
+			print(json.stringify(trojan, 1))
+		end,
+		trojan_go = function()
+			trojan.ssl.cipher = server.fingerprint == nil and cipher or (server.fingerprint == "disable" and cipher13 .. ":" .. cipher or "")
+			trojan.ssl.cipher_tls13 = server.fingerprint == nil and cipher13 or nil
+			trojan.ssl.fingerprint = (server.fingerprint ~= nil and server.fingerprint ~= "disable") and server.fingerprint or ""
+			trojan.ssl.alpn = server.trojan_transport == 'ws' and {} or {"h2", "http/1.1"}
+			if server.tls ~= "1" and server.trojan_transport == "original" then
+				--
+				trojan.ssl = nil
+				trojan.transport_plugin = server.trojan_transport == "original" and {
+					enabled = server.plugin_type ~= nil,
+					type = server.plugin_type or "plaintext",
+					command = server.plugin_type ~= "plaintext" and server.plugin_cmd or nil,
+					option = server.plugin_type ~= "plaintext" and server.plugin_option or nil,
+					arg = server.plugin_type ~= "plaintext" and {server.plugin_arg} or nil,
+					env = {}
+				} or nil
+			end
+			trojan.websocket = server.trojan_transport and server.trojan_transport:find('ws') and {
+				--
+				enabled = true,
+				path = server.ws_path or "/",
+				host = server.ws_host or (server.tls_host or server.server)
+			} or nil
+			trojan.shadowsocks = (server.ss_aead == "1") and {
+				--
+				enabled = true,
+				method = server.ss_aead_method or "aead_aes_128_gcm",
+				password = server.ss_aead_pwd or ""
+			} or nil
+			print(json.stringify(trojan, 1))
+		end,
+		naiveproxy = function()
+			print(json.stringify(naiveproxy, 1))
+		end
+	}
+	if switch[index] then
+		switch[index]()
 	end
-    trojan.websocket = server.trojan_transport and server.trojan_transport:find('ws') and {
-        enabled = true,
-        path = server.ws_path or "/",
-        host = server.ws_host or (server.tls_host or server.server)
-    } or nil
-    trojan.shadowsocks = (server.ss_aead == "1") and {
-        enabled = true,
-        method = server.ss_aead_method or "aead_aes_128_gcm",
-        password = server.ss_aead_pwd or ""
-    } or nil
-	print(json.stringify(trojan, 1))
-end
-if server.type == "naiveproxy" then
-	print(json.stringify(naiveproxy, 1))
 end
+local f = config:new()
+f:handleIndex(server.type)

+ 5 - 4
luci-app-ssr-plus/root/usr/share/shadowsocksr/subscribe.lua

@@ -232,7 +232,8 @@ local function processData(szType, content)
 		local userinfo = hostInfo[1]
 		local password = userinfo
 		result.alias = UrlDecode(alias)
-		result.type = "trojan"
+		result.type = "v2ray"
+		result.v2ray_protocol = "trojan"
 		result.server = host[1]
 		-- 按照官方的建议 默认验证ssl证书
 		result.insecure = "0"
@@ -459,11 +460,11 @@ local execute = function()
 				end
 			else
 				if not old.alias then
-					if not old.server or old.server_port then
-						ucic:delete(name, old['.name'])
-					else
+					if old.server or old.server_port then
 						old.alias = old.server .. ':' .. old.server_port
 						log('忽略手动添加的节点: ' .. old.alias)
+					else
+						ucic:delete(name, old['.name'])
 					end
 				else
 					log('忽略手动添加的节点: ' .. old.alias)

+ 0 - 4
naiveproxy/Makefile

@@ -128,10 +128,6 @@ define Build/Compile
 )
 endef
 
-define Package/naiveproxy/conffiles
-        /etc/config/naiveproxy
-endef
-
 define Package/naiveproxy/install
 	$(INSTALL_DIR) $(1)/usr/bin
 	$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/out/Release/naive $(1)/usr/bin/naive

+ 0 - 88
trojan-go/Makefile

@@ -1,88 +0,0 @@
-# Copyright (C) 2020 Lienol
-#
-# This is free software, licensed under the GNU General Public License v3.
-#
-
-include $(TOPDIR)/rules.mk
-
-PKG_NAME:=trojan-go
-PKG_VERSION:=0.8.2
-PKG_RELEASE:=1
-
-PKG_SOURCE_PROTO:=git
-PKG_SOURCE_URL:=https://github.com/p4gefau1t/trojan-go.git
-PKG_SOURCE_VERSION:=d051cf4c8852d708769ca1c4e514306a88da830b
-PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
-PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION)
-
-PKG_CONFIG_DEPENDS := \
-	CONFIG_TROJAN_GO_COMPRESS_GOPROXY \
-	CONFIG_TROJAN_GO_COMPRESS_UPX
-
-PKG_BUILD_DEPENDS:=golang/host
-PKG_BUILD_PARALLEL:=1
-PKG_USE_MIPS16:=0
-
-GO_PKG:=github.com/p4gefau1t/trojan-go
-GO_PKG_TAG:=-tags full
-GO_PKG_LDFLAGS:=-s -w
-GO_PKG_LDFLAGS_X:= \
-	$(GO_PKG)/constant.Version=$(PKG_VERSION) \
-	$(GO_PKG)/constant.Commit=$(PKG_SOURCE_VERSION)
-
-include $(INCLUDE_DIR)/package.mk
-include $(TOPDIR)/feeds/packages/lang/golang/golang-package.mk
-
-define Package/$(PKG_NAME)
-	SECTION:=net
-	CATEGORY:=Network
-	SUBMENU:=Web Servers/Proxies
-	DEPENDS:=$(GO_ARCH_DEPENDS)
-	TITLE:=An unidentifiable mechanism that helps you bypass GFW. It's compatible with original trojan with experimental features.
-	URL:=https://github.com/p4gefau1t/trojan-go
-endef
-
-define Package/$(PKG_NAME)/config
-
-menu "Configuration"
-	depends on PACKAGE_$(PKG_NAME)
-
-config TROJAN_GO_COMPRESS_GOPROXY
-	bool "Compiling with GOPROXY proxy"
-	default n
-
-config TROJAN_GO_COMPRESS_UPX
-	bool "Compress executable files with UPX"
-	default y
-
-endmenu
-
-endef
-
-ifeq ($(CONFIG_TROJAN_GO_COMPRESS_GOPROXY),y)
-export GO111MODULE=on
-export GOPROXY=https://goproxy.io
-#export GOPROXY=https://mirrors.aliyun.com/goproxy/
-endif
-
-define Build/Prepare
-	tar -zxvf $(DL_DIR)/$(PKG_SOURCE) -C $(PKG_BUILD_DIR) --strip-components 1
-endef
-
-define Build/Compile
-	$(eval GO_PKG_BUILD_PKG:=$(GO_PKG))
-	$(call GoPackage/Build/Configure)
-	$(call GoPackage/Build/Compile,$(GO_PKG_TAG))
-ifeq ($(CONFIG_TROJAN_GO_COMPRESS_UPX),y)
-	$(STAGING_DIR_HOST)/bin/upx --lzma --best $(GO_PKG_BUILD_BIN_DIR)/$(PKG_NAME) || true
-endif
-endef
-
-define Package/$(PKG_NAME)/install
-	$(call GoPackage/Package/Install/Bin,$(PKG_INSTALL_DIR))
-	$(INSTALL_DIR) $(1)/usr/bin
-	$(INSTALL_BIN) $(GO_PKG_BUILD_BIN_DIR)/$(PKG_NAME) $(1)/usr/bin/$(PKG_NAME)
-endef
-
-$(eval $(call GoBinPackage,$(PKG_NAME)))
-$(eval $(call BuildPackage,$(PKG_NAME)))