-
Notifications
You must be signed in to change notification settings - Fork 2.4k
/
Copy pathredirect_google_cn.tengo
41 lines (41 loc) · 1.35 KB
/
redirect_google_cn.tengo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// www.google.cn 重定向到 www.google.com
// [CA]
modules = append(modules, {
dnsquery: func(m) {
if m.domain == "www.google.cn" {
return {} // Interrupt next modules, default to fake dns
}
},
address: func(m) {
if m.domainaddress {
if m.domainaddress == "www.google.cn:80" {
if m.network == "tcp" {
return { mitm: true, mitmprotocol: "http"}
}
}
if m.domainaddress == "www.google.cn:443" {
if m.network == "tcp" {
return { mitm: true, mitmprotocol: "https"}
}
if m.network == "udp" {
return { "block": true }
}
}
}
},
httprequest: func(request) {
text := import("text")
if text.has_prefix(request["URL"], "http://www.google.cn/") {
return {
"StatusCode": 302,
"Location": text.replace(request["URL"], "http://www.google.cn", "https://www.google.com", 1)
}
}
if text.has_prefix(request["URL"], "https://www.google.cn/") {
return {
"StatusCode": 302,
"Location": text.replace(request["URL"], "https://www.google.cn", "https://www.google.com", 1)
}
}
}
})