ircutils

package
v0.0.0-...-9e9a443 Latest Latest
Warning

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

Go to latest
Published: May 22, 2024 License: ISC Imports: 6 Imported by: 0

Documentation

Overview

Package ircutils provides small, useful utility functions and classes.

This package is in an alpha stage.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSASLLimitExceeded = errors.New("SASL total response size exceeded configured limit")
	ErrSASLTooLong       = errors.New("SASL response chunk exceeded 400-byte limit")
)
View Source
var TruncateUTF8Safe = ircmsg.TruncateUTF8Safe

Functions

func EncodeSASLResponse

func EncodeSASLResponse(raw []byte) (result []string)

EncodeSASLResponse encodes a raw SASL response as parameters to successive AUTHENTICATE commands, as described in the IRCv3 SASL specification.

func HostnameIsValid

func HostnameIsValid(hostname string) bool

HostnameIsValid provides a way for servers to check whether a looked-up client hostname is valid (see InspIRCd #1033 for why this is required).

This function shouldn't be called by clients since they don't need to validate hostnames for IRC use, just by servers that need to confirm hostnames of incoming clients.

In addition to this function, servers should impose their own limits on max hostname length -- this function limits it to 200 but most servers will probably want to make it smaller than that.

func SanitizeText

func SanitizeText(message string, byteLimit int) (result string)

SanitizeText Sanitizes human-readable text to make it safe for IRC; assumes UTF-8 and uses the replacement character where applicable.

Types

type SASLBuffer

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

SASLBuffer handles buffering and decoding SASL responses sent as parameters to AUTHENTICATE commands, as described in the IRCv3 SASL specification. Do not copy a SASLBuffer after first use.

func NewSASLBuffer

func NewSASLBuffer(maxLength int) *SASLBuffer

NewSASLBuffer returns a new SASLBuffer. maxLength is the maximum amount of data to buffer (0 for no limit).

func (*SASLBuffer) Add

func (b *SASLBuffer) Add(value string) (done bool, output []byte, err error)

Add processes an additional SASL response chunk sent via AUTHENTICATE. If the response is complete, it resets the buffer and returns the decoded response along with any decoding or protocol errors detected.

func (*SASLBuffer) Clear

func (b *SASLBuffer) Clear()

Clear resets the buffer state.

func (*SASLBuffer) Initialize

func (b *SASLBuffer) Initialize(maxLength int)

Initialize initializes a SASLBuffer in place.

Jump to

Keyboard shortcuts

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