Update documentation

This commit is contained in:
世界 2022-08-08 20:57:50 +08:00
parent 4067e0f25c
commit 55d9a0ef2f
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4
10 changed files with 235 additions and 11 deletions

3
docs/changelog.md Normal file
View File

@ -0,0 +1,3 @@
#### 2022/08/08
No changelog before.

View File

@ -21,6 +21,7 @@
| `http` | [HTTP](./http) |
| `shadowsocks` | [Shadowsocks](./shadowsocks) |
| `vmess` | [VMess](./vmess) |
| `trojan` | [Trojan](./trojan) |
| `tun` | [Tun](./tun) |
| `redirect` | [Redirect](./redirect) |
| `tproxy` | [TProxy](./tproxy) |

View File

@ -0,0 +1,75 @@
### Structure
```json
{
"inbounds": [
{
"type": "trojan",
"tag": "trojan-in",
"listen": "::",
"listen_port": 2080,
"tcp_fast_open": false,
"sniff": false,
"sniff_override_destination": false,
"domain_strategy": "prefer_ipv6",
"users": [
{
"name": "sekai",
"password": "8JCsPssfgS8tiRwiMlhARg=="
}
],
"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.
### Trojan Fields
#### users
Trojan users.
#### tls
TLS configuration, see [TLS inbound structure](/configuration/shared/tls/#inbound-structure).

View File

@ -10,13 +10,15 @@
{
"type": "tun",
"tag": "tun-in",
"interface_name": "tun0",
"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,
"stack": "gvisor",
"sniff": true,
"sniff_override_destination": false,
@ -26,8 +28,16 @@
}
```
!!! warning ""
If tun is running in non-privileged mode, the address and MTU will not be configured automatically, please make sure the settings are accurate.
### Tun Fields
#### interface_name
Virtual device name, automatically selected if empty.
#### inet4_address
==Required==
@ -60,6 +70,19 @@ Performance may degrade slightly, so it is not recommended to enable on when it
UDP NAT expiration time in seconds, default is 300 (5 minutes).
#### stack
TCP/IP stack.
| Stack | Upstream | Status |
|------------------|-----------------------------------------------------------------------|-------------------|
| gVisor (default) | [google/gvisor](https://github.com/google/gvisor) | recommended |
| LWIP | [eycorsican/go-tun2socks](https://github.com/eycorsican/go-tun2socks) | upstream archived |
!!! warning ""
The LWIP stack is not included by default, see [Installation](/#Installation).
### Listen Fields
#### sniff

View File

@ -21,6 +21,7 @@
| `http` | [HTTP](./http) |
| `shadowsocks` | [Shadowsocks](./shadowsocks) |
| `vmess` | [VMess](./vmess) |
| `trojan` | [Trojan](./trojan) |
| `dns` | [DNS](./dns) |
| `selector` | [Selector](./selector) |

View File

@ -0,0 +1,114 @@
### Structure
```json
{
"outbounds": [
{
"type": "trojan",
"tag": "trojan-out",
"server": "127.0.0.1",
"server_port": 1080,
"password": "8JCsPssfgS8tiRwiMlhARg==",
"network": "tcp",
"tls": {},
"multiplex": {},
"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"
}
]
}
```
### Trojan Fields
#### server
==Required==
The server address.
#### server_port
==Required==
The server port.
#### password
==Required==
The Trojan password.
#### network
Enabled network
One of `tcp` `udp`.
Both is enabled by default.
#### tls
TLS configuration, see [TLS outbound structure](/configuration/shared/tls/#outbound-structure).
#### multiplex
Multiplex configuration, see [Multiplex structure](/configuration/shared/multiplex).
### 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`.

View File

@ -2,7 +2,7 @@
Configuration examples for sing-box.
* [Linux Server Install](./linux-server-install)
* [Linux Server Installation](./linux-server-installation)
* [Shadowsocks Server](./ss-server)
* [Shadowsocks Client](./ss-client)
* [Shadowsocks Tun](./ss-tun)

View File

@ -6,7 +6,7 @@ The universal proxy platform.
## Installation
sing-box requires Golang 1.18 or a higher version.
sing-box requires Golang **1.18.5** or a higher version.
```bash
go install -v github.com/sagernet/sing-box/cmd/sing-box@latest
@ -15,14 +15,15 @@ go install -v github.com/sagernet/sing-box/cmd/sing-box@latest
Install with options:
```bash
go install -v -tags "with_clash_api,no_gvisor" github.com/sagernet/sing-box/cmd/sing-box@latest
go install -v -tags with_clash_api github.com/sagernet/sing-box/cmd/sing-box@latest
```
| Build Tag | Description |
|------------------|---------------------------------------------------------------------------------------------------------|
| `with_quic` | Build with quic support, which required by [QUIC and HTTP3](./configuration/dns/server) dns transports. |
| `with_clash_api` | Build with clash api support, see [Experimental](./configuration/experimental#clash-api-fields). |
| `no_gvisor` | Build without gVisor, which required by the [Tun](./configuration/inbound/tun) inbound. |
| Build Tag | Description |
|----------------------------|--------------------------------------------------------------------------------------------------|
| `with_quic` | Build with QUIC support, see [QUIC and HTTP3](./configuration/dns/server) dns transports. |
| `with_clash_api` | Build with Clash api support, see [Experimental](./configuration/experimental#clash-api-fields). |
| `no_gvisor` | Build without gVisor tun stack support, see [Tun](./configuration/inbound/tun#stack). |
| `with_lwip` (CGO required) | Build with LWIP tun stack support, see [Tun](./configuration/inbound/tun#stack). |
The binary is built under $GOPATH/bin
@ -30,6 +31,8 @@ The binary is built under $GOPATH/bin
sing-box version
```
It is also recommended to use systemd to manage sing-box service, see [Linux server installation example](./examples/linux-server-installation).
## License
```

View File

@ -30,7 +30,9 @@ theme:
- navigation.sections
- header.autohide
nav:
- Getting Started: index.md
- Getting Started:
- index.md
- Change Log: changelog.md
- Configuration:
- configuration/index.md
- Log: configuration/log.md
@ -46,6 +48,7 @@ nav:
- HTTP: configuration/inbound/http.md
- Shadowsocks: configuration/inbound/shadowsocks.md
- VMess: configuration/inbound/vmess.md
- Trojan: configuration/inbound/trojan.md
- Tun: configuration/inbound/tun.md
- Redirect: configuration/inbound/redirect.md
- TProxy: configuration/inbound/tproxy.md
@ -57,6 +60,7 @@ nav:
- HTTP: configuration/outbound/http.md
- Shadowsocks: configuration/outbound/shadowsocks.md
- VMess: configuration/outbound/vmess.md
- Trojan: configuration/outbound/trojan.md
- DNS: configuration/outbound/dns.md
- Selector: configuration/outbound/selector.md
- Route:
@ -71,7 +75,7 @@ nav:
- Multiplex: configuration/shared/multiplex.md
- Examples:
- examples/index.md
- Linux Server Install: examples/linux-server-install.md
- Linux Server Installation: examples/linux-server-installation.md
- Shadowsocks Server: examples/ss-server.md
- Shadowsocks Client: examples/ss-client.md
- Shadowsocks Tun: examples/ss-tun.md