-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
710 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: Update hosts | ||
|
||
on: | ||
push: | ||
paths: | ||
- 'setHosts.py' | ||
- 'requirements.txt' | ||
schedule: | ||
- cron: '0 */4 * * *' | ||
workflow_dispatch: # 允许手动触发 | ||
|
||
jobs: | ||
update-hosts: | ||
runs-on: ubuntu-latest | ||
|
||
# 添加并发限制,避免同时运行多个工作流 | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 1 # 减少克隆深度,加快检出速度 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 # 使用最新的 v5 版本 | ||
with: | ||
python-version: '3.11' | ||
cache: 'pip' # 启用 pip 缓存 | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
- name: Run hosts update script | ||
run: | | ||
sudo python setHosts.py | ||
- name: Commit and push changes | ||
run: | | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "action_bot" | ||
if [[ -n $(git status -s) ]]; then | ||
git add . | ||
git commit -m "更新 hosts 内容" | ||
git push | ||
else | ||
echo "No changes to commit" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
# cnNetTool | ||
|
||
[![Release Version](https://img.shields.io/github/v/release/sinspired/cnNetTool?display_name=tag&logo=github&label=Release)](https://github.com/sinspired/cnNetTool/releases/latest) | ||
[![GitHub repo size](https://img.shields.io/github/repo-size/sinspired/cnNetTool?logo=github) | ||
](https://github.com/sinspired/cnNetTool) | ||
[![GitHub last commit](https://img.shields.io/github/last-commit/sinspired/cnNetTool?logo=github&label=最后提交:)](ttps://github.com/sinspired/cnNetTool) | ||
|
||
全面解锁Github,解决加载慢、无法访问等问题!解锁Google翻译,支持chrome网页翻译及插件,解锁划词翻译,以及依赖Google翻译API的各种平台插件。解锁tinyMediaManager影视刮削。 | ||
|
||
自动设置最佳DNS服务器。 | ||
|
||
> 适合部分地区饱受dns污染困扰,访问 GitHub 卡顿、抽风、图裂,无法使用Chrome浏览器 自带翻译功能,无法刮削影视封面等问题。分别使用 `setDNS` 自动查找最快服务器并设置,使用 `setHosts` 自动查找DNS映射主机并设置。支持Windows、Linux、MacOS。Enjoy!❤ | ||
> [!NOTE] | ||
> 首次运行大约需要2分钟以获取DNS主机,请耐心等待。后续运行速度大约10秒左右 | ||
## 一、使用方法 | ||
|
||
### 1.1 自动操作 | ||
|
||
直接下载下方文件,解压后双击运行,enjoy❤! | ||
|
||
[![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) | ||
|
||
> 强烈建议采用本方法,如果喜欢折腾,可以继续往下看。 | ||
### 1.2 手动操作 | ||
|
||
#### 1.2.1 复制下面的内容 | ||
|
||
```bash | ||
{hosts_str} | ||
``` | ||
|
||
该内容会自动定时更新, 数据更新时间:{update_time} | ||
|
||
#### 1.2.2 修改 hosts 文件 | ||
|
||
hosts 文件在每个系统的位置不一,详情如下: | ||
- Windows 系统:`C:\Windows\System32\drivers\etc\hosts` | ||
- Linux 系统:`/etc/hosts` | ||
- Mac(苹果电脑)系统:`/etc/hosts` | ||
- Android(安卓)系统:`/system/etc/hosts` | ||
- iPhone(iOS)系统:`/etc/hosts` | ||
|
||
修改方法,把第一步的内容复制到文本末尾: | ||
|
||
1. Windows 使用记事本。 | ||
2. Linux、Mac 使用 Root 权限:`sudo vi /etc/hosts`。 | ||
3. iPhone、iPad 须越狱、Android 必须要 root。 | ||
|
||
|
||
## 二、安装 | ||
|
||
首先安装 python,然后在终端中运行以下命令: | ||
|
||
```bash | ||
git clone https://github.com/sinspired/cnNetTool.git | ||
cd cnNetTool | ||
pip install -r requirements.txt | ||
``` | ||
这将安装所有依赖项 | ||
|
||
## 参数说明 | ||
|
||
**cnNetTool** 可以接受以下参数: | ||
|
||
### DNS 服务器工具 `SetDNS.py` | ||
|
||
* --debug 启用调试日志 | ||
* --show-availbale-list, --list 显示可用dns列表,通过 --num 控制显示数量 | ||
* --best-dns-num BEST_DNS_NUM, --num 显示最佳DNS服务器的数量 | ||
* --algorithm --mode {region,overall} 默认 `region` 平衡IPv4和ipv6 DNS | ||
* --show-resolutions, --show 显示域名解析结果 | ||
|
||
### Hosts文件工具 `SetHosts.py` | ||
|
||
* -log 设置日志输出等级,'DEBUG', 'INFO', 'WARNING', 'ERROR' | ||
* -num --num-fastest 限定Hosts主机 ip 数量 | ||
* -max --max-latency 设置允许的最大延迟(毫秒) | ||
* -v --verbose 打印运行信息 | ||
|
||
命令行键入 `-h` `help` 获取帮助 | ||
|
||
`py SetDNS.py -h` | ||
|
||
`py SetHosts.py -h` | ||
|
||
## 三、运行 | ||
|
||
请使用管理员权限,在项目目录运行,分别设置解析最快的DNS服务器,更新hosts文件。 **接受传递参数,大部分时候直接运行即可**。 | ||
|
||
```bash | ||
py SetDNS.py | ||
py SetHosts.py | ||
``` | ||
可执行文件也可带参数运行 | ||
```pwsh | ||
./SetDNS.exe --best-dns-num 10 | ||
./SetHosts.exe --num-fastest 3 --max-latency 500 | ||
``` | ||
|
Oops, something went wrong.