From 581d6c22cdeb339340071c8185507dcf03c0ed8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BB=83=E4=BA=AE=E6=96=8C?= <1129525450@qq.com> Date: Fri, 28 Feb 2020 23:19:38 +0800 Subject: [PATCH] luci-app-ssr-plus: add Trojan subscribe support (#3388) * add tl-wr720n-v3-16m * luci-app-ssr-plus: support trojan subscribe. --- .../luci-app-ssr-plus/po/zh-cn/ssr-plus.po | 2 +- .../root/usr/share/shadowsocksr/subscribe.lua | 39 +++++++++++++++++-- target/linux/ar71xx/image/tiny-tp-link.mk | 11 ++++++ 3 files changed, 47 insertions(+), 5 deletions(-) diff --git a/package/lean/luci-app-ssr-plus/po/zh-cn/ssr-plus.po b/package/lean/luci-app-ssr-plus/po/zh-cn/ssr-plus.po index a97fd1db7..4a2875cd4 100644 --- a/package/lean/luci-app-ssr-plus/po/zh-cn/ssr-plus.po +++ b/package/lean/luci-app-ssr-plus/po/zh-cn/ssr-plus.po @@ -422,7 +422,7 @@ msgid "Auto Update Server subscription, GFW list and CHN route" msgstr "自动更新服务器订阅、GFW列表和 CHN路由表" msgid "Subscribe URL" -msgstr "SS/SSR/V2RAY订阅URL地址" +msgstr "SS/SSR/V2RAY/Trojan订阅URL地址" msgid "Update" msgstr "更新" diff --git a/package/lean/luci-app-ssr-plus/root/usr/share/shadowsocksr/subscribe.lua b/package/lean/luci-app-ssr-plus/root/usr/share/shadowsocksr/subscribe.lua index 2819b978c..131919ad8 100644 --- a/package/lean/luci-app-ssr-plus/root/usr/share/shadowsocksr/subscribe.lua +++ b/package/lean/luci-app-ssr-plus/root/usr/share/shadowsocksr/subscribe.lua @@ -223,6 +223,37 @@ local function processData(szType, content) result.plugin = content.plugin result.plugin_opts = content.plugin_options result.alias = "[" .. content.airport .. "] " .. content.remarks + elseif szType == "trojan" then + local idx_sp = 0 + local alias = "" + if content:find("#") then + idx_sp = content:find("#") + alias = content:sub(idx_sp + 1, -1) + end + local info = content:sub(1, idx_sp - 1) + local hostInfo = split(info, "@") + local host = split(hostInfo[2], ":") + local userinfo = hostInfo[1] + local password = userinfo + result.alias = UrlDecode(alias) + result.type = "trojan" + result.server = host[1] + if host[2]:find("?") then + local query = split(host[2], "?") + result.server_port = query[1] + local params = {} + for _, v in pairs(split(query[2], '&')) do + local t = split(v, '=') + params[t[1]] = t[2] + end + if params.peer then + result.tls = "1" + result.tls_host = params.peer + end + else + result.server_port = host[2] + end + result.password = password end if not result.alias then result.alias = result.server .. ':' .. result.server_port @@ -289,7 +320,7 @@ local execute = function() local node = trim(v) local dat = split(node, "://") if dat and dat[1] and dat[2] then - if dat[1] == 'ss' then + if dat[1] == 'ss' or dat[1] == 'trojan' then result = processData(dat[1], dat[2]) else result = processData(dat[1], base64Decode(dat[2])) @@ -342,9 +373,9 @@ local execute = function() setmetatable(nodeResult[old.grouphashkey][old.hashkey], { __index = { _ignore = true } }) end else - if not old.alias then - old.alias = old.server .. ':' .. old.server_port - end + if not old.alias then + old.alias = old.server .. ':' .. old.server_port + end log('忽略手动添加的节点: ' .. old.alias) end diff --git a/target/linux/ar71xx/image/tiny-tp-link.mk b/target/linux/ar71xx/image/tiny-tp-link.mk index 340a2a7ec..a0b42ae7c 100644 --- a/target/linux/ar71xx/image/tiny-tp-link.mk +++ b/target/linux/ar71xx/image/tiny-tp-link.mk @@ -383,6 +383,17 @@ define Device/tl-wr720n-v3 endef TARGET_DEVICES += tl-wr720n-v3 +define Device/tl-wr720n-v3-16m + $(Device/tplink-16mlzma) + DEVICE_TITLE := TP-LINK TL-WR720N v3 16M + DEVICE_PACKAGES := kmod-usb-core kmod-usb2 + BOARDNAME := TL-WR720N-v3 + DEVICE_PROFILE := TLWR720 + TPLINK_HWID := 0x07200103 + CONSOLE := ttyATH0,115200 +endef +TARGET_DEVICES += tl-wr720n-v3-16m + define Device/tl-wr720n-v4 $(Device/tl-wr720n-v3) DEVICE_TITLE := TP-LINK TL-WR720N v4