Install
openclaw skills install github-hosts-windowsOptimize GitHub access speed on Windows by finding the fastest IPs and updating the hosts file to reduce latency.
openclaw skills install github-hosts-windowsOn Windows, directly modify C:\Windows\System32\drivers\etc\hosts to map GitHub domains to faster IPs.
Resolve GitHub IPs using nslookup:
Ping each IP to measure latency (ping -n 3 <IP>)
Select fastest IP (lowest average latency)
Update hosts file with entries:
<fastest_ip> github.com
<fastest_ip> api.github.com
<fastest_ip> github.com (duplicate for reliability)
Flush DNS cache:
ipconfig /flushdns
$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"