From eff0f23129d40db3cf92e30d02aa8a6daeb48c68 Mon Sep 17 00:00:00 2001 From: CN_SZTL Date: Sun, 16 Feb 2020 22:59:53 +0800 Subject: [PATCH] luci-app-ssr-plus-Jo: sync with upstream source --- package/ctcgfw/luci-app-ssr-plus-Jo/Makefile | 20 +- .../luasrc/controller/shadowsocksr.lua | 2 +- .../luasrc/model/cbi/shadowsocksr/client.lua | 55 ++++ .../po/zh_Hans/ssr-plus.zh-cn.lmo | Bin 9152 -> 9516 bytes .../usr/share/shadowsocksr/genv2config.lua | 254 ++++++++++++------ 5 files changed, 235 insertions(+), 96 deletions(-) diff --git a/package/ctcgfw/luci-app-ssr-plus-Jo/Makefile b/package/ctcgfw/luci-app-ssr-plus-Jo/Makefile index a286df7d5a..0f4924be94 100644 --- a/package/ctcgfw/luci-app-ssr-plus-Jo/Makefile +++ b/package/ctcgfw/luci-app-ssr-plus-Jo/Makefile @@ -1,11 +1,11 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-ssr-plus-Jo -PKG_VERSION:=1.45 +PKG_VERSION:=1.46 PKG_RELEASE:=8 PKG_CONFIG_DEPENDS:= CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Shadowsocks \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_V2ray \ - CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Trojan \ + CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Trojan \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Kcptun:kcptun \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_ShadowsocksR_Server \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Shadowsocks_Server \ @@ -16,8 +16,8 @@ PKG_CONFIG_DEPENDS:= CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Shadowsocks \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_dnsforwarder \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_ChinaDNS \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_haproxy \ - CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_udpspeeder \ - CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_udp2raw-tunnel \ + CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_udpspeeder \ + CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_udp2raw-tunnel \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_privoxy \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_simple-obfs\ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_simple-obfs-server\ @@ -59,10 +59,10 @@ config PACKAGE_$(PKG_NAME)_INCLUDE_ShadowsocksR_Socks config PACKAGE_$(PKG_NAME)_INCLUDE_Shadowsocks_Socks bool "Include Shadowsocks Socks and Tunnel" default y - + config PACKAGE_$(PKG_NAME)_INCLUDE_ipt2socks bool "Include ipt2socks" - default y + default y config PACKAGE_$(PKG_NAME)_INCLUDE_dnscrypt_proxy bool "Include dnscrypt-proxy-full" @@ -91,7 +91,7 @@ config PACKAGE_$(PKG_NAME)_INCLUDE_simple-obfs config PACKAGE_$(PKG_NAME)_INCLUDE_simple-obfs-server bool "Include simple-obfs-server" default y - + config PACKAGE_$(PKG_NAME)_INCLUDE_udpspeeder bool "Include udpspeeder" default y @@ -99,11 +99,11 @@ config PACKAGE_$(PKG_NAME)_INCLUDE_udpspeeder config PACKAGE_$(PKG_NAME)_INCLUDE_udp2raw-tunnel bool "Include udp2raw-tunnel" default y - + config PACKAGE_$(PKG_NAME)_INCLUDE_GoQuiet-client bool "Include GoQuiet-client" default y - + config PACKAGE_$(PKG_NAME)_INCLUDE_GoQuiet-server bool "Include GoQuiet-server" default y @@ -128,7 +128,7 @@ define Package/luci-app-ssr-plus-Jo +PACKAGE_$(PKG_NAME)_INCLUDE_Shadowsocks_Server:shadowsocks-libev-ss-server \ +PACKAGE_$(PKG_NAME)_INCLUDE_ShadowsocksR_Socks:shadowsocksr-libev-ssr-local \ +PACKAGE_$(PKG_NAME)_INCLUDE_Shadowsocks_Socks:shadowsocks-libev-ss-local \ - +PACKAGE_$(PKG_NAME)_INCLUDE_ipt2socks:ipt2socks \ + +PACKAGE_$(PKG_NAME)_INCLUDE_ipt2socks:ipt2socks \ +PACKAGE_$(PKG_NAME)_INCLUDE_dnscrypt_proxy:dnscrypt-proxy-full \ +PACKAGE_$(PKG_NAME)_INCLUDE_dnsforwarder:dnsforwarder \ +PACKAGE_$(PKG_NAME)_INCLUDE_ChinaDNS:openwrt_chinadns \ diff --git a/package/ctcgfw/luci-app-ssr-plus-Jo/luasrc/controller/shadowsocksr.lua b/package/ctcgfw/luci-app-ssr-plus-Jo/luasrc/controller/shadowsocksr.lua index dc51ea28b7..3eb8a231e1 100644 --- a/package/ctcgfw/luci-app-ssr-plus-Jo/luasrc/controller/shadowsocksr.lua +++ b/package/ctcgfw/luci-app-ssr-plus-Jo/luasrc/controller/shadowsocksr.lua @@ -7,7 +7,7 @@ function index() return end if nixio.fs.access("/usr/bin/ssr-redir") then - entry({"admin", "vpn"}, firstchild(), "VPN", 45).dependent = false + entry({"admin", "vpn"}, firstchild(), "VPN", 45).dependent = false entry({"admin", "vpn", "shadowsocksr"},alias("admin", "vpn", "shadowsocksr", "client"), _("ShadowSocksR Plus+"),10).dependent = true entry({"admin", "vpn", "shadowsocksr", "client"},cbi("shadowsocksr/client"),_("SSR Client"),10).leaf = true entry({"admin", "vpn", "shadowsocksr", "servers"}, cbi("shadowsocksr/servers"), _("Severs Nodes"), 11).leaf = true diff --git a/package/ctcgfw/luci-app-ssr-plus-Jo/luasrc/model/cbi/shadowsocksr/client.lua b/package/ctcgfw/luci-app-ssr-plus-Jo/luasrc/model/cbi/shadowsocksr/client.lua index e295d590c0..4f4779d8b5 100644 --- a/package/ctcgfw/luci-app-ssr-plus-Jo/luasrc/model/cbi/shadowsocksr/client.lua +++ b/package/ctcgfw/luci-app-ssr-plus-Jo/luasrc/model/cbi/shadowsocksr/client.lua @@ -33,12 +33,20 @@ m = Map(shadowsocksr) m:section(SimpleSection).template = "shadowsocksr/status" local server_table = {} +local v2ray_table = {} uci:foreach(shadowsocksr, "servers", function(s) if s.alias then server_table[s[".name"]] = "[%s]:%s" %{string.upper(s.type), s.alias} elseif s.server and s.server_port then server_table[s[".name"]] = "[%s]:%s:%s" %{string.upper(s.type), s.server, s.server_port} end +if s.type == "v2ray" then + if s.alias then + v2ray_table[s[".name"]] = "[%s]:%s" %{string.upper(s.type), s.alias} + elseif s.server and s.server_port then + v2ray_table[s[".name"]] = "[%s]:%s:%s" %{string.upper(s.type), s.server, s.server_port} + end + end end) local key_table = {} @@ -48,6 +56,13 @@ end table.sort(key_table) +local key_table_v2 = {} +for key,_ in pairs(v2ray_table) do + table.insert(key_table_v2,key) +end + +table.sort(key_table_v2) + -- [[ Global Setting ]]-- s = m:section(TypedSection, "global", translate("Server settings")) s.anonymous = true @@ -66,6 +81,46 @@ o:value("", translate("Disable")) o:value("same", translate("Same as Global Server")) for _,key in pairs(key_table) do o:value(key,server_table[key]) end +o = s:option(Flag, "v2ray_flow", translate("Open v2ray split-flow")) +o.rmempty = false +o.description = translate("When open v2ray split-flow,your main server must be a v2ray server") + +o = s:option(ListValue, "youtube_server", translate("Youtube Proxy")) +o:value("nil", translate("Same as Global Server")) +for _,key in pairs(key_table_v2) do o:value(key,v2ray_table[key]) end +o:depends("v2ray_flow", "1") +o.default = "nil" + + + +o = s:option(ListValue, "tw_video_server", translate("TaiWan Video Proxy")) +o:value("nil", translate("Same as Global Server")) +for _,key in pairs(key_table_v2) do o:value(key,v2ray_table[key]) end +o:depends("v2ray_flow", "1") +o.default = "nil" + + +o = s:option(ListValue, "netflix_server", translate("Netflix Proxy")) +o:value("nil", translate("Same as Global Server")) +for _,key in pairs(key_table_v2) do o:value(key,v2ray_table[key]) end +o:depends("v2ray_flow", "1") +o.default = "nil" + + +o = s:option(ListValue, "disney_server", translate("Diseny+ Proxy")) +o:value("nil", translate("Same as Global Server")) +for _,key in pairs(key_table_v2) do o:value(key,v2ray_table[key]) end +o:depends("v2ray_flow", "1") +o.default = "nil" + + +o = s:option(ListValue, "prime_server", translate("Prime Video Proxy")) +o:value("nil", translate("Same as Global Server")) +for _,key in pairs(key_table_v2) do o:value(key,v2ray_table[key]) end +o:depends("v2ray_flow", "1") +o.default = "nil" + + o = s:option(ListValue, "threads", translate("Multi Threads Option")) o:value("0", translate("Auto Threads")) o:value("1", translate("1 Thread")) diff --git a/package/ctcgfw/luci-app-ssr-plus-Jo/po/zh_Hans/ssr-plus.zh-cn.lmo b/package/ctcgfw/luci-app-ssr-plus-Jo/po/zh_Hans/ssr-plus.zh-cn.lmo index 150c9efccef4a1ff4ca3841d935c361696ceacf8..dfc4e6b40684a23848effc7a0582ebc8146863e0 100644 GIT binary patch delta 4375 zcmZ9Odt8j`7RTSFF*VaWm!_tBDWWJ!iqLjDc1Y!tP?E|-9g*D>$z_U)65T~YDM?7| zr0C`zyA*QEEt%;?7lbJG`91j@`*Y48FYotR>sjl!)_UG&s+xV;Awf&(;^!?6+~g9t zYOQ3E;evn=iJ4*hnUt24($<*W@`SUkDR~qnkH{GOza{OsyfO`377o)At03>q^4-xb z7a}OEl_$%}E8({BpJjRM(YBrCEosGuvXaX!8GGfiS@MH<^2(_8tjn^JOC*4Fvs++D zaEOnuq3m*YYeF;v#TT}eR%>Kzd9OX;7V znDZHbdMRmf7W`Uki`~(>qqMEySo?t}S;@ZEf-I=+F5BIba<(Nd;^(?NDXt}Ek32R{ zezr^=b=<{ek;RgAz7k1$az)F&j-uhh=yDFnu%>tu`*ak;2QJU7>+HNKXi&DuE?qwg6Mj% zaOg)HlM}(E`!E7Am^PfgD|^Uooh*!$6wEg~_W7XO9jX5dw3H}f8|k?!`FK?0gJTlr z8|meIuwG(``K#N3M;QI}YRb9RPe?`^f>nn-(8x>77z2TfP%u60mBPrahZT0fn2=_yn|7^Fb;y8t>E{ zbo+!azG6j^K-XF@YkO{Z!5s)J1M{u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)QxUxeHL3Ld!`Uv0x)|6%T1(uKK4#)l^=T={K zHzmR%cJq0#0a&oYCT2tE+rj1*4G5J)OQuWXM? zopSFa64YqG`jmLppnx{t_)o|{lmZ81--YE$LHh(RP|{!$fbi_(=Lo180~Yv(MuoWW zmS9h)TYzV*R?vhAjR|3J zd_;n6n;FW>Cg++jPwii|wPPDz;Q4_iA&l1WobBTUa3#A~6ykKEIwtJi2iT3khM|@- z3Oug#!Ud6W12AX5ODF%5Ms697kv&*=AUoN|}6tH3J9nPx0z#&k~F98pW{dAkrQ**Nx8K;4zho-o<9sXtf1_3R=biB^5 z#y^{oLxT;HD)(vnm@jKUMa~j?ieNKeduc1Or%44wDH(#eb1mAn=s%r_3GT5U_uIlV z-atL?GkAFF{wHRK=6=J8;F6XIQzJ#DyX|ie!I=DMrIjRCd*{4W!Y)>T4KutF&bCOxNb{5s6A(O!geEwTcO3+CGr&nFKY0}uhC2TB(d5njFcI##wPTw*%ia=yRQUhoDm zT~g!EYjI4%F;dY4b4ml#G}5(_Euf_jtX7(HGr4C=&;^Vm@fbdI+2-J=qf!VH+D1tp z#yJR_au%Wmv;r(FJ0kCT)t=Fco@opahw}J^jW&g9a8M%^5IsJwA9i+K76kFiz#0|1 z7)5`sQWYYQuKcU@zUgVF7Wkh9ODj9=j!j?02*InL!Ftcw&m!kHsboUyJFwun=Kbtk z|A%614>jw_~K4>uUxDV{Cwj{m$+7%cl2#qo>?Fu(<)wV$GQ^IB=F~u?|5R%ebSOJ5%vUwoNM8?sIs5y{^vCp$&dv^->%k- zJNn8W38*dutM`q(ws@lLKphfNfCYV^0LE_BJo|qSdbHF4 diff --git a/package/ctcgfw/luci-app-ssr-plus-Jo/root/usr/share/shadowsocksr/genv2config.lua b/package/ctcgfw/luci-app-ssr-plus-Jo/root/usr/share/shadowsocksr/genv2config.lua index dd3a323c51..c5c301cc6f 100644 --- a/package/ctcgfw/luci-app-ssr-plus-Jo/root/usr/share/shadowsocksr/genv2config.lua +++ b/package/ctcgfw/luci-app-ssr-plus-Jo/root/usr/share/shadowsocksr/genv2config.lua @@ -1,96 +1,180 @@ -local ucursor = require "luci.model.uci".cursor() +local ucursor = require"luci.model.uci".cursor() +local name = "shadowsocksr" local json = require "luci.jsonc" local server_section = arg[1] -local proto = arg[2] - +local proto = arg[2] local local_port = arg[3] +local host = arg[4] -local server = ucursor:get_all("shadowsocksr", server_section) +local v2ray_flow = ucursor:get_first(name, 'global', 'v2ray_flow', '0') +local youtube_server = ucursor:get_first(name, 'global', 'youtube_server') +local tw_video_server = ucursor:get_first(name, 'global', 'tw_video_server') +local netflix_server = ucursor:get_first(name, 'global', 'netflix_server') +local disney_server = ucursor:get_first(name, 'global', 'disney_server') +local prime_server = ucursor:get_first(name, 'global', 'prime_server') -local v2ray = { - log = { - -- error = "/var/ssrplus.log", - loglevel = "warning" - }, - -- 传入连接 - inbound = { - port = local_port, - protocol = "dokodemo-door", - settings = { - network = proto, - followRedirect = true - }, - sniffing = { - enabled = true, - destOverride = { "http", "tls" } - } - }, - -- 传出连接 - outbound = { - protocol = "vmess", - settings = { - vnext = { - { - address = server.server, - port = tonumber(server.server_port), - users = { - { - id = server.vmess_id, - alterId = tonumber(server.alter_id), - security = server.security +function gen_outbound(server_node, tags) + local bound = {} + if server_node == "nil" then + bound = nil + else + local server = ucursor:get_all(name, server_node) + bound = { + tag = tags, + protocol = "vmess", + settings = { + vnext = { + { + address = server.server, + port = tonumber(server.server_port), + users = { + { + id = server.vmess_id, + alterId = tonumber(server.alter_id), + security = server.security + } } } } - } - }, - -- 底层传输配置 - streamSettings = { - network = server.transport, - security = (server.tls == '1') and "tls" or "none", - tlsSettings = {allowInsecure = (server.insecure == "1") and true or false,}, - kcpSettings = (server.transport == "kcp") and { - mtu = tonumber(server.mtu), - tti = tonumber(server.tti), - uplinkCapacity = tonumber(server.uplink_capacity), - downlinkCapacity = tonumber(server.downlink_capacity), - congestion = (server.congestion == "1") and true or false, - readBufferSize = tonumber(server.read_buffer_size), - writeBufferSize = tonumber(server.write_buffer_size), - header = { - type = server.kcp_guise - } - } or nil, - wsSettings = (server.transport == "ws") and { - path = server.ws_path, - headers = (server.ws_host ~= nil) and { - Host = server.ws_host + }, + -- 底层传输配置 + streamSettings = { + network = server.transport, + security = (server.tls == '1') and "tls" or "none", + tlsSettings = { + allowInsecure = (server.insecure == "1") and true or false, + serverName = server.ws_host + }, + kcpSettings = (server.transport == "kcp") and { + mtu = tonumber(server.mtu), + tti = tonumber(server.tti), + uplinkCapacity = tonumber(server.uplink_capacity), + downlinkCapacity = tonumber(server.downlink_capacity), + congestion = (server.congestion == "1") and true or false, + readBufferSize = tonumber(server.read_buffer_size), + writeBufferSize = tonumber(server.write_buffer_size), + header = {type = server.kcp_guise} } or nil, - } or nil, - httpSettings = (server.transport == "h2") and { - path = server.h2_path, - host = server.h2_host, - } or nil, - quicSettings = (server.transport == "quic") and { - security = server.quic_security, - key = server.quic_key, - header = { - type = server.quic_guise - } - } or nil - }, - mux = { - enabled = (server.mux == "1") and true or false, - concurrency = tonumber(server.concurrency) - } - }, - - -- 额外传出连接 - outboundDetour = { - { - protocol = "freedom", - tag = "direct", - settings = { keep = "" } + wsSettings = (server.transport == "ws") and + (server.ws_path ~= nil or server.ws_host ~= nil) and { + path = server.ws_path, + headers = (server.ws_host ~= nil) and + {Host = server.ws_host} or nil + } or nil, + httpSettings = (server.transport == "h2") and + {path = server.h2_path, host = server.h2_host} or nil, + quicSettings = (server.transport == "quic") and { + security = server.quic_security, + key = server.quic_key, + header = {type = server.quic_guise} + } or nil + }, + mux = { + enabled = (server.mux == "1") and true or false, + concurrency = tonumber(server.concurrency) + } } - } + end + return bound +end + +local outbounds_table = {} + +table.insert(outbounds_table, gen_outbound(server_section, "main")) +if v2ray_flow == "1" then + table.insert(outbounds_table, gen_outbound(youtube_server, "youtube")) + table.insert(outbounds_table, gen_outbound(tw_video_server, "twvideo")) + table.insert(outbounds_table, gen_outbound(netflix_server, "netflix")) + table.insert(outbounds_table, gen_outbound(disney_server, "disney")) + table.insert(outbounds_table, gen_outbound(prime_server, "prime")) +end + +-- rules gen + +local youtube_rule = { + type = "field", + domain = {"youtube", "googlevideo.com", "gvt2.com", "youtu.be"}, + outboundTag = "youtube" } -print(json.stringify(v2ray, 1)) + +local tw_video_rule = { + type = "field", + domain = { + "vidol.tv", "hinet.net", "books.com", "litv.tv", "pstatic.net", + "app-measurement.com", "kktv.com.tw", "gamer.com.tw" + }, + outboundTag = "twvideo" +} + +local netflix_rule = { + type = "field", + domain = { + "netflix.com", "netflix.net", "nflxso.net", "nflxext.com", + "nflximg.com", "nflximg.net", "nflxvideo.net" + }, + ip = { + "23.246.0.0/12", "37.77.0.0/12", "45.57.0.0/12", "64.120.128.0/17", + "66.197.128.0/17", "108.175.0.0/12", "185.2.0.0/12", "185.9.188.0/22", + "192.173.64.0/18", "198.38.0.0/12", "198.45.0.0/12" + }, + outboundTag = "netflix" +} + +local disney_rule = { + type = "field", + domain = { + "cdn.registerdisney.go.com", "disneyplus.com", "disney-plus.net", + "dssott.com", "bamgrid.com", "execute-api.us-east-1.amazonaws.com" + }, + outboundTag = "disney" +} + +local prime_rule = { + type = "field", + domain = {"aiv-cdn.net", "amazonaws.com", "amazonvideo.com", "llnwd.net"}, + outboundTag = "prime" +} + +local rules_table = {} + +if (youtube_server ~= "nil" and v2ray_flow == "1") then + table.insert(rules_table, youtube_rule) +end + +if (tw_video_server ~= "nil" and v2ray_flow == "1") then + table.insert(rules_table, tw_video_rule) +end + +if (netflix_server ~= "nil" and v2ray_flow == "1") then + table.insert(rules_table, netflix_rule) +end + +if (disney_server ~= "nil" and v2ray_flow == "1") then + table.insert(rules_table, disney_rule) +end + +if (prime_server ~= "nil" and v2ray_flow == "1") then + table.insert(rules_table, prime_rule) +end + +local v2ray = { + log = { + -- error = "/var/ssrplus.log", + loglevel = "warning" + }, + -- 传入连接 + inbounds = { + { + port = local_port, + protocol = "dokodemo-door", + settings = {network = proto, followRedirect = true}, + sniffing = {enabled = true, destOverride = {"http", "tls"}} + } + + }, + -- 传出连接 + outbounds = outbounds_table, + routing = {domainStrategy = "IPIfNonMatch", rules = rules_table} + +} +print(json.stringify(v2ray, 1)) \ No newline at end of file