soju

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2022 License: AGPL-3.0 Imports: 55 Imported by: 0

README

soju

builds.sr.ht status

A user-friendly IRC bouncer.

  • Multi-user
  • Support multiple clients for a single user, with proper backlog synchronization
  • Support connecting to multiple upstream servers via a single IRC connection to the bouncer

Usage

Building and installing

Dependencies:

  • Go
  • BSD or GNU make
  • a C89 compiler (for SQLite)
  • scdoc (optional, for man pages)

For end users, a Makefile is provided:

make
sudo make install

For development, you can use go run ./cmd/soju as usual.

To link with the system libsqlite3, set GOFLAGS="-tags=libsqlite3".

Contributing

Send patches on the mailing list or on GitHub, report bugs on the issue tracker. Discuss in #soju on Libera Chat.

License

AGPLv3, see LICENSE.

Copyright (C) 2020 The soju Contributors

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetNick added in v0.3.0

func GetNick(user *User, net *Network) string

func GetRealname added in v0.2.0

func GetRealname(user *User, net *Network) string

func GetUsername added in v0.3.0

func GetUsername(user *User, net *Network) string

Types

type Channel

type Channel struct {
	ID   int64
	Name string
	Key  string

	Detached              bool
	DetachedInternalMsgID string

	RelayDetached MessageFilter
	ReattachOn    MessageFilter
	DetachAfter   time.Duration
	DetachOn      MessageFilter
}

type Config added in v0.3.0

type Config struct {
	Hostname        string
	Title           string
	LogPath         string
	HTTPOrigins     []string
	AcceptProxyIPs  config.IPSet
	MaxUserNetworks int
	MultiUpstream   bool
	MOTD            string
	UpstreamUserIPs []*net.IPNet
}

type Database added in v0.2.0

type Database interface {
	Close() error
	Stats(ctx context.Context) (*DatabaseStats, error)

	ListUsers(ctx context.Context) ([]User, error)
	GetUser(ctx context.Context, username string) (*User, error)
	StoreUser(ctx context.Context, user *User) error
	DeleteUser(ctx context.Context, id int64) error

	ListNetworks(ctx context.Context, userID int64) ([]Network, error)
	StoreNetwork(ctx context.Context, userID int64, network *Network) error
	DeleteNetwork(ctx context.Context, id int64) error
	ListChannels(ctx context.Context, networkID int64) ([]Channel, error)
	StoreChannel(ctx context.Context, networKID int64, ch *Channel) error
	DeleteChannel(ctx context.Context, id int64) error

	ListDeliveryReceipts(ctx context.Context, networkID int64) ([]DeliveryReceipt, error)
	StoreClientDeliveryReceipts(ctx context.Context, networkID int64, client string, receipts []DeliveryReceipt) error

	GetReadReceipt(ctx context.Context, networkID int64, name string) (*ReadReceipt, error)
	StoreReadReceipt(ctx context.Context, networkID int64, receipt *ReadReceipt) error
}

func OpenDB added in v0.3.0

func OpenDB(driver, source string) (Database, error)

func OpenPostgresDB added in v0.3.0

func OpenPostgresDB(source string) (Database, error)

func OpenSqliteDB added in v0.2.0

func OpenSqliteDB(source string) (Database, error)

type DatabaseStats added in v0.3.0

type DatabaseStats struct {
	Users    int64
	Networks int64
	Channels int64
}

type DeliveryReceipt

type DeliveryReceipt struct {
	ID            int64
	Target        string // channel or nick
	Client        string
	InternalMsgID string
}

type Identd

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

Identd implements an ident server, as described in RFC 1413.

func NewIdentd

func NewIdentd() *Identd

func (*Identd) Delete

func (s *Identd) Delete(remoteAddr, localAddr string)

func (*Identd) Serve

func (s *Identd) Serve(ln net.Listener) error

func (*Identd) Store

func (s *Identd) Store(remoteAddr, localAddr, ident string)

type Logger

type Logger interface {
	Printf(format string, v ...interface{})
	Debugf(format string, v ...interface{})
}

func NewLogger added in v0.4.0

func NewLogger(out io.Writer, debug bool) Logger

type MessageFilter

type MessageFilter int
const (
	// TODO: use customizable user defaults for FilterDefault
	FilterDefault MessageFilter = iota
	FilterNone
	FilterHighlight
	FilterMessage
)

type MetricsCollectorDatabase added in v0.3.0

type MetricsCollectorDatabase interface {
	Database
	RegisterMetrics(r prometheus.Registerer) error
}

type Network

type Network struct {
	ID              int64
	Name            string
	Addr            string
	Nick            string
	Username        string
	Realname        string
	Pass            string
	ConnectCommands []string
	SASL            SASL
	Enabled         bool
}

func (*Network) GetName

func (net *Network) GetName() string

func (*Network) URL

func (net *Network) URL() (*url.URL, error)

type PostgresDB added in v0.3.0

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

func (*PostgresDB) Close added in v0.3.0

func (db *PostgresDB) Close() error

func (*PostgresDB) DeleteChannel added in v0.3.0

func (db *PostgresDB) DeleteChannel(ctx context.Context, id int64) error

func (*PostgresDB) DeleteNetwork added in v0.3.0

func (db *PostgresDB) DeleteNetwork(ctx context.Context, id int64) error

func (*PostgresDB) DeleteUser added in v0.3.0

func (db *PostgresDB) DeleteUser(ctx context.Context, id int64) error

func (*PostgresDB) GetReadReceipt added in v0.4.0

func (db *PostgresDB) GetReadReceipt(ctx context.Context, networkID int64, name string) (*ReadReceipt, error)

func (*PostgresDB) GetUser added in v0.3.0

func (db *PostgresDB) GetUser(ctx context.Context, username string) (*User, error)

func (*PostgresDB) ListChannels added in v0.3.0

func (db *PostgresDB) ListChannels(ctx context.Context, networkID int64) ([]Channel, error)

func (*PostgresDB) ListDeliveryReceipts added in v0.3.0

func (db *PostgresDB) ListDeliveryReceipts(ctx context.Context, networkID int64) ([]DeliveryReceipt, error)

func (*PostgresDB) ListNetworks added in v0.3.0

func (db *PostgresDB) ListNetworks(ctx context.Context, userID int64) ([]Network, error)

func (*PostgresDB) ListUsers added in v0.3.0

func (db *PostgresDB) ListUsers(ctx context.Context) ([]User, error)

func (*PostgresDB) RegisterMetrics added in v0.4.0

func (db *PostgresDB) RegisterMetrics(r prometheus.Registerer) error

func (*PostgresDB) Stats added in v0.3.0

func (db *PostgresDB) Stats(ctx context.Context) (*DatabaseStats, error)

func (*PostgresDB) StoreChannel added in v0.3.0

func (db *PostgresDB) StoreChannel(ctx context.Context, networkID int64, ch *Channel) error

func (*PostgresDB) StoreClientDeliveryReceipts added in v0.3.0

func (db *PostgresDB) StoreClientDeliveryReceipts(ctx context.Context, networkID int64, client string, receipts []DeliveryReceipt) error

func (*PostgresDB) StoreNetwork added in v0.3.0

func (db *PostgresDB) StoreNetwork(ctx context.Context, userID int64, network *Network) error

func (*PostgresDB) StoreReadReceipt added in v0.4.0

func (db *PostgresDB) StoreReadReceipt(ctx context.Context, networkID int64, receipt *ReadReceipt) error

func (*PostgresDB) StoreUser added in v0.3.0

func (db *PostgresDB) StoreUser(ctx context.Context, user *User) error

type ReadReceipt added in v0.4.0

type ReadReceipt struct {
	ID        int64
	Target    string // channel or nick
	Timestamp time.Time
}

type SASL

type SASL struct {
	Mechanism string

	Plain struct {
		Username string
		Password string
	}

	// TLS client certificate authentication.
	External struct {
		// X.509 certificate in DER form.
		CertBlob []byte
		// PKCS#8 private key in DER form.
		PrivKeyBlob []byte
	}
}

type Server

type Server struct {
	Logger          Logger
	Identd          *Identd               // can be nil
	MetricsRegistry prometheus.Registerer // can be nil
	// contains filtered or unexported fields
}

func NewServer

func NewServer(db Database) *Server

func (*Server) Config added in v0.3.0

func (s *Server) Config() *Config

func (*Server) Serve

func (s *Server) Serve(ln net.Listener) error

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, req *http.Request)

func (*Server) SetConfig added in v0.3.0

func (s *Server) SetConfig(cfg *Config)

func (*Server) Shutdown

func (s *Server) Shutdown()

func (*Server) Start

func (s *Server) Start() error

func (*Server) Stats added in v0.3.0

func (s *Server) Stats() *ServerStats

type ServerStats added in v0.3.0

type ServerStats struct {
	Users       int
	Downstreams int64
	Upstreams   int64
}

type SqliteDB added in v0.2.0

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

func (*SqliteDB) Close added in v0.2.0

func (db *SqliteDB) Close() error

func (*SqliteDB) DeleteChannel added in v0.2.0

func (db *SqliteDB) DeleteChannel(ctx context.Context, id int64) error

func (*SqliteDB) DeleteNetwork added in v0.2.0

func (db *SqliteDB) DeleteNetwork(ctx context.Context, id int64) error

func (*SqliteDB) DeleteUser added in v0.2.0

func (db *SqliteDB) DeleteUser(ctx context.Context, id int64) error

func (*SqliteDB) GetReadReceipt added in v0.4.0

func (db *SqliteDB) GetReadReceipt(ctx context.Context, networkID int64, name string) (*ReadReceipt, error)

func (*SqliteDB) GetUser added in v0.2.0

func (db *SqliteDB) GetUser(ctx context.Context, username string) (*User, error)

func (*SqliteDB) ListChannels added in v0.2.0

func (db *SqliteDB) ListChannels(ctx context.Context, networkID int64) ([]Channel, error)

func (*SqliteDB) ListDeliveryReceipts added in v0.2.0

func (db *SqliteDB) ListDeliveryReceipts(ctx context.Context, networkID int64) ([]DeliveryReceipt, error)

func (*SqliteDB) ListNetworks added in v0.2.0

func (db *SqliteDB) ListNetworks(ctx context.Context, userID int64) ([]Network, error)

func (*SqliteDB) ListUsers added in v0.2.0

func (db *SqliteDB) ListUsers(ctx context.Context) ([]User, error)

func (*SqliteDB) RegisterMetrics added in v0.4.0

func (db *SqliteDB) RegisterMetrics(r prometheus.Registerer) error

func (*SqliteDB) Stats added in v0.3.0

func (db *SqliteDB) Stats(ctx context.Context) (*DatabaseStats, error)

func (*SqliteDB) StoreChannel added in v0.2.0

func (db *SqliteDB) StoreChannel(ctx context.Context, networkID int64, ch *Channel) error

func (*SqliteDB) StoreClientDeliveryReceipts added in v0.2.0

func (db *SqliteDB) StoreClientDeliveryReceipts(ctx context.Context, networkID int64, client string, receipts []DeliveryReceipt) error

func (*SqliteDB) StoreNetwork added in v0.2.0

func (db *SqliteDB) StoreNetwork(ctx context.Context, userID int64, network *Network) error

func (*SqliteDB) StoreReadReceipt added in v0.4.0

func (db *SqliteDB) StoreReadReceipt(ctx context.Context, networkID int64, receipt *ReadReceipt) error

func (*SqliteDB) StoreUser added in v0.2.0

func (db *SqliteDB) StoreUser(ctx context.Context, user *User) error

type User

type User struct {
	ID       int64
	Username string
	Password string // hashed
	Realname string
	Admin    bool
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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