connections

package
v0.0.0-...-7571207 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: MPL-2.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BannedConnectionError

func BannedConnectionError(c net.Conn, cause error) error

BannedConnectionError bans a connection.

Types

type BanIPv4

type BanIPv4 struct{}

BanIPv4 ban IPv4 addresses

func (BanIPv4) Blocked

func (BanIPv4) Blocked(ip net.IP, port int) error

Blocked prevents connections from IPv4 addresses.

type BanIPv6

type BanIPv6 struct{}

BanIPv6 ban IPv6 addresses

func (BanIPv6) Blocked

func (BanIPv6) Blocked(ip net.IP, p int) error

Blocked prevents connections from IPv6 addresses.

type BanInvalidPort

type BanInvalidPort struct{}

BanInvalidPort blocks connections with invalid port values.

func (BanInvalidPort) Blocked

func (BanInvalidPort) Blocked(ip net.IP, port int) error

Blocked prevents connections from ipv4 addresses.

type BloomBanIP

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

BloomBanIP bans an IP address by adding it to a bloom filter. BloomBanIP is stateful, and will track banned connections using a bloom filter.

func NewBloomBanIP

func NewBloomBanIP(d time.Duration) *BloomBanIP

NewBloomBanIP bans an IP address by adding to a bloom filter.

func (*BloomBanIP) Blocked

func (t *BloomBanIP) Blocked(ip net.IP, p int) error

Blocked prevents connections from IPv6 addresses.

func (*BloomBanIP) Inhibit

func (t *BloomBanIP) Inhibit(ip net.IP, port int, cause error)

Inhibit ban an IP address within the smallest 8 bit range.

type Firewall

type Firewall interface {
	Blocked(ip net.IP, port int) error
}

Firewall used to prevent connections.

type FirewallStateful

type FirewallStateful interface {
	Firewall
	Inhibit(ip net.IP, port int, cause error)
}

FirewallStateful used when the firewall needs to be updated dynamically.

func AutoFirewall

func AutoFirewall() FirewallStateful

AutoFirewall reasonable default firewall settings.

func NewFirewall

func NewFirewall(rules ...Firewall) FirewallStateful

NewFirewall compose multiple firewalls into a single firewall.

type Handshaker

type Handshaker interface {
	Accept(l net.Listener) (net.Conn, error)
	Release(c net.Conn, cause error) error
}

Handshaker accepts connections from a net listener and performs a handshake to ensure the connection is acceptable.

func NewHandshaker

func NewHandshaker(firewall FirewallStateful) Handshaker

NewHandshaker default handshake method.

Jump to

Keyboard shortcuts

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