← 返回 Skills 市场
n1e

GitHub Hosts CN

作者 n1e · GitHub ↗ · v1.0.1 · MIT-0
cross-platform ⚠ suspicious
129
总下载
0
收藏
0
当前安装
2
版本数
在 OpenClaw 中安装
/install github-hosts-cn-n1e
功能描述
GitHub Hosts 更新工具(中国用户专用)。安全地更新系统hosts文件以访问GitHub,保留原有非GitHub条目,仅替换GitHub相关地址。支持备份恢复、风险提示。当用户需要解决GitHub访问问题时使用此技能。
使用说明 (SKILL.md)

GitHub Hosts CN - 中国用户专用 GitHub Hosts 更新工具

安全、智能地更新系统hosts文件,帮助中国用户正常访问GitHub。

🌟 特性

  • 🛡️ 安全优先:自动备份、保留原有配置、仅替换GitHub条目
  • 🌍 多源获取:从多个镜像源获取最新GitHub hosts(HelloGitHub、GitLab、Gitee等)
  • ⚡ 自动选择:并行测试所有源,使用最快的可用源
  • 💾 智能备份:时间戳备份,支持一键恢复
  • 🔍 精确替换:只替换GitHub相关域名,保留其他所有hosts配置
  • 📋 风险提示:执行前显示详细风险说明,需用户确认

📦 安装

cd /Users/claw/Documents/trae_projects/skills/github-hosts-cn
npm install

🚀 使用方法

# 更新GitHub hosts
node update.js

# 查看帮助
node update.js --help

# 恢复最近的备份
node update.js --restore

# 查看当前状态
node update.js --status

# 仅获取不更新(预览模式)
node update.js --preview

📊 数据源

URL 类型 优先级
HelloGitHub raw.hellogithub.com 独立站点 1
GitLab Mirror gitlab.com/ineo6 GitLab 2
Gitee Mirror gitee.com 国内镜像 3
JSDelivr CDN cdn.jsdelivr.net CDN 4

🔧 工作流程

1. 显示风险提示 → 用户确认
2. 读取当前 /etc/hosts
3. 创建时间戳备份
4. 从多源获取最新GitHub hosts
5. 合并:保留非GitHub条目 + 新GitHub条目
6. 写入新的hosts文件
7. 刷新DNS缓存
8. 显示更新结果

🛡️ 安全机制

备份策略

  • 每次修改前自动备份
  • 备份文件命名:hosts.backup.YYYY-MM-DDTHH-mm-ss
  • 备份位置:~/.openclaw/backups/github-hosts/
  • 保留最近10个备份文件

合并策略

  • 识别所有GitHub相关域名(github.com, github.global.ssl.fastly.net等)
  • 保留hosts文件中的所有非GitHub条目
  • 仅替换GitHub相关IP地址

恢复机制

  • --restore 恢复最近备份
  • --restore \x3Cbackup-file> 恢复指定备份

⚠️ 风险说明

修改hosts文件存在以下风险:

  1. 权限风险:需要sudo权限,请确保在可信环境执行
  2. 网络风险:错误的hosts可能导致无法访问某些网站
  3. IP失效风险:GitHub IP可能随时变化,需要定期更新
  4. 备份风险:请确保备份目录可写

建议:

  • 在执行前理解hosts文件的作用
  • 定期检查备份文件
  • 如遇问题立即使用 --restore 恢复

📋 系统要求

  • Node.js 16+
  • macOS / Linux
  • sudo权限(用于修改/etc/hosts)
  • 网络连接

📜 License

MIT

安全使用建议
This skill is coherent for updating GitHub host entries and includes sensible safeguards (preview, backups, restore). Before installing or running it: 1) Inspect and verify the listed data sources (raw.hellogithub.com, gitlab.com, gitee.com, jsdelivr) — if a source is compromised it can supply malicious IP mappings. 2) Use the --preview mode first to review exact changes and confirm backups exist. 3) Run in a trusted environment and avoid running with sudo in automated/unattended contexts; prefer manual confirmation. 4) Keep backups (the tool stores them under ~/.openclaw/backups/github-hosts/) and test restore. 5) If you need higher assurance, run it on a disposable/test machine or manually fetch and vet hosts content before applying. If you want me to, I can: list the exact domains the tool will change, fetch the current preview output from the fastest source (non-destructively), or help craft a checklist to vet the remote sources.
功能分析
Type: OpenClaw Skill Name: github-hosts-cn-n1e Version: 1.0.1 The skill is designed to update the system hosts file to facilitate GitHub access in China, a task that inherently requires high-risk operations including sudo privileges and shell command execution (execSync) in update.js. While the code appears well-structured with safety features like automated backups, path validation, and a restore mechanism, the capability to modify core system files (/etc/hosts) and execute system-level commands (cp, dscacheutil, etc.) via an AI agent falls under the 'risky capabilities' threshold. No evidence of malicious intent, data exfiltration, or prompt injection was found; the tool functions as described using community-standard data sources like raw.hellogithub.com.
能力评估
Purpose & Capability
Name/description (GitHub hosts updater for China) match what the skill does: reads /etc/hosts, fetches hosts from multiple public mirrors, merges GitHub entries, backs up, and writes the file. No unrelated credentials, binaries, or config paths are requested.
Instruction Scope
SKILL.md and update.js explicitly describe reading /etc/hosts, creating timestamped backups in ~/.openclaw/backups/github-hosts/, fetching remote hosts files, parsing/merging entries, writing /etc/hosts, and flushing DNS. The instructions are scoped to the stated task and include preview/restore options and an explicit user confirmation step.
Install Mechanism
No install script in the registry; the package is an npm project with update.js and package.json. Nothing is downloaded or executed at install time. At runtime the script fetches remote hosts data from listed public URLs (HelloGitHub, GitLab, Gitee, jsdelivr), which is expected for this function but is a trust surface to review.
Credentials
The skill requests no environment variables, no secrets, and no unrelated credentials. It does require Node.js and elevated privileges to modify /etc/hosts (documented). The requested permissions are proportional to the task.
Persistence & Privilege
The skill is not always: true and has default autonomous-invocation allowed by platform. It performs privileged actions (writing system hosts) and requires sudo; however the SKILL.md and code show an interactive confirmation and preview mode. Users should be aware that if an agent runs this skill without interactive confirmation (or with automated confirmation flags), it will perform privileged writes.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install github-hosts-cn-n1e
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /github-hosts-cn-n1e 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.1
- Maintenance update with no user-facing feature changes. - Internal update in the update.js file; documentation and skill description remain unchanged.
v1.0.0
Initial release of github-hosts-cn: a secure GitHub Hosts updating tool for users in China. - Safely updates system hosts file for GitHub access, preserving non-GitHub entries. - Features automatic and timestamped backups with easy restore options. - Fetches latest GitHub hosts from multiple sources, tests speed, and selects the fastest. - Provides risk warnings and requires user confirmation before making changes. - Maintains detailed logs and supports preview mode for changes.
元数据
Slug github-hosts-cn-n1e
版本 1.0.1
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 2
常见问题

GitHub Hosts CN 是什么?

GitHub Hosts 更新工具(中国用户专用)。安全地更新系统hosts文件以访问GitHub,保留原有非GitHub条目,仅替换GitHub相关地址。支持备份恢复、风险提示。当用户需要解决GitHub访问问题时使用此技能。 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 129 次。

如何安装 GitHub Hosts CN?

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

GitHub Hosts CN 是免费的吗?

是的,GitHub Hosts CN 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

GitHub Hosts CN 支持哪些平台?

GitHub Hosts CN 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 GitHub Hosts CN?

由 n1e(@n1e)开发并维护,当前版本 v1.0.1。

💬 留言讨论