From 15c55dfb99013eccc2b58125260cbfe7d8715f41 Mon Sep 17 00:00:00 2001 From: coolsnowwolf Date: Tue, 23 Apr 2019 15:03:40 +0800 Subject: [PATCH] luci ssr plus: sort socks5 servers --- package/lean/luci-app-ssr-plus/Makefile | 2 +- .../luasrc/model/cbi/shadowsocksr/advanced.lua | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/package/lean/luci-app-ssr-plus/Makefile b/package/lean/luci-app-ssr-plus/Makefile index 06d730392..15b40708d 100644 --- a/package/lean/luci-app-ssr-plus/Makefile +++ b/package/lean/luci-app-ssr-plus/Makefile @@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-ssr-plus PKG_VERSION:=1 -PKG_RELEASE:=90 +PKG_RELEASE:=91 PKG_CONFIG_DEPENDS:= CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Shadowsocks \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_V2ray \ diff --git a/package/lean/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/advanced.lua b/package/lean/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/advanced.lua index 5d9334823..5c7657424 100644 --- a/package/lean/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/advanced.lua +++ b/package/lean/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/advanced.lua @@ -3,13 +3,20 @@ local uci = luci.model.uci.cursor() local server_table = {} uci:foreach(shadowsocksr, "servers", function(s) - if s.alias and s.type == "ssr" then - server_table[s[".name"]] = s.alias - elseif s.server and s.server_port and s.type == "ssr" then - server_table[s[".name"]] = "%s:%s" %{s.server, s.server_port} + 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 end) +local key_table = {} +for key,_ in pairs(server_table) do + table.insert(key_table,key) +end + +table.sort(key_table) + m = Map(shadowsocksr) s = m:section(TypedSection, "global", translate("Server failsafe auto swith settings")) @@ -38,7 +45,7 @@ s.anonymous = true o = s:option(ListValue, "server", translate("Server")) o:value("nil", translate("Disable")) -for k, v in pairs(server_table) do o:value(k, v) end +for _,key in pairs(key_table) do o:value(key,server_table[key]) end o.default = "nil" o.rmempty = false