Skip to content

feat: 内置 Cloudflare 隧道,默认关闭地暴露推理接口以支持远程访问 #24

Description

@shaohongwu

Agent issue

Agent

  • Tool: omp (Oh My Pi coding harness)
  • Tool version: omp/18.2.8
  • Model (full id): xiaomi/mimo-v2.6-flash
  • Host (CLI / IDE / GitHub coding agent / other): CLI
  • Date (UTC): 2026-09-23 15:40 UTC

User request

  • Verbatim: cloudflare 有个免费远程穿透 能安排?
  • Later constraints or corrections from the user (quote, or none):
    • 「不用推送 给我们本地编译下」(指先前的安全修复不推送)
    • 「先关闭, 你功能做到的软件里面没有」——经澄清为「把穿透做进软件」
    • 「Cloudflare 这个你能提交一个 pr么?」

Out of scope — refuse

  • Matched: no
  • If yes, what was told to the user (stop here; do not open a PR): n/a

File gate — do not file unless all are satisfied

  • Out of scope: no
  • Usage / configuration / integration (answered instead of filing): no
  • Required facts present without invention (bugs: actual behavior, impact, frequency and applicable type fields; features: current limitation and use case): yes
  • Body is short and factual; no unfiltered AI-generated text: yes
  • File: yes
  • If no, what was told to the user (stop here): n/a

Kind

  • Feature

Usage / configuration / integration check

  • https://github.com/Calcium-Ion/AstrLink/tree/main/docs/guides — 搜索 tunnel、cloudflare、远程访问、remote access、穿透:无匹配文件,结论:文档未提供对外暴露能力。
  • https://github.com/Calcium-Ion/AstrLink/blob/main/CONTRIBUTING.md — 搜索远程/隧道相关:仅涵盖环境要求、源码运行、检查改动、打包与 GitHub Actions,结论:不含任何对外暴露配置。
  • README / repo docs: 安装、接入订阅或 API、创建访问令牌、本地隐私保护;默认地址为 http://127.0.0.1:8317,无远程接入章节。
  • Relevant code paths and conclusion:
    • core/internal/ingress/handler.go — NewProduction 要求 AllowedHost 必须是固定 127.0.0.1 权威,否则拒绝构造。
    • core/internal/ingress/handler.go — 请求 Host 不等于监听地址时返回 421 host_forbidden。
    • core/internal/coreapp/app.go — DefaultInferenceListen 与 DefaultControlListen 均为回环地址。
  • Can the current version already do this? (required for feature requests): 否。基线 e39bb7d 的 apps/desktop/scripts/build-sidecar.mjs 中 cloudflared 计数为 0,core/go.mod 中同样为 0,仓库不含任何隧道组件。
  • Verdict: product bug or new feature / usage question (stop here): new feature

Environment

  • AstrLink version / commit (not latest / unknown): 源码基线 e39bb7d,构建版本 0.1.0-dev.1
  • Install source (repo release / GitHub Actions artifact / source build / other): source build
  • OS and architecture: macOS 26.6.2 (25G83), arm64
  • Runtime (desktop app / standalone core / browser preview): desktop app,另以 standalone core 做对照实验

Problem facts

  • Actual behavior: not applicable — 这是 feature 请求,不存在缺陷行为。
  • Impact: not applicable — 同上。
  • Frequency: not applicable — 同上。

Type-specific details

Relay / API

  • 不适用:本改动不修改上游转发、协议转换与路由。
  • 其余字段: not applicable

Cost / usage

  • 不适用:不涉及计费、用量与定价。
  • 其余字段: not applicable

Desktop / frontend

  • 不适用(当前版本):当前版本不存在该界面,界面本身属于本 feature 的交付内容。
  • 其余字段: not applicable

Installation / upgrade

  • Installation or build method: source build(bun install --frozen-lockfile + bun run tauri build)
  • OS and architecture: macOS arm64
  • Data migration involved (yes/no): no
  • Versions before and after the upgrade: not applicable — feature 尚未实现
  • Startup, sidecar / worker, or database migration logs: not applicable — 无迁移

Reproduction and expected result

  • Steps to reproduce:
    1. 以默认配置启动(未修改监听地址)。
    2. 执行 lsof -nP -iTCP:8317 -sTCP:LISTEN。
    3. 从外部地址连接,或让中间层改写 Host 后转发。
  • Expected result: 提供一个默认关闭的开关,把推理接口安全暴露到公网;控制接口始终留在回环。
  • Related screenshots (optional): n/a

Feature (feature requests only)

  • Feature description: 内置 Cloudflare quick tunnel,默认关闭,仅转发推理接口;设置页展示并可复制公网地址。
  • Use case: 让运行在其他设备或云端的 AI Agent 访问本机网关(无公网 IP、不便做端口映射、或需要临时远程接入的场景)。

Duplicate check

  • Search queries (issues, PRs, discussions): tunnel、cloudflare、remote、远程、公网、穿透、expose、ngrok
  • Closest existing threads: 无。仓库现有 8 个 issue、15 个 PR 全部与隧道或对外暴露无关。
  • Why this is not a duplicate: issue、PR、docs/guides、README 与源码中均不存在隧道或对外暴露主题。

Research

Docs

Code

  • core/internal/ingress/handler.go — NewProduction 强制 AllowedHost 为固定 127.0.0.1 权威;请求 Host 与监听地址不一致时返回 421 host_forbidden。含义:任何隧道若改写 Host,请求都会被拒。
  • core/internal/coreapp/app.go — 两个平面默认均监听回环,含义:外部默认不可达。
  • core/cmd/astrlink-core/main.go — NewInferenceHandler 收到的是 listener 绑定之后的真实地址(含端口回退),含义:这是隧道目标唯一可信来源。

Experiments

  • Command: lsof -nP -iTCP:8317 -sTCP:LISTEN
    Observed result: 127.0.0.1:8317
    Conclusion: 仅监听回环,外部不可达。
  • Command: curl -X POST http://127.0.0.1:8317/v1/chat/completions -H "Host: anything.trycloudflare.com" -H "Content-Type: application/json" -d '{"model":"x"}'
    Observed result: HTTP 421,{"code":"host_forbidden","message":"request Host does not match the inference listener"}
    Conclusion: 隧道转发必须保留原 Host,否则必然 421。
  • Command: git show e39bb7d:apps/desktop/scripts/build-sidecar.mjs | grep -c cloudflared 与 git show e39bb7d:core/go.mod | grep -c cloudflared
    Observed result: 均为 0
    Conclusion: 当前版本不含任何隧道组件。

Working theory

  • not applicable: 这是 feature 请求,不涉及缺陷诊断。

Scope

  • In scope for a later PR: 控制接口的隧道状态与启停、隧道管理(仅回环目标、保留 Host)、cloudflared 随包分发与哈希固定、设置页开关与公网地址展示、安全提示。
  • Out of scope / not this repo: 需账号与域名的 named tunnel、Cloudflare Access 二次认证、其他隧道厂商。
  • Large or directional feature? If yes, this issue is for maintainer alignment; do not open a PR yet.: yes — 产品以本地隐私为核心,新增公网暴露入口属方向性变更,先在此对齐,本 issue 阶段不开 PR。

Proposed direction

  1. 默认关闭,显式确认后才开启。
  2. 仅转发推理接口;控制接口永不转发。
  3. 隧道目标必须取自绑定后的真实回环地址,并保留 Host 以通过现有 421 校验。
  4. cloudflared 缺失或未就绪时明确报错,不静默失败。
  5. 不改动隐私策略与脱敏链路。

Not verified

  • Linux 与 Windows 打包路径。
  • 需账号的 named tunnel。
  • 隧道之外的其他暴露方式。

Related

  • Issues / PRs / upstream docs: 无

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions