From 026af02ed043df0e0d80177924e40b25dfb93b38 Mon Sep 17 00:00:00 2001 From: SunBK201 Date: Thu, 21 Nov 2024 16:03:09 +0800 Subject: [PATCH] feat: update User-Agent regex pattern to include 'Mobile' for better matching --- README.md | 2 +- openwrt/files/luci/cbi.lua | 2 +- openwrt/files/ua3f.uci | 2 +- src/main.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index fe3cfd5..c0f5603 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ UA3F 支持 LuCI Web 页面,可以打开 Services -> UA3F 进行相关配置 > - Bind Address: UA3F 监听地址,默认 `127.0.0.1`。 > - Log Level: 日志等级,默认 `info`, 如果需要调试排查错误可以设置为 `debug`。 > - User-Agent: 自定义 User-Agent,默认 `FFF`。 -> - User-Agent Regex Pattern: User-Agent 正则表达式规则。如果流量中的 User-Agent 匹配该正则表达式,则会被修改为 User-Agent 字段的内容,否则不会被修改;如果该字段为空,则所有流量 User-Agent 都会被修改。默认 `(iPhone|iPad|Android|Macintosh|Windows|Linux)`,即只修改携带设备与系统信息的 User-Agent。 +> - User-Agent Regex Pattern: User-Agent 正则表达式规则。如果流量中的 User-Agent 匹配该正则表达式,则会被修改为 User-Agent 字段的内容,否则不会被修改;如果该字段为空,则所有流量 User-Agent 都会被修改。默认 `(iPhone|iPad|Android|Macintosh|Windows|Linux|Apple|Mac OS X|Mobile)`,即只修改携带设备与系统信息的 User-Agent。 > - Partial Replace: 部分替换,如果开启,则只替换 User-Agent Regex Pattern 中匹配到的部分。该选项仅在 User-Agent Regex Pattern 不为空时生效。 ### 手动命令行启动 diff --git a/openwrt/files/luci/cbi.lua b/openwrt/files/luci/cbi.lua index eb07068..1557aee 100644 --- a/openwrt/files/luci/cbi.lua +++ b/openwrt/files/luci/cbi.lua @@ -52,7 +52,7 @@ ua = main:taboption("general", Value, "ua", "User-Agent") ua.placeholder = "FFF" uaRegexPattern = main:taboption("general", Value, "ua_regex", "User-Agent Regex Pattern") -uaRegexPattern.placeholder = "(iPhone|iPad|Android|Macintosh|Windows|Linux|Apple|Mac OS X)" +uaRegexPattern.placeholder = "(iPhone|iPad|Android|Macintosh|Windows|Linux|Apple|Mac OS X|Mobile)" uaRegexPattern.description = "Regular expression pattern for matching User-Agent" partialRepalce = main:taboption("general", Flag, "partial_replace", "Partial Replace") diff --git a/openwrt/files/ua3f.uci b/openwrt/files/ua3f.uci index f765cbc..6dffdb1 100644 --- a/openwrt/files/ua3f.uci +++ b/openwrt/files/ua3f.uci @@ -5,6 +5,6 @@ config 'ua3f' 'main' option port '1080' option bind '127.0.0.1' option ua 'FFF' - option ua_regex '(iPhone|iPad|Android|Macintosh|Windows|Linux|Apple|Mac OS X)' + option ua_regex '(iPhone|iPad|Android|Macintosh|Windows|Linux|Apple|Mac OS X|Mobile)' option partial_replace false option log_level 'info' \ No newline at end of file diff --git a/src/main.go b/src/main.go index 6bdbfff..aac0e2e 100644 --- a/src/main.go +++ b/src/main.go @@ -39,7 +39,7 @@ func main() { flag.StringVar(&addr, "b", "127.0.0.1", "bind address (default: 127.0.0.1)") flag.IntVar(&port, "p", 1080, "port") flag.StringVar(&payload, "f", "FFF", "User-Agent") - flag.StringVar(&uaPattern, "r", "(iPhone|iPad|Android|Macintosh|Windows|Linux|Apple|Mac OS X)", "UA-Pattern") + flag.StringVar(&uaPattern, "r", "(iPhone|iPad|Android|Macintosh|Windows|Linux|Apple|Mac OS X|Mobile)", "UA-Pattern") flag.BoolVar(&enablePartialReplace, "s", false, "Enable Regex Partial Replace") flag.StringVar(&loglevel, "l", "info", "Log level (default: info)") flag.Bool("v", false, "show version")