client

package
v0.0.0-...-15ac6bc Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2023 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrFlood = errors.New("Flooding")

Functions

This section is empty.

Types

type Client

type Client struct {
	Nick     string
	User     string
	Realname string
	Host     string

	// uxin timestamp when client first connects
	JoinTime int64
	// last time that client sent a succcessful message
	Idle time.Time

	Mode              Mode
	AwayMsg           string
	ServerPassAttempt []byte
	RegSuspended      bool

	// Represents a set of IRCv3 capabilities
	Caps map[string]bool
	// The maximum CAP version that this client supports. If no version is
	// explicity requested, this will be 0.
	CapVersion int

	// Mechanism that is currently in use for this client
	SASLMech sasl.Mechanism

	// True if this client has authenticated using SASL
	IsAuthenticated bool

	// used to signal when client has successfully responded to server PING
	PONG chan struct{}

	AuthCtx []byte
	// contains filtered or unexported fields
}

func New

func New(conn net.Conn) *Client

func (*Client) AddGrant

func (c *Client) AddGrant()

Increment the grant counter by 1. If the client already has max grants, this does nothing.

func (*Client) ApplyCap

func (c *Client) ApplyCap(cap string, remove bool)

func (*Client) ApplyMode

func (c *Client) ApplyMode(m mode.Mode) bool

given a modeStr, apply the modes to c. If one of the runes does not correspond to a user mode, return it

func (*Client) CapsSet

func (c *Client) CapsSet() string

func (*Client) Certificate

func (c *Client) Certificate() ([]byte, error)

func (*Client) CertificateFingerprint

func (c *Client) CertificateFingerprint() (string, error)

return a hex string of the sha256 hash of the client's tls certificate. if the client is not connected via tls, or they have not provided a cert, return nil.

func (*Client) CertificateSha

func (c *Client) CertificateSha() ([sha256.Size]byte, error)

func (*Client) Close

func (c *Client) Close() error

func (*Client) FillGrants

func (c *Client) FillGrants()

FillGrants fills the clients grant queue to the max.

func (*Client) HasMessageTags

func (c *Client) HasMessageTags() bool

func (*Client) Id

func (c *Client) Id() string

An Id is used anywhere where a nick is requested in a reply. If Client.Nick is not set yet, then Id returns "*" as a generic placeholder.

func (*Client) Is

func (c *Client) Is(m Mode) bool

func (*Client) IsSecure

func (c *Client) IsSecure() bool

returns true if the client is connected over tls

func (*Client) ReadMsg

func (c *Client) ReadMsg() ([]byte, error)

Read until encountering a newline. If the client does not have any grants left, this returns an error.

func (*Client) RemoteAddr

func (c *Client) RemoteAddr() net.Addr

func (*Client) SetMode

func (c *Client) SetMode(m Mode)

func (*Client) String

func (c *Client) String() string

func (*Client) SupportsCapVersion

func (c *Client) SupportsCapVersion(v int) bool

func (*Client) UnsetMode

func (c *Client) UnsetMode(m Mode)

func (*Client) Write

func (c *Client) Write(b []byte) (int, error)

func (*Client) WriteMessage

func (c *Client) WriteMessage(m msg.Msg)

func (*Client) WriteMessageFrom

func (c *Client) WriteMessageFrom(m msg.Msg, from *Client)

type Mode

type Mode uint8
const (
	Registered Mode = 1 << iota
	Invisible
	Wallops
	// away can stay here as long as it is never allowed to be set with
	// the MODE command; client must explicitly ask for this mode with AWAY
	Away
	Op
	LocalOp
	Bot
)

Modes are represented as bit masks

func (Mode) String

func (m Mode) String() string

Jump to

Keyboard shortcuts

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