You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+97-12Lines changed: 97 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ For high-performance matching: Uses a hash table for domain rules, and an IP pre
12
12
13
13
## Usage
14
14
15
-
1.**Domain Rule Configuration**
15
+
### 1. **Domain Rule Configuration**
16
16
17
17
The project contains some example configuration files:
18
18
@@ -25,24 +25,31 @@ For high-performance matching: Uses a hash table for domain rules, and an IP pre
25
25
26
26
To use these files, remove the `.example` extension. Each file represents a different proxy behavior:
27
27
28
+
#### a. Auto-Proxy
29
+
28
30
-**Auto-Proxy Rules**: Add rules to `auto-proxy.txt` to control how websites are accessed.
29
31
30
32
All files starting with `auto-proxy` and ending with `.txt` will be parsed as Auto-Proxy rules. If you have multiple Auto-Proxy rules, you can save them as multiple files, like `auto-proxy-1.txt`, `auto-proxy-2.txt`, etc.
31
33
32
34
**Note**: Currently, the URL matching rules in Auto-Proxy are ignored, and only domain rules are handled.
33
35
36
+
#### b. Domain and IP Address
37
+
34
38
-**Blocked**: Domains added to `domain-rules-blocked.txt` will be blocked from access.
35
39
-**Direct**:
36
40
- Domains added to `domain-rules-direct.txt` will bypass the proxy and connect directly.
37
41
- IPv4 networks (in CIDR format) added to `ipv4-rules-direct.txt` will bypass the proxy and connect directly.
38
42
- IPv6 networks (in CIDR format) added to `ipv6-rules-direct.txt` will bypass the proxy and connect directly.
39
43
-**Proxy**: Domains added to `domain-rules-proxy.txt` will use the default proxy.
40
44
41
-
Add your domain names or IP network segments to the appropriate file, with one entry per line. Lines starting with `#` are treated as comments. For example:
45
+
Add your domains or IP networks to the appropriate file, one per line. Subdomains will inherit the proxy behavior of their parent domain. You can also add country-level top domains to simplify the configuration. Lines starting with `#` are treated as comments.
46
+
47
+
For example:
42
48
43
49
Domains added to `domain-rules-direct.txt`, along with their subdomains, will bypass the proxy and connect directly:
44
50
```
45
51
# Direct connect domains
52
+
cn # All domains ending with .cn will connect directly by default
46
53
google.com
47
54
example.org
48
55
```
@@ -56,7 +63,43 @@ For high-performance matching: Uses a hash table for domain rules, and an IP pre
56
63
57
64
You can also create your own custom rule files, following the format `<domain|ipv4|ipv6>-rules-<rule_name>.txt`. For example, `domain-rules-companyProxy.txt` will make all domains in this file use the `companyProxy` setting defined in `proxy.pac`. `ipv4-rules-block.txt` will block all networks listed in the file.
58
65
59
-
2.**Generate the `proxy.pac` File**
66
+
#### c. Domain Regular Expressions
67
+
68
+
-**Domain Regular Expressions**: `domain-regexp.txt` is used to define domain rules based on regular expressions, which allows for flexible matching of similar domains.
69
+
70
+
File structure:
71
+
```
72
+
[direct]
73
+
# host regex ...
74
+
75
+
[blocked]
76
+
# ...
77
+
78
+
[proxy]
79
+
# ...
80
+
```
81
+
82
+
Each section represents a different proxy behavior, which can be `direct`, `blocked`, `proxy`, or a custom behavior (e.g., `[companyProxy]`).
83
+
84
+
-**[direct]**: Domains matched by regular expressions in this section will bypass the proxy and connect directly.
85
+
-**[blocked]**: Domains matched by regular expressions in this section will be blocked.
86
+
-**[proxy]**: Domains matched by regular expressions in this section will use the default proxy.
87
+
-**Custom Behavior**: You can add your own section name, such as `[companyProxy]`, to indicate that domains matching those patterns will use a custom proxy configuration.
88
+
89
+
Each line is a regular expression for matching specific domains or their subdomains. Lines starting with `#` are treated as comments. For example:
90
+
```
91
+
[direct]
92
+
# Direct connection domains
93
+
^img-[0-9][0-9].*\.example\.com$
94
+
95
+
[blocked]
96
+
# Blocked domains
97
+
^ad-[a-z0-9]\.cdn[0-9]\.example\.com$
98
+
```
99
+
100
+
Ensure that the regular expressions are valid to avoid affecting normal network access.
101
+
102
+
### 2. **Generate the `proxy.pac` File**
60
103
61
104
Run the script to generate the `proxy.pac` file:
62
105
@@ -66,7 +109,7 @@ For high-performance matching: Uses a hash table for domain rules, and an IP pre
66
109
67
110
The `proxy.pac` file will be automatically generated in the project root directory.
68
111
69
-
3.**Default Rule Sources**
112
+
### 3. **Default Rule Sources**
70
113
71
114
The build script [`build.sh`](./build.sh) will, by default, download the following files without overwriting existing files of the same name:
72
115
@@ -76,7 +119,7 @@ For high-performance matching: Uses a hash table for domain rules, and an IP pre
76
119
77
120
If you do not need the Auto-Proxy rules or IP networks rules, you can create empty files with the same name to skip the download.
78
121
79
-
4.**Proxy Configuration**
122
+
### 4. **Proxy Configuration**
80
123
81
124
The generated `proxy.pac` file uses the following default proxy configurations (note that the default proxy server is `SOCKS5 127.0.0.1:1080`):
82
125
@@ -92,7 +135,7 @@ For high-performance matching: Uses a hash table for domain rules, and an IP pre
92
135
93
136
You can modify these values after generating `proxy.pac`, or customize them directly in the original script `proxy.js` to use different default settings. Please adjust these settings according to your environment and requirements.
94
137
95
-
5.**Testing**
138
+
### 5. **Testing**
96
139
97
140
If you have Node.js installed, you can run the following command to test and verify the configuration:
98
141
@@ -133,7 +176,7 @@ Run `./build.sh` to regenerate the `proxy.pac` file, which will block access to
133
176
134
177
## 使用方法
135
178
136
-
1.**域名规则配置**
179
+
### 1. **域名规则配置**
137
180
138
181
项目包含一些示例配置文件:
139
182
@@ -143,27 +186,35 @@ Run `./build.sh` to regenerate the `proxy.pac` file, which will block access to
0 commit comments