firewalls

package
v1.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 18, 2023 License: BSD-3-Clause Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SharedDDoSProtectionManager = NewDDoSProtectionManager()

Functions

func DropTemporaryTo added in v1.0.0

func DropTemporaryTo(ip string, expiresAt int64)

DropTemporaryTo 使用本地防火墙临时拦截IP数据包

Types

type BaseFirewall added in v0.5.2

type BaseFirewall struct {
	// contains filtered or unexported fields
}

type DDoSProtectionManager

type DDoSProtectionManager struct {
	// contains filtered or unexported fields
}

DDoSProtectionManager DDoS防护

func NewDDoSProtectionManager

func NewDDoSProtectionManager() *DDoSProtectionManager

NewDDoSProtectionManager 获取新对象

func (*DDoSProtectionManager) Apply

Apply 应用配置

type FirewallInterface

type FirewallInterface interface {
	// Name 名称
	Name() string

	// IsReady 是否已准备被调用
	IsReady() bool

	// IsMock 是否为模拟
	IsMock() bool

	// AllowPort 允许端口
	AllowPort(port int, protocol string) error

	// RemovePort 删除端口
	RemovePort(port int, protocol string) error

	// RejectSourceIP 拒绝某个源IP连接
	RejectSourceIP(ip string, timeoutSeconds int) error

	// DropSourceIP 丢弃某个源IP数据
	// ip 要封禁的IP
	// timeoutSeconds 过期时间
	// async 是否异步
	DropSourceIP(ip string, timeoutSeconds int, async bool) error

	// RemoveSourceIP 删除某个源IP
	RemoveSourceIP(ip string) error
}

FirewallInterface 防火墙接口

func Firewall

func Firewall() FirewallInterface

Firewall 查找当前系统中最适合的防火墙

type Firewalld

type Firewalld struct {
	BaseFirewall
	// contains filtered or unexported fields
}

func NewFirewalld

func NewFirewalld() *Firewalld

func (*Firewalld) AllowPort

func (this *Firewalld) AllowPort(port int, protocol string) error

func (*Firewalld) AllowPortRangesPermanently added in v0.4.10

func (this *Firewalld) AllowPortRangesPermanently(portRanges [][2]int, protocol string) error

func (*Firewalld) DropSourceIP

func (this *Firewalld) DropSourceIP(ip string, timeoutSeconds int, async bool) error

func (*Firewalld) IsMock

func (this *Firewalld) IsMock() bool

IsMock 是否为模拟

func (*Firewalld) IsReady

func (this *Firewalld) IsReady() bool

func (*Firewalld) Name

func (this *Firewalld) Name() string

Name 名称

func (*Firewalld) PortRangeString added in v0.4.10

func (this *Firewalld) PortRangeString(portRange [2]int, protocol string) string

func (*Firewalld) RejectSourceIP

func (this *Firewalld) RejectSourceIP(ip string, timeoutSeconds int) error

func (*Firewalld) RemovePort

func (this *Firewalld) RemovePort(port int, protocol string) error

func (*Firewalld) RemovePortRangePermanently added in v0.4.10

func (this *Firewalld) RemovePortRangePermanently(portRange [2]int, protocol string) error

func (*Firewalld) RemoveSourceIP

func (this *Firewalld) RemoveSourceIP(ip string) error

type MockFirewall

type MockFirewall struct {
}

MockFirewall 模拟防火墙

func NewMockFirewall

func NewMockFirewall() *MockFirewall

func (*MockFirewall) AllowPort

func (this *MockFirewall) AllowPort(port int, protocol string) error

AllowPort 允许端口

func (*MockFirewall) DropSourceIP

func (this *MockFirewall) DropSourceIP(ip string, timeoutSeconds int, async bool) error

DropSourceIP 丢弃某个源IP数据

func (*MockFirewall) IsMock

func (this *MockFirewall) IsMock() bool

IsMock 是否为模拟

func (*MockFirewall) IsReady

func (this *MockFirewall) IsReady() bool

IsReady 是否已准备被调用

func (*MockFirewall) Name

func (this *MockFirewall) Name() string

Name 名称

func (*MockFirewall) RejectSourceIP

func (this *MockFirewall) RejectSourceIP(ip string, timeoutSeconds int) error

RejectSourceIP 拒绝某个源IP连接

func (*MockFirewall) RemovePort

func (this *MockFirewall) RemovePort(port int, protocol string) error

RemovePort 删除端口

func (*MockFirewall) RemoveSourceIP

func (this *MockFirewall) RemoveSourceIP(ip string) error

RemoveSourceIP 删除某个源IP

type NFTablesFirewall

type NFTablesFirewall struct {
	BaseFirewall
	// contains filtered or unexported fields
}

func NewNFTablesFirewall

func NewNFTablesFirewall() (*NFTablesFirewall, error)

func (*NFTablesFirewall) AllowPort

func (this *NFTablesFirewall) AllowPort(port int, protocol string) error

AllowPort 允许端口

func (*NFTablesFirewall) AllowSourceIP

func (this *NFTablesFirewall) AllowSourceIP(ip string) error

AllowSourceIP Allow把IP加入白名单

func (*NFTablesFirewall) DropSourceIP

func (this *NFTablesFirewall) DropSourceIP(ip string, timeoutSeconds int, async bool) error

DropSourceIP 丢弃某个源IP数据

func (*NFTablesFirewall) IsMock

func (this *NFTablesFirewall) IsMock() bool

IsMock 是否为模拟

func (*NFTablesFirewall) IsReady

func (this *NFTablesFirewall) IsReady() bool

IsReady 是否已准备被调用

func (*NFTablesFirewall) Name

func (this *NFTablesFirewall) Name() string

Name 名称

func (*NFTablesFirewall) RejectSourceIP

func (this *NFTablesFirewall) RejectSourceIP(ip string, timeoutSeconds int) error

RejectSourceIP 拒绝某个源IP连接 we did not create set for drop ip, so we reuse DropSourceIP() method here

func (*NFTablesFirewall) RemovePort

func (this *NFTablesFirewall) RemovePort(port int, protocol string) error

RemovePort 删除端口

func (*NFTablesFirewall) RemoveSourceIP

func (this *NFTablesFirewall) RemoveSourceIP(ip string) error

RemoveSourceIP 删除某个源IP

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL