add: global devicelimit

This commit is contained in:
pocketW 2022-11-13 12:21:37 +11:00
parent 38838ab558
commit 712dad2991
3 changed files with 47 additions and 6 deletions

View File

@ -10,9 +10,35 @@
每一个独立IP地址视为一个设备。
{% endhint %}
## 全局设备限制
## SSPanel 全局设备限制
当XrayR版本>=v0.7.1SSpanel版本>=[2021.9](https://github.com/Anankke/SSPanel-Uim/releases/tag/2021.9)XrayR将会针对SSpanel启用全局设备限制功能。此时不同后端结点将会全局限制独立IP连接数量而非各后端本地限制。
当XrayR版本>=v0.7.1SSpanel版本>=[2021.9](https://github.com/Anankke/SSPanel-Uim/releases/tag/2021.9)XrayR将会针对SSPanel启用全局设备限制功能。此时不同后端结点将会全局限制独立IP连接数量而非各后端本地限制。
当设备限制为1时不同结点之间的切换会受到限制建议至少设置设备数为2。并且由于SSPanel面板限制IP连接信息可能需要至少2分钟才能传递到全部的后端结点因此在2分钟内的同时连接将不能被限制。
## 全局设备限制
当XrayR版本>=v0.8.6可以启用基于redis的全局设备限制功能可以跨节点支持基于IP的设备限制兼容所有面板。可在`ControllerConfig` 中配置如下项。
```yaml
GlobalDeviceLimitConfig:
Limit: 0 # The global device limit of a user, 0 means disable
RedisAddr: 127.0.0.1:6379 # The redis server address
RedisPassword: YOUR PASSWORD # Redis password
RedisDB: 0 # Redis DB
Timeout: 5 # Timeout for redis request
Expiry: 60 # Expiry time (second)
```
| 参数 | 说明 |
| ------------- | -------------------------------------------------------------------- |
| Limit | 每个用户限制独立IP数量设置为0则禁用 |
| RedisAddr | redis连接地址不同节点需要连接到同一redis数据库来实现全局设备限制 |
| RedisPassword | redis密码 |
| RedisDB | redis数据库编号 |
| Timeout | 连接redis超时时间单位秒 |
| Expiry | redis中存储的在线用户过期时间单位秒 |
{% hint style="info" %}
为保证最大效率启用全局设备限制后建议将其他设备限制相关配置设为0包括配置文件中的`DeviceLimit`和面板相关配置。
{% endhint %}

View File

@ -16,7 +16,7 @@ DnsConfigPath: # /etc/XrayR/dns.json # Path to dns config, check https://xtls.gi
RouteConfigPath: # /etc/XrayR/route.json # Path to route config, check https://xtls.github.io/config/routing.html for help
InboundConfigPath: # /etc/XrayR/custom_inbound.json # Path to custom inbound config, check https://xtls.github.io/config/inbound.html for help
OutboundConfigPath: # /etc/XrayR/custom_outbound.json # Path to custom outbound config, check https://xtls.github.io/config/outbound.html for help
ConnetionConfig:
ConnectionConfig:
Handshake: 4 # Handshake time limit, Second
ConnIdle: 10 # Connection idle time limit, Second
UplinkOnly: 2 # Time limit when the connection downstream is closed, Second
@ -52,6 +52,13 @@ Nodes:
WarnTimes: 0 # After (WarnTimes) consecutive warnings, the user will be limited. Set to 0 to punish overspeed user immediately.
LimitSpeed: 0 # The speedlimit of a limited user (unit: mbps)
LimitDuration: 0 # How many minutes will the limiting last (unit: minute)
GlobalDeviceLimitConfig:
Limit: 0 # The global device limit of a user, 0 means disable
RedisAddr: 127.0.0.1:6379 # The redis server address
RedisPassword: YOUR PASSWORD # Redis password
RedisDB: 0 # Redis DB
Timeout: 5 # Timeout for redis request
Expiry: 60 # Expiry time (second)
EnableFallback: false # Only support for Trojan and Vless
FallBackConfigs: # Support multiple fallbacks
-
@ -112,7 +119,7 @@ DnsConfigPath: # /etc/XrayR/dns.json # Path to dns config, check https://xtls.gi
RouteConfigPath: # /etc/XrayR/route.json # Path to route config, check https://xtls.github.io/config/routing.html for help
InboundConfigPath: # /etc/XrayR/custom_inbound.json # Path to custom inbound config, check https://xtls.github.io/config/inbound.html for help
OutboundConfigPath: # /etc/XrayR/custom_outbound.json # Path to custom outbound config, check https://xtls.github.io/config/outbound.html for help
ConnetionConfig:
ConnectionConfig:
Handshake: 4 # Handshake time limit, Second
ConnIdle: 10 # Connection idle time limit, Second
UplinkOnly: 2 # Time limit when the connection downstream is closed, Second
@ -186,7 +193,7 @@ OutboundConfigPath: # /etc/XrayR/custom_outbound.json # Path to custom outbound
自定义连接释放的相关配置,可以一定程度优化内存占用
```yaml
ConnetionConfig:
ConnectionConfig:
Handshake: 4 # Handshake time limit, Second
ConnIdle: 10 # Connection idle time limit, Second
UplinkOnly: 2 # Time limit when the connection downstream is closed, Second
@ -338,6 +345,13 @@ ControllerConfig:
WarnTimes: 0 # After (WarnTimes) consecutive warnings, the user will be limited. Set to 0 to punish overspeed user immediately.
LimitSpeed: 0 # The speedlimit of a limited user (unit: mbps)
LimitDuration: 0 # How many minutes will the limiting last (unit: minute)
GlobalDeviceLimitConfig:
Limit: 0 # The global device limit of a user, 0 means disable
RedisAddr: 127.0.0.1:6379 # The redis server address
RedisPassword: YOUR PASSWORD # Redis password
RedisDB: 0 # Redis DB
Timeout: 5 # Timeout for redis request
Expiry: 60 # Expiry time (second)
EnableFallback: false # Only support for Trojan and Vless
FallBackConfigs: # Support multiple fallbacks
-
@ -360,6 +374,7 @@ ControllerConfig:
| `DisableSniffing` | `false`, `true` | 是否关闭domain sniffing默认`false` |
| `EnableProxyProtocol` | `true`,`false` | 是否为当前节点启用ProxyProtocol获取中转IP |
| `AutoSpeedLimitConfig` | list | 动态限速相关配置,请查看 [动态限速](../gong-neng-shuo-ming/speedlimit.md) |
| `GlobalDeviceLimitConfig` | list | 全局设备限制相关配置,请查看 [全局设备限制](../gong-neng-shuo-ming/devicelimit.md) |
| `EnableFallback` | `true`,`false` | 是否为当前节点启用Fallback只对Vless和Trojan协议有效 |
| `FallBackConfigs` | list | Fallback 相关配置,请查看 [Fallback功能说明](../gong-neng-shuo-ming/fallback.md) |

View File

@ -2,7 +2,7 @@
## 链接控制优化
通过自定义`ConnetionConfig`连接释放的[相关配置](../xrayr-pei-zhi-wen-jian-shuo-ming/config.md#lian-jie-kong-zhi),可以一定程度优化内存占用
通过自定义`ConnectionConfig`连接释放的[相关配置](../xrayr-pei-zhi-wen-jian-shuo-ming/config.md#lian-jie-kong-zhi),可以一定程度优化内存占用
1. 减少`ConnIdle`有可能可以优化高连接数量时的内存占用,但是会导致用户连接延时变高。
2. 在 HTTP 浏览的场景中,可以将 `UplinkOnly``DownlinkOnly` 设为 0以提高连接关闭的效率减少内存占用。