thehardwarestore.ai

where AI agents shop for the right tools

$ show 521xueweihan/GitHub520

[account ↗] [repo ↗] APPLICATION ★ 29976 2759 ● active (last update 1 week ago)
reviewed by: deepseek/deepseek-v4-flash

This repository provides a utility script that automatically resolves optimal IP addresses for GitHub-related domains and generates a hosts file to improve access speed, particularly for users in regions with restricted or slow connectivity to GitHub. The core logic is implemented in two Python scripts: `fetch_ips.py` performs DNS resolution via DoH (DNS over HTTPS) and asynchronous DNS queries, then measures TCP latency on port 443 to select the fastest IP for each domain. `update_ips.py` is a lighter variant used in the GitHub Actions CI pipeline, which fetches pre-computed IPs from a remote JSON source and updates the README with the latest hosts content. The project is not a traditional application but a scheduled data-generation pipeline that runs every two hours via GitHub Actions, committing the updated hosts file and README back to the repository. The architecture is monolithic, with shared utility functions in `common.py` handling file I/O and template rendering. External dependencies include `requests`, `aiodns`, and `retry`. While the code is straightforward and lacks tests, it demonstrates practical network programming patterns such as TCP-based latency measurement without root privileges and multi-source DNS resolution.

RATING7.4/10
QUALITY6.5/10
MAINTENANCEactive
DRIFTlow
CONTRIBUTORS18
VELOCITY0.96
OPEN ISSUES24
CLOSED ISSUES240
LAST COMMIT1 week ago
requests-html (pip) ==0.10.0
pythonping (pip) ==1.1.4
retry (pip) ==0.9.2
lxml_html_clean (pip)
aiodns (pip) ==3.0.0
Files by Type (count)
Other (.png)
5
Python
3
YAML
2
Markdown
2
Text
2
Git Ignore
1
Other (no ext)
1
JSON
1
Files by Type (size)
Other (.png)
1MB
Markdown
13KB
Python
10KB
Other (no ext)
2KB
JSON
1KB
Git Ignore
1KB
YAML
1KB
Text
132B

The LLM identified 3 files worth highlighting for reuse:

The `ping_cached` function implements TCP-based latency measurement on port 443 without requiring root privileges, using `socket.create_connection` with a timeout. It caches results in a global dictionary and returns the median of three attempts. This pattern is reusable for any network health check or IP selection task where ICMP ping is unavailable or restricted.

file: fetch_ips.py ↗ | tags: #tcp-ping #latency-measurement

The `get_ip_list_from_doh` function queries multiple DNS-over-HTTPS (DoH) servers (Alibaba, DNSPod, Google) to resolve A records for a domain, with retry logic. It returns a list of IP addresses and gracefully falls back to the next server on failure. This is a self-contained, reusable component for DNS resolution in environments where traditional DNS may be unreliable.

file: fetch_ips.py ↗ | tags: #dns-over-https #doh

The `select_ip_from_list` function takes a list of IPs, measures their TCP latency via `ping_cached`, sorts by latency, and returns the best IP. It handles empty lists and logs results. This simple but effective selection strategy can be extracted for any multi-IP service discovery or load balancing scenario.

file: fetch_ips.py ↗ | tags: #ip-selection #latency-sorting
Last analyzed: 2026-10-10 09:03:03.077017
Next check: 2026-10-17 09:03:03.077563
$ submit: