ipblocker

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockedIP

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

type Blocker

type Blocker struct {
	BlockTime   time.Duration
	MaxAttempts int

	Identifier string
	// contains filtered or unexported fields
}

Blocker 用于管理IP封禁

func NewBlocker

func NewBlocker(blockTime int, maxAttempts int, identifier string) *Blocker

NewBlocker 创建一个新的Blocker

func (*Blocker) BlockIP

func (b *Blocker) BlockIP(ip string) error

BlockIP 封禁IP

func (*Blocker) CleanupOldRules

func (b *Blocker) CleanupOldRules()

CleanupOldRules 清理旧的iptables规则

func (*Blocker) Close

func (b *Blocker) Close()

Close 关闭Blocker,释放资源并清除IP封禁规则

func (*Blocker) RegisterFailedAttempt

func (b *Blocker) RegisterFailedAttempt(ip string) bool

RegisterFailedAttempt 注册一次失败的尝试

func (*Blocker) UnblockIP

func (b *Blocker) UnblockIP(ip string) error

UnblockIP 解封IP

Jump to

Keyboard shortcuts

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