onionpipe

cmarsMIT活跃维护

把本地任意服务通过 Tor 洋葱地址暴露出去,无需公网 IP 或端口映射,就能实现匿名、去中心化的内网穿透与隧道转发。

Onion addresses for anything.

v1.1.11发布于 2024-12-19 17:25 UTC617star37fork同步于 2026-11-10 11:57 UTC

怎么上手

由 README 提炼,执行前请确认
docker run --rm ghcr.io/cmars/onionpipe:main host.docker.internal:80
make onionpipe
硬件要求按 README 说明

README 未说明具体硬件要求;本地构建的二进制需要 $PATH 中有 tor 守护进程,静态版内置 libtor,理论上支持 Linux、Darwin、Android

有 Docker 镜像
下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

用 Tor 隐藏服务把本地端口映射成 .onion 地址,绕过 NAT 和防火墙做隧道

把本地任意服务通过 Tor 洋葱地址暴露出去,无需公网 IP 或端口映射,就能实现匿名、去中心化的内网穿透与隧道转发。

核心能力

  • 把本地端口转发为临时或持久 .onion 隐藏服务
  • 支持反向导入远程 .onion 端口到本地接口
  • 用昵称复用同一 onion 地址配置多条转发
  • 支持 Tor 客户端授权密钥限制访问者
  • 提供 Docker 镜像,可配合 Compose 或 K8s 发布服务

容易踩的坑

本地构建的二进制依赖系统已安装 tor 可执行文件;用 libtor 静态构建需先装 tor、openssl、libevent、zlib 等 C 库且首次编译很慢;Docker 方式转发的是容器内地址,需相应调整本地地址

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v1.1.11
  1. v1.1.11最新正式版2024-12-19 · 2024-12-19 17:25 UTC

    Changelog

    • cbae9e7f0074e23f742db324b744056f17898690 fix(deps): update module golang.org/x/crypto to v0.31.0 [security] (#117)
  2. v1.1.102024-10-15 · 2024-10-15 17:27 UTC
    查看更新说明

    Changelog

    • fa6459c397be49315ad1d0b47ab70c2fc0cc8dd7 fix(deps): update module golang.org/x/net to v0.30.0 (#107)
  3. v1.1.92024-10-15 · 2024-10-15 17:25 UTC
    查看更新说明

    Changelog

    • 18470b64c37f8803cb5d70fadc20cac108bd6925 fix(deps): update module golang.org/x/crypto to v0.28.0 (#106)
  4. v1.1.82024-10-14 · 2024-10-14 23:52 UTC
    查看更新说明

    Changelog

    • 16da626d07c4ea4a10d48c5917d5a8868fbfec0c fix(deps): update module github.com/urfave/cli/v2 to v2.27.5 (#104)
  5. v1.1.72024-08-07 · 2024-08-07 01:23 UTC
    查看更新说明

    Changelog

    • 37f970fd79ef1582ea2c2025314a4829c0b9beb7 fix(deps): update module golang.org/x/net to v0.28.0 (#102)
    • 520d8d56bef757315989ce1f81ce574be6014c22 chore(deps): update docker/build-push-action digest to 2dbe91d (#100)

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    onionpipe

    Onion addresses for anything.

    onionpipe forwards ports on the local host to remote Onion addresses as Tor hidden services and vice-versa.

    Why would I want to use this?

    onionpipe is a decentralized way to create virtually unstoppable global network tunnels.

    For example, you might want to securely publish and access a personal service from anywhere in the world, across all sorts of network obstructions -- your ISP doesn't allow ingress traffic to your home lab, your clients might be in heavily firewalled environments (public WiFi, mobile tether), etc.

    With onionpipe, that service doesn't need a public IPv4 or IPv6 ingress. You can publish services with a globally-unique persistent onion address, and share access securely and privately to your own allowlist of authorized keys.

    You don't need to rely on, and share your personal data with for-profit services (like Tailscale, ZeroTier, etc.) to get to it.

    What can I do with it right now?

    onionpipe sets up socket forwarding tunnels. It's like socat(1), for onions.

    Export services on local networks to onion addresses

    Export localhost port 8000 to a temporary, one-time remote onion address.

    onionpipe 8000
    

    Export localhost port 8000 to temporary remote onion port 80. ~ is shorthand for the forward between source~destination.

    onionpipe 8000~80
    

    Export localhost port 8000 to a persistent remote onion address nicknamed 'my-app'.

    onionpipe 8000~80@my-app
    

    Nicknames can be re-used in multiple forwarding expressions to reference the same onion address. Let's set up a little web forum for our Minecraft server.

    onionpipe 8000~80@minecraft 25565@minecraft
    

    All the forwards without nicknames use the same temporary address.

    onionpipe 192.168.1.100:8000~80,8080,9000 9090
    

    Export a UNIX socket to an onion address.

    onionpipe /run/server.sock~80
    

    Export to a non-anonymous remote onion service, trading network privacy for possibly reduced latency.

    onionpipe --anonymous=false 8000
    
    Import onion services to local network interfaces.

    Import a remote onion's port 80 to localhost port 80.

    onionpipe xxx.onion:80
    

    Import remote onion port 80 to local port 80 on all interfaces. This can be used for creating an ingress to the onion on public networks.

    onionpipe xxx.onion:80~0.0.0.0:80
    

    Running with Docker is simple and easy, the only caveat is that its the container forwarding, so adjust local addresses accordingly.

    Forward port 80 on Docker host.

    docker run --rm ghcr.io/cmars/onionpipe:main host.docker.internal:80
    

    If you're using Podman, exposing the local host network is another option.

    podman run --network=host --rm ghcr.io/cmars/onionpipe:main 8000 
    

    Because local forwarding addresses are DNS resolved, it's very easy to publish hidden services from within Docker Compose or K8s. Check out this nextcloud example (watch the log for the onion address)!

    Client auth

    Client auth is great for securing personal services over Tor. How to use it:

    Alice creates a new client auth public key pair.

    onionpipe client new alice
    
    {
      "alice": {
        "identity": "p2pof7vumwsrqqavtovfwqqaw6cqzvtqqe7cjvxt754k6j7blufa"
      }
    }
    

    Alice shares this public key with Bob, who forwards an onion service that only Alice can use.

    onionpipe --require-auth p2pof7vumwsrqqavtovfwqqaw6cqzvtqqe7cjvxt754k6j7blufa 8000~80@test
    
    2022/02/13 21:25:46 starting tor...
    127.0.0.1:8000 => sd6aq2r6jvuoeisrudq7jbqufjh6nck5buuzjmgalicgwrobgfj4lkqd.onion:80
    

    Alice can use her client private key to connect to this onion and forward to a local port.

    onionpipe --auth alice sd6aq2r6jvuoeisrudq7jbqufjh6nck5buuzjmgalicgwrobgfj4lkqd.onion:80~7000
    
    2022/02/13 21:29:17 starting tor...
    sd6aq2r6jvuoeisrudq7jbqufjh6nck5buuzjmgalicgwrobgfj4lkqd.onion:80 => 127.0.0.1:7000
    

    How do I install it?

    Each commit into main triggers an automated release, which publishes a Docker image.

    Docker

    The provided Dockerfile builds a minimal image that can run onionpipe in a container with the latest Tor release from the Tor Project. Build and runtime is Debian-based.

    Local build

    In a local clone of this project,

    make onionpipe
    

    The built binary onionpipe will require a tor daemon executable to be in your $PATH.

    Static standalone binary with libtor

    See the latest release for Linux and Darwin binaries.

    Should theoretically work on: Linux, Darwin, Android (gomobile) according to the berty.tech/go-libtor README. There are some quirks; see comments in tor/init_libtor.go for details.

    In a local clone of this project,

    make onionpipe_libtor
    

    This will take a long time the first time you build, because it compiles CGO wrappers for Tor and its dependencies.

    You'll need to have C library dependencies installed for the build to work:

    • tor
    • openssl
    • libevent
    • zlib

    If you're on NixOS, you can run nix-shell in this directory to get these dependencies installed into your shell context.

    What features are planned?

    Declare forwards and operate from a yaml file rather than CLI arguments.

    onionpipe --config config.yaml
    

    Considering a fancy TUI.

    Considering a control plane for onionpipe SDN orchestration.

    Stay tuned.

    How can I contribute?

    Donate to the Tor project with your dollar, or by hosting honest proxies and exit nodes. If you like and use this project, support the public infrastructure that benefits us all and makes this wonderful magic possible.