Skip to content

Commit

Permalink
pref: 优化通过dns记录获取ip,优化域名分组,优化域名匹配正则表达式
Browse files Browse the repository at this point in the history
  • Loading branch information
sinspired committed Dec 6, 2024
2 parents a73bf71 + 6ebfdfa commit 007b111
Show file tree
Hide file tree
Showing 5 changed files with 413 additions and 438 deletions.
115 changes: 58 additions & 57 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,80 +30,80 @@

```bash

# cnNetTool Start in 2024-11-30 12:24:58 +08:00
140.82.113.26 alive.github.com
140.82.112.5 api.github.com
140.82.112.21 central.github.com
140.82.113.9 codeload.github.com
# cnNetTool Start in 2024-12-05 16:28:37 +08:00
140.82.114.26 alive.github.com
140.82.112.6 api.github.com
140.82.112.22 central.github.com
140.82.112.10 codeload.github.com
140.82.114.22 collector.github.com
140.82.113.4 gist.github.com
140.82.114.3 github.com
140.82.114.18 github.community
140.82.114.4 github.com
140.82.113.18 github.community
146.75.29.194 github.global.ssl.fastly.net
16.182.38.33 github-com.s3.amazonaws.com
16.15.185.16 github-production-release-asset-2e65be.s3.amazonaws.com
140.82.114.26 live.github.com
3.5.11.158 github-com.s3.amazonaws.com
52.216.236.243 github-production-release-asset-2e65be.s3.amazonaws.com
140.82.112.26 live.github.com
13.107.42.16 pipelines.actions.githubusercontent.com
185.199.110.154 github.githubassets.com
185.199.109.154 github.githubassets.com
185.199.108.153 github.io
185.199.108.153 githubstatus.com
185.199.108.153 assets-cdn.github.com
185.199.109.133 avatars.githubusercontent.com
185.199.109.133 avatars0.githubusercontent.com
185.199.109.133 avatars1.githubusercontent.com
185.199.109.133 avatars2.githubusercontent.com
185.199.109.133 avatars3.githubusercontent.com
185.199.109.133 avatars4.githubusercontent.com
185.199.109.133 avatars5.githubusercontent.com
185.199.109.133 camo.githubusercontent.com
185.199.109.133 cloud.githubusercontent.com
185.199.109.133 desktop.githubusercontent.com
185.199.109.133 favicons.githubusercontent.com
185.199.109.133 github.map.fastly.net
185.199.109.133 media.githubusercontent.com
185.199.109.133 objects.githubusercontent.com
185.199.109.133 private-user-images.githubusercontent.com
185.199.109.133 raw.githubusercontent.com
185.199.109.133 user-images.githubusercontent.com
18.160.200.13 tmdb.org
18.160.200.13 api.tmdb.org
18.160.200.13 files.tmdb.org
52.85.247.30 themoviedb.org
52.85.247.30 api.themoviedb.org
52.85.247.30 www.themoviedb.org
52.85.247.30 auth.themoviedb.org
185.93.1.244 image.tmdb.org
185.93.1.244 images.tmdb.org
52.94.225.248 imdb.com
185.199.108.133 avatars.githubusercontent.com
185.199.108.133 avatars0.githubusercontent.com
185.199.108.133 avatars1.githubusercontent.com
185.199.108.133 avatars2.githubusercontent.com
185.199.108.133 avatars3.githubusercontent.com
185.199.108.133 avatars4.githubusercontent.com
185.199.108.133 avatars5.githubusercontent.com
185.199.108.133 camo.githubusercontent.com
185.199.108.133 cloud.githubusercontent.com
185.199.108.133 desktop.githubusercontent.com
185.199.108.133 favicons.githubusercontent.com
185.199.108.133 github.map.fastly.net
185.199.108.133 media.githubusercontent.com
185.199.108.133 objects.githubusercontent.com
185.199.108.133 private-user-images.githubusercontent.com
185.199.108.133 raw.githubusercontent.com
185.199.108.133 user-images.githubusercontent.com
18.160.200.103 tmdb.org
18.160.200.103 api.tmdb.org
18.160.200.103 files.tmdb.org
108.159.227.111 themoviedb.org
108.159.227.111 api.themoviedb.org
108.159.227.111 www.themoviedb.org
108.159.227.111 auth.themoviedb.org
169.150.236.97 image.tmdb.org
169.150.236.97 images.tmdb.org
52.94.237.74 imdb.com
3.168.35.144 www.imdb.com
52.94.237.74 secure.imdb.com
3.168.35.144 s.media-imdb.com
52.94.237.74 us.dd.imdb.com
52.94.228.167 us.dd.imdb.com
3.168.35.144 www.imdb.to
52.94.225.248 imdb-webservice.amazon.com
52.94.237.74 imdb-webservice.amazon.com
44.215.137.99 origin-www.imdb.com
146.75.29.16 m.media-amazon.com
18.172.138.122 m.media-amazon.com
146.75.29.16 Images-na.ssl-images-amazon.com
104.123.159.75 images-fe.ssl-images-amazon.com
3.167.162.195 images-eu.ssl-images-amazon.com
18.160.216.100 images-fe.ssl-images-amazon.com
23.220.246.166 images-eu.ssl-images-amazon.com
146.75.29.16 ia.media-imdb.com
146.75.29.16 f.media-amazon.com
52.84.18.90 imdb-video.media-imdb.com
3.167.180.205 dqpnq362acqdi.cloudfront.net
142.250.190.74 translate.google.com
142.250.190.74 translate.googleapis.com
142.250.190.74 translate-pa.googleapis.com
3.167.138.84 plugins.jetbrains.com
3.167.138.84 download.jetbrains.com
3.167.138.84 cache-redirector.jetbrains.com

# Update time: 2024-11-30 12:24:58 +08:00
52.84.18.105 imdb-video.media-imdb.com
3.167.180.176 dqpnq362acqdi.cloudfront.net
142.250.191.170 translate.google.com
142.250.191.170 translate.googleapis.com
142.250.191.170 translate-pa.googleapis.com
54.230.18.115 plugins.jetbrains.com
54.230.18.115 download.jetbrains.com
54.230.18.115 cache-redirector.jetbrains.com

# Update time: 2024-12-05 16:28:37 +08:00
# GitHub仓库: https://github.com/sinspired/cnNetTool
# cnNetTool End

```

以上内容会自动定时更新, 数据更新时间:2024-11-30 12:24:58 +08:00
以上内容会自动定时更新, 数据更新时间:2024-12-05 16:28:37 +08:00

#### 1.2.2 修改 hosts 文件

Expand Down Expand Up @@ -141,10 +141,11 @@ pip install -r requirements.txt
### DNS 服务器工具 `SetDNS.py`

* --debug 启用调试日志
* --show-availbale-list, --list 显示可用dns列表,通过 --num 控制显示数量
* --best-dns-num BEST_DNS_NUM, --num 显示最佳DNS服务器的数量
* --show-availbale-list, --list, -l 显示可用dns列表,通过 --num 控制显示数量
* --best-dns-num BEST_DNS_NUM, --num, -n 显示最佳DNS服务器的数量
* --algorithm --mode {region,overall} 默认 `region` 平衡IPv4和ipv6 DNS,选择 `overall` 则会在所有IP中选择最快IP
* --show-resolutions, --show 显示域名解析结果
* --show-resolutions, --resolutions, -r 显示域名解析结果
* --only-global, --global 仅使用国际DNS服务器

### Hosts文件工具 `SetHosts.py`

Expand Down
13 changes: 10 additions & 3 deletions README_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
> 适合部分地区饱受dns污染困扰,访问 GitHub 卡顿、抽风、图裂,无法使用Chrome浏览器 自带翻译功能,无法刮削影视封面等问题。分别使用 `setDNS` 自动查找最快服务器并设置,使用 `setHosts` 自动查找DNS映射主机并设置。支持Windows、Linux、MacOS。Enjoy!❤
> [!NOTE]
> 首次运行大约需要2分钟以获取DNS主机,请耐心等待。后续运行速度大约10秒左右
> 首次运行大约需要2分钟以获取DNS主机并建立缓存,请耐心等待。后续运行速度大概二三十秒。
## 一、使用方法

Expand All @@ -22,6 +22,10 @@

[![Release Detail](https://img.shields.io/github/v/release/sinspired/cnNetTool?sort=date&display_name=release&logo=github&label=Release)](https://github.com/sinspired/cnNetTool/releases/latest)

程序使用DNS服务器实时解析和DNS A、AAAA记录获取IPv4及IPv6地址,通过本地网络环境检测延迟并进行SSL证书验证。

由于需要进行 `hosts` 修改备份操作,exe文件已标记需要管理员权限,如果被系统误报病毒,请允许后再次操作。

> 强烈建议采用本方法,如果喜欢折腾,可以继续往下看。
### 1.2 手动操作
Expand All @@ -34,6 +38,9 @@

以上内容会自动定时更新, 数据更新时间:{update_time}

> [!NOTE]
> 由于数据获取于非本地网络环境,请自行测试可用性,否则请采用方法 1,使用本地网络环境自动设置。
#### 1.2.2 修改 hosts 文件

hosts 文件在每个系统的位置不一,详情如下:
Expand All @@ -50,7 +57,7 @@ hosts 文件在每个系统的位置不一,详情如下:
3. iPhone、iPad 须越狱、Android 必须要 root。

> [!NOTE]
> 请先把 `hosts` 文件复制到其他目录,修改后再复制回去,否则可能无法修改
> Windows系统可能需要先把 `hosts` 文件复制到其他目录,修改后再复制回去,否则可能没有修改权限
## 二、安装

Expand Down Expand Up @@ -99,7 +106,7 @@ py SetHosts.py
```
可执行文件也可带参数运行
```pwsh
./SetDNS.exe --best-dns-num 10
./SetDNS.exe --best-dns-num 10 --mode 'overall' --show-resolutions
./SetHosts.exe --num-fastest 3 --max-latency 500
```

104 changes: 52 additions & 52 deletions hosts
Original file line number Diff line number Diff line change
@@ -1,71 +1,71 @@

# cnNetTool Start in 2024-11-30 12:24:58 +08:00
140.82.113.26 alive.github.com
140.82.112.5 api.github.com
140.82.112.21 central.github.com
140.82.113.9 codeload.github.com
# cnNetTool Start in 2024-12-05 16:28:37 +08:00
140.82.114.26 alive.github.com
140.82.112.6 api.github.com
140.82.112.22 central.github.com
140.82.112.10 codeload.github.com
140.82.114.22 collector.github.com
140.82.113.4 gist.github.com
140.82.114.3 github.com
140.82.114.18 github.community
140.82.114.4 github.com
140.82.113.18 github.community
146.75.29.194 github.global.ssl.fastly.net
16.182.38.33 github-com.s3.amazonaws.com
16.15.185.16 github-production-release-asset-2e65be.s3.amazonaws.com
140.82.114.26 live.github.com
3.5.11.158 github-com.s3.amazonaws.com
52.216.236.243 github-production-release-asset-2e65be.s3.amazonaws.com
140.82.112.26 live.github.com
13.107.42.16 pipelines.actions.githubusercontent.com
185.199.110.154 github.githubassets.com
185.199.109.154 github.githubassets.com
185.199.108.153 github.io
185.199.108.153 githubstatus.com
185.199.108.153 assets-cdn.github.com
185.199.109.133 avatars.githubusercontent.com
185.199.109.133 avatars0.githubusercontent.com
185.199.109.133 avatars1.githubusercontent.com
185.199.109.133 avatars2.githubusercontent.com
185.199.109.133 avatars3.githubusercontent.com
185.199.109.133 avatars4.githubusercontent.com
185.199.109.133 avatars5.githubusercontent.com
185.199.109.133 camo.githubusercontent.com
185.199.109.133 cloud.githubusercontent.com
185.199.109.133 desktop.githubusercontent.com
185.199.109.133 favicons.githubusercontent.com
185.199.109.133 github.map.fastly.net
185.199.109.133 media.githubusercontent.com
185.199.109.133 objects.githubusercontent.com
185.199.109.133 private-user-images.githubusercontent.com
185.199.109.133 raw.githubusercontent.com
185.199.109.133 user-images.githubusercontent.com
18.160.200.13 tmdb.org
18.160.200.13 api.tmdb.org
18.160.200.13 files.tmdb.org
52.85.247.30 themoviedb.org
52.85.247.30 api.themoviedb.org
52.85.247.30 www.themoviedb.org
52.85.247.30 auth.themoviedb.org
185.93.1.244 image.tmdb.org
185.93.1.244 images.tmdb.org
52.94.225.248 imdb.com
185.199.108.133 avatars.githubusercontent.com
185.199.108.133 avatars0.githubusercontent.com
185.199.108.133 avatars1.githubusercontent.com
185.199.108.133 avatars2.githubusercontent.com
185.199.108.133 avatars3.githubusercontent.com
185.199.108.133 avatars4.githubusercontent.com
185.199.108.133 avatars5.githubusercontent.com
185.199.108.133 camo.githubusercontent.com
185.199.108.133 cloud.githubusercontent.com
185.199.108.133 desktop.githubusercontent.com
185.199.108.133 favicons.githubusercontent.com
185.199.108.133 github.map.fastly.net
185.199.108.133 media.githubusercontent.com
185.199.108.133 objects.githubusercontent.com
185.199.108.133 private-user-images.githubusercontent.com
185.199.108.133 raw.githubusercontent.com
185.199.108.133 user-images.githubusercontent.com
18.160.200.103 tmdb.org
18.160.200.103 api.tmdb.org
18.160.200.103 files.tmdb.org
108.159.227.111 themoviedb.org
108.159.227.111 api.themoviedb.org
108.159.227.111 www.themoviedb.org
108.159.227.111 auth.themoviedb.org
169.150.236.97 image.tmdb.org
169.150.236.97 images.tmdb.org
52.94.237.74 imdb.com
3.168.35.144 www.imdb.com
52.94.237.74 secure.imdb.com
3.168.35.144 s.media-imdb.com
52.94.237.74 us.dd.imdb.com
52.94.228.167 us.dd.imdb.com
3.168.35.144 www.imdb.to
52.94.225.248 imdb-webservice.amazon.com
52.94.237.74 imdb-webservice.amazon.com
44.215.137.99 origin-www.imdb.com
146.75.29.16 m.media-amazon.com
18.172.138.122 m.media-amazon.com
146.75.29.16 Images-na.ssl-images-amazon.com
104.123.159.75 images-fe.ssl-images-amazon.com
3.167.162.195 images-eu.ssl-images-amazon.com
18.160.216.100 images-fe.ssl-images-amazon.com
23.220.246.166 images-eu.ssl-images-amazon.com
146.75.29.16 ia.media-imdb.com
146.75.29.16 f.media-amazon.com
52.84.18.90 imdb-video.media-imdb.com
3.167.180.205 dqpnq362acqdi.cloudfront.net
142.250.190.74 translate.google.com
142.250.190.74 translate.googleapis.com
142.250.190.74 translate-pa.googleapis.com
3.167.138.84 plugins.jetbrains.com
3.167.138.84 download.jetbrains.com
3.167.138.84 cache-redirector.jetbrains.com
52.84.18.105 imdb-video.media-imdb.com
3.167.180.176 dqpnq362acqdi.cloudfront.net
142.250.191.170 translate.google.com
142.250.191.170 translate.googleapis.com
142.250.191.170 translate-pa.googleapis.com
54.230.18.115 plugins.jetbrains.com
54.230.18.115 download.jetbrains.com
54.230.18.115 cache-redirector.jetbrains.com

# Update time: 2024-11-30 12:24:58 +08:00
# Update time: 2024-12-05 16:28:37 +08:00
# GitHub仓库: https://github.com/sinspired/cnNetTool
# cnNetTool End
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
aiohttp==3.11.7
aiohttp==3.11.10
dnspython==2.7.0
httpx==0.28.0
prettytable==3.12.0
rich==13.9.4
wcwidth==0.2.13
Loading

0 comments on commit 007b111

Please sign in to comment.