suika

package module
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: AGPL-3.0 Imports: 55 Imported by: 0

README

suika

Go Documentation

A user-friendly IRC bouncer. Hard-fork of the 0.3 series of soju, named after Suika Ibuki from Touhou 7.5: Immaterial and Missing Power

  • 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

Building and installing

Dependencies:

  • Go
  • BSD or GNU make

For end users, a Makefile is provided:

make
doas make install

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

License

AGPLv3, see LICENSE.

  • Copyright (C) 2020 The soju Contributors
  • Copyright (C) 2023-present Izuru Yakumo

The code for version.go is stolen verbatim from one of @prologic's projects. It's probably under MIT

Documentation

Overview

Package suika is a hard-fork of the 0.3 series of soju, an user-friendly IRC bouncer in Go.

# Copyright (C) 2020 The soju Contributors # Copyright (C) 2023-present Izuru Yakumo et al.

suika is covered by the AGPLv3 license:

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

Index

Constants

This section is empty.

Variables

View Source
var (
	// Version is the tagged release version in the form <major>.<minor>.<patch>
	// following semantic versioning and is overwritten by the build system.
	Version = defaultVersion

	// Commit is the commit sha of the build (normally from Git) and is overwritten
	// by the build system.
	Commit = defaultCommit

	// Build is the date and time of the build as an RFC3339 formatted string
	// and is overwritten by the build system.
	Build = defaultBuild
)

Functions

func FullVersion added in v0.3.4

func FullVersion() string

FullVersion display the full version and build

func GetNick

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

func GetRealname

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

func GetUsername

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

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

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

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

func OpenPostgresDB

func OpenPostgresDB(source string) (Database, error)

func OpenSqliteDB

func OpenSqliteDB(source string) (Database, error)

type DatabaseStats

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

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

type MetricsCollectorDatabase interface {
	Database
	MetricsCollector() prometheus.Collector
}

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

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

func (*PostgresDB) Close

func (db *PostgresDB) Close() error

func (*PostgresDB) DeleteChannel

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

func (*PostgresDB) DeleteNetwork

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

func (*PostgresDB) DeleteUser

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

func (*PostgresDB) GetReadReceipt

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

func (*PostgresDB) GetUser

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

func (*PostgresDB) ListChannels

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

func (*PostgresDB) ListDeliveryReceipts

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

func (*PostgresDB) ListNetworks

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

func (*PostgresDB) ListUsers

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

func (*PostgresDB) MetricsCollector

func (db *PostgresDB) MetricsCollector() prometheus.Collector

func (*PostgresDB) Stats

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

func (*PostgresDB) StoreChannel

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

func (*PostgresDB) StoreClientDeliveryReceipts

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

func (*PostgresDB) StoreNetwork

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

func (*PostgresDB) StoreReadReceipt

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

func (*PostgresDB) StoreUser

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

type ReadReceipt

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

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

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

func (*Server) Shutdown

func (s *Server) Shutdown()

func (*Server) Start

func (s *Server) Start() error

func (*Server) Stats

func (s *Server) Stats() *ServerStats

type ServerStats

type ServerStats struct {
	Users       int
	Downstreams int64
	Upstreams   int64
}

type SqliteDB

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

func (*SqliteDB) Close

func (db *SqliteDB) Close() error

func (*SqliteDB) DeleteChannel

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

func (*SqliteDB) DeleteNetwork

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

func (*SqliteDB) DeleteUser

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

func (*SqliteDB) GetReadReceipt

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

func (*SqliteDB) GetUser

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

func (*SqliteDB) ListChannels

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

func (*SqliteDB) ListDeliveryReceipts

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

func (*SqliteDB) ListNetworks

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

func (*SqliteDB) ListUsers

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

func (*SqliteDB) MetricsCollector

func (db *SqliteDB) MetricsCollector() prometheus.Collector

func (*SqliteDB) Stats

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

func (*SqliteDB) StoreChannel

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

func (*SqliteDB) StoreClientDeliveryReceipts

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

func (*SqliteDB) StoreNetwork

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

func (*SqliteDB) StoreReadReceipt

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

func (*SqliteDB) StoreUser

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