mirror of
https://github.com/CHN-beta/xmurp-ua.git
synced 2024-10-22 19:38:44 +08:00
增加offload说明 修改mark位点
This commit is contained in:
parent
508ba59c92
commit
d4940f3c2c
4
Makefile
4
Makefile
@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
PKG_NAME:=xmurp-ua
|
||||
PKG_RELEASE:=22
|
||||
PKG_RELEASE:=23
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
@ -19,7 +19,7 @@ define KernelPackage/xmurp-ua
|
||||
SUBMENU:=Other modules
|
||||
TITLE:=xmurp-ua
|
||||
FILES:=$(PKG_BUILD_DIR)/xmurp-ua.ko
|
||||
# AUTOLOAD:=$(call AutoLoad,99,xmurp-ua)
|
||||
AUTOLOAD:=$(call AutoLoad,99,xmurp-ua)
|
||||
KCONFIG:=
|
||||
endef
|
||||
|
||||
|
17
README.md
17
README.md
@ -1,9 +1,18 @@
|
||||
喵喵喵,这里是一个修改 UA 的小模块。细致地讲,就是用在 OpenWrt 上修改发给外网 80 端口 GET 和 POST 请求的 UA 字段 为`XMURP/1.0`再加很多个空格的内核模块,用来防止学校检测到使用代理(接路由器)。具体情况,百度“厦大路由”然后看我的简书文章就好了。在 WNDR4300 OpenWrt 18.06.1(内核 4.9.120)测试似乎没问题。前两天还适配了一下 4.14的内核。
|
||||
喵喵喵,这里是一个修改 UA 的小模块。细致地讲,就是用在 OpenWrt 上修改发给外网 80 端口 GET 和 POST 请求的 UA 字段 为`XMURP/1.0`再加很多个空格的内核模块,用来防止学校检测到使用代理(接路由器)。具体情况,百度“厦大路由”然后看我的简书文章就好了。在 WNDR4300 OpenWrt 18.06.1(内核 4.9.120)测试似乎没问题。前两天还适配了一下 4.14的内核。
|
||||
|
||||
如果有一些包不希望被改 UA,只要在防火墙规则里将 MARK 的最低位设置为 1 就可以了。例如:
|
||||
如果有一些包不希望被改 UA,只要在防火墙规则里将 MARK 的第九位设置为 1 就可以了。例如:
|
||||
|
||||
```
|
||||
iptables -t mangle -A PREROUTING -i br-lan_raw -j MARK --set-mark 1
|
||||
iptables -t mangle -A PREROUTING -p tcp -m tcp --dport 80 -m mac --mac-source f8:94:c2:85:e8:14 -j MARK --set-xmark 0x100/0x100
|
||||
```
|
||||
|
||||
这是我第一次在 GitHub 上搞自己的仓库,可能会有些小问题哈。要是有的话,请各路大佬指正。
|
||||
在之前的版本中,使用的是 `0x1/0x1` 位,但是与 luci-app-shadowsocks 冲突,所以改到了 `0x100/0x100`。
|
||||
|
||||
另外,不要在 luci 中启用 flow offloading(流量分载,即 nat 加速),否则这个模块会失效。可以通过下面的命令(二选一,不需要两句都写)来对不需要这个模块的流量启用。
|
||||
|
||||
```
|
||||
iptables -t filter -I FORWARD -p tcp ! --dport 80 -m conntrack --ctstate RELATED,ESTABLISHED -j FLOWOFFLOAD --hw
|
||||
iptables -t filter -I FORWARD -p tcp ! --dport 80 -m conntrack --ctstate RELATED,ESTABLISHED -j FLOWOFFLOAD
|
||||
```
|
||||
|
||||
两句的区别的话,大概是前者用硬件,后者用软件。具体的东西我也不熟悉。
|
||||
|
@ -139,8 +139,6 @@ inline u_int8_t skb_scan(char *data_start, char *data_end)
|
||||
// ip地址、端口号、iph->tot_len需要网络顺序到主机顺序的转换。校验和时,除长度字段外,不需要手动进行网络顺序和主机顺序的转换。
|
||||
unsigned int hook_funcion(void *priv, struct sk_buff *skb, const struct nf_hook_state *state)
|
||||
{
|
||||
static u_int32_t debug_n = 0;
|
||||
|
||||
register struct tcphdr *tcph;
|
||||
register struct iphdr *iph;
|
||||
register char *data_start, *data_end;
|
||||
@ -155,57 +153,21 @@ unsigned int hook_funcion(void *priv, struct sk_buff *skb, const struct nf_hook_
|
||||
|
||||
// 过滤发往外网的HTTP请求的包,且要求包的应用层内容不短于3字节
|
||||
if(skb == 0)
|
||||
{
|
||||
// if(debug_n < 10)
|
||||
// printk("xmurp-ua warning, something maybe wrong.\n");
|
||||
return NF_ACCEPT;
|
||||
}
|
||||
iph = ip_hdr(skb);
|
||||
if((ntohl(iph->daddr) & 0xffff0000) == 0xc0a80000)
|
||||
{
|
||||
// if(debug_n < 10)
|
||||
// printk("xmurp-ua bypass as dst in local net.\n");
|
||||
return NF_ACCEPT;
|
||||
}
|
||||
if(iph->protocol != IPPROTO_TCP)
|
||||
{
|
||||
// if(debug_n < 10)
|
||||
// printk("xmurp-ua bypass as protocol not tcp.\n");
|
||||
return NF_ACCEPT;
|
||||
}
|
||||
tcph = tcp_hdr(skb);
|
||||
if(ntohs(tcph->dest) != 80)
|
||||
{
|
||||
// if(debug_n < 10)
|
||||
// printk("xmurp-ua bypass as port %u not 80.\n", ntohs(tcph->dest));
|
||||
return NF_ACCEPT;
|
||||
}
|
||||
data_start = (char *)tcph + tcph->doff * 4;
|
||||
data_end = (char *)tcph + ntohs(iph->tot_len) - iph->ihl * 4;
|
||||
debug_n++;
|
||||
if(data_end - data_start < 4)
|
||||
{
|
||||
if(debug_n < 10)
|
||||
printk("xmurp-ua bypass as data too short.");
|
||||
if(debug_n < 10)
|
||||
printk("xmurp-ua tcph -> doff = %x, iph -> tot_len = %x, iph -> ihl = %x.\n", tcph -> doff, iph -> tot_len, iph -> ihl);
|
||||
if(debug_n < 10)
|
||||
printk("xmurp-ua iph -> tot_len - iph, %x.\n", (char*)&(iph -> tot_len) - (char*)iph);
|
||||
if(debug_n < 10)
|
||||
printk("xmurp-ua iph -> tot_len %x.\n", *((u_int16_t*)&(iph -> tot_len)));
|
||||
if(debug_n < 10)
|
||||
printk("xmurp-ua iph message %x %x %x %x %x %x %x %x %x %x %x.\n", iph -> version, iph -> ihl, iph -> tos, iph -> tot_len, iph -> id, iph -> frag_off, iph -> ttl, iph -> protocol, iph -> check, iph -> saddr, iph -> daddr);
|
||||
return NF_ACCEPT;
|
||||
}
|
||||
if(skb->mark & 0x00000001)
|
||||
{
|
||||
if(debug_n < 10)
|
||||
printk("xmurp-ua bypass as mark.\n");
|
||||
if(skb->mark & 0x100)
|
||||
return NF_ACCEPT;
|
||||
}
|
||||
|
||||
if(debug_n++ < 10)
|
||||
printk("xmurp-ua catch a package.\n");
|
||||
|
||||
// 决定是否发送到下一层
|
||||
if(catch_next_frag && iph->saddr == saddr && iph->daddr == daddr &&
|
||||
|
Loading…
Reference in New Issue
Block a user