Skip to content

Commit 82de133

Browse files
committed
feat: start relay over HTTP by default
1 parent 91744b6 commit 82de133

19 files changed

Lines changed: 457 additions & 507 deletions

CHANGELOG.en.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
All notable changes to `ii` are documented here. The default Chinese version is [CHANGELOG.md](CHANGELOG.md).
44

5+
## 0.2.8 - 2026-08-03
6+
7+
### Changed
8+
9+
- `ii relay` now starts an HTTP relay without arguments on a random port and supports `--port` for a fixed port; it prints reachable IPv4 URLs and other interface URLs.
10+
- `--tls` is now an optional self-signed HTTPS switch, `--domain` selects the TLS name, and `--cert` plus `--key` replace the generated certificate; `--public` and `-H` were removed.
11+
- `ii send --relay` and `ii tunnel -s --relay` accept HTTP or HTTPS URLs; `-k` is HTTPS-only.
12+
513
## 0.2.7 - 2026-08-03
614

715
### Changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
本文件记录 `ii` 的重要变更。默认中文版本在这里,英文版本见 [CHANGELOG.en.md](CHANGELOG.en.md)
44

5+
## 0.2.8 - 2026-08-03
6+
7+
### 变更
8+
9+
- `ii relay` 改为无参启动 HTTP relay,默认随机端口,支持 `--port` 固定端口;终端输出可访问 IPv4 URL 和 `other:` 网卡 URL。
10+
- `--tls` 改为可选自签 HTTPS 开关,`--domain` 指定 TLS 域名,`--cert``--key` 可替换自动证书;删除 `--public``-H`
11+
- `ii send --relay``ii tunnel -s --relay` 支持 HTTP 或 HTTPS URL;`-k` 仅可用于 HTTPS relay。
12+
513
## 0.2.7 - 2026-08-03
614

715
### 变更

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ exclude = ["vendor/iroh", "vendor/suppaftp"]
44
resolver = "3"
55

66
[workspace.package]
7-
version = "0.2.7"
7+
version = "0.2.8"
88
edition = "2024"
99
rust-version = "1.91"
1010
license = "MIT"

README.en.md

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@ ii tunnel -c ii1k7v...x9a --listen 0.0.0.0:8022
163163
Connections to B's listener travel over an encrypted Iroh connection to A, where A connects to the target TCP port. Direct paths are preferred and the default Iroh relay remains available. For a self-hosted public relay, specify it on A; the ticket carries the relay and self-signed trust policy to B:
164164

165165
```powershell
166-
ii relay --public https://PUBLIC_IP:8443
167-
ii tunnel -s 192.168.1.10:5000 --relay https://PUBLIC_IP:8443 -k
166+
ii relay --port 8443
167+
ii tunnel -s 192.168.1.10:5000 --relay http://PUBLIC_IP:8443
168168
```
169169

170170
The relay forwards encrypted Iroh traffic only. It does not expose the target TCP port to the public Internet. The ticket contains this tunnel's bearer access key, so anyone holding it can connect until A stops the service. The first release supports TCP only.
@@ -256,40 +256,50 @@ ii version
256256

257257
You do not need to understand relay hosting to send ordinary files. This section is only for running your own relay service or using a fixed relay entrypoint in a company network.
258258

259-
Start a self-signed HTTPS relay:
259+
Start an HTTP relay:
260260

261261
```powershell
262-
ii relay --public https://SERVER_PUBLIC_IP:8443
262+
ii relay
263263
```
264264

265-
You can use a domain too:
265+
By default it listens on `0.0.0.0` at a random free port and prints the primary IPv4 URL plus other local IPv4 interfaces. `0.0.0.0` is only a bind address, never a client address; clients use a reachable LAN or public IP with the printed port. A cloud public IP may be NAT-provided and therefore absent from the interface list.
266+
267+
Choose a fixed port:
266268

267269
```powershell
268-
ii relay --public https://relay.example.com
270+
ii relay --port 8443
269271
```
270272

271-
`--public` is the public HTTPS address used by clients and must be `https://host[:port]`. On first start, `ii` generates and persists a self-signed certificate and key in the relay state directory. It listens on the public URL port, or on `443` when the URL has no port. Use `-H` for a different local backend port behind NAT or a reverse proxy:
273+
Send through the HTTP relay:
272274

273275
```powershell
274-
ii relay --public https://relay.example.com:8443 -H 9443
276+
ii send .\video.mp4 --relay http://SERVER_PUBLIC_IP:8443
275277
```
276278

277-
Send through the relay:
279+
For HTTPS, let `ii` generate a self-signed certificate for this process:
278280

279281
```powershell
282+
ii relay --tls --port 8443
280283
ii send .\video.mp4 --relay https://SERVER_PUBLIC_IP:8443 -k
281284
```
282285

283-
`-k` accepts the self-signed certificate and puts that policy in the ticket; the receiver needs no certificate installation or relay configuration. A first connection can still be replaced by a man-in-the-middle.
286+
`-k` is HTTPS-only. It skips certificate verification for that relay and puts the policy in the ticket; the receiver needs no certificate installation or relay configuration. A first connection can still be replaced by a man-in-the-middle.
287+
288+
For a named self-signed TLS relay:
289+
290+
```powershell
291+
ii relay --tls --domain relay.example.com --port 8443
292+
ii send .\video.mp4 --relay https://relay.example.com:8443 -k
293+
```
284294

285-
With a domain and PEM certificate files, use manual TLS:
295+
To replace the generated certificate with PEM files:
286296

287297
```powershell
288-
ii relay --tls relay.example.com -H 8443 --cert D:\certs\fullchain.pem --key D:\certs\privkey.pem
298+
ii relay --tls --domain relay.example.com --port 8443 --cert D:\certs\fullchain.pem --key D:\certs\privkey.pem
289299
ii send .\video.mp4 --relay https://relay.example.com:8443
290300
```
291301

292-
Manual TLS does not use `-k`; clients use normal system TLS verification. Both `--relay` modes force HTTPS relay-only transport and skip UDP and direct paths. See [ii.md](ii.md) for ports, state paths, and the security boundary. FTP and SFTP configuration, tickets, and security limits are documented in [ftp.md](ftp.md) and [sftp.md](sftp.md).
302+
Manual TLS does not use `-k`; clients use normal system TLS verification. HTTP and HTTPS `--relay` modes both force relay-only transport and skip UDP and direct paths. See [ii.md](ii.md) for ports, TLS, public NAT boundaries, and the security boundary. FTP and SFTP configuration, tickets, and security limits are documented in [ftp.md](ftp.md) and [sftp.md](sftp.md).
293303

294304
## Full Manual
295305

README.md

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ ii tunnel -c ii1k7v...x9a --listen 0.0.0.0:8022
166166
本机连接 B 的监听端口,流量会经 Iroh 加密连接送到 A,再由 A 连接目标 TCP 端口。直连失败时默认可用 Iroh relay;自建公网 relay 时,在 A 上指定它,ticket 会把 relay 和自签信任策略带给 B:
167167

168168
```powershell
169-
ii relay --public https://公网IP:8443
170-
ii tunnel -s 192.168.1.10:5000 --relay https://公网IP:8443 -k
169+
ii relay --port 8443
170+
ii tunnel -s 192.168.1.10:5000 --relay http://公网IP:8443
171171
```
172172

173173
relay 只转发加密 Iroh 流量,不会把目标 TCP 端口直接开放到公网。ticket 内含本次 tunnel 的访问密钥,持有者可接入直到 A 停止服务,不要泄露。首版只支持 TCP。
@@ -268,40 +268,50 @@ ii version
268268

269269
普通发文件不需要先理解 relay。只有你要自建中继服务,或者公司网络环境需要固定中继入口时,才需要看这一段。
270270

271-
启动自签 HTTPS relay:
271+
直接启动 HTTP relay:
272272

273273
```powershell
274-
ii relay --public https://服务器公网IP:8443
274+
ii relay
275275
```
276276

277-
也可以使用域名:
277+
默认监听 `0.0.0.0` 的随机空闲端口,终端会打印主网卡 URL 和 `other:` 下的其余 IPv4 网卡 URL。`0.0.0.0` 仅用于监听,不能作为客户端地址;客户端使用实际可达的局域网 IP 或公网 IP 加打印出的端口。云服务器的公网 IP 可能由 NAT 提供,不一定出现在网卡列表中。
278+
279+
固定端口:
278280

279281
```powershell
280-
ii relay --public https://relay.example.com
282+
ii relay --port 8443
281283
```
282284

283-
`--public` 是客户端实际访问的公网 HTTPS 地址,必须是 `https://主机[:端口]`。首次启动会自动在 relay 状态目录生成并持久化自签证书和私钥。默认监听 `--public` 的端口,未写端口就是 `443`;NAT 或反向代理需要转到不同后端端口时,用 `-H`
285+
发送端指定 HTTP relay:
284286

285287
```powershell
286-
ii relay --public https://relay.example.com:8443 -H 9443
288+
ii send .\video.mp4 --relay http://服务器公网IP:8443
287289
```
288290

289-
发送端指定 relay
291+
需要 HTTPS 时由 `ii` 自动生成当前进程使用的自签证书
290292

291293
```powershell
294+
ii relay --tls --port 8443
292295
ii send .\video.mp4 --relay https://服务器公网IP:8443 -k
293296
```
294297

295-
`-k` 表示接受自签证书,并把该策略带进 ticket;接收方无需安装证书或配置 relay。首次连接仍可能遭遇中间人替换。
298+
`-k` 只用于 HTTPS,表示跳过该 relay 的证书校验,并把该策略带进 ticket;接收方无需安装证书或配置 relay。首次连接仍可能遭遇中间人替换。
299+
300+
自签 TLS 需要域名显示时:
301+
302+
```powershell
303+
ii relay --tls --domain relay.example.com --port 8443
304+
ii send .\video.mp4 --relay https://relay.example.com:8443 -k
305+
```
296306

297-
已有域名和 PEM 证书时,使用手工证书模式
307+
已有 PEM 证书时,使用手工证书替换自签证书
298308

299309
```powershell
300-
ii relay --tls relay.example.com -H 8443 --cert D:\certs\fullchain.pem --key D:\certs\privkey.pem
310+
ii relay --tls --domain relay.example.com --port 8443 --cert D:\certs\fullchain.pem --key D:\certs\privkey.pem
301311
ii send .\video.mp4 --relay https://relay.example.com:8443
302312
```
303313

304-
手工证书模式不带 `-k`,客户端使用系统正常 TLS 校验。两种 `--relay` 都只走 HTTPS relay,不尝试 UDP 或直连;完整端口、状态路径和安全边界见 [ii.md](ii.md)。FTP 和 SFTP 的配置、ticket 和安全限制分别见 [ftp.md](ftp.md)[sftp.md](sftp.md)
314+
手工证书模式不带 `-k`,客户端使用系统正常 TLS 校验。HTTP 或 HTTPS 的 `--relay` 都只走 relay-only,不尝试 UDP 或直连;完整端口、TLS 和公网 NAT 边界见 [ii.md](ii.md)。FTP 和 SFTP 的配置、ticket 和安全限制分别见 [ftp.md](ftp.md)[sftp.md](sftp.md)
305315

306316
## 详细手册
307317

ii.md

Lines changed: 38 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010

1111
```text
1212
ii help [<command>]
13-
ii send [<path>] [--name <name>] [-t] [-c] [-o <path>] [--web [--port <port>] [--token [<value>]] [--upload] [--path <dir>] | --s3 | --webdav | --ftp | --sftp] [--profile <name>] [-d] [-p] [--local] [--relay <https-url> [-k]] [--no-relay]
13+
ii send [<path>] [--name <name>] [-t] [-c] [-o <path>] [--web [--port <port>] [--token [<value>]] [--upload] [--path <dir>] | --s3 | --webdav | --ftp | --sftp] [--profile <name>] [-d] [-p] [--local] [--relay <url> [-k]] [--no-relay]
1414
ii web [<目录>] [--port <port>] [--token [<value>]] [--upload] [--path <目录>]
1515
ii webrtc [--port <port>] [--token [<value>]]
16-
ii tunnel -s <target-host:port> [--relay <https-url> [-k]]
16+
ii tunnel -s <target-host:port> [--relay <url> [-k]]
1717
ii tunnel -c <ticket> [--listen <ip:port>]
1818
ii recv <ticket> [-o <dir>] [--stdout] [--overwrite] [--resume] [--local] [--trace]
19-
ii relay (--public <https-url> | --tls <domain> --cert <path> --key <path>) [-H <bind-port>]
19+
ii relay [--port <port>] [--tls [--domain <name>] [--cert <path> --key <path>]]
2020
ii doctor
2121
ii version
2222
```
@@ -103,13 +103,13 @@ tar czf - .\project | ii send --name project.tar.gz
103103
: 只走局域网优先路径,不走公网发现,不走公网 relay。
104104

105105
`--relay <url>`
106-
: 使用 HTTPS relay-only 模式,URL 必须是 `https://主机[:端口]`
106+
: 使用 HTTP 或 HTTPS relay-only 模式,URL 必须是 `http://主机[:端口]` `https://主机[:端口]`
107107
发送端和接收端都只通过该 relay 传输,不尝试 UDP、局域网发现或点对点直连。
108-
默认按系统证书链校验 relay,适合 `ii relay --tls --cert --key` 的手工证书模式。
108+
HTTPS 默认按系统证书链校验,适合 `ii relay --tls --cert --key` 的手工证书模式。
109109

110110
`-k`
111-
: 只允许和 `--relay` 一起使用,表示接受该 relay 的自签证书。
112-
用于 `ii relay --public https://...`。带 `-k` 的 ticket 会让接收端自动沿用自签信任策略。
111+
: 只允许和 HTTPS `--relay` 一起使用,表示接受该 relay 的自签证书。
112+
用于 `ii relay --tls`。带 `-k` 的 ticket 会让接收端自动沿用自签信任策略。
113113

114114
`--no-relay`
115115
: 禁用 relay,只允许直连和局域网路径。
@@ -147,7 +147,7 @@ tar czf - .\project | ii send --name project.tar.gz
147147
- `--web``--s3``--webdav``--ftp``--sftp``--local``--relay``--no-relay` 互斥。
148148
- 默认不需要用户选 relay。
149149
- 如果没有局域网或直连可用,默认会自动退到公网 relay。
150-
- 指定 `--relay https://...` 后,当前发送会强制走 HTTPS relay-only,不使用默认公网 relay。
150+
- 指定 `--relay http://...``--relay https://...` 后,当前发送会强制走 relay-only,不使用默认公网 relay。
151151
- 手工证书 relay 不带 `-k`;自签 relay 必须带 `-k`
152152

153153
## `ii web`
@@ -196,11 +196,11 @@ ii tunnel -c ii1k7v...x9a
196196
默认先尝试直连和局域网路径,必要时使用 Iroh 默认 relay。指定 relay 时只在 A 上使用:
197197

198198
```powershell
199-
ii relay --public https://公网IP:8443
200-
ii tunnel -s 192.168.1.10:5000 --relay https://公网IP:8443 -k
199+
ii relay --port 8443
200+
ii tunnel -s 192.168.1.10:5000 --relay http://公网IP:8443
201201
```
202202

203-
`--relay <url>` 必须为 `https://主机[:端口]`,使本次 tunnel 强制走该 HTTPS relay;`-k` 仅和 `-s --relay` 同用,接受自签 relay。ticket 会把 relay URL 和自签信任策略带给 B,B 不需要再次配置。relay 只转发加密 Iroh 流量,不会把目标 TCP 端口直接暴露到公网。
203+
`--relay <url>` 可为 `http://主机[:端口]``https://主机[:端口]`,使本次 tunnel 强制走该 relay;`-k` 仅和 HTTPS `-s --relay` 同用,接受自签 relay。ticket 会把 relay URL 和自签信任策略带给 B,B 不需要再次配置。relay 只转发加密 Iroh 流量,不会把目标 TCP 端口直接暴露到公网。
204204

205205
ticket 内有一次随机访问密钥。持有 ticket 的设备可以接入,直到 A 按 `Ctrl+C` 停止 tunnel;不要泄露 ticket。首版不支持 UDP、SOCKS、反向 tunnel 或后台守护。
206206

@@ -336,74 +336,65 @@ ticket 里可以带足够完成连接、恢复传输和重复文件判定的最
336336

337337
## `ii relay`
338338

339-
`ii relay` 支持两种 HTTPS relay-only 服务模式:`--public` 自动生成自签证书,或 `--tls --cert --key` 使用已有证书。
340-
341-
### 自签模式
342-
343-
`--public` 启动自动生成证书的自签 relay,格式只能是 `https://主机[:公网端口]`
339+
`ii relay` 默认启动 HTTP relay,不需要参数:
344340

345341
```powershell
346-
ii relay --public https://relay.example.com
347-
ii relay --public https://relay.example.com:8443
342+
ii relay
343+
ii relay --port 8443
348344
```
349345

350-
不传 `-H` 时,relay 监听 `--public` 中的端口;URL 没写端口时监听 `443`。如果 NAT 或反向代理把公网端口转发到不同的本机端口,用 `-H` 指定本机监听端口:
351-
352-
```powershell
353-
ii relay --public https://relay.example.com:8443 -H 9443
354-
```
346+
它监听 `0.0.0.0:随机端口`,或监听 `--port` 指定的 `0.0.0.0:端口`。终端按 `ii web` 的格式输出主 IPv4 URL 和 `other:` 下的其余物理、虚拟网卡 IPv4 URL,但不显示二维码。`0.0.0.0` 只是 bind 地址,不能作为客户端 URL;客户端必须使用实际可达 IP 或域名。
355347

356-
上例中客户端访问 `https://relay.example.com:8443`,relay 本机监听 `9443/tcp`。必须对外开放公网 HTTPS 端口;relay 不开放 HTTP、UDP 或 QUIC 端口
348+
裸机或公网 IP 直接绑在网卡时,打印列表会包含公网地址。云服务器常由 NAT 映射公网 IP,网卡列表只有私网地址;这时从云控制台取得公网 IP,再与终端打印的端口拼成 relay URL。`ii` 不尝试猜测 NAT 映射
357349

358-
自签 relay 的客户端必须带 `-k`
350+
HTTP relay 示例
359351

360352
```powershell
361-
ii send .\video.mp4 --relay https://203.0.113.10:8443 -k
362-
ii send .\video.mp4 --relay https://relay.example.com -k
353+
ii relay --port 8443
354+
ii send .\video.mp4 --relay http://公网IP:8443
355+
ii tunnel -s 192.168.1.10:5000 --relay http://公网IP:8443
363356
```
364357

365-
`-k` 会把“接受自签证书”的策略写入 ticket。接收方只需运行 ticket 打印出的 `ii recv ...`,不需要另装证书、不需要写 relay 配置。
366-
367-
### 自签证书和状态文件
358+
### TLS
368359

369-
首次成功启动时,`ii relay` 自动生成并持久化自签 TLS 证书和私钥;重启时复用同一份材料
360+
`--tls` 开启 HTTPS。没有 `--cert``--key` 时,`ii` 仅为当前进程生成自签证书;客户端必须带 `-k`
370361

371-
- Windows:`ii.exe` 同目录的 `relay.toml``relay-cert.pem``relay-key.pem`
372-
- Linux/macOS/其他 Unix-like:`/etc/ii/relay.toml``/etc/ii/relay-cert.pem``/etc/ii/relay-key.pem`
373-
374-
`relay.toml` 记录该 relay 的公网 URL。后续必须继续使用同一 `--public`;若要换公网地址,删除这三个 state 文件后重新启动,让它生成新的 relay 身份。私钥或证书只剩其中一个、或内容损坏时,`ii relay` 会明确报错,不会悄悄换证书。
375-
376-
自签模式不接受 `--tls``--cert``--key`。它不使用 ACME、Let’s Encrypt、HTTP relay、QUIC 或 metrics。
377-
378-
### 手工证书模式
362+
```powershell
363+
ii relay --tls --port 8443
364+
ii send .\video.mp4 --relay https://公网IP:8443 -k
365+
```
379366

380-
使用已有的 PEM 完整证书链与私钥时
367+
需要以域名访问时
381368

382369
```powershell
383-
ii relay --tls relay.example.com -H 8443 --cert .\fullchain.pem --key .\privkey.pem
370+
ii relay --tls --domain relay.example.com --port 8443
371+
ii send .\video.mp4 --relay https://relay.example.com:8443 -k
384372
```
385373

386-
`--tls` 必须是证书 SAN 包含的裸域名;`--cert` 是 PEM 格式的完整证书链,`--key` 是匹配的 PEM 私钥。手工模式不读、不写 `relay.toml` 或自签证书文件
374+
`--domain` 时,终端只输出该域名 HTTPS URL;自动证书包含该 DNS SAN。没有 `--domain` 时,终端输出 HTTPS 网卡 IP URL,仍需 `-k`
387375

388-
客户端使用正常 TLS 校验,不带 `-k`
376+
已有 PEM 完整证书链和私钥时,成对提供 `--cert``--key` 替换自动证书
389377

390378
```powershell
379+
ii relay --tls --domain relay.example.com --port 8443 --cert .\fullchain.pem --key .\privkey.pem
391380
ii send .\video.mp4 --relay https://relay.example.com:8443
392381
```
393382

394-
两种模式的 `--relay` 都强制 relay-only:不尝试局域网发现、UDP 打洞或点对点直连。
383+
手工证书模式通常配合 `--domain`,客户端正常校验证书,不带 `-k`。允许不带 `--domain` 使用手工证书;此时终端输出 HTTPS 网卡 IP URL,证书必须包含对应 IP SAN,否则用户需要自行改用匹配证书名或 `-k`
384+
385+
`--domain` 只能与 `--tls` 同用;`--cert``--key` 必须成对出现,且也要求 `--tls`。旧 `--public``-H` 已删除。HTTP 或 HTTPS 的 `--relay` 都强制 relay-only:不尝试局域网发现、UDP 打洞或点对点直连。
395386

396387
### 安全边界
397388

398-
`-k` 对该 relay 自动接受自签证书,部署最简单,但首次连接时可被中间人替换 relay。Iroh 的端到端节点认证仍在;这个限制只针对 relay HTTPS 连接的首次信任。手工证书模式不带 `-k`,继续使用系统 TLS 证书校验。
389+
HTTP relay 不提供 relay 连接层 TLS;HTTPS 自签模式的 `-k` 会跳过证书校验,首次连接可能被中间人替换 relay。Iroh 的端到端节点认证仍在;手工证书模式不带 `-k`,继续使用系统 TLS 证书校验。
399390

400391
### 日志
401392

402-
启动后会输出公网地址、本机监听端口、客户端连接和断开日志。需要更详细的协议日志时设置 `RUST_LOG`,例如:
393+
启动后会输出可访问 URL、客户端连接和断开日志。需要更详细的协议日志时设置 `RUST_LOG`,例如:
403394

404395
```powershell
405396
$env:RUST_LOG="debug"
406-
ii relay --public https://203.0.113.10:8443
397+
ii relay --port 8443
407398
```
408399

409400
## `ii doctor`

0 commit comments

Comments
 (0)