mirror of
				https://github.com/TeaOSLab/EdgeCommon.git
				synced 2025-11-04 13:10:24 +08:00 
			
		
		
		
	DDoS防护增加单IP TCP新连接速率黑名单
This commit is contained in:
		@@ -17,6 +17,10 @@ const (
 | 
				
			|||||||
	DefaultTCPMinConnectionsPerIP           = 5       // 单IP最小连接数
 | 
						DefaultTCPMinConnectionsPerIP           = 5       // 单IP最小连接数
 | 
				
			||||||
	DefaultTCPNewConnectionsRate            = 500     // 单IP连接速率限制(按分钟)
 | 
						DefaultTCPNewConnectionsRate            = 500     // 单IP连接速率限制(按分钟)
 | 
				
			||||||
	DefaultTCPNewConnectionsMinRate         = 5       // 单IP最小连接速率
 | 
						DefaultTCPNewConnectionsMinRate         = 5       // 单IP最小连接速率
 | 
				
			||||||
 | 
						DefaultTCPDenyNewConnectionsRate        = 1000    // 加入黑名单的连接速率
 | 
				
			||||||
 | 
						DefaultTCPDenyNewConnectionsMinRate     = 5       // 加入黑名单的最小连接速率
 | 
				
			||||||
 | 
						DefaultTCPDenyNewConnectionsRateTimeout = 1800    // 超过黑名单连接速率禁止时间
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	DefaultTCPLinger           = 3 // 单节点TCP Linger值
 | 
						DefaultTCPLinger           = 3 // 单节点TCP Linger值
 | 
				
			||||||
	DefaultTLSHandshakeTimeout = 3 // TLS握手超时时间
 | 
						DefaultTLSHandshakeTimeout = 3 // TLS握手超时时间
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
@@ -27,4 +31,7 @@ var DefaultConfigs = maps.Map{
 | 
				
			|||||||
	"tcpMinConnectionsPerIP":           DefaultTCPMinConnectionsPerIP,
 | 
						"tcpMinConnectionsPerIP":           DefaultTCPMinConnectionsPerIP,
 | 
				
			||||||
	"tcpNewConnectionsRate":            DefaultTCPNewConnectionsRate,
 | 
						"tcpNewConnectionsRate":            DefaultTCPNewConnectionsRate,
 | 
				
			||||||
	"tcpNewConnectionsMinRate":         DefaultTCPNewConnectionsMinRate,
 | 
						"tcpNewConnectionsMinRate":         DefaultTCPNewConnectionsMinRate,
 | 
				
			||||||
 | 
						"tcpDenyNewConnectionsRate":        DefaultTCPDenyNewConnectionsRate,
 | 
				
			||||||
 | 
						"tcpDenyNewConnectionsMinRate":     DefaultTCPDenyNewConnectionsMinRate,
 | 
				
			||||||
 | 
						"tcpDenyNewConnectionsRateTimeout": DefaultTCPDenyNewConnectionsRateTimeout,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,6 +17,10 @@ const (
 | 
				
			|||||||
	DefaultTCPMinConnectionsPerIP           = 5       // 单IP最小连接数
 | 
						DefaultTCPMinConnectionsPerIP           = 5       // 单IP最小连接数
 | 
				
			||||||
	DefaultTCPNewConnectionsRate            = 500     // 单IP连接速率限制(按分钟)
 | 
						DefaultTCPNewConnectionsRate            = 500     // 单IP连接速率限制(按分钟)
 | 
				
			||||||
	DefaultTCPNewConnectionsMinRate         = 5       // 单IP最小连接速率
 | 
						DefaultTCPNewConnectionsMinRate         = 5       // 单IP最小连接速率
 | 
				
			||||||
 | 
						DefaultTCPDenyNewConnectionsRate        = 1000    // 加入黑名单的连接速率
 | 
				
			||||||
 | 
						DefaultTCPDenyNewConnectionsMinRate     = 5       // 加入黑名单的最小连接速率
 | 
				
			||||||
 | 
						DefaultTCPDenyNewConnectionsRateTimeout = 1800    // 超过黑名单连接速率禁止时间
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	DefaultTCPLinger           = 3 // 单节点TCP Linger值
 | 
						DefaultTCPLinger           = 3 // 单节点TCP Linger值
 | 
				
			||||||
	DefaultTLSHandshakeTimeout = 3 // TLS握手超时时间
 | 
						DefaultTLSHandshakeTimeout = 3 // TLS握手超时时间
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
@@ -27,4 +31,7 @@ var DefaultConfigs = maps.Map{
 | 
				
			|||||||
	"tcpMinConnectionsPerIP":           DefaultTCPMinConnectionsPerIP,
 | 
						"tcpMinConnectionsPerIP":           DefaultTCPMinConnectionsPerIP,
 | 
				
			||||||
	"tcpNewConnectionsRate":            DefaultTCPNewConnectionsRate,
 | 
						"tcpNewConnectionsRate":            DefaultTCPNewConnectionsRate,
 | 
				
			||||||
	"tcpNewConnectionsMinRate":         DefaultTCPNewConnectionsMinRate,
 | 
						"tcpNewConnectionsMinRate":         DefaultTCPNewConnectionsMinRate,
 | 
				
			||||||
 | 
						"tcpDenyNewConnectionsRate":        DefaultTCPDenyNewConnectionsRate,
 | 
				
			||||||
 | 
						"tcpDenyNewConnectionsMinRate":     DefaultTCPDenyNewConnectionsMinRate,
 | 
				
			||||||
 | 
						"tcpDenyNewConnectionsRateTimeout": DefaultTCPDenyNewConnectionsRateTimeout,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,6 +8,11 @@ type TCPConfig struct {
 | 
				
			|||||||
	MaxConnections      int32 `json:"maxConnections"`
 | 
						MaxConnections      int32 `json:"maxConnections"`
 | 
				
			||||||
	MaxConnectionsPerIP int32 `json:"maxConnectionsPerIP"`
 | 
						MaxConnectionsPerIP int32 `json:"maxConnectionsPerIP"`
 | 
				
			||||||
	NewConnectionsRate  int32 `json:"newConnectionsRate"`
 | 
						NewConnectionsRate  int32 `json:"newConnectionsRate"`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// 自动加入黑名单连接速率
 | 
				
			||||||
 | 
						DenyNewConnectionsRate        int32 `json:"denyNewConnectionsRate"`
 | 
				
			||||||
 | 
						DenyNewConnectionsRateTimeout int32 `json:"denyNewConnectionsRateTimeout"`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	AllowIPList []*IPConfig   `json:"allowIPList"`
 | 
						AllowIPList []*IPConfig   `json:"allowIPList"`
 | 
				
			||||||
	Ports       []*PortConfig `json:"ports"`
 | 
						Ports       []*PortConfig `json:"ports"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user