Initial commit (code only without large binaries)

This commit is contained in:
robin
2026-02-15 18:58:44 +08:00
commit 35df75498f
9442 changed files with 1495866 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
package ddosconfigs
type IPConfig struct {
IP string `json:"ip"`
Description string `json:"description"`
}

View File

@@ -0,0 +1,8 @@
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
package ddosconfigs
type PortConfig struct {
Port int32 `json:"port"`
Description string `json:"description"`
}

View File

@@ -0,0 +1,51 @@
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
package ddosconfigs
func DefaultProtectionConfig() *ProtectionConfig {
return &ProtectionConfig{}
}
type ProtectionConfig struct {
TCP *TCPConfig `yaml:"tcp" json:"tcp"`
}
func (this *ProtectionConfig) Init() error {
// tcp
if this.TCP != nil {
err := this.TCP.Init()
if err != nil {
return err
}
}
return nil
}
func (this *ProtectionConfig) IsPriorEmpty() bool {
if this.TCP != nil && this.TCP.IsPrior {
return false
}
return true
}
func (this *ProtectionConfig) IsOn() bool {
// tcp
if this.TCP != nil && this.TCP.IsOn {
return true
}
return false
}
func (this *ProtectionConfig) Merge(childConfig *ProtectionConfig) {
if childConfig == nil {
return
}
// tcp
if childConfig.TCP != nil && childConfig.TCP.IsPrior {
this.TCP = childConfig.TCP
}
}

View File

@@ -0,0 +1,25 @@
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
package ddosconfigs
type TCPConfig struct {
IsPrior bool `json:"isPrior"`
IsOn bool `json:"isOn"`
MaxConnections int32 `json:"maxConnections"`
MaxConnectionsPerIP int32 `json:"maxConnectionsPerIP"`
// 分钟级速率
NewConnectionsMinutelyRate int32 `json:"newConnectionsRate"` // 分钟
NewConnectionsMinutelyRateBlockTimeout int32 `json:"newConnectionsRateBlockTimeout"` // 拦截时间
// 秒级速率
NewConnectionsSecondlyRate int32 `json:"newConnectionsSecondlyRate"`
NewConnectionsSecondlyRateBlockTimeout int32 `json:"newConnectionsSecondlyRateBlockTimeout"`
AllowIPList []*IPConfig `json:"allowIPList"`
Ports []*PortConfig `json:"ports"`
}
func (this *TCPConfig) Init() error {
return nil
}