storage

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2018 License: MIT Imports: 16 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidCert      = errors.New("Invalid certificate")
	ErrCouldNotSaveCert = errors.New("Could not save certificate")
)
View Source
var Path directory

Functions

func DefaultDirectory

func DefaultDirectory() string

func Initialize

func Initialize(dir string)

Types

type Channel

type Channel struct {
	Server string
	Name   string
	Topic  string
}

func (*Channel) Marshal

func (d *Channel) Marshal(buf []byte) ([]byte, error)

func (*Channel) Size

func (d *Channel) Size() (s uint64)

func (*Channel) Unmarshal

func (d *Channel) Unmarshal(buf []byte) (uint64, error)

type ChannelStore

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

func NewChannelStore

func NewChannelStore() *ChannelStore

func (*ChannelStore) AddUser

func (c *ChannelStore) AddUser(user, server, channel string)

func (*ChannelStore) GetTopic

func (c *ChannelStore) GetTopic(server, channel string) string

func (*ChannelStore) GetUsers

func (c *ChannelStore) GetUsers(server, channel string) []string

func (*ChannelStore) RemoveUser

func (c *ChannelStore) RemoveUser(user, server, channel string)

func (*ChannelStore) RemoveUserAll

func (c *ChannelStore) RemoveUserAll(user, server string)

func (*ChannelStore) RenameUser

func (c *ChannelStore) RenameUser(oldNick, newNick, server string)

func (*ChannelStore) SetMode

func (c *ChannelStore) SetMode(server, channel, user, add, remove string)

func (*ChannelStore) SetTopic

func (c *ChannelStore) SetTopic(topic, server, channel string)

func (*ChannelStore) SetUsers

func (c *ChannelStore) SetUsers(users []string, server, channel string)

type ChannelStoreUser

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

func NewChannelStoreUser

func NewChannelStoreUser(nick string) *ChannelStoreUser

func (*ChannelStoreUser) String

func (c *ChannelStoreUser) String() string

type ClientSettings

type ClientSettings struct {
	ColoredNicks bool
}

func DefaultClientSettings

func DefaultClientSettings() *ClientSettings

func (*ClientSettings) Marshal

func (d *ClientSettings) Marshal(buf []byte) ([]byte, error)

func (ClientSettings) MarshalEasyJSON

func (v ClientSettings) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (ClientSettings) MarshalJSON

func (v ClientSettings) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*ClientSettings) Size

func (d *ClientSettings) Size() (s uint64)

func (*ClientSettings) Unmarshal

func (d *ClientSettings) Unmarshal(buf []byte) (uint64, error)

func (*ClientSettings) UnmarshalEasyJSON

func (v *ClientSettings) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*ClientSettings) UnmarshalJSON

func (v *ClientSettings) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Message

type Message struct {
	ID      string `json:"-" bleve:"-"`
	Server  string `json:"-" bleve:"server"`
	From    string `bleve:"-"`
	To      string `json:"-" bleve:"to"`
	Content string `bleve:"content"`
	Time    int64  `bleve:"-"`
}

func (*Message) Marshal

func (d *Message) Marshal(buf []byte) ([]byte, error)

func (*Message) Size

func (d *Message) Size() (s uint64)

func (Message) Type

func (m Message) Type() string

func (*Message) Unmarshal

func (d *Message) Unmarshal(buf []byte) (uint64, error)

type MessageSearchProvider

type MessageSearchProvider interface {
	SearchMessages(server, channel, q string) ([]string, error)
	Index(id string, message *Message) error
	Close()
}

type MessageStore

type MessageStore interface {
	LogMessage(message *Message) error
	GetMessages(server, channel string, count int, fromID string) ([]Message, bool, error)
	GetMessagesByID(server, channel string, ids []string) ([]Message, error)
	Close()
}

type Server

type Server struct {
	Name     string
	Host     string
	Port     string
	TLS      bool
	Password string
	Nick     string
	Username string
	Realname string
}

func (*Server) Marshal

func (d *Server) Marshal(buf []byte) ([]byte, error)

func (*Server) Size

func (d *Server) Size() (s uint64)

func (*Server) Unmarshal

func (d *Server) Unmarshal(buf []byte) (uint64, error)

type SessionStore

type SessionStore interface {
	GetSessions() ([]*session.Session, error)
	SaveSession(session *session.Session) error
	DeleteSession(key string) error
}

type Store

type Store interface {
	GetUsers() ([]*User, error)
	SaveUser(user *User) error
	DeleteUser(user *User) error

	GetServers(user *User) ([]*Server, error)
	AddServer(user *User, server *Server) error
	RemoveServer(user *User, host string) error
	SetNick(user *User, nick, host string) error
	SetServerName(user *User, name, host string) error

	GetChannels(user *User) ([]*Channel, error)
	AddChannel(user *User, channel *Channel) error
	RemoveChannel(user *User, server, channel string) error
}

type User

type User struct {
	ID       uint64
	IDBytes  []byte
	Username string
	// contains filtered or unexported fields
}

func LoadUsers

func LoadUsers(store Store) ([]*User, error)

func NewUser

func NewUser(store Store) (*User, error)

func (*User) AddChannel

func (u *User) AddChannel(channel *Channel) error

func (*User) AddServer

func (u *User) AddServer(server *Server) error

func (*User) GetCertificate

func (u *User) GetCertificate() *tls.Certificate

func (*User) GetChannels

func (u *User) GetChannels() ([]*Channel, error)

func (*User) GetClientSettings

func (u *User) GetClientSettings() *ClientSettings

func (*User) GetLastIP

func (u *User) GetLastIP() []byte

func (*User) GetLastMessages

func (u *User) GetLastMessages(server, channel string, count int) ([]Message, bool, error)

func (*User) GetMessages

func (u *User) GetMessages(server, channel string, count int, fromID string) ([]Message, bool, error)

func (*User) GetServers

func (u *User) GetServers() ([]*Server, error)

func (*User) LogMessage

func (u *User) LogMessage(id, server, from, to, content string) error

func (*User) Marshal

func (d *User) Marshal(buf []byte) ([]byte, error)

func (*User) Remove

func (u *User) Remove()

func (*User) RemoveChannel

func (u *User) RemoveChannel(server, channel string) error

func (*User) RemoveServer

func (u *User) RemoveServer(address string) error

func (*User) SearchMessages

func (u *User) SearchMessages(server, channel, q string) ([]Message, error)

func (*User) SetCertificate

func (u *User) SetCertificate(certPEM, keyPEM []byte) error

func (*User) SetClientSettings

func (u *User) SetClientSettings(settings *ClientSettings) error

func (*User) SetLastIP

func (u *User) SetLastIP(ip []byte) error

func (*User) SetMessageSearchProvider

func (u *User) SetMessageSearchProvider(search MessageSearchProvider)

func (*User) SetMessageStore

func (u *User) SetMessageStore(store MessageStore)

func (*User) SetNick

func (u *User) SetNick(nick, address string) error

func (*User) SetServerName

func (u *User) SetServerName(name, address string) error

func (*User) Size

func (d *User) Size() (s uint64)

func (*User) Unmarshal

func (d *User) Unmarshal(buf []byte) (uint64, error)

func (*User) UnmarshalClientSettingsJSON

func (u *User) UnmarshalClientSettingsJSON(b []byte) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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