Skip to content

Commit ed79da7

Browse files
committed
edit manual
1 parent c939376 commit ed79da7

File tree

3 files changed

+152
-19
lines changed

3 files changed

+152
-19
lines changed

doc/book/book.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ src = "src"
66
title = "ruci_manual"
77

88
[output.html]
9-
git-repository-url = "https://e1732a364fed.github.io/ruci/"
9+
git-repository-url = "https://github.com/e1732a364fed/ruci/"
1010
git-repository-icon = "fa-github"
1111
additional-css = ["theme/pagetoc.css"]
1212
additional-js = ["theme/pagetoc.js"]

doc/book/src/lua/infinite.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# 介绍
12

23
infinite 模式下,lua配置不使用 Config 变量,而使用 Infinite 变量
34

doc/book/src/lua/map_config.md

Lines changed: 150 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,32 @@
33

44
开发相关:因为 代码实现方式不同,有些功能相近的 Map的Config是独立的
55

6+
# 说明
7+
68
在 Map说明的 首部标有 in, out 或 in/out 字样,表明可用于 InMapConfig 还是 OutMapConfig
79

810
没有任何示例的Map 意为着其写法为 `"Name"`, 不 外加大括号,如 `"Echo"` , `"Blackhole"`
911

1012
其它的配置均要外加 大括号,如 `Direct = {}` 意味着要 写为 `{Direct = {}}` 才算一个完整的 table
1113

14+
标有 ` --optional` 的项为可选项。
15+
16+
## `_addr` 的写法
17+
18+
一些项,如 bind_addr,dial_addr, listen_addr, fixed_target_addr 等,其写法都是相同的。如下每一行都是合法的示例
19+
20+
fake.com:80
21+
[::1]:30800
22+
unix://file1
23+
udp://127.0.0.1:20800
24+
tcp://0.0.0.0:80
25+
ip://10.0.0.1:24#utun321
26+
27+
`{scheme}://`没给出时,默认使用 tcp. unix 表示 uds(unix domain socket)
28+
29+
方括号括起的表示 ipv6
30+
31+
ip 示例中的 24 表示 子网掩码的CIDR表示, utun321 为指定要创建的 tun网卡 名称
1232

1333

1434
# 入口、出口 Map
@@ -103,6 +123,30 @@ BindDialer 中所有项都是可选的,但 bind_addr 或 dial_addr 中至少
103123
[Ext](#ext)
104124

105125

126+
in_auto_route 用于 tun
127+
128+
```lua
129+
in_auto_route = {
130+
tun_dev_name = "utun321",
131+
tun_gateway = "10.0.0.1",
132+
router_ip = "192.168.0.1",
133+
original_dev_name = "enp0s1", -- windows/macos 可不填 original_dev_name, linux 要填 original_dev_name
134+
--direct_list = { "192.168.0.204" }, -- 服务端的ip要直连
135+
dns_list = { "114.114.114.114" }
136+
}
137+
138+
```
139+
140+
out_auto_route 只用于 ip转发 (从本地的tun 转发到 服务器上的 tun)
141+
142+
```lua
143+
out_auto_route = {
144+
tun_dev_name = "utun321",
145+
original_dev_name = "enp0s1", --wlp3s0
146+
router_ip = "192.168.0.1",
147+
}
148+
```
149+
106150
### OptDialer
107151
in
108152

@@ -149,13 +193,13 @@ TcpOptListener = {
149193
in/out
150194

151195
```lua
152-
StdioConfig = {
153-
write_mode = "Bytes", --UTF8
196+
Stdio = {
197+
write_mode = "Bytes", --optional
154198
ext={},--optional
155199
}
156200
```
157201

158-
默认的 write_mode 为 UTF8, 可以用 Bytes 模式来观察16进制数据
202+
默认的 write_mode 为 `UTF8`, 可以用 `Bytes` 模式来观察16进制数据
159203

160204
[Ext](#ext)
161205

@@ -173,13 +217,73 @@ in/out
173217
}
174218
```
175219

220+
i 表示 输入文件名,o表示输出文件名。
221+
222+
i为自己预先定义好的文件,o则是一个给出的文件名,其内容只有通讯后才知道。
223+
224+
sleep_interval 和 bytes_per_turn 两项配置用于设置发送信息的速率。
225+
226+
176227
[Ext](#ext)
177228

178229
## Tproxy
179230
in
180231

181232
linux only
182233

234+
tproxy 的配置要复杂一些,要分 tcp 和 udp 两部分配置,自动路由的配置则是在 TproxyTcpResolver 中设置的。
235+
236+
```lua
237+
local tproxy_tcp_listen = {
238+
TcpOptListener = {
239+
listen_addr = "0.0.0.0:12345",
240+
sockopt = {
241+
tproxy = true,
242+
}
243+
}
244+
}
245+
246+
local tproxy_listen_tcp_chain = {
247+
tproxy_tcp_listen, {
248+
TproxyTcpResolver = {
249+
port = 12345,
250+
--auto_route_tcp = true, -- only set route for tcp
251+
auto_route = true, -- auto_route will set route for both tcp and udp at the appointed port
252+
253+
route_ipv6 = true, -- 如果为true, 则 也会 对 ipv6 网段执行 自动路由
254+
255+
proxy_local_udp_53 = true, -- 如果为true, 则 udp 53 端口不会直连, 而是会流经 tproxy
256+
257+
-- local_net4 = "192.168.0.0/16" -- 直连 ipv4 局域网段 不给出时, 默认即为 192.168.0.0/16
258+
}
259+
}
260+
}
261+
262+
263+
local tproxy_udp_listen = {
264+
TproxyUdpListener = {
265+
listen_addr = "udp://0.0.0.0:12345",
266+
sockopt = {
267+
tproxy = true,
268+
}
269+
}
270+
}
271+
272+
local tproxy_listen_inbounds = {
273+
{
274+
chain = tproxy_listen_tcp_chain,
275+
tag = "listen_tproxy_tcp"
276+
},
277+
{
278+
chain = { tproxy_udp_listen },
279+
tag = "listen_tproxy_udp"
280+
}
281+
}
282+
283+
```
284+
285+
286+
183287
### TproxyUdpListener
184288

185289
```lua
@@ -286,6 +390,8 @@ out:
286390
## NativeTLS
287391
同上
288392

393+
NativeTLS 使用 系统自己的 tls栈,这样就没有 rust 特征了。
394+
289395
## http2
290396

291397
服务端用 H2, 客户端用 H2Single 或 H2Mux,一般用 H2Mux 以使用 多路复用
@@ -301,8 +407,8 @@ in
301407

302408
```lua
303409
H2 ={
304-
is_grpc=false,
305-
http_config={},
410+
is_grpc=false,--optional
411+
http_config={},--optional
306412
}
307413
```
308414
[HttpCommonConfig](#httpcommonconfig)
@@ -313,8 +419,8 @@ out
313419

314420
```lua
315421
H2Single ={
316-
is_grpc=false,
317-
http_config={},
422+
is_grpc=false,--optional
423+
http_config={},--optional
318424
},
319425
```
320426

@@ -326,8 +432,8 @@ out
326432

327433
```lua
328434
H2Mux ={
329-
is_grpc=false,
330-
http_config={},
435+
is_grpc=false,--optional
436+
http_config={},--optional
331437
},
332438
```
333439
[HttpCommonConfig](#httpcommonconfig)
@@ -341,8 +447,8 @@ in:
341447
```lua
342448
WebSocket={
343449
http_config = {
344-
--... optional
345-
}
450+
--...
451+
} --optional
346452
}
347453
```
348454
[HttpCommonConfig](#httpcommonconfig)
@@ -373,7 +479,7 @@ Quic= {
373479
key_path="",
374480
cert_path="",
375481
listen_addr="",
376-
alpn = { "h2", "h3"},--optional
482+
alpn = { "h2", "h3"},
377483
}
378484
```
379485

@@ -382,13 +488,22 @@ out:
382488
```lua
383489
Quic= {
384490
server_addr="",
385-
server_name="",
491+
server_name="www.mytest.com",
386492
cert_path="",--optional
387-
alpn = { "h2", "h3"},--optional
493+
alpn = { "h2", "h3"}, --要明确指定 alpn
388494
is_insecure=true,--optional
389495
}
390496
```
391497

498+
须给出 server_name (域名),
499+
且 若 is_insecure 为 false, 须为 证书中所写的 CN 或 Subject Alternative Name;
500+
ruci 提供的 test2.crt中的 Subject
501+
502+
503+
cert_path:可给出 服务端的 证书, 这样就算 is_insecure = false 也通过验证
504+
证书须为 真证书, 或真fullchain 证书, 或自签的根证书
505+
506+
392507

393508
# 辅助 Map
394509

@@ -403,6 +518,8 @@ in/out
403518
Adder=3
404519
```
405520

521+
给 输出 的信息 每字节都加 给定的数值。比如 输入abc, Adder=1, 则输出为 bcd
522+
406523
## Counter
407524

408525
in/out
@@ -427,15 +544,29 @@ HttpFilter={
427544
```lua
428545
dns_client = {
429546
dns_server_list = { { "127.0.0.1:20800", "udp" } }, -- 8.8.8.8:53
430-
ip_strategy = "Ipv4Only",
547+
ip_strategy = "Ipv4Only", --optional
431548
static_pairs = {
432549
['www.baidu.com'] = "103.235.47.188"
433-
}
550+
} --optional
434551
}
435552

436553
```
437554
Direct,OptDirect,BindDialer,OptDialer 都可加此块。
438555

556+
557+
ip_strategy 的可能的值:
558+
```rust
559+
pub enum LookupIpStrategy {
560+
Ipv4Only,
561+
Ipv6Only,
562+
Ipv4AndIpv6,
563+
Ipv6thenIpv4,
564+
Ipv4thenIpv6,
565+
}
566+
```
567+
不给出时,默认为 Ipv4thenIpv6
568+
569+
439570
## SockOpt
440571

441572
```lua
@@ -488,10 +619,11 @@ listen 一个 本地的 udp 端口 (a), 指定 ext.fixed_target_addr (b), 其为
488619

489620
```lua
490621
{
491-
method = "GET",--optional
492-
scheme = "https",--optional
493622
authority = "www.myhost.com",
494623
path = "/ruci_jiandan",
624+
625+
method = "GET",--optional
626+
scheme = "https",--optional
495627
headers= { ["header1"] = "value1", ["header2"] = "value2", },--optional
496628
}
497629
```

0 commit comments

Comments
 (0)