Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 18 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,29 @@
<a href="https://github.com/lanthora/candy/pulls"><img src="https://img.shields.io/github/issues-pr-raw/lanthora/candy" /></a>
</p>

一个简单的组网工具.
A simple networking tool.

## 如何使用
**[中文文档](docs/README.zh-CN.md)**

- [安装 Windows 客户端](https://docs.canets.org/install-client-for-windows)
- [安装 macOS 客户端](https://docs.canets.org/install-client-for-macos)
- [安装 Linux 客户端](https://docs.canets.org/install-client-for-linux)
- [部署 Web 服务端](https://docs.canets.org/deploy-web-server)
- [部署 CLI 服务端](https://docs.canets.org/deploy-cli-server)
- [使用社区服务器](https://docs.canets.org/use-the-community-server)
- [多局域网组网](https://docs.canets.org/software-defined-wide-area-network)
## How to Use

## 相关项目
- [Install Windows Client](docs/install-client-for-windows.md)
- [Install macOS Client](docs/install-client-for-macos.md)
- [Install Linux Client](docs/install-client-for-linux.md)
- [Deploy Web Server](docs/deploy-web-server.md)
- [Deploy CLI Server](docs/deploy-cli-server.md)
- [Use Community Server](docs/use-the-community-server.md)
- [Multi-LAN Networking](docs/software-defined-wide-area-network.md)

- [Cacao](https://github.com/lanthora/cacao): WebUI 版的 Candy 服务器
- [Cake](https://github.com/lanthora/cake): Qt 实现的 Candy GUI 桌面应用程序
- [Candy Android](https://github.com/Jercrox/Candy_Android_Client): Android 客户端
- [EasyTier](https://github.com/EasyTier/EasyTier): 一个简单、安全、去中心化的内网穿透 VPN 组网方案,使用 Rust 语言和 Tokio 框架实现
- [candygo](https://github.com/SoraKasvgano/candygo): 一个简单的与candy原项目配置文件兼容的go版本
## Related Projects

## 交流群
- [Cacao](https://github.com/lanthora/cacao): WebUI version of Candy server
- [Cake](https://github.com/lanthora/cake): Qt-based Candy GUI desktop application
- [Candy Android](https://github.com/Jercrox/Candy_Android_Client): Android client
- [EasyTier](https://github.com/EasyTier/EasyTier): A simple, secure, decentralized NAT traversal VPN networking solution implemented in Rust using Tokio framework
- [candygo](https://github.com/SoraKasvgano/candygo): A simple Go version compatible with candy project configuration files

## Community

- QQ: 768305206
- TG: [Click to Join](https://t.me/CandyUserGroup)
38 changes: 23 additions & 15 deletions candy-service/README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,36 @@
# candy-service

Candy 客户端的另一个实现.
**[中文文档](README.zh-CN.md)**

- **无状态**: 进程本身不持久化任何数据, 进程重启后数据丢失,需要外部维护网络配置信息
- **API 交互**: 对外提供 HTTP API 交互接口,可以远程控制和访问
Another implementation of the Candy client.

- **Stateless**: The process itself does not persist any data. Data is lost after process restart and requires external maintenance of network configuration information
- **API Interaction**: Provides HTTP API interaction interface externally, enabling remote control and access

## API

### 帮助
### Help

Linux
Linux:

```bash
candy-service --help
```

Windows
Windows:

```bat
candy-service /help
```

请求响应中的 **id** 用于标识网络连接, 通过不同标识可以同时加入多个网络, 这个标识用于查看状态和关闭网络.
The **id** in the request response is used to identify the network connection. Different identifiers can be used to join multiple networks simultaneously. This identifier is used to view status and close networks.

### Run

启动参数的含义与[配置文件](../candy.cfg)相同,此外还有两个额外的配置项.
The meaning of startup parameters is the same as the [configuration file](../candy.cfg), with two additional configuration items:

- vmac: 用于标识唯一设备,当同一网络中有两台不同 vmac 的设备申请相同 IP 地址时, 后者会报告 IP 冲突. 为 16 个字符的随机数字字母字符串, 需要持久化存储, 建议在首次启动进程时生成.
- expt: 期望使用的 IP 地址, 这个参数用于实现有优先分配曾经使用过的地址, 由客户端主动向服务器报告, 可以为空. 建议由服务端随机分配地址的情况下, 通过 `/api/status` 查看分配的地址并保存, 下次连接时携带这个地址.
- **vmac**: Used to identify a unique device. When two devices with different vmac in the same network apply for the same IP address, the latter will report an IP conflict. It is a 16-character random alphanumeric string that needs to be persisted. It is recommended to generate it when starting the process for the first time.
- **expt**: The expected IP address to use. This parameter is used to implement priority allocation of previously used addresses. It is actively reported to the server by the client and can be empty. It is recommended that when the server randomly assigns an address, view the assigned address through `/api/status` and save it, and carry this address when connecting next time.

`POST /api/run`

Expand All @@ -53,10 +55,12 @@ candy-service /help
}
```

Response:

```json
{
"id": "test",
"message": "success"
"id": "test",
"message": "success"
}
```

Expand All @@ -70,6 +74,8 @@ candy-service /help
}
```

Response:

```json
{
"id": "test",
Expand All @@ -90,9 +96,11 @@ candy-service /help
}
```

Response:

```json
{
"id": "test",
"message": "success"
"id": "test",
"message": "success"
}
```
100 changes: 100 additions & 0 deletions candy-service/README.zh-CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# candy-service

**[English](README.md)**

Candy 客户端的另一个实现.

- **无状态**: 进程本身不持久化任何数据, 进程重启后数据丢失,需要外部维护网络配置信息
- **API 交互**: 对外提供 HTTP API 交互接口,可以远程控制和访问

## API

### 帮助

Linux

```bash
candy-service --help
```

Windows

```bat
candy-service /help
```

请求响应中的 **id** 用于标识网络连接, 通过不同标识可以同时加入多个网络, 这个标识用于查看状态和关闭网络.

### Run

启动参数的含义与[配置文件](../candy.cfg)相同,此外还有两个额外的配置项.

- vmac: 用于标识唯一设备,当同一网络中有两台不同 vmac 的设备申请相同 IP 地址时, 后者会报告 IP 冲突. 为 16 个字符的随机数字字母字符串, 需要持久化存储, 建议在首次启动进程时生成.
- expt: 期望使用的 IP 地址, 这个参数用于实现有优先分配曾经使用过的地址, 由客户端主动向服务器报告, 可以为空. 建议由服务端随机分配地址的情况下, 通过 `/api/status` 查看分配的地址并保存, 下次连接时携带这个地址.

`POST /api/run`

```json
{
"id": "test",
"config": {
"mode": "client",
"websocket": "wss://canets.org",
"password": "",
"name": "",
"tun": "",
"stun": "stun://stun.canets.org",
"discovery": 300,
"route": 5,
"port": 0,
"localhost": "",
"mtu": 1400,
"expt": "",
"vmac": "16-char rand str"
}
}
```

```json
{
"id": "test",
"message": "success"
}
```

### Status

`POST /api/status`

```json
{
"id": "test"
}
```

```json
{
"id": "test",
"message": "success",
"status": {
"address": "192.168.202.1/24"
}
}
```

### Shutdown

`POST /api/shutdown`

```json
{
"id": "test"
}
```

```json
{
"id": "test",
"message": "success"
}
```
36 changes: 36 additions & 0 deletions docs/README.zh-CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Candy

<p>
<a href="https://github.com/lanthora/candy/releases/latest"><img src="https://img.shields.io/github/release/lanthora/candy" /></a>
<a href="https://github.com/lanthora/candy/actions/workflows/release.yaml"><img src="https://img.shields.io/github/actions/workflow/status/lanthora/candy/release.yaml" /></a>
<a href="https://github.com/lanthora/candy/graphs/contributors"><img src="https://img.shields.io/github/contributors-anon/lanthora/candy" /></a>
<a href="https://github.com/lanthora/candy/issues"><img src="https://img.shields.io/github/issues-raw/lanthora/candy" /></a>
<a href="https://github.com/lanthora/candy/pulls"><img src="https://img.shields.io/github/issues-pr-raw/lanthora/candy" /></a>
</p>

一个简单的组网工具.

**[English](../README.md)**

## 如何使用

- [安装 Windows 客户端](install-client-for-windows.zh-CN.md)
- [安装 macOS 客户端](install-client-for-macos.zh-CN.md)
- [安装 Linux 客户端](install-client-for-linux.zh-CN.md)
- [部署 Web 服务端](deploy-web-server.zh-CN.md)
- [部署 CLI 服务端](deploy-cli-server.zh-CN.md)
- [使用社区服务器](use-the-community-server.zh-CN.md)
- [多局域网组网](software-defined-wide-area-network.zh-CN.md)

## 相关项目

- [Cacao](https://github.com/lanthora/cacao): WebUI 版的 Candy 服务器
- [Cake](https://github.com/lanthora/cake): Qt 实现的 Candy GUI 桌面应用程序
- [Candy Android](https://github.com/Jercrox/Candy_Android_Client): Android 客户端
- [EasyTier](https://github.com/EasyTier/EasyTier): 一个简单、安全、去中心化的内网穿透 VPN 组网方案,使用 Rust 语言和 Tokio 框架实现
- [candygo](https://github.com/SoraKasvgano/candygo): 一个简单的与candy原项目配置文件兼容的go版本

## 交流群

- QQ: 768305206
- TG: [Click to Join](https://t.me/CandyUserGroup)
8 changes: 5 additions & 3 deletions docs/deploy-cli-server.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# 部署 CLI 服务端
# Deploy CLI Server

根据帮助信息 `candy --help` 和配置文件描述部署.
**[中文文档](deploy-cli-server.zh-CN.md)**

非专业用户请[部署 Web 服务端](https://docs.canets.org/deploy-web-server).
Deploy according to the help information `candy --help` and configuration file description.

Non-professional users should [deploy the web server](deploy-web-server.md).
7 changes: 7 additions & 0 deletions docs/deploy-cli-server.zh-CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# 部署 CLI 服务端

**[English](deploy-cli-server.md)**

根据帮助信息 `candy --help` 和配置文件描述部署.

非专业用户请[部署 Web 服务端](deploy-web-server.zh-CN.md).
38 changes: 20 additions & 18 deletions docs/deploy-web-server.md
Original file line number Diff line number Diff line change
@@ -1,54 +1,56 @@
# 部署 Web 服务端
# Deploy Web Server

## 前置条件
**[中文文档](deploy-web-server.zh-CN.md)**

知道如何部署 Web 服务,并能够申请证书后对外提供 HTTPS 服务.
## Prerequisites

否则使用明文传输将导致数据泄漏,存在安全隐患.此时建议使用社区服务器构建私有网络.
Know how to deploy web services and obtain certificates to provide HTTPS services externally.

## 一键部署服务端
Otherwise, using plaintext transmission will lead to data leakage and security risks. In this case, it is recommended to use the community server to build a private network.

## One-Click Server Deployment

```bash
docker run --name=cacao --detach --volume /var/lib/cacao:/var/lib/cacao --publish 8080:80 docker.io/lanthora/cacao:latest
```

## 使用
## Usage

假设你的域名为 `example.com`, 此时通过 `https://example.com` 应该能够正常访问服务.如果不是 `https` 请回到最开始解决前置条件.
Assume your domain is `example.com`. At this point, you should be able to access the service normally via `https://example.com`. If it's not `https`, please go back to the beginning and solve the prerequisites.

服务器启动后的第一个注册用户默认被设置为管理员.管理员无法创建网络,且无权查看其他用户的网络.
The first registered user after the server starts is set as administrator by default. Administrators cannot create networks and have no permission to view other users' networks.

管理员配置页面,能够配置是否允许注册,以及允许注册时的注册间隔(避免脚本小子刷注册用户).同时可以配置自动清理不活跃用户.
The administrator configuration page allows you to configure whether registration is allowed, and the registration interval when registration is allowed (to avoid script kiddies flooding registration users). You can also configure automatic cleanup of inactive users.

![](images/cacao-admin-setting.png)

### 单网络模式
### Single Network Mode

在不允许注册时,管理员可以手动添加用户.其中名为 @ 的用户是一个特殊用户,这个用户只能创建一个名为 @ 的网络.用户名和网络名的作用在后面说明.先创建这个用户.
When registration is not allowed, administrators can manually add users. Among them, the user named `@` is a special user who can only create a network named `@`. The role of username and network name will be explained later. First, create this user.

![](images/cacao-admin-user.png)

退出管理员,并以 @ 用户登录.此时已经默认添加了 @ 网络.默认网络生成了随机密码 `ZrhaUcz1`
Log out as administrator and log in as the `@` user. At this point, the `@` network has been added by default. The default network generated a random password `ZrhaUcz1`.

![](images/cacao-network.png)

此时连接这个网络的客户端仅需要修改以下配置:
At this point, clients connecting to this network only need to modify the following configuration:

```cfg
websocket = "wss://example.com"
password = "ZrhaUcz1"
```

除非你知道自己在做什么,否则请不要修改任何其他配置项.
Unless you know what you're doing, please do not modify any other configuration items.

### 多用户多网络模式
### Multi-User Multi-Network Mode

如果只是创建一个网络,单网络模式已经足够了.如果要允许多个用户使用,且每个用户可以创建多个网络.则可以使用多用户多网络模式.
If you just want to create one network, single network mode is sufficient. If you want to allow multiple users to use it, and each user can create multiple networks, you can use multi-user multi-network mode.

假设由管理员创建或自行注册的普通用户名为 `${username}`, 这个用户拥有的一个网络名是 `${netname}`,那么客户端对应的配置仅需要修改为:
Assume a normal user created by the administrator or self-registered is named `${username}`, and this user has a network named `${netname}`, then the corresponding client configuration only needs to be modified to:

```cfg
websocket = "wss://example.com/${username}/${netname}"
```

当用户名或者网络名为 @ 时,在客户端的配置中需要留空.当用户名和网络名都为空时,就是所谓的单网络模式
When the username or network name is `@`, it needs to be left blank in the client configuration. When both username and network name are blank, it is the so-called single network mode.
Loading
Loading