diff --git a/luci-app-ssr-plus/Makefile b/luci-app-ssr-plus/Makefile index 04875d49d6d..907e975780d 100644 --- a/luci-app-ssr-plus/Makefile +++ b/luci-app-ssr-plus/Makefile @@ -1,8 +1,8 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-ssr-plus -PKG_VERSION:=189 -PKG_RELEASE:=2 +PKG_VERSION:=189.2 +PKG_RELEASE:= PKG_CONFIG_DEPENDS:= \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_NONE_V2RAY \ diff --git a/luci-app-ssr-plus/root/etc/init.d/shadowsocksr b/luci-app-ssr-plus/root/etc/init.d/shadowsocksr index 4029a074380..9a4d2d70e1b 100755 --- a/luci-app-ssr-plus/root/etc/init.d/shadowsocksr +++ b/luci-app-ssr-plus/root/etc/init.d/shadowsocksr @@ -17,14 +17,10 @@ LOCK_FILE=/var/lock/ssrplus.lock LOG_FILE=/var/log/ssrplus.log TMP_PATH=/var/etc/ssrplus TMP_BIN_PATH=$TMP_PATH/bin -# 获取默认的 DNSMasq 配置 ID -DEFAULT_DNSMASQ_CFGID=$(uci show dhcp.@dnsmasq[0] | awk -F '.' '{print $2}' | awk -F '=' '{print $1}' | head -1) -# 查找包含 conf-dir 选项的 dnsmasq.conf 文件路径 -DNSMASQ_CONF_PATH=$(grep -l "^conf-dir=" "/tmp/etc/dnsmasq.conf.${DEFAULT_DNSMASQ_CFGID}") -# 从 conf-dir 行中提取目录路径 -DNSMASQ_CONF_DIR=$(grep '^conf-dir=' "$DNSMASQ_CONF_PATH" | cut -d'=' -f2 | head -n 1) -# 设置 TMP_DNSMASQ_PATH,并去除路径末尾的斜杠 -TMP_DNSMASQ_PATH=${DNSMASQ_CONF_DIR%*/}/dnsmasq-ssrplus.d +# Ensure DNSMASQ_CONF_DIR and TMP_DNSMASQ_PATH is set correctly +[ -f /etc/openwrt_release ] && { + eval $(lua /usr/share/shadowsocksr/dnsmasqconfdir.lua) +} chain_config_file= #generate shadowtls chain proxy config file tcp_config_file= diff --git a/luci-app-ssr-plus/root/usr/share/shadowsocksr/dnsmasqconfdir.lua b/luci-app-ssr-plus/root/usr/share/shadowsocksr/dnsmasqconfdir.lua new file mode 100755 index 00000000000..79c25f7cd59 --- /dev/null +++ b/luci-app-ssr-plus/root/usr/share/shadowsocksr/dnsmasqconfdir.lua @@ -0,0 +1,40 @@ +#!/usr/bin/lua + +local uci = require("uci") +local cursor = uci.cursor() + +-- Function to get the DNSMasq configuration ID +local function get_dnsmasq_cfg_id() + local id = nil + cursor:foreach("dhcp", "dnsmasq", function(s) + if not id then + id = s[".name"] -- Get the internal ID of the first dnsmasq entry + end + end) + return id +end + +-- Get the DNSMasq configuration ID +local DEFAULT_DNSMASQ_CFGID = get_dnsmasq_cfg_id() +local DNSMASQ_CONF_DIR = nil +local TMP_DNSMASQ_PATH = nil + +if DEFAULT_DNSMASQ_CFGID then + local dnsmasq_conf_path = io.popen("grep -l '^conf-dir=' /tmp/etc/dnsmasq.conf." .. DEFAULT_DNSMASQ_CFGID):read("*a") + dnsmasq_conf_path = dnsmasq_conf_path:gsub("%s+", "") -- Trim whitespace + + if dnsmasq_conf_path ~= "" then + local dnsmasq_conf_dir = io.popen("grep '^conf-dir=' " .. dnsmasq_conf_path .. " | cut -d'=' -f2 | head -n 1"):read("*a") + dnsmasq_conf_dir = dnsmasq_conf_dir:gsub("%s+", "") -- Trim whitespace + + if dnsmasq_conf_dir ~= "" then + DNSMASQ_CONF_DIR = dnsmasq_conf_dir:gsub("/$", "") -- Remove trailing slash + TMP_DNSMASQ_PATH = DNSMASQ_CONF_DIR .. "/dnsmasq-ssrplus.d" + end + end +end + +-- Output variables in a format usable by shell scripts +io.write("DNSMASQ_CONF_DIR='", DNSMASQ_CONF_DIR or "", "'\n") +io.write("TMP_DNSMASQ_PATH='", TMP_DNSMASQ_PATH or "", "'\n") + diff --git a/luci-app-ssr-plus/root/usr/share/shadowsocksr/update.lua b/luci-app-ssr-plus/root/usr/share/shadowsocksr/update.lua index d9fa08060b5..b242c888a9d 100755 --- a/luci-app-ssr-plus/root/usr/share/shadowsocksr/update.lua +++ b/luci-app-ssr-plus/root/usr/share/shadowsocksr/update.lua @@ -9,13 +9,20 @@ require "luci.model.uci" local icount = 0 local args = arg[1] local uci = luci.model.uci.cursor() -local TMP_DNSMASQ_PATH = luci.sys.exec("find /tmp/dnsmasq.*/dnsmasq-ssrplus.d -type d -print 2>/dev/null"):gsub("%s+", "") +-- Execute the Lua script and capture its output +local TMP_DNSMASQ_CONF_OUTPUT = io.popen("lua /usr/share/shadowsocksr/dnsmasqconfdir.lua"):read("*a") +-- Extract only the TMP_DNSMASQ_PATH value using a pattern +local TMP_DNSMASQ_PATH = TMP_DNSMASQ_CONF_OUTPUT:match("TMP_DNSMASQ_PATH=['\"]([^\"]+)['\"]") local TMP_PATH = "/var/etc/ssrplus" -- match comments/title/whitelist/ip address/excluded_domain local comment_pattern = "^[!\\[@]+" local ip_pattern = "^%d+%.%d+%.%d+%.%d+" local domain_pattern = "([%w%-%_]+%.[%w%.%-%_]+)[%/%*]*" -local excluded_domain = {"apple.com", "sina.cn", "sina.com.cn", "baidu.com", "byr.cn", "jlike.com", "weibo.com", "zhongsou.com", "youdao.com", "sogou.com", "so.com", "soso.com", "aliyun.com", "taobao.com", "jd.com", "qq.com"} +local excluded_domain = { + "apple.com", "sina.cn", "sina.com.cn", "baidu.com", "byr.cn", "jlike.com", + "weibo.com", "zhongsou.com", "youdao.com", "sogou.com", "so.com", "soso.com", + "aliyun.com", "taobao.com", "jd.com", "qq.com" +} -- gfwlist parameter local mydnsip = '127.0.0.1' local mydnsport = '5335'