webircgateway

package
v0.0.0-...-a3056fc Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2024 License: Apache-2.0 Imports: 38 Imported by: 3

Documentation

Index

Constants

View Source
const (
	// ClientStateIdle - Client connected and just sat there
	ClientStateIdle = "idle"
	// ClientStateConnecting - Connecting upstream
	ClientStateConnecting = "connecting"
	// ClientStateRegistering - Registering to the IRC network
	ClientStateRegistering = "registering"
	// ClientStateConnected - Connected upstream
	ClientStateConnected = "connected"
	// ClientStateEnding - Client is ending its connection
	ClientStateEnding = "ending"
)

Variables

View Source
var MAX_EXTJWT_SIZE = 200
View Source
var (
	Version = "-"
)

Functions

func HookRegister

func HookRegister(hookName string, p interface{})

func Ipv4ToHex

func Ipv4ToHex(ip string) string

Types

type Client

type Client struct {
	Gateway *Gateway
	Id      uint64
	State   string
	EndWG   sync.WaitGroup

	SeenQuit      bool
	Recv          chan string
	ThrottledRecv *ThrottledStringChannel

	UpstreamRecv    chan string
	UpstreamSend    chan string
	UpstreamStarted bool
	UpstreamConfig  *ConfigUpstream
	RemoteAddr      string
	RemoteHostname  string
	RemotePort      int
	DestHost        string
	DestPort        int
	DestTLS         bool
	IrcState        *irc.State
	Encoding        string
	// Tags get passed upstream via the WEBIRC command
	Tags map[string]string
	// Captchas may be needed to verify a client
	RequiresVerification bool
	Verified             bool
	SentPass             bool
	// Signals for the transport to make use of (data, connection state, etc)
	Signals  chan ClientSignal
	Features struct {
		Messagetags bool
		Metadata    bool
		ExtJwt      bool
	}
	// The specific message-tags CAP that the client has requested if we are wrapping it
	RequestedMessageTagsCap string
	// Prefix used by the server when sending its own messages
	ServerMessagePrefix irc.Mask
	// contains filtered or unexported fields
}

Client - Connecting client struct

func NewClient

func NewClient(gateway *Gateway) *Client

NewClient - Makes a new client

func (*Client) IsShuttingDown

func (c *Client) IsShuttingDown() bool

func (*Client) Log

func (c *Client) Log(level int, format string, args ...interface{})

Log - Log a line of text with context of this client

func (*Client) ProcessLineFromClient

func (c *Client) ProcessLineFromClient(line string) (string, error)

* ProcessLineFromClient * Processes and makes any changes to a line of data sent from a client

func (*Client) ProcessLineFromUpstream

func (c *Client) ProcessLineFromUpstream(data string) string

* ProcessLineFromUpstream * Processes and makes any changes to a line of data sent from an upstream

func (*Client) Ready

func (c *Client) Ready()

func (*Client) SendClientSignal

func (c *Client) SendClientSignal(signal string, args ...string)

func (*Client) SendIrcError

func (c *Client) SendIrcError(message string)

func (*Client) SendIrcFail

func (c *Client) SendIrcFail(params ...string)

func (*Client) StartShutdown

func (c *Client) StartShutdown(reason string)

func (*Client) TrafficLog

func (c *Client) TrafficLog(isUpstream bool, toGateway bool, traffic string)

TrafficLog - Log out raw IRC traffic

type ClientSignal

type ClientSignal [3]string

type Config

type Config struct {
	ConfigFile            string
	LogLevel              int
	Gateway               bool
	GatewayName           string
	GatewayWhitelist      []glob.Glob
	GatewayThrottle       int
	GatewayTimeout        int
	GatewayWebircPassword map[string]string
	GatewayProtocol       string
	GatewayLocalAddr      string
	Proxy                 ConfigServer
	Upstreams             []ConfigUpstream
	Servers               []ConfigServer
	ServerTransports      []string
	RemoteOrigins         []glob.Glob
	ReverseProxies        []net.IPNet
	Webroot               string
	ClientRealname        string
	ClientUsername        string
	ClientHostname        string
	Identd                bool
	RequiresVerification  bool
	SendQuitOnClientClose string
	ReCaptchaURL          string
	ReCaptchaSecret       string
	ReCaptchaKey          string
	Secret                string
	Plugins               []string
	DnsblServers          []string
	// DnsblAction - "deny" = deny the connection. "verify" = require verification
	DnsblAction string
	// contains filtered or unexported fields
}

Config - Config options for the running app

func NewConfig

func NewConfig(gateway *Gateway) *Config

func (*Config) CurrentConfigFile

func (c *Config) CurrentConfigFile() string

CurrentConfigFile - Return the full path or command for the config file in use

func (*Config) Load

func (c *Config) Load() error

func (*Config) ResolvePath

func (c *Config) ResolvePath(path string) string

ConfigResolvePath - If relative, resolve a path to it's full absolute path relative to the config file

func (*Config) SetConfigFile

func (c *Config) SetConfigFile(configFile string)

type ConfigProxy

type ConfigProxy struct {
	Type      string
	Hostname  string
	Port      int
	TLS       bool
	Username  string
	Interface string
}

type ConfigServer

type ConfigServer struct {
	LocalAddr           string
	BindMode            os.FileMode
	Port                int
	TLS                 bool
	CertFile            string
	KeyFile             string
	LetsEncryptCacheDir string
}

ConfigServer - A web server config

type ConfigUpstream

type ConfigUpstream struct {
	// Plugins may assign an arbitary address to an upstream network
	NetworkCommonAddress string
	Hostname             string
	Port                 int
	TLS                  bool
	Timeout              int
	Throttle             int
	WebircPassword       string
	ServerPassword       string
	GatewayName          string
	Proxy                *ConfigProxy
	Protocol             string
	LocalAddr            string
}

ConfigUpstream - An upstream config

type Gateway

type Gateway struct {
	Config     *Config
	HttpRouter *http.ServeMux
	LogOutput  chan string

	Clients  cmap.ConcurrentMap
	Acme     *LEManager
	Function string
	// contains filtered or unexported fields
}

func NewGateway

func NewGateway(function string) *Gateway

func (*Gateway) Close

func (s *Gateway) Close()

func (*Gateway) GetRemoteAddressFromRequest

func (s *Gateway) GetRemoteAddressFromRequest(req *http.Request) net.IP

func (*Gateway) IsClientOriginAllowed

func (s *Gateway) IsClientOriginAllowed(originHeader string) bool

func (*Gateway) Log

func (s *Gateway) Log(level int, format string, args ...interface{})

func (*Gateway) NewClient

func (s *Gateway) NewClient() *Client

func (*Gateway) Start

func (s *Gateway) Start()

func (*Gateway) WaitClose

func (s *Gateway) WaitClose()

type Hook

type Hook struct {
	ID   string
	Halt bool
}

type HookClientInit

type HookClientInit struct {
	Hook
	Client    *Client
	Connected bool
}

*

  • HookClientInit
  • Dispatched directly after a new Client instance has been created
  • Types: client.init

func (*HookClientInit) Dispatch

func (h *HookClientInit) Dispatch(eventType string)

type HookClientState

type HookClientState struct {
	Hook
	Client    *Client
	Connected bool
}

*

  • HookClientState
  • Dispatched after a client connects or disconnects
  • Types: client.state

func (*HookClientState) Dispatch

func (h *HookClientState) Dispatch(eventType string)

type HookGatewayClosing

type HookGatewayClosing struct {
	Hook
}

*

  • HookGatewayClosing
  • Dispatched when the gateway has been told to shutdown
  • Types: gateway.closing

func (*HookGatewayClosing) Dispatch

func (h *HookGatewayClosing) Dispatch(eventType string)

type HookIrcConnectionPre

type HookIrcConnectionPre struct {
	Hook
	Client         *Client
	UpstreamConfig *ConfigUpstream
}

*

  • HookIrcConnectionPre
  • Dispatched just before an IRC connection is attempted
  • Types: irc.connection.pre

func (*HookIrcConnectionPre) Dispatch

func (h *HookIrcConnectionPre) Dispatch(eventType string)

type HookIrcLine

type HookIrcLine struct {
	Hook
	Client         *Client
	UpstreamConfig *ConfigUpstream
	Line           string
	Message        *irc.Message
	ToServer       bool
}

*

  • HookIrcLine
  • Dispatched when either:
  • * A line arrives from the IRCd, before sending to the client
  • * A line arrives from the client, before sending to the IRCd
  • Types: irc.line

func (*HookIrcLine) Dispatch

func (h *HookIrcLine) Dispatch(eventType string)

type HookStatus

type HookStatus struct {
	Hook
	Client *Client
	Line   string
}

*

  • HookStatus
  • Dispatched for each line output of the _status HTTP request
  • Types: status.client

func (*HookStatus) Dispatch

func (h *HookStatus) Dispatch(eventType string)

type LEManager

type LEManager struct {
	// ensure only one instance of the manager and handler is running
	// while allowing multiple listeners to use it
	Mutex   sync.Mutex
	Manager *autocert.Manager
	// contains filtered or unexported fields
}

func NewLetsEncryptManager

func NewLetsEncryptManager(gateway *Gateway) *LEManager

func (*LEManager) Get

func (le *LEManager) Get(certCacheDir string) *autocert.Manager

type MessageTagManager

type MessageTagManager struct {
	Mutex sync.Mutex
	// contains filtered or unexported fields
}

func NewMessageTagManager

func NewMessageTagManager() *MessageTagManager

func (*MessageTagManager) AddTagsFromMessage

func (tags *MessageTagManager) AddTagsFromMessage(client *Client, fromNick string, msg *irc.Message)

func (*MessageTagManager) CanMessageContainClientTags

func (tags *MessageTagManager) CanMessageContainClientTags(msg *irc.Message) bool

func (*MessageTagManager) GetTagsFromMessage

func (tags *MessageTagManager) GetTagsFromMessage(client *Client, fromNick string, msg *irc.Message) (MessageTags, bool)

func (*MessageTagManager) RunGarbageCollectionLoop

func (tags *MessageTagManager) RunGarbageCollectionLoop()

type MessageTags

type MessageTags struct {
	Tags map[string]string
}

type ThrottledStringChannel

type ThrottledStringChannel struct {
	Input chan<- string

	Output <-chan string
	*rate.Limiter
	// contains filtered or unexported fields
}

func NewThrottledStringChannel

func NewThrottledStringChannel(wrappedChan chan string, limiter *rate.Limiter) *ThrottledStringChannel

type TransportKiwiirc

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

func (*TransportKiwiirc) Init

func (t *TransportKiwiirc) Init(g *Gateway)

type TransportKiwiircChannel

type TransportKiwiircChannel struct {
	Conn   sockjs.Session
	Client *Client
	Id     string

	ClosedLock sync.Mutex
	Closed     bool
	// contains filtered or unexported fields
}

type TransportSockjs

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

func (*TransportSockjs) Init

func (t *TransportSockjs) Init(g *Gateway)

type TransportTcp

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

func (*TransportTcp) Init

func (t *TransportTcp) Init(g *Gateway)

func (*TransportTcp) Start

func (t *TransportTcp) Start(lAddr string)

type TransportWebsocket

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

func (*TransportWebsocket) Init

func (t *TransportWebsocket) Init(g *Gateway)

Jump to

Keyboard shortcuts

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