From 14b6200fd81c41af243e4c87f0d9d4e43d717209 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Mon, 1 Aug 2022 17:02:13 +0800 Subject: [PATCH] Add documentation for vmess --- docs/configuration/inbound/index.md | 1 + docs/configuration/inbound/redirect.md | 2 +- docs/configuration/inbound/shadowsocks.md | 2 - docs/configuration/inbound/tproxy.md | 2 - docs/configuration/inbound/tun.md | 2 + docs/configuration/inbound/vmess.md | 85 +++++++++++++ docs/configuration/outbound/index.md | 1 + docs/configuration/outbound/socks.md | 2 + docs/configuration/outbound/vmess.md | 143 ++++++++++++++++++++++ go.mod | 2 +- go.sum | 4 +- mkdocs.yml | 2 + test/go.mod | 2 +- test/go.sum | 4 +- 14 files changed, 243 insertions(+), 11 deletions(-) create mode 100644 docs/configuration/inbound/vmess.md create mode 100644 docs/configuration/outbound/vmess.md diff --git a/docs/configuration/inbound/index.md b/docs/configuration/inbound/index.md index 487d8ec9..4894ab71 100644 --- a/docs/configuration/inbound/index.md +++ b/docs/configuration/inbound/index.md @@ -20,6 +20,7 @@ | `socks` | [Socks](./socks) | | `http` | [HTTP](./http) | | `shadowsocks` | [Shadowsocks](./shadowsocks) | +| `vmess` | [VMess](./vmess) | | `tun` | [Tun](./tun) | | `redirect` | [Redirect](./redirect) | | `tproxy` | [TProxy](./tproxy) | diff --git a/docs/configuration/inbound/redirect.md b/docs/configuration/inbound/redirect.md index 8ed7c502..59805789 100644 --- a/docs/configuration/inbound/redirect.md +++ b/docs/configuration/inbound/redirect.md @@ -1,4 +1,4 @@ -`redirect` inbound is a linux Redirect server. +`redirect` inbound is a linux redirect server. ### Structure diff --git a/docs/configuration/inbound/shadowsocks.md b/docs/configuration/inbound/shadowsocks.md index 0672d410..5c3c8323 100644 --- a/docs/configuration/inbound/shadowsocks.md +++ b/docs/configuration/inbound/shadowsocks.md @@ -1,5 +1,3 @@ -`shadowsocks` inbound is a shadowsocks server. - ### Structure ```json diff --git a/docs/configuration/inbound/tproxy.md b/docs/configuration/inbound/tproxy.md index 2d11bee5..edac0e6c 100644 --- a/docs/configuration/inbound/tproxy.md +++ b/docs/configuration/inbound/tproxy.md @@ -1,5 +1,3 @@ -`tproxy` inbound is a linux TProxy server. - ### Structure ```json diff --git a/docs/configuration/inbound/tun.md b/docs/configuration/inbound/tun.md index 2b661339..5046b8c7 100644 --- a/docs/configuration/inbound/tun.md +++ b/docs/configuration/inbound/tun.md @@ -10,12 +10,14 @@ { "type": "tun", "tag": "tun-in", + "inet4_address": "172.19.0.1/30", "inet6_address": "fdfe:dcba:9876::1/128", "mtu": 1500, "auto_route": true, "endpoint_independent_nat": false, "udp_timeout": 300, + "sniff": true, "sniff_override_destination": false, "domain_strategy": "prefer_ipv4" diff --git a/docs/configuration/inbound/vmess.md b/docs/configuration/inbound/vmess.md new file mode 100644 index 00000000..c641c313 --- /dev/null +++ b/docs/configuration/inbound/vmess.md @@ -0,0 +1,85 @@ +### Structure + +```json +{ + "inbounds": [ + { + "type": "vmess", + "tag": "vmess-in", + + "listen": "::", + "listen_port": 2080, + "tcp_fast_open": false, + "sniff": false, + "sniff_override_destination": false, + "domain_strategy": "prefer_ipv6", + + "users": [ + { + "name": "sekai", + "uuid": "bf000d23-0752-40b4-affe-68f7707a9661", + "alterId": 0 + } + ], + "tls": {} + } + ] +} +``` + +### Listen Fields + +#### listen + +==Required== + +Listen address. + +#### listen_port + +==Required== + +Listen port. + +#### tcp_fast_open + +Enable tcp fast open for listener. + +#### sniff + +Enable sniffing. + +See [Sniff](/configuration/route/sniff/) for details. + +#### sniff_override_destination + +Override the connection destination address with the sniffed domain. + +If the domain name is invalid (like tor), this will not work. + +#### domain_strategy + +One of `prefer_ipv4` `prefer_ipv6` `ipv4_only` `ipv6_only`. + +If set, the requested domain name will be resolved to IP before routing. + +If `sniff_override_destination` is in effect, its value will be taken as a fallback. + +### VMess Fields + +#### users + +VMess users. + +| Alter ID | Description | +|----------|-------------------------| +| 0 | Disable legacy protocol | +| > 0 | Enable legacy protocol | + +!!! warning "" + + Legacy protocol support (VMess MD5 Authentication) is provided for compatibility purposes only, use of alterId > 1 is not recommended. + +#### tls + +TLS configuration, see [TLS inbound structure](/configuration/shared/tls/#inbound-structure). diff --git a/docs/configuration/outbound/index.md b/docs/configuration/outbound/index.md index dad87189..29928998 100644 --- a/docs/configuration/outbound/index.md +++ b/docs/configuration/outbound/index.md @@ -20,6 +20,7 @@ | `socks` | [Socks](./socks) | | `http` | [HTTP](./http) | | `shadowsocks` | [Shadowsocks](./shadowsocks) | + | `vmess` | [VMess](./vmess) | | `dns` | [DNS](./dns) | | `selector` | [Selector](./selector) | diff --git a/docs/configuration/outbound/socks.md b/docs/configuration/outbound/socks.md index 97b0e507..275135e6 100644 --- a/docs/configuration/outbound/socks.md +++ b/docs/configuration/outbound/socks.md @@ -8,12 +8,14 @@ { "type": "socks", "tag": "socks-out", + "server": "127.0.0.1", "server_port": 1080, "version": "5", "username": "sekai", "password": "admin", "network": "udp", + "detour": "upstream-out", "bind_interface": "en0", "routing_mark": 1234, diff --git a/docs/configuration/outbound/vmess.md b/docs/configuration/outbound/vmess.md new file mode 100644 index 00000000..786c9cf9 --- /dev/null +++ b/docs/configuration/outbound/vmess.md @@ -0,0 +1,143 @@ +### Structure + +```json +{ + "outbounds": [ + { + "type": "vmess", + "tag": "vmess-out", + + "server": "127.0.0.1", + "server_port": 1080, + "uuid": "bf000d23-0752-40b4-affe-68f7707a9661", + "security": "auto", + "alter_id": 0, + "global_padding": false, + "authenticated_length": true, + "network": "tcp", + "tls": {}, + + "detour": "upstream-out", + "bind_interface": "en0", + "routing_mark": 1234, + "reuse_addr": false, + "connect_timeout": "5s", + "tcp_fast_open": false, + "domain_strategy": "prefer_ipv6", + "fallback_delay": "300ms" + } + ] +} +``` + +### VMess Fields + +#### server + +==Required== + +The server address. + +#### server_port + +==Required== + +The server port. + +#### uuid + +==Required== + +The VMess user id. + +#### security + +Encryption methods: + +* `auto` +* `none` +* `zero` +* `aes-128-gcm` +* `chancha20-poly1305` + +Legacy encryption methods: + +* `aes-128-ctr` + +#### alter_id + +| Alter ID | Description | +|----------|---------------------| +| 0 | Use AEAD protocol | +| 1 | Use legacy protocol | +| > 1 | Unused, same as 1 | + +#### global_padding + +Protocol parameter. Will waste traffic randomly if enabled (enabled by default in v2ray and cannot be disabled). + +#### authenticated_length + +Protocol parameter. Enable length block encryption. + +#### network + +Enabled network + +One of `tcp` `udp`. + +Both is enabled by default. + +#### tls + +TLS configuration, see [TLS outbound structure](/configuration/shared/tls/#outbound-structure). + +### Dial Fields + +#### detour + +The tag of the upstream outbound. + +Other dial fields will be ignored when enabled. + +#### bind_interface + +The network interface to bind to. + +#### routing_mark + +!!! error "" + + Linux only + +The iptables routing mark. + +#### reuse_addr + +Reuse listener address. + +#### connect_timeout + +Connect timeout, in golang's Duration format. + +A duration string is a possibly signed sequence of +decimal numbers, each with optional fraction and a unit suffix, +such as "300ms", "-1.5h" or "2h45m". +Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h". + +#### domain_strategy + +One of `prefer_ipv4` `prefer_ipv6` `ipv4_only` `ipv6_only`. + +If set, the server domain name will be resolved to IP before connecting. + +`dns.strategy` will be used if empty. + +#### fallback_delay + +The length of time to wait before spawning a RFC 6555 Fast Fallback connection. +That is, is the amount of time to wait for IPv6 to succeed before assuming +that IPv6 is misconfigured and falling back to IPv4 if `prefer_ipv4` is set. +If zero, a default delay of 300ms is used. + +Only take effect when `domain_strategy` is `prefer_ipv4` or `prefer_ipv6`. \ No newline at end of file diff --git a/go.mod b/go.mod index b9ffaa56..6dd2a48e 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,7 @@ require ( github.com/sagernet/sing-dns v0.0.0-20220730061139-c8e0fb296da9 github.com/sagernet/sing-shadowsocks v0.0.0-20220730132258-5c45f99276b8 github.com/sagernet/sing-tun v0.0.0-20220731115551-4a805410a2e8 - github.com/sagernet/sing-vmess v0.0.0-20220801041428-8f2785c629c3 + github.com/sagernet/sing-vmess v0.0.0-20220801082718-0b96d703437a github.com/spf13/cobra v1.5.0 github.com/stretchr/testify v1.8.0 go.uber.org/atomic v1.9.0 diff --git a/go.sum b/go.sum index 57408fcf..0546aa90 100644 --- a/go.sum +++ b/go.sum @@ -157,8 +157,8 @@ github.com/sagernet/sing-shadowsocks v0.0.0-20220730132258-5c45f99276b8 h1:d6Sda github.com/sagernet/sing-shadowsocks v0.0.0-20220730132258-5c45f99276b8/go.mod h1:aNTIkd+bCIUgr5C43aZBGXDxIc0Y9NOozLLzH2vUydM= github.com/sagernet/sing-tun v0.0.0-20220731115551-4a805410a2e8 h1:xXpkIml1GbkNlQwlmdLWvXBmOBPHDEIjv/QSrKPsLgY= github.com/sagernet/sing-tun v0.0.0-20220731115551-4a805410a2e8/go.mod h1:1V/Scct3DGHi925AasPCj1k+6SRWIcg0TvRHM0ZXB8I= -github.com/sagernet/sing-vmess v0.0.0-20220801041428-8f2785c629c3 h1:2ZTNZND525FxPkal2hiibrsVjtT8DRjAKA15PXkvggE= -github.com/sagernet/sing-vmess v0.0.0-20220801041428-8f2785c629c3/go.mod h1:NnKMgOr0WvyHsLICWTIz4xW3+yd3Ft2BtU8N5ycT4OU= +github.com/sagernet/sing-vmess v0.0.0-20220801082718-0b96d703437a h1:U4I/CHpGposYUF6RkQjzixr93ww2trnFJDo7JhFrBY0= +github.com/sagernet/sing-vmess v0.0.0-20220801082718-0b96d703437a/go.mod h1:4/SUIlK6Xn+hT7srzTcqVFQ/jX3EX4y3nYDfP0BnAuk= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/shurcooL/component v0.0.0-20170202220835-f88ec8f54cc4/go.mod h1:XhFIlyj5a1fBNx5aJTbKoIq0mNaPvOagO+HjB3EtxrY= github.com/shurcooL/events v0.0.0-20181021180414-410e4ca65f48/go.mod h1:5u70Mqkb5O5cxEA8nxTsgrgLehJeAw6Oc4Ab1c/P1HM= diff --git a/mkdocs.yml b/mkdocs.yml index 9e370451..9d8fd83a 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -45,6 +45,7 @@ nav: - Socks: configuration/inbound/socks.md - HTTP: configuration/inbound/http.md - Shadowsocks: configuration/inbound/shadowsocks.md + - VMess: configuration/inbound/vmess.md - Tun: configuration/inbound/tun.md - Redirect: configuration/inbound/redirect.md - TProxy: configuration/inbound/tproxy.md @@ -55,6 +56,7 @@ nav: - Socks: configuration/outbound/socks.md - HTTP: configuration/outbound/http.md - Shadowsocks: configuration/outbound/shadowsocks.md + - VMess: configuration/outbound/vmess.md - DNS: configuration/outbound/dns.md - Selector: configuration/outbound/selector.md - Route: diff --git a/test/go.mod b/test/go.mod index ae19ca0a..313d16a4 100644 --- a/test/go.mod +++ b/test/go.mod @@ -54,7 +54,7 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect github.com/sagernet/sing-dns v0.0.0-20220730061139-c8e0fb296da9 // indirect github.com/sagernet/sing-tun v0.0.0-20220731115551-4a805410a2e8 // indirect - github.com/sagernet/sing-vmess v0.0.0-20220801041428-8f2785c629c3 // indirect + github.com/sagernet/sing-vmess v0.0.0-20220801082718-0b96d703437a // indirect github.com/sirupsen/logrus v1.8.1 // indirect github.com/vishvananda/netlink v1.1.0 // indirect github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74 // indirect diff --git a/test/go.sum b/test/go.sum index 21c9d61d..8086b6be 100644 --- a/test/go.sum +++ b/test/go.sum @@ -180,8 +180,8 @@ github.com/sagernet/sing-shadowsocks v0.0.0-20220730132258-5c45f99276b8 h1:d6Sda github.com/sagernet/sing-shadowsocks v0.0.0-20220730132258-5c45f99276b8/go.mod h1:aNTIkd+bCIUgr5C43aZBGXDxIc0Y9NOozLLzH2vUydM= github.com/sagernet/sing-tun v0.0.0-20220731115551-4a805410a2e8 h1:xXpkIml1GbkNlQwlmdLWvXBmOBPHDEIjv/QSrKPsLgY= github.com/sagernet/sing-tun v0.0.0-20220731115551-4a805410a2e8/go.mod h1:1V/Scct3DGHi925AasPCj1k+6SRWIcg0TvRHM0ZXB8I= -github.com/sagernet/sing-vmess v0.0.0-20220801041428-8f2785c629c3 h1:2ZTNZND525FxPkal2hiibrsVjtT8DRjAKA15PXkvggE= -github.com/sagernet/sing-vmess v0.0.0-20220801041428-8f2785c629c3/go.mod h1:NnKMgOr0WvyHsLICWTIz4xW3+yd3Ft2BtU8N5ycT4OU= +github.com/sagernet/sing-vmess v0.0.0-20220801082718-0b96d703437a h1:U4I/CHpGposYUF6RkQjzixr93ww2trnFJDo7JhFrBY0= +github.com/sagernet/sing-vmess v0.0.0-20220801082718-0b96d703437a/go.mod h1:4/SUIlK6Xn+hT7srzTcqVFQ/jX3EX4y3nYDfP0BnAuk= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/shurcooL/component v0.0.0-20170202220835-f88ec8f54cc4/go.mod h1:XhFIlyj5a1fBNx5aJTbKoIq0mNaPvOagO+HjB3EtxrY= github.com/shurcooL/events v0.0.0-20181021180414-410e4ca65f48/go.mod h1:5u70Mqkb5O5cxEA8nxTsgrgLehJeAw6Oc4Ab1c/P1HM=