Skip to content

Commit

Permalink
breaking: 重构代码,大版本更新:
Browse files Browse the repository at this point in the history
- 大幅提高性能;
- 全面解锁Github;
- 解锁Google翻译、chrome浏览器翻译;
- 解锁tinyMediaManager刮削
  • Loading branch information
sinspired committed Nov 16, 2024
1 parent 91598e3 commit 1766a67
Show file tree
Hide file tree
Showing 7 changed files with 1,297 additions and 141 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
- name: Build executables (Linux)
if: matrix.os == 'ubuntu-latest'
run: |
for script in SetDNS.py SetHosts-IPv4.py SetHosts.py; do
for script in SetDNS.py SetHosts.py SetHosts_Classic.py; do
pyinstaller --onefile "$script"
mv "dist/${script%.py}" "dist/${script%.py}-Linux-x64"
done
Expand All @@ -47,7 +47,7 @@ jobs:
- name: Build executables (Windows)
if: matrix.os == 'windows-latest'
run: |
$scripts = @("SetDNS.py", "SetHosts-IPv4.py", "SetHosts.py")
$scripts = @("SetDNS.py", "SetHosts.py", "SetHosts_Classic.py")
if (Test-Path -Path "dist") {
Remove-Item -Recurse -Force "dist"
}
Expand All @@ -70,7 +70,7 @@ jobs:
- name: Build executables (macOS)
if: matrix.os == 'macos-latest'
run: |
for script in SetDNS.py SetHosts-IPv4.py SetHosts.py; do
for script in SetDNS.py SetHosts.py SetHosts_Classic.py; do
pyinstaller --onefile "$script"
mv "dist/${script%.py}" "dist/${script%.py}-macOS-x64"
done
Expand Down
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@
](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)

基于Python的网络小工具
全面解锁Github,解决加载慢、无法访问等问题!解锁Google翻译,支持chrome网页翻译及插件,解锁划词翻译,以及依赖Google翻译API的各种平台插件。解锁tinyMediaManager影视刮削

针对某些区域DNS污染问题,自动筛选解析速度最快的 DNS 服务器、自动设置hosts文件(包括tinyMediaManager刮削源tmdb.org、themoviedb.org,Google/chrome网页翻译等),支持Windows、Linux、MacOS
自动设置最佳DNS服务器

> 适合部分地区饱受dns污染困扰,访问 GitHub 卡顿、抽风、图裂,无法使用Chrome浏览器 自带翻译功能,无法刮削影视封面等问题。分别使用 `setDNS` 自动查找最快服务器并设置,使用 `setHosts` 自动查找DNS映射主机并设置。支持Windows、Linux、MacOS。Enjoy!❤
> [!NOTE]
> 首次运行大约需要2分钟以获取DNS主机,请耐心等待。后续运行速度大约10秒左右
# 安装

Expand All @@ -23,20 +27,20 @@ pip install -r requirements.txt

# 参数说明

**CloudflareBestIP** 可以接受以下参数:
**cnNetTool** 可以接受以下参数:

### DNS 服务器工具 `SetDNS.py`

* --debug 启用调试日志
* --show-availbale-list, --list 显示可用dns列表,通过 --num 控制娴熟数量
* --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-level 设置日志输出等级,'DEBUG', 'INFO', 'WARNING', 'ERROR'
* --num-fastest 设置选择的最快IP数量
* --num-fastest 限定Hosts主机 ip 数量
* --max-latency 设置允许的最大延迟(毫秒)

命令行键入 `-h` `help` 获取帮助
Expand Down
22 changes: 17 additions & 5 deletions SetDNS.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def set_dns_servers(ipv4_dns_list: list[str], ipv6_dns_list: list[str]):
"static",
ipv4_dns_list[0],
],
check=True
check=True,
)
for dns in ipv4_dns_list[1:]:
subprocess.run(
Expand All @@ -288,7 +288,7 @@ def set_dns_servers(ipv4_dns_list: list[str], ipv6_dns_list: list[str]):
dns,
"index=2",
],
check=True
check=True,
)
except subprocess.CalledProcessError as e:
logger.error(f"设置IPv4 DNS for {interface}失败: {e}")
Expand All @@ -308,7 +308,7 @@ def set_dns_servers(ipv4_dns_list: list[str], ipv6_dns_list: list[str]):
"static",
ipv6_dns_list[0],
],
check=True
check=True,
)
for dns in ipv6_dns_list[1:]:
subprocess.run(
Expand All @@ -322,7 +322,7 @@ def set_dns_servers(ipv4_dns_list: list[str], ipv6_dns_list: list[str]):
dns,
"index=2",
],
check=True
check=True,
)
except subprocess.CalledProcessError as e:
logger.error(f"设置IPv6 DNS for {interface}失败: {e}")
Expand Down Expand Up @@ -583,7 +583,19 @@ def run_as_admin():

if __name__ == "__main__":
parser = argparse.ArgumentParser(
description="DNS解析器和设置工具,请使用管理员权限运行"
description=(
"------------------------------------------------------------\n"
"DNS解析器和设置工具,请使用管理员权限运行,自动设置最佳 DNS 服务器。\n"
"------------------------------------------------------------\n"
),
epilog=(
"------------------------------------------------------------\n"
"项目: https://github.com/sinspired/cnNetTool\n"
"作者: Sinspired\n"
"邮箱: [email protected]\n"
"发布: 2024-11-11\n"
),
formatter_class=argparse.RawTextHelpFormatter, # 允许换行格式
)
parser.add_argument("--debug", action="store_true", help="启用调试日志")
parser.add_argument(
Expand Down
Loading

0 comments on commit 1766a67

Please sign in to comment.