← 返回 Skills 市场
vay-qz

github改hosts文件加速skill,仅针对windows

作者 qz · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ⚠ suspicious
73
总下载
1
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install github-hosts-windows
功能描述
Optimize GitHub access speed on Windows by finding the fastest IPs and updating the hosts file to reduce latency.
使用说明 (SKILL.md)

GitHub Hosts Optimizer

On Windows, directly modify C:\Windows\System32\drivers\etc\hosts to map GitHub domains to faster IPs.

Workflow

  1. Resolve GitHub IPs using nslookup:

    • github.com
    • api.github.com
    • objects.githubusercontent.com
  2. Ping each IP to measure latency (ping -n 3 \x3CIP>)

  3. Select fastest IP (lowest average latency)

  4. Update hosts file with entries:

    \x3Cfastest_ip> github.com
    \x3Cfastest_ip> api.github.com
    \x3Cfastest_ip> github.com  (duplicate for reliability)
    
  5. Flush DNS cache:

    ipconfig /flushdns
    

PowerShell Script

$hostsPath = "$env:SystemRoot\System32\drivers\etc\hosts"
$domains = @("github.com", "api.github.com", "objects.githubusercontent.com")

# Resolve IPs
$ips = @{}
foreach ($domain in $domains) {
    $result = nslookup $domain 2>$null
    $ips[$domain] = ($result | Select-String -Pattern "Addresses:" -Context 0,10 | ForEach-Object { $_.Context.PostContext }) -replace '\s+', '' | Where-Object { $_ -match '^\d+\.\d+\.\d+\.\d+$' }
}

# Ping each IP and find fastest
$results = @()
foreach ($ip in ($ips.Values | Select-Object -Unique)) {
    $avg = (ping -n 3 $ip | Select-String -Pattern "平均").ToString() -replace '.*= (\d+)ms.*', '$1'
    if ($avg) { $results += [PSCustomObject]@{ IP = $ip; Avg = [int]$avg } }
}
$fastest = ($results | Sort-Object Avg | Select-Object -First 1).IP

# Update hosts
$entry = "$fastest github.com`n$fastest api.github.com"
$current = Get-Content $hostsPath -Raw -ErrorAction SilentlyContinue
if ($current -notmatch "github\.com") {
    Add-Content -Path $hostsPath -Value $entry
} else {
    $updated = $current -replace "[\d\.]+\s+github\.com`n?[\d\.]+\s+api\.github\.com", $entry
    Set-Content -Path $hostsPath -Value $updated
}

# Flush DNS
ipconfig /flushdns | Out-Null
Write-Host "Done! Fastest IP: $fastest"

Key Notes

  • Hosts file requires Administrator privileges to modify
  • If direct edit fails, output the entry and instruct user to manually add it
  • The fastest IP may change over time; re-run when GitHub access slows again
安全使用建议
This skill does what it says (probe IPs and edit Windows hosts), but it performs a high‑privilege, system‑wide change with sloppy, locale‑dependent parsing and brittle replacement logic. Before installing or running it: (1) get the skill's source or homepage and review the exact script, (2) ensure you run it only with Administrator consent and after making a backup of C:\Windows\System32\drivers\etc\hosts, (3) prefer the script be modified to: back up hosts, validate IP ownership for GitHub, avoid locale‑dependent parsing, and use safer, more specific host entry replacement, (4) consider testing manually first rather than allowing an agent to run it autonomously. The domain/entry mismatches in the SKILL.md should be corrected before use.
功能分析
Type: OpenClaw Skill Name: github-hosts-windows Version: 1.0.0 The skill automates the modification of the Windows system hosts file (C:\Windows\System32\drivers\etc\hosts) to optimize GitHub connectivity. While the logic in SKILL.md appears to serve its stated purpose by dynamically resolving IPs via nslookup and selecting the fastest via ping, the requirement for administrative privileges and the direct modification of system-level network configurations are high-risk behaviors. Additionally, the PowerShell script relies on localized string parsing (e.g., searching for '平均' for latency), which may cause unpredictable behavior on non-Chinese system locales.
能力评估
Purpose & Capability
Name/description align with the actions (resolve IPs, test latency, edit Windows hosts). However the SKILL.md lists domains to resolve (including objects.githubusercontent.com) but the script only writes entries for github.com and api.github.com; the Workflow section also mentions a duplicate github.com line that the script does not include. These inconsistencies are sloppy and reduce confidence.
Instruction Scope
Instructions instruct the agent to read and modify C:\Windows\System32\drivers\etc\hosts (system‑wide), run nslookup/ping/ipconfig, and implicitly require Administrator privileges. The script does not back up the hosts file, its pattern matching/replacement is brittle (may fail or clobber unrelated lines), and parsing relies on locale-specific output (e.g., Chinese ping output matching '平均'). Those behaviors expand scope beyond a simple 'helper' and carry risk to network access.
Install Mechanism
Instruction-only skill with no install actions; nothing is written to disk by an installer. This is the lowest install risk.
Credentials
No environment variables, credentials, or external config paths are requested — appropriate for the stated purpose.
Persistence & Privilege
The skill asks the agent to modify the system hosts file, a persistent, system‑wide change that requires Administrator rights. While 'always' is false, the modification itself is high‑privilege and can affect all apps on the machine; the SKILL.md notes this but does not instruct creating a backup or a safe rollback.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install github-hosts-windows
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /github-hosts-windows 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
- Initial release of github-hosts-windows skill. - Automatically finds the fastest IP addresses for key GitHub domains on Windows. - Updates the hosts file to map GitHub domains to these IPs for improved access speed. - Provides a ready-to-use PowerShell script for the entire workflow: resolving IPs, measuring latency, updating hosts, and flushing DNS cache. - Triggers when users mention GitHub slowness or need to optimize/update GitHub-related hosts entries.
元数据
Slug github-hosts-windows
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

github改hosts文件加速skill,仅针对windows 是什么?

Optimize GitHub access speed on Windows by finding the fastest IPs and updating the hosts file to reduce latency. 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 73 次。

如何安装 github改hosts文件加速skill,仅针对windows?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install github-hosts-windows」即可一键安装,无需额外配置。

github改hosts文件加速skill,仅针对windows 是免费的吗?

是的,github改hosts文件加速skill,仅针对windows 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

github改hosts文件加速skill,仅针对windows 支持哪些平台?

github改hosts文件加速skill,仅针对windows 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 github改hosts文件加速skill,仅针对windows?

由 qz(@vay-qz)开发并维护,当前版本 v1.0.0。

💬 留言讨论