Change User-Agent to F-string on OpenWRT router to prevent being detected.
Go to file
2023-12-25 20:28:44 +08:00
.github/workflows ci: fix option on uci 2023-12-25 20:28:44 +08:00
openwrt feat: check http request method 2023-10-31 16:08:04 +08:00
src feat: make it possible to run without uci 2023-12-25 20:23:23 +08:00
test feat: check http request method 2023-10-31 16:08:04 +08:00
.gitattributes chore: force eol lf 2023-05-24 19:41:21 +08:00
.gitignore style: clean code 2023-04-12 22:08:34 +08:00
CMakeLists.txt feat: make it possible to run without uci 2023-12-25 20:23:23 +08:00
CODE_OF_CONDUCT.md chore: add code of conduct 2022-03-12 17:36:38 +08:00
LICENSE Update LICENSE 2021-01-06 15:18:01 +08:00
README.md docs: update badge 2023-10-22 11:31:56 +08:00

UA2F

FOSSA Status CodeQL Build OpenWRT Package

参照 博客文章 完成操作

如果遇到了任何问题,欢迎提出 Issues但是更欢迎直接提交 Pull Request

由于新加入的 CONNMARK 影响,编译内核时需要添加 NETFILTER_NETLINK_GLUE_CT flag

uci command

# 启用 UA2F
uci set ua2f.enabled.enabled=1

# 可选的防火墙配置选项
# 是否自动添加防火墙规则
uci set ua2f.firewall.handle_fw=1

# 是否尝试处理 443 端口的流量, 通常来说,流经 443 端口的流量是加密的,因此无需处理
uci set ua2f.firewall.handle_tls=1

# 是否处理微信的流量,微信的流量通常是加密的,因此无需处理。这一规则在启用 nftables 时无效
uci set ua2f.firewall.handle_mmtls=1

# 是否处理内网流量,如果你的路由器是在内网中,且你想要处理内网中的流量,那么请启用这一选项
uci set ua2f.firewall.handle_intranet=1

# 使用自定义 User-Agent
uci set ua2f.main.custom_ua="Test UA/1.0"

# 应用配置
uci commit ua2f

# 开机自启
service ua2f enable

# 启动 UA2F
service ua2f start

自定义 User-Agent

集成到二进制

make menuconfig 后,使用 option 设置

image

UA2F_CUSTOM_UA 的值必须是一个字符串,且长度不超过 (65535 + (MNL_SOCKET_BUFFER_SIZE / 2)) 字节。 MNL_SOCKET_BUFFER_SIZE 的值通常为 8192。

使用 uci 设置

uci set ua2f.main.custom_ua="Test UA/1.0"
uci commit ua2f

UA2F 不会修改包的大小,因此即使自定义了 User-Agent 运行时实际的 User-Agent 会是一个从 custom ua 中截取的长度与原始 User-Agent 相同的子串,长度不足时会在末尾补空格。

TODO

  • pthread 支持,由不同线程完成入队出队
  • 清除 TCP Header 中的 timestamp有论文认为这可以被用来识别 NAT 后的多设备,劫持 NTP 服务器并不一定有效

License

FOSSA Status