Skip to content

Commit

Permalink
edit book
Browse files Browse the repository at this point in the history
  • Loading branch information
e1732a364fed committed Jan 1, 2099
1 parent caf6fcc commit 40f4e82
Show file tree
Hide file tree
Showing 10 changed files with 442 additions and 25 deletions.
7 changes: 5 additions & 2 deletions doc/book/src/SUMMARY.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Summary

- [读我](index.md)
- [欢迎](index.md)

- [入门](get_started.md)

- [ruci-cmd程序](app/cmd.md)
- [订阅](app/subscrible.md)
Expand All @@ -9,4 +11,5 @@
- [Config入门](lua/config_intro.md)
- [MapConfig](lua/map_config.md)
- [Route Config](lua/route_config.md)
- [Infinite](lua/infinite.md)
- [Infinite](lua/infinite.md)
- [lua自定义协议](lua/user_defined_protocol.md)
76 changes: 74 additions & 2 deletions doc/book/src/app/subscrible.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,79 @@
# 订阅

ruci 中使用一种非常简单的方法来实现订阅,分为三步:打包、服务文件(生成订阅url)、下载。



## 示例流程
```sh
./ruci-cmd utils pack-z resource
mkdir static
mv 83c649c74b8a4c6ebc07a9a99ee350a0.tar.zip static/
./ruci-cmd utils serve-folder
./ruci-cmd -c http://0.0.0.0:18143/download/83c649c74b8a4c6ebc07a9a99ee350a0.tar.zip --in-memory
```
./ruci-cmd utils pack resource

## 打包

./ruci-cmd utils pack-z resource

它会把 ruci-cmd 目录下的 resource 文件夹中的全部内容打包为一个 {md5}.tar.zip 文件。
这个 zip文件里面只有一个文件,即 {md5}.tar, 而 {md5}.tar 里面则是 resource 文件夹中的所有文件内容(不包含resource 这个层级)

其中 {md5} 是 {md5}.tar 这个文件的 md5 哈希值。

## 服务文件(生成订阅url)

之后把 {md5}.tar.zip 文件移动到 ruci-cmd 所在目录的 static 文件夹下。若没有则创建一个。

```sh
mkdir static
mv 83c649c74b8a4c6ebc07a9a99ee350a0.tar.zip static/
```

然后运行 ruci-cmd 的文件服务器

```sh
./ruci-cmd utils serve-folder
./ruci-cmd -c http://0.0.0.0:18143/download/folder1/83c649c74b8a4c6ebc07a9a99ee350a0.tar.zip --in-memory
```

这样,订阅链接就会自动为
http://0.0.0.0:18143/download/83c649c74b8a4c6ebc07a9a99ee350a0.tar.zip

注意,0.0.0.0 是本机地址,如果您要在公网,可以将ip换为 您的公网ip。

ruci 不提供https、用户鉴权的机制,您可以通过一些反向代理的方式来提供安全性。


## 在客户端使用订阅链接

正常使用配置文件时,是用的 `ruci-cmd -c local.lua`, 此时,只要把 -c 的参数改为对应的下载链接即可:

```sh
./ruci-cmd -c http://0.0.0.0:18143/download/83c649c74b8a4c6ebc07a9a99ee350a0.tar.zip
```

该命令会下载该压缩包、保存到当前目录并使用。它会自动阅读包中的 local.lua 或 local.toml 文件。

如果不想把下载的包保存,则可以加 ` --in-memory` 选项。

如果已经保存了下载好的包,下一次使用时可以直接解压缩里面的内容使用,也可以直接用

```sh
./ruci-cmd -c 83c649c74b8a4c6ebc07a9a99ee350a0.tar.zip
```

或者

```sh
./ruci-cmd -c 83c649c74b8a4c6ebc07a9a99ee350a0.tar
```

注意,如果不解压缩,则不要修改 tar 或 tar.zip 的名字。因为名字要作为 md5 由 ruci-cmd 检查其包内容是否一致。
如果 包的实际内容的 md5 与 名字不一致,则 ruci-cmd 会拒绝运行。

# 接下来

- [toml配置](../toml/index.md)
- [lua配置](../lua/lua.md)
- [路由配置](lua/route_config.md)
107 changes: 107 additions & 0 deletions doc/book/src/get_started.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# ruci 入门

ruci 的可执行文件叫做 ruci-cmd, 客户端和服务端都是使用这同一个程序。

## 安装ruci

从这里下载 ruci-cmd 的最新发布版:[Release](https://github.com/e1732a364fed/ruci/releases)


发布版 以 .tar.xz 为后缀,是一个压缩包,包含 ruci-cmd 以及相关的 resource 文件夹。

压缩包对于不同的平台有不同的后缀。

### windows

建议下载后缀为 `x86_64-pc-windows-msvc.tar.xz` 的版本

下载后,可以用 7zip 来解压,先解压出一个 tar, 再解压一遍得到程序。

第一次运行时,windows 可能弹出提示,询问是否允许连接到网络,同意即可。


### macOS

apple silicon(m1,m2,m3,m4) 下载
`aarch64-apple-darwin.tar.xz`

老机型下载
`x86_64-apple-darwin.tar.xz `

解压:

tar xf archive.tar.xz

第一次运行时,macOS 会提示您该程序不受信任,您可以到 设置-隐私与安全 中,许可本程序的使用。


### x64 linux
建议 x64的 linux 用户下载 后缀为 `x86_64-unknown-linux-gnu.tar.xz` 的版本

如果运行闪退,则可以下载 后缀为 `x86_64-unknown-linux-musl.tar.xz` 的版本

解压:

tar xf archive.tar.xz
chmod +x ruci-cmd

### 安卓

termux 用户可以下载 后缀为 `aarch64-linux-android.tar.xz` 的版本

可以先在电脑上解压好,再传到手机中

之后在 termux 中

chmod +x ruci-cmd

## 开始使用

在ruci-cmd 所在的文件夹中:

windows下,打开 cmd 或 powershell, 运行:

.\ruci-cmd.exe

其它平台,进入终端,输入

./ruci-cmd

为了保持本文的简洁,下面命令行示例统一使用 linux 的格式。


运行ruci-cmd后它会在相同目录下的 resource 文件夹 或 ruci_config 文件夹寻找 `local.lua` 文件,如果
找到了,就会运行,否则就会退出。

运行时,会同时在 ruci-cmd 的当前目录下生成一个 logs 文件夹,用于存放生成的日志文件。

如果要指定配置文件运行,可以加 -c 参数:

./ruci-cmd -c remote.lua
./ruci-cmd -c local.toml

如果要了解编译等方面的细节,可参考 [这里](https://github.com/e1732a364fed/ruci/blob/tokio/crates/ruci-cmd/README.md)

为了不让 resource 文件夹中的示例文件影响您的自定义配置,您可以把 resource 文件夹重命名为其它名称,
然后建立一个 ruci_config 文件夹,将您的配置文件放在 ruci_config 文件夹中。

```sh
mv resource resource_default
mkdir ruci_config
cp resource_default/local.toml ruci_config/local.toml
```

resource 文件夹中的内容有助于参考使用,建议保留。

调节日志等级为 debug:

./ruci-cmd -l debug


# 接下来

- [ruci-cmd程序](app/cmd.md)
- [订阅](app/subscrible.md)
- [toml配置](toml/index.md)
- [lua配置](lua/lua.md)
- [路由配置](lua/route_config.md)
11 changes: 3 additions & 8 deletions doc/book/src/index.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# readme
# 欢迎使用ruci!


本手册 是面向使用ruci 作为 代理的用户 而写的用户手册, 旨在让您快速上手。
Expand All @@ -9,12 +9,7 @@

而手册专注于帮助 通过 release 下载程序包的 用户 快速学会使用ruci.

链接:

[命令行参数 与 程序运行](app/cmd.md)

[lua配置](lua/lua.md)

[toml配置](toml/index.md)
让我们开始吧!
[入门](get_started.md)

本手册基于 ruci v0.0.7 制作
4 changes: 2 additions & 2 deletions doc/book/src/lua/config_intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ inbounds/outbounds 是 [inbound/outbound](#inboundoutbound) 的列表:

我们先学简单的几个 Config

## InMapConfig 初探
## InMapConfig初探

先学两种 InMapConfig,Listener 和 Sock5Http

Expand Down Expand Up @@ -140,7 +140,7 @@ Config = {

这样 我们第一个 inbounds 配置就做好了!

## OutMapConfig 初探
## OutMapConfig初探

先学 最简单的 `OutMapConfig` Direct:

Expand Down
27 changes: 24 additions & 3 deletions doc/book/src/lua/lua.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Config = {

先学 简单的 [Config 入门](./config_intro.md) 吧。

## 关于 lua语法
# 关于 lua语法

在lua中,大括号 `{}` 被叫做 table, 它即可以当数组用也可以当"字典"用。

Expand All @@ -47,5 +47,26 @@ Config = {
]]
```

如写 x = 1, 则 x会默认成为 全局变量,这不太好。因此一般都写成
local x = 1
如写 `x = 1`, 则 x会默认成为 全局变量,这不太好。因此一般都写成
`local x = 1`

字符串就是 `"abc"`, 块级字符串为:
```lua
a = [[
abcd
abcd
]]
```

函数是 :

```lua
local function(c)
return 1
end
```

# 接下来

- [路由配置](lua/route_config.md)

24 changes: 24 additions & 0 deletions doc/book/src/lua/map_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,31 @@ ruci 提供的 test2.crt中的 Subject Alternative Name 为 www.mytest.com 和 l
cert_path:可给出 服务端的 证书, 这样就算 is_insecure = false 也通过验证
证书须为 真证书, 或真fullchain 证书, 或自签的根证书

## spe1: Steganography Protocol Exmaple1

隐写示例协议1

```lua
SPE1 = { qa = { { "q1", "a1" }, { "q2", "a2" } } }
```

qa 中要为 2的偶数次幂个 问答对,问答的内容任意填。但是内容越真实,隐写效果越好。


如果不给出qa,则协议会使用自己生成的问答对。

```lua
SPE1 = {}
```


## lua自定义协议

```lua
Lua = { file_name = "lua_protocol_e1.lua", handshake_function = "Handshake2" }
```

lua自定义协议 的写法是高级用法,见 [lua自定义协议](user_defined_protocol.md)

# 辅助 Map

Expand Down
Loading

0 comments on commit 40f4e82

Please sign in to comment.