Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trojan-go:// 分享链接规范 #132

Open
DuckSoft opened this issue Jul 11, 2020 · 3 comments
Open

trojan-go:// 分享链接规范 #132

DuckSoft opened this issue Jul 11, 2020 · 3 comments
Labels
documentation Improvements or additions to documentation enhancement New feature or request help wanted Extra attention is needed

Comments

@DuckSoft
Copy link
Contributor

DuckSoft commented Jul 11, 2020

原则

  • 必须是合法的 URL
  • 对人类/机器友好
  • URL 字段顺序不敏感,但不能重复出现

概览

trojan-go://
    $(trojan-password)
    @
    trojan-host
    :
    port
?
    sni=$(update.microsoft.com)&
    type=$(original|ws|h2|h2+ws)& 
        host=$(update-01.microsoft.com)&
        path=$(/update/whatever)&
    encryption=$(ss;aes-256-gcm:ss-password)&
    plugin=$(...)
#$(descriptive-text)

特别说明:$() 代表此处需要 encodeURIComponent

举例

  • trojan-go://f@uck.me/?sni=microsoft.com&type=ws&path=%2Fgo&encryption=ss%3Baes-256-gcm%3Afuckgfw

详述

注意:所有参数名和常数字符串均区分大小写。

trojan-password

Trojan 的密码。
不可省略,不能为空字符串,不建议含有非 ASCII 可打印字符。
必须使用 encodeURIComponent 编码。

trojan-host

节点 IP / 域名。
不可省略,不能为空字符串。
IPv6 地址必须扩方括号。
IDN 域名(如“百度.cn”)必须使用 xn--xxxxxx 格式。

port

节点端口。
省略时默认为 443
必须取 [1,65535] 中的整数。

tls

没有这个字段。
TLS 默认一直启用,除非有传输插件禁用它。
TLS 默认不允许不安全证书,所以不要想什么 allowInsecure 之类的,这种节点不适合分享给别人。

sni

自定义 TLS 的 SNI。
省略时默认与 trojan-host 同值。不得为空字符串。

必须使用 encodeURIComponent 编码。

type

传输类型。
省略时默认为 original,但不可为空字符串。
目前可选值只有 originalws,未来可能会有 h2h2+ws 等取值。

当取值为 original 时,使用原始 Trojan 传输方式,无法方便通过 CDN。
当取值为 ws 时,使用 wss 作为传输层。

host

自定义 HTTP Host 头。
可以省略,省略时值同 trojan-host
可以为空字符串,但可能带来非预期情形。

警告:若你的端口非标准端口(不是 80 / 443),RFC 标准规定 Host 应在主机名后附上端口号,例如 example.com:44333。至于是否遵守,请自行斟酌。

必须使用 encodeURIComponent 编码。

path

当传输类型 typewsh2h2+ws 时,此项有效。
不可省略,不可为空。
必须以 / 开头。
可以使用 URL 中的 & # ? 等字符,但应当是合法的 URL 路径。

必须使用 encodeURIComponent 编码。

mux

没有这个字段。
当前服务器默认一直支持 mux
启用 mux 与否各有利弊,应由客户端决定自己是否启用。

encryption

用于保证 Trojan 流量密码学安全的加密层。
可省略,默认为 none,即不使用加密。
不可以为空字符串。

必须使用 encodeURIComponent 编码。

使用 Shadowsocks 算法进行流量加密时,其格式为:

ss;method:password

其中 ss 是固定内容,method 是加密方法,必须为下列之一:

  • aes-128-gcm
  • aes-256-gcm
  • chacha20-ietf-poly1305

其中的 password 是 Shadowsocks 的密码,不得为空字符串。
password 中若包含分号或冒号,不需要进行转义。
password 应为英文可打印 ASCII 字符。

其他加密方案待定。

plugin

额外的插件选项。本字段保留。
可省略,但不可以为空字符串。

URL Fragment (# 后内容)

节点说明。
不建议省略,不建议为空字符串。

必须使用 encodeURIComponent 编码。

@p4gefau1t p4gefau1t added documentation Improvements or additions to documentation enhancement New feature or request help wanted Extra attention is needed labels Jul 11, 2020
@DuckSoft
Copy link
Contributor Author

Update:写了一个 coverage 100% 的 parser:#133
已经 PR 给 trojan-go 仓库了。

@DuckSoft
Copy link
Contributor Author

@p4gefau1t 建议 pin 一下。

@likecreep
Copy link

指纹伪造的参数是什么呢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants