etcdircd

package module
v0.0.0-...-7ddc71e Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2017 License: AGPL-3.0 Imports: 16 Imported by: 0

README

etcdircd

An encrypted irc daemon backed by etcd.

Running etcdircd

Install go, then build etcd and etcdircd:

$ go get github.com/heyitsanthony/etcdircd/cmd/etcdircd
$ go get github.com/coreos/etcd/cmd/etcd

Launch an etcd server and an etcdircd server:

$ etcd &
$ etcdircd &

Connect with an irc client:

$ irssi -n mynick --connect localhost

If it all worked, the client will connect and display the welcome banner. See the security guide to encrypt everything.

How it works

An etcdircd server communicates with other etcdircd servers through etcd. Each server receives messages by watching on etcd keys; network disconnection is tolerated by resuming the watches. If an etcdircd server permanently loses contact with etcd, its resources are automatically released through session expiration.

User information is stored under /user/ with a given <nick>. The key /user/ctl/<nick> holds user metadata including modes, name, and joined channels. The key /user/msg/<nick> forwards IRC messages to <nick>'s connection. For example, writing a PRIVMSG message to /user/msg/<nick> will send a private message to <nick>.

Channel information is similar; its keys are prefixed with /chan/ and take a given <channel>. The key /chan/ctl/<channel> holds metadata such as the channel topic. The key /chan/msg/<nick> forwards IRC messages to all users on the channel. To notify channels when users disconnect, joined users are written to per-server keys /chan/nicks/<channel>/<session>; when the session expires, the key deletion event signals server loss and all the server's users are removed from the channel.

Limitations

etcdircd is still under active development. It's enough to chat, but not much else!

etcd backend encryption is missing:

  • Key revocation
  • Key rotation (2^32 messages before risking repeat IV)
  • Replay attack protection
  • Certificates other than 4096-bit RSA
  • Physical attestation

The irc frontend:

  • Many IRC commands and modes
  • Services
  • Server linking

Contact

Use the issue tracker

Or try the etcd channel on freenode.

License

etcdircd is under the AGPLv3 license. See LICENSE for details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClientDo

func ClientDo(c Client, msg *irc.Message) error

func EncodeMessage

func EncodeMessage(m irc.Message) string

func IsChan

func IsChan(ch string) bool

func KeyChanMsg

func KeyChanMsg(ch string) string

func KeyOperCtl

func KeyOperCtl(n string) string

func KeyUserMsg

func KeyUserMsg(n string) string

func NewKeyEncoder

func NewKeyEncoder(ke keyencode.KeyEncoder) keyencode.KeyEncoder

NewKeyEncoder creates a key encoder that will encode sensitive parts of a given key.

Types

type ChannelCtl

type ChannelCtl struct {
	Name    string
	Topic   string
	Mode    ModeValue
	Created time.Time
}

ChannelCtl represents a channel in etcd.

type ChannelNick

type ChannelNick struct {
	Nick string
	Mode ModeValue
}

ChannelNick contains per-channel information for a nick.

type ChannelNicks

type ChannelNicks struct {
	Nicks []ChannelNick
}

ChannelNicks is one per server session; holds all nick data for a channel.

type Client

type Client interface {
	ConnIRC

	Nick(n string) error
	Mode(m []string) error
	Join(ch string) error
	List(ch []string) error
	Names(ch string) error
	Ping(msg string) error
	Part(ch, msg string) error
	Quit(msg string) error
	Whois(n string) error
	Who(args []string) error
	PrivMsg(target, msg string) error
	Topic(ch string, msg *string) error
	Away(msg string) error
	Oper(login, pass string) error
	Die() error
	Kick(ch string, nicks []string, msg string) error

	Close() error
	// contains filtered or unexported methods
}

Client accepts messages from a connected IRC client.

type Config

type Config struct {
	NetworkName string
	HostName    string
	Motd        string

	MaxChannels uint
	MaxBans     uint
	NickLen     uint
	TopicLen    uint

	PinnedUserModes string
}

config defines the server configuration for IRC.

func NewConfig

func NewConfig() (cfg Config)

NewConfig creates a configuration populated with some defaults

type Conn

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

func NewConn

func NewConn(rwc io.ReadWriteCloser) *Conn

func (*Conn) Close

func (c *Conn) Close()

func (*Conn) Err

func (c *Conn) Err() <-chan error

func (*Conn) Reader

func (c *Conn) Reader() <-chan *irc.Message

func (*Conn) Send

func (c *Conn) Send(ctx context.Context, cmd string, params ...string) error

func (*Conn) SendMsg

func (c *Conn) SendMsg(ctx context.Context, msg irc.Message) error

func (*Conn) SendMsgSync

func (c *Conn) SendMsgSync(msg irc.Message) error

func (*Conn) Writer

func (c *Conn) Writer() chan<- irc.Message

type ConnIRC

type ConnIRC interface {
	Send(ctx context.Context, cmd string, params ...string) error
	SendMsg(ctx context.Context, msg irc.Message) error
	SendMsgSync(msg irc.Message) error
}

type ModeValue

type ModeValue []byte

func (ModeValue) Equal

func (mv ModeValue) Equal(mv2 ModeValue) bool

type OperValue

type OperValue struct {
	Pass   string
	Global bool
}

func NewOperValue

func NewOperValue(ov string) (*OperValue, error)

func (OperValue) Encode

func (ov OperValue) Encode() string

type Server

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

func NewServer

func NewServer(cfg Config, ln net.Listener, cli *etcd.Client) *Server

func (*Server) Close

func (s *Server) Close()

func (*Server) Serve

func (s *Server) Serve() (err error)

type UserValue

type UserValue struct {
	Nick       string
	User       []string
	ServerName string
	Mode       ModeValue
	Host       string
	RealName   string

	Created  time.Time
	Channels []string
	AwayMsg  string

	Lease int64 // stm needs to support Lease()
}

Directories

Path Synopsis
cmd
internal

Jump to

Keyboard shortcuts

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