Skip to content

Commit

Permalink
统一配置文件格式
Browse files Browse the repository at this point in the history
  • Loading branch information
lanthora committed Jul 4, 2024
1 parent 976fdba commit 40b8a52
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ candy -c /path/to/candy.cfg

监听所有网卡的 80 端口,客户端连接后自动在 10.0.0.0/24 子网分配地址,并设置登录口令为 123456

```bash
```ini
# 以服务端模式工作
mode = "server"
# 服务端不支持 wss, 需要由外部的服务加密,例如 nginx/caddy, 生产环境建议使用 wss
Expand All @@ -166,17 +166,17 @@ password = "123456"

配置[多局域网组网](docs/muti-lan-interconn.md)

```bash
```ini
# 进入设备网络 10.0.0.1/32 且目的网络为 192.168.2.0/24 的 IP 报文通过 10.0.0.2 转发,
# 通过分号分割的多条规则,配置中禁止出现空白符.
sdwan = "10.0.0.1/32,192.168.2.0/24,10.0.0.2;10.0.0.2/32,192.168.1.0/24,10.0.0.1";
sdwan = "10.0.0.1/32,192.168.2.0/24,10.0.0.2;10.0.0.2/32,192.168.1.0/24,10.0.0.1"
```

#### 客户端

与上述服务端匹配的客户端配置

```bash
```ini
# 以客户端模式工作
mode = "client"
# 示例以 ws 传输明文,客户端支持 wss 协议
Expand All @@ -196,7 +196,7 @@ port = 0

配置客户端中继

```bash
```ini
# 路由功能在对等连接的基础上工作,对等连接是被动启动,
# 有些设备本可以作为中继,但由于此前没有与中继设备的流量导致无法使用路由.
# 此配置以秒为单位周期性的尝试让网络中的其他设备与本设备建立对等连接.
Expand All @@ -211,7 +211,7 @@ route = 5

配置局域网内对等链接

```bash
```ini
# 用于建立对等连接的本机局域网 IP 地址,不配置此项时将尝试自动获取.
# 有多个物理网卡时建议手动配置.
localhost = "127.0.0.1"
Expand Down
26 changes: 13 additions & 13 deletions candy.cfg
Original file line number Diff line number Diff line change
@@ -1,69 +1,69 @@
############################## Client and Server ##############################
# [Required] Working mode, "client" or "server"
mode = "client";
mode = "client"

# [Required] The address for communication between the client and the server.
# Server only supports ws and needs to provide wss through an external web
# service. Client supports ws and wss.
websocket = "wss://canets.org/demo";
websocket = "wss://canets.org/demo"

# [Optional] Password used to verify identity
# Only the hashed content of the password and timestamp is transmitted on the
# network, and the password cannot be obtained from the message.
#password = "this is the password";

# [Optional] Show debug log
#debug = false;
#debug = false

# [Optional] Restart interval
# default configuration is 0 which means no restart.
#restart = 0;
#restart = 0

################################# Server Only #################################
# [Optional] The range of addresses automatically assigned by the server
# Server address allocation is not enabled by default, and the client needs to
# configure a static address through tun.
#dhcp = "172.16.0.0/16";
#dhcp = "172.16.0.0/16"

# [Optional] software-defined wide area network
# IP packets entering 172.16.0.1/32 with the destination address 192.168.2.0/24
# will be forwarded to 172.16.0.2. Multiple rules are separated by semicolons.
# Extraneous whitespace characters are prohibited.
#sdwan = "172.16.0.1/32,192.168.2.0/24,172.16.0.2;172.16.0.2/32,192.168.1.0/24,172.16.0.1";
#sdwan = "172.16.0.1/32,192.168.2.0/24,172.16.0.2;172.16.0.2/32,192.168.1.0/24,172.16.0.1"

################################# Client Only #################################
# [Optional] Network interface name
# Used to differentiate networks when running multiple clients.
name = "demo";
name = "demo"

# [Optional] Static address
# If dhcp is not configured, tun must be configured. When there is an address
# conflict, the previous client will be kicked out.
#tun = "172.16.0.1/16";
#tun = "172.16.0.1/16"

# [Optional] STUN server address
# If the STUN server is not configured, P2P will be disabled.
stun = "stun://stun.canets.org";
stun = "stun://stun.canets.org"

# [Optional] Active discovery interval
# Periodically sends broadcasts to try to establish P2P with devices on the
# network. The default configuration is 0, which means disabled.
discovery = 300;
discovery = 300

# [Optional] The cost of routing through this machine
# Use all nodes in the network to establish the link with the lowest latency.
# This configuration represents the cost of using this node as a relay. The
# default configuration is 0 which means disabled.
route = 5;
route = 5

# [Optional] Local UDP port used for P2P
# The default configuration is 0, which means it is allocated by the operating
# system. This configuration can be used when the firewall is strict and can
# only open specific ports.
#port = 0;
#port = 0

# [Optional] Local IPv4 address used for peering connections
# By default the IPv4 address of the local physical network card will be
# detected. When there are multiple physical network cards, the detection
# results may not be the best. You can specify it manually.
#localhost = "127.0.0.1";
#localhost = "127.0.0.1"

0 comments on commit 40b8a52

Please sign in to comment.