Bladeren bron

Merge pull request #1685 from zxlhhyccc/socks

luci-app-ssr-plus: Fix when `SOCKS5` is initial disabled `Netflix` shunt faild issue.
zxl hhyccc 8 maanden geleden
bovenliggende
commit
dc8a87a5fd

+ 3 - 3
luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/advanced.lua

@@ -169,15 +169,15 @@ o.rmempty = false
 o.cfgvalue = function(self, section)
     local enabled = m:get(section, "enabled")
     if enabled == "0" then
-        return m:get(section, "old_server") or "same"
+        return m:get(section, "old_server")
     end
-    return Value.cfgvalue(self, section) or "same" -- Default to `same` when enabled
+    return Value.cfgvalue(self, section) -- Default to `same` when enabled
 end
 
 o.write = function(self, section, value)
     local enabled = m:get(section, "enabled")
     if enabled == "0" then
-        local old_server = Value.cfgvalue(self, section) or "same"
+        local old_server = Value.cfgvalue(self, section)
         if old_server ~= "nil" then
             m:set(section, "old_server", old_server)
         end

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

@@ -543,6 +543,8 @@ shunt_dns_config_file_port() {
                    jq --arg port "$port" '.inbounds |= .[0:1] + [{"protocol":"socks","port":($port | tonumber),"settings":{"udp":true,"auth":"noauth"}}] + .[1:]' "$shunt_config_file" > "$shunt_config_file.tmp" && mv "$shunt_config_file.tmp" $shunt_config_file
             echo "$port"  # 返回端口号
             return 0  # 成功返回
+        else
+            sed -i -e '/"mixed"/d' $shunt_config_file
         fi
     else
         # NetFlix 和 全局 socks 节点不相同
@@ -553,6 +555,8 @@ shunt_dns_config_file_port() {
                    -e '/"mixed"/d' \
                    -e 's/"auth"\s*:\s*"password"/\"auth\": \"noauth\"/g' \
                    -e '/"accounts": \[/,/\]/d' $shunt_config_file
+        else
+            sed -i -e '/"mixed"/d' $shunt_config_file
         fi
     fi
     # 使用传入的端口

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

@@ -184,11 +184,11 @@ if proto and proto:find("tcp") and socks_port ~= "0" then
         -- socks
         protocol = "socks",
         port = tonumber(socks_port),
-        settings = (socks_server.server ~= "same") and {
-			auth = socks_server.socks5_auth,
+        settings = {
+			auth = socks_server.socks5_auth or "noauth",
 			udp = true,
-			mixed = (socks_server.socks5_mixed == '1') and true or false,
-			accounts = (socks_server.socks5_auth ~= "noauth") and {
+			mixed = ((socks_server.socks5_mixed == '1') and true or false) or (socks_server.server == 'same') and nil,
+			accounts = (socks_server.server ~= "same" and (socks_server.socks5_auth and socks_server.socks5_auth ~= "noauth")) and {
 				{
 					user = socks_server.socks5_user,
 					pass = socks_server.socks5_pass