ircconn

package
v0.0.0-...-1a94ce6 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package ircconn provides transport connections that frame IRC messages, along with outbound rate limiting.

Index

Constants

View Source
const (
	// DefaultMaxLine is the default maximum length of an IRC message line in bytes.
	DefaultMaxLine = 512
	// MaxTagBytes is the maximum length of the IRC message tags section in bytes.
	MaxTagBytes = 8191
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

type Conn interface {
	ReadMessage(ctx context.Context) (ircmsg.Message, error)
	WriteMessage(ctx context.Context, m ircmsg.Message) error
	Close() error
	RemoteAddr() net.Addr
}

Conn represents a transport that frames IRC messages on the wire.

type Dialer

type Dialer interface {
	Dial(ctx context.Context, addr string) (Conn, error)
}

Dialer establishes a Conn to the given address.

type Limiter

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

Limiter gates outbound sends through a token bucket.

func (*Limiter) Wait

func (l *Limiter) Wait(ctx context.Context) error

Wait blocks until a send is permitted or ctx is cancelled.

type RateLimit

type RateLimit struct {
	Burst       int
	PerInterval time.Duration
	Disabled    bool
}

RateLimit configures outbound flood protection.

func (RateLimit) NewLimiter

func (r RateLimit) NewLimiter() *Limiter

NewLimiter returns a Limiter built from the RateLimit configuration.

type TCPDialer

type TCPDialer struct {
	NetDialer  *net.Dialer
	TLSConfig  *tls.Config
	MaxLineLen int
	Logger     *slog.Logger
}

TCPDialer dials a plain TCP connection, or a TLS connection when TLSConfig is non-nil.

func (*TCPDialer) Dial

func (d *TCPDialer) Dial(ctx context.Context, addr string) (Conn, error)

Dial establishes a Conn to addr, using TLS when TLSConfig is set.

Jump to

Keyboard shortcuts

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