mirror of
https://github.com/TeaOSLab/EdgeCommon.git
synced 2025-11-05 22:30:25 +08:00
DDoS防护增加秒级连接速率限制
This commit is contained in:
@@ -15,11 +15,12 @@ const (
|
|||||||
DefaultTCPMaxConnections = 100_000 // 单节点TCP最大连接数
|
DefaultTCPMaxConnections = 100_000 // 单节点TCP最大连接数
|
||||||
DefaultTCPMaxConnectionsPerIP = 1000 // 单IP最大连接数
|
DefaultTCPMaxConnectionsPerIP = 1000 // 单IP最大连接数
|
||||||
DefaultTCPMinConnectionsPerIP = 5 // 单IP最小连接数
|
DefaultTCPMinConnectionsPerIP = 5 // 单IP最小连接数
|
||||||
DefaultTCPNewConnectionsRate = 500 // 单IP连接速率限制(按分钟)
|
|
||||||
DefaultTCPNewConnectionsMinRate = 5 // 单IP最小连接速率
|
DefaultTCPNewConnectionsMinutelyRate = 500 // 单IP连接速率限制(按分钟)
|
||||||
DefaultTCPDenyNewConnectionsRate = 1000 // 加入黑名单的连接速率
|
DefaultTCPNewConnectionsMinMinutelyRate = 3 // 单IP最小连接速率
|
||||||
DefaultTCPDenyNewConnectionsMinRate = 5 // 加入黑名单的最小连接速率
|
|
||||||
DefaultTCPDenyNewConnectionsRateTimeout = 1800 // 超过黑名单连接速率禁止时间
|
DefaultTCPNewConnectionsSecondlyRate = 300 // 单IP连接速率限制(按秒)
|
||||||
|
DefaultTCPNewConnectionsMinSecondlyRate = 3 // 单IP最小连接速率
|
||||||
|
|
||||||
DefaultTCPLinger = 3 // 单节点TCP Linger值
|
DefaultTCPLinger = 3 // 单节点TCP Linger值
|
||||||
DefaultTLSHandshakeTimeout = 3 // TLS握手超时时间
|
DefaultTLSHandshakeTimeout = 3 // TLS握手超时时间
|
||||||
@@ -29,9 +30,8 @@ var DefaultConfigs = maps.Map{
|
|||||||
"tcpMaxConnections": DefaultTCPMaxConnections,
|
"tcpMaxConnections": DefaultTCPMaxConnections,
|
||||||
"tcpMaxConnectionsPerIP": DefaultTCPMaxConnectionsPerIP,
|
"tcpMaxConnectionsPerIP": DefaultTCPMaxConnectionsPerIP,
|
||||||
"tcpMinConnectionsPerIP": DefaultTCPMinConnectionsPerIP,
|
"tcpMinConnectionsPerIP": DefaultTCPMinConnectionsPerIP,
|
||||||
"tcpNewConnectionsRate": DefaultTCPNewConnectionsRate,
|
"tcpNewConnectionsMinutelyRate": DefaultTCPNewConnectionsMinutelyRate,
|
||||||
"tcpNewConnectionsMinRate": DefaultTCPNewConnectionsMinRate,
|
"tcpNewConnectionsMinMinutelyRate": DefaultTCPNewConnectionsMinMinutelyRate,
|
||||||
"tcpDenyNewConnectionsRate": DefaultTCPDenyNewConnectionsRate,
|
"tcpNewConnectionsSecondlyRate": DefaultTCPNewConnectionsSecondlyRate,
|
||||||
"tcpDenyNewConnectionsMinRate": DefaultTCPDenyNewConnectionsMinRate,
|
"tcpNewConnectionsMinSecondlyRate": DefaultTCPNewConnectionsMinSecondlyRate,
|
||||||
"tcpDenyNewConnectionsRateTimeout": DefaultTCPDenyNewConnectionsRateTimeout,
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,11 +15,12 @@ const (
|
|||||||
DefaultTCPMaxConnections = 100_000 // 单节点TCP最大连接数
|
DefaultTCPMaxConnections = 100_000 // 单节点TCP最大连接数
|
||||||
DefaultTCPMaxConnectionsPerIP = 1000 // 单IP最大连接数
|
DefaultTCPMaxConnectionsPerIP = 1000 // 单IP最大连接数
|
||||||
DefaultTCPMinConnectionsPerIP = 5 // 单IP最小连接数
|
DefaultTCPMinConnectionsPerIP = 5 // 单IP最小连接数
|
||||||
DefaultTCPNewConnectionsRate = 500 // 单IP连接速率限制(按分钟)
|
|
||||||
DefaultTCPNewConnectionsMinRate = 5 // 单IP最小连接速率
|
DefaultTCPNewConnectionsMinutelyRate = 500 // 单IP连接速率限制(按分钟)
|
||||||
DefaultTCPDenyNewConnectionsRate = 1000 // 加入黑名单的连接速率
|
DefaultTCPNewConnectionsMinMinutelyRate = 3 // 单IP最小连接速率
|
||||||
DefaultTCPDenyNewConnectionsMinRate = 5 // 加入黑名单的最小连接速率
|
|
||||||
DefaultTCPDenyNewConnectionsRateTimeout = 1800 // 超过黑名单连接速率禁止时间
|
DefaultTCPNewConnectionsSecondlyRate = 300 // 单IP连接速率限制(按秒)
|
||||||
|
DefaultTCPNewConnectionsMinSecondlyRate = 3 // 单IP最小连接速率
|
||||||
|
|
||||||
DefaultTCPLinger = 3 // 单节点TCP Linger值
|
DefaultTCPLinger = 3 // 单节点TCP Linger值
|
||||||
DefaultTLSHandshakeTimeout = 3 // TLS握手超时时间
|
DefaultTLSHandshakeTimeout = 3 // TLS握手超时时间
|
||||||
@@ -29,9 +30,8 @@ var DefaultConfigs = maps.Map{
|
|||||||
"tcpMaxConnections": DefaultTCPMaxConnections,
|
"tcpMaxConnections": DefaultTCPMaxConnections,
|
||||||
"tcpMaxConnectionsPerIP": DefaultTCPMaxConnectionsPerIP,
|
"tcpMaxConnectionsPerIP": DefaultTCPMaxConnectionsPerIP,
|
||||||
"tcpMinConnectionsPerIP": DefaultTCPMinConnectionsPerIP,
|
"tcpMinConnectionsPerIP": DefaultTCPMinConnectionsPerIP,
|
||||||
"tcpNewConnectionsRate": DefaultTCPNewConnectionsRate,
|
"tcpNewConnectionsMinutelyRate": DefaultTCPNewConnectionsMinutelyRate,
|
||||||
"tcpNewConnectionsMinRate": DefaultTCPNewConnectionsMinRate,
|
"tcpNewConnectionsMinMinutelyRate": DefaultTCPNewConnectionsMinMinutelyRate,
|
||||||
"tcpDenyNewConnectionsRate": DefaultTCPDenyNewConnectionsRate,
|
"tcpNewConnectionsSecondlyRate": DefaultTCPNewConnectionsSecondlyRate,
|
||||||
"tcpDenyNewConnectionsMinRate": DefaultTCPDenyNewConnectionsMinRate,
|
"tcpNewConnectionsMinSecondlyRate": DefaultTCPNewConnectionsMinSecondlyRate,
|
||||||
"tcpDenyNewConnectionsRateTimeout": DefaultTCPDenyNewConnectionsRateTimeout,
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,11 +7,14 @@ type TCPConfig struct {
|
|||||||
IsOn bool `json:"isOn"`
|
IsOn bool `json:"isOn"`
|
||||||
MaxConnections int32 `json:"maxConnections"`
|
MaxConnections int32 `json:"maxConnections"`
|
||||||
MaxConnectionsPerIP int32 `json:"maxConnectionsPerIP"`
|
MaxConnectionsPerIP int32 `json:"maxConnectionsPerIP"`
|
||||||
NewConnectionsRate int32 `json:"newConnectionsRate"`
|
|
||||||
|
|
||||||
// 自动加入黑名单连接速率
|
// 分钟级速率
|
||||||
DenyNewConnectionsRate int32 `json:"denyNewConnectionsRate"`
|
NewConnectionsMinutelyRate int32 `json:"newConnectionsRate"` // 分钟
|
||||||
DenyNewConnectionsRateTimeout int32 `json:"denyNewConnectionsRateTimeout"`
|
NewConnectionsMinutelyRateBlockTimeout int32 `json:"newConnectionsRateBlockTimeout"` // 拦截时间
|
||||||
|
|
||||||
|
// 秒级速率
|
||||||
|
NewConnectionsSecondlyRate int32 `json:"newConnectionsSecondlyRate"`
|
||||||
|
NewConnectionsSecondlyRateBlockTimeout int32 `json:"newConnectionsSecondlyRateBlockTimeout"`
|
||||||
|
|
||||||
AllowIPList []*IPConfig `json:"allowIPList"`
|
AllowIPList []*IPConfig `json:"allowIPList"`
|
||||||
Ports []*PortConfig `json:"ports"`
|
Ports []*PortConfig `json:"ports"`
|
||||||
|
|||||||
Reference in New Issue
Block a user