File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# Opti Hosts
22
3+ [[ English]] ( ./README.md ) [[ 中文]] ( ./README.zh-CN.md )
4+
35Resolve domains by latency, not CDN zones.
46
7+ This tool retrieves DNS records from Globalping, selects IPs with lowest latency, and updates the hosts file.
8+
59## Quickstart
610
7- 1 . Add directives in your ` /etc/hosts ` :
11+ 1 . Download from [ Releases] ( https://github.com/Zhousiru/opti-hosts/releases/latest ) .
12+
13+ For example:
14+
15+ ``` bash
16+ sudo wget https://github.com/Zhousiru/opti-hosts/releases/download/latest/opti-hosts-x86_64-unknown-linux-gnu -O /usr/local/bin/opti-hosts
17+ sudo chmod +x /usr/local/bin/opti-hosts
18+ ```
19+
20+ 2. Add directives in your ` /etc/hosts` :
821
9- ``` plaintext
10- # ...
22+ ` ` ` plaintext
23+ # ...
1124
12- # OPTI-HOSTS example.com [Beijing, HK * 2, AS6939]
13- # HINT: Record for example.com will be generated here.
25+ # OPTI-HOSTS example.com [Beijing, HK * 2, AS6939]
26+ # HINT: Record for example.com will be generated here.
1427
15- # ...
16- ```
28+ # ...
29+ ` ` `
1730
18- 2 . Run:
31+ 3. Run:
1932
20- ``` bash
21- sudo opti-hosts
22- sudo opti-hosts --dry-run # Preview changes
23- ```
33+ ` ` ` bash
34+ sudo opti-hosts
35+ sudo opti-hosts --dry-run # Preview changes
36+ ` ` `
2437
25- 3 . Add to your crontab (recommend):
38+ 4. Add to your crontab (recommend):
2639
27- ``` bash
28- 0 * /12 * * * opti-hosts
29- ```
40+ ` ` ` bash
41+ 0 * /12 * * * opti-hosts
42+ ` ` `
3043
3144# # Hosts Directive
3245
Original file line number Diff line number Diff line change 1+ # Opti Hosts:拼好 Hosts
2+
3+ [[ English]] ( ./README.md ) [[ 中文]] ( ./README.zh-CN.md )
4+
5+ 通过延迟而非 CDN 区域解析域名。
6+
7+ 这个工具从 Globalping 检索 DNS 记录,选择延迟最低的 IP 地址,并更新 hosts 文件。
8+
9+ ## 快速开始
10+
11+ 1 . 从 [ Releases] ( https://github.com/Zhousiru/opti-hosts/releases/latest ) 下载。
12+
13+ 例如:
14+
15+ ``` bash
16+ sudo wget https://github.com/Zhousiru/opti-hosts/releases/download/latest/opti-hosts-x86_64-unknown-linux-gnu -O /usr/local/bin/opti-hosts
17+ sudo chmod +x /usr/local/bin/opti-hosts
18+ ```
19+
20+ 2. 在你的 ` /etc/hosts` 中添加指令:
21+
22+ ` ` ` plaintext
23+ # ...
24+
25+ # OPTI-HOSTS example.com [Beijing, HK * 2, AS6939]
26+ # 提示: example.com 的记录将在此处生成。
27+
28+ # ...
29+ ` ` `
30+
31+ 3. 运行:
32+
33+ ` ` ` bash
34+ sudo opti-hosts
35+ sudo opti-hosts --dry-run # 预览更改
36+ ` ` `
37+
38+ 4. 添加到你的 crontab(推荐):
39+
40+ ` ` ` bash
41+ 0 * /12 * * * opti-hosts
42+ ` ` `
43+
44+ # # Hosts 指令
45+
46+ ```
47+ # OPTI-HOSTS <域名> [ <位置> * <限制>, <位置>, ...]
48+ ```
49+
50+ - **域名**
51+
52+ 你想要解析的域名。
53+
54+ - **位置**
55+
56+ 你想要从哪个地理位置或网络解析域名。
57+
58+ 参见 [Globalping Network](https://globalping.io/network),或在 [Globalping](https://globalping.io/) 上尝试。
59+
60+ - **限制**
61+
62+ 用于特定位置的最大节点数。
63+
64+ 默认为 1。
65+
66+ ## 用法
67+
68+ ```bash
69+ opti-hosts [选项]
70+ ```
71+
72+ ``` plaintext
73+ 选项:
74+ --dry-run 预览输出而不对 hosts 文件进行任何更改
75+ --file <FILE> Hosts 文件路径 [默认: /etc/hosts]
76+ -h, --help 打印帮助
77+ -V, --version 打印版本
78+ ```
You can’t perform that action at this time.
0 commit comments