Skip to content

Commit

Permalink
fix: 变量和格式错误
Browse files Browse the repository at this point in the history
  • Loading branch information
sinspired committed Dec 9, 2024
1 parent 06fbdbb commit e6eda76
Show file tree
Hide file tree
Showing 7 changed files with 492 additions and 402 deletions.
42 changes: 37 additions & 5 deletions .github/workflows/update_hosts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- 'setHosts_Classic.py'
- 'requirements.txt'
branches:
- 'main'
- 'master'
schedule:
- cron: '0 */4 * * *'
workflow_dispatch:
Expand All @@ -16,6 +16,38 @@ permissions:
contents: write

jobs:
format-fix:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Install formatting tools
run: |
pip install black flake8 isort
- name: Run and fix formatting
run: |
black .
isort .
flake8 --ignore=E501,W503,E203 .
# 提交修复的代码
- name: Commit and push fixes
if: success() || failure()
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "[email protected]"
git add .
git commit -m "Fix formatting issues" || echo "No changes to commit"
git push
update-hosts:
runs-on: ubuntu-latest

Expand All @@ -37,12 +69,12 @@ jobs:

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install pip
sudo pip install -r requirements.txt
- name: Run hosts update script1
run: |
sudo python setHosts.py
run: |
sudo python3 setHosts_Classic.py
# 提交并推送更新(仅在文件变更时)
- name: Commit and push changes
Expand Down
196 changes: 125 additions & 71 deletions README.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 @@ -30,80 +34,130 @@

```bash

# 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.4 github.com
140.82.113.18 github.community
146.75.29.194 github.global.ssl.fastly.net
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
# cnNetTool Start in 2024-12-09 14:15:15 +08:00
140.82.112.25 alive.github.com
140.82.113.25 live.github.com
20.205.243.168 api.github.com
20.205.243.165 codeload.github.com
140.82.114.22 central.github.com
140.82.112.3 gist.github.com
20.205.243.166 github.com
140.82.112.17 github.community
151.101.129.194 github.global.ssl.fastly.net
2a03:2880:f136:83:face:b00c:0:25de github.global.ssl.fastly.net
3.5.25.108 github-com.s3.amazonaws.com
3.5.28.157 github-production-release-asset-2e65be.s3.amazonaws.com
3.5.30.172 github-production-user-asset-6210df.s3.amazonaws.com
3.5.24.52 github-production-repository-file-5c1aeb.s3.amazonaws.com
13.107.42.16 pipelines.actions.githubusercontent.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.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.228.167 us.dd.imdb.com
3.168.35.144 www.imdb.to
52.94.237.74 imdb-webservice.amazon.com
44.215.137.99 origin-www.imdb.com
18.172.138.122 m.media-amazon.com
146.75.29.16 Images-na.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.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
2620:1ec:22::16 pipelines.actions.githubusercontent.com
185.199.108.154 github.githubassets.com
16.182.106.1 github-cloud.s3.amazonaws.com
192.0.66.2 github.blog
185.199.109.153 githubstatus.com
2606:50c0:8003::153 githubstatus.com
185.199.109.153 assets-cdn.github.com
2606:50c0:8003::153 assets-cdn.github.com
185.199.109.153 github.io
2606:50c0:8003::153 github.io
140.82.114.22 collector.github.com
140.82.114.22 education.github.com
185.199.109.133 avatars.githubusercontent.com
2606:50c0:8002::154 avatars.githubusercontent.com
185.199.109.133 avatars0.githubusercontent.com
2606:50c0:8002::154 avatars0.githubusercontent.com
185.199.109.133 avatars1.githubusercontent.com
2606:50c0:8002::154 avatars1.githubusercontent.com
185.199.109.133 avatars2.githubusercontent.com
2606:50c0:8002::154 avatars2.githubusercontent.com
185.199.109.133 avatars3.githubusercontent.com
2606:50c0:8002::154 avatars3.githubusercontent.com
185.199.109.133 avatars4.githubusercontent.com
2606:50c0:8002::154 avatars4.githubusercontent.com
185.199.109.133 avatars5.githubusercontent.com
2606:50c0:8002::154 avatars5.githubusercontent.com
185.199.109.133 camo.githubusercontent.com
2606:50c0:8002::154 camo.githubusercontent.com
185.199.109.133 cloud.githubusercontent.com
2606:50c0:8002::154 cloud.githubusercontent.com
185.199.109.133 desktop.githubusercontent.com
2606:50c0:8002::154 desktop.githubusercontent.com
185.199.109.133 favicons.githubusercontent.com
2606:50c0:8002::154 favicons.githubusercontent.com
185.199.109.133 github.map.fastly.net
2606:50c0:8002::154 github.map.fastly.net
185.199.109.133 media.githubusercontent.com
2606:50c0:8002::154 media.githubusercontent.com
185.199.109.133 objects.githubusercontent.com
2606:50c0:8002::154 objects.githubusercontent.com
185.199.109.133 private-user-images.githubusercontent.com
2606:50c0:8002::154 private-user-images.githubusercontent.com
185.199.109.133 raw.githubusercontent.com
2606:50c0:8002::154 raw.githubusercontent.com
185.199.109.133 user-images.githubusercontent.com
2606:50c0:8002::154 user-images.githubusercontent.com
18.67.51.128 tmdb.org
2600:9000:2816:d800:e:5373:440:93a1 tmdb.org
18.67.51.128 api.tmdb.org
2600:9000:2816:d800:e:5373:440:93a1 api.tmdb.org
18.67.51.128 files.tmdb.org
2600:9000:2816:d800:e:5373:440:93a1 files.tmdb.org
18.67.51.128 themoviedb.org
2600:9000:2816:d800:e:5373:440:93a1 themoviedb.org
18.67.51.128 api.themoviedb.org
2600:9000:2816:d800:e:5373:440:93a1 api.themoviedb.org
18.67.51.128 www.themoviedb.org
2600:9000:2816:d800:e:5373:440:93a1 www.themoviedb.org
18.67.51.128 auth.themoviedb.org
2600:9000:2816:d800:e:5373:440:93a1 auth.themoviedb.org
143.244.50.84 image.tmdb.org
2400:52e0:1500::1092:1 image.tmdb.org
143.244.50.84 images.tmdb.org
2400:52e0:1500::1092:1 images.tmdb.org
13.35.217.192 imdb.com
13.35.217.192 www.imdb.com
13.35.217.192 secure.imdb.com
13.35.217.192 s.media-imdb.com
13.35.217.192 us.dd.imdb.com
13.35.217.192 www.imdb.to
13.35.217.192 imdb-webservice.amazon.com
13.35.217.192 origin-www.imdb.com
23.202.34.219 m.media-amazon.com
2600:9000:2079:4000:1d:d7f6:39d4:e6e1 m.media-amazon.com
23.202.34.219 Images-na.ssl-images-amazon.com
2600:9000:2079:4000:1d:d7f6:39d4:e6e1 Images-na.ssl-images-amazon.com
23.202.34.219 images-fe.ssl-images-amazon.com
2600:9000:2079:4000:1d:d7f6:39d4:e6e1 images-fe.ssl-images-amazon.com
23.202.34.219 images-eu.ssl-images-amazon.com
2600:9000:2079:4000:1d:d7f6:39d4:e6e1 images-eu.ssl-images-amazon.com
23.202.34.219 ia.media-imdb.com
2600:9000:2079:4000:1d:d7f6:39d4:e6e1 ia.media-imdb.com
23.202.34.219 f.media-amazon.com
2600:9000:2079:4000:1d:d7f6:39d4:e6e1 f.media-amazon.com
23.202.34.219 imdb-video.media-imdb.com
2600:9000:2079:4000:1d:d7f6:39d4:e6e1 imdb-video.media-imdb.com
23.202.34.219 dqpnq362acqdi.cloudfront.net
2600:9000:2079:4000:1d:d7f6:39d4:e6e1 dqpnq362acqdi.cloudfront.net
2404:6800:4005:81b::200a translate.google.com
2404:6800:4005:81b::200a translate.googleapis.com
2404:6800:4005:81b::200a translate-pa.googleapis.com
13.33.88.22 plugins.jetbrains.com
2600:9000:2014:c00:12:7c44:15c0:93a1 plugins.jetbrains.com
13.33.88.22 download.jetbrains.com
2600:9000:2014:c00:12:7c44:15c0:93a1 download.jetbrains.com
13.33.88.22 cache-redirector.jetbrains.com
2600:9000:2014:c00:12:7c44:15c0:93a1 cache-redirector.jetbrains.com

# Update time: 2024-12-09 14:15:15 +08:00
# GitHub仓库: https://github.com/sinspired/cnNetTool
# cnNetTool End

```

以上内容会自动定时更新, 数据更新时间:2024-12-05 16:28:37 +08:00
以上内容会自动定时更新, 数据更新时间:2024-12-09 14:15:15 +08:00

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

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

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

Expand Down Expand Up @@ -170,7 +224,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
```

Loading

0 comments on commit e6eda76

Please sign in to comment.