package ircneg

import "github.com/hlandau/ircproto/ircneg"

Package ircneg provides functions for the initial handshaking of new IRC connections.

Index

Types

type Config

type Config struct {
	IRCNick         []string             // IRC nicknames in order of preference.
	IRCNickFunc     func(idx int) string // Called to generate nicks if IRCNick list is exhausted. Optional.
	IRCUser         string               // IRC username.
	IRCReal         string               // IRC realname.
	IRCPass         string               // IRC server password. This is not an account password.
	SASLCredentials ircsasl.Credentials  // Leave empty to avoid using SASL.

	// Do not attempt to use IRCv3 capabilities negotiation with the server.
	// SASLCredentials will be ignored if set.
	InhibitCapSupport bool

	// List of capabilities which should be requested if they are supported by
	// the server.
	DesiredCaps []string
}

Configuration settings for the IRC connection negotiation process.

type Result

type Result struct {
	ChosenNick    string            // The nick that was ultimately negotiated.
	CapsAvailable []string          // The capabilities which the server can support.
	CapsEnabled   []string          // The capabilities which were actually enabled.
	CapValues     map[string]string // Caps with values (e.g. sasl=EXTERNAL,PLAIN) list the values here.
	ReadMsgs      []*ircparse.Msg   // All messages which were read during the negotiation.
}

Results of an IRC negotiation process.

func Negotiate

func Negotiate(ctx context.Context, conn ircconn.Abstract, cfg *Config) (res *Result, err error)

Given a freshly created IRC connection, perform the negotiation process.

If successful, returns a Result with information about the negotiated parameters. The connection can then be used to join channels, etc.

If this function returns failure, the Conn is spent and must be disposed of.

Source Files

ircneg.go

Version
v0.0.0-20240529044229-f1af42e426cd (latest)
Published
May 29, 2024
Platform
linux/amd64
Imports
7 packages
Last checked
2 months ago

Tools for package owners.