bncDataStoreBuntdb

package
v0.0.0-...-3d3f267 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2018 License: MIT Imports: 12 Imported by: 1

Documentation

Index

Constants

View Source
const (

	// key for the primary salt used by the ircd
	KeySalt = "crypto.salt"

	// KeyUserInfo stores the general info of a specific user in our database
	KeyUserInfo = "user.info %s"
	// KeyUserPermissions stores the permissions that the given user has access to
	KeyUserPermissions = "user.permissions %s"

	KeyServerConnectionInfo      = "user.server.info %s %s"
	KeyServerConnectionAddresses = "user.server.addresses %s %s"
	KeyServerConnectionBuffers   = "user.server.channels %s %s"
)

Variables

This section is empty.

Functions

func CompareHashAndPassword

func CompareHashAndPassword(hashedPassword []byte, bncSalt []byte, specialSalt []byte, password string) bool

CompareHashAndPassword compares an ircbnc hashed password with its possible plaintext equivalent. Returns nil on success, or an error on failure.

func GenerateFromPassword

func GenerateFromPassword(bncSalt []byte, specialSalt []byte, password string) ([]byte, error)

GenerateFromPassword takes our salts and encrypts the given password.

func InitDB

func InitDB(path string)

InitDB creates the database.

func NewSalt

func NewSalt() []byte

NewSalt returns a salt for crypto uses.

func UpgradeDB

func UpgradeDB(path string)

UpgradeDB upgrades the datastore to the latest schema.

Types

type DataStore

type DataStore struct {
	ircbnc.DataStoreInterface
	Db      *buntdb.DB
	Manager *ircbnc.Manager
	// contains filtered or unexported fields
}

func (*DataStore) AuthUser

func (ds *DataStore) AuthUser(username string, password string) (string, bool)

func (*DataStore) DelConnection

func (ds *DataStore) DelConnection(connection *ircbnc.ServerConnection) error

func (*DataStore) GetAllUsers

func (ds *DataStore) GetAllUsers() []*ircbnc.User

func (*DataStore) GetUserById

func (ds *DataStore) GetUserById(id string) *ircbnc.User

func (*DataStore) GetUserByUsername

func (ds *DataStore) GetUserByUsername(username string) *ircbnc.User

func (*DataStore) GetUserNetworks

func (ds *DataStore) GetUserNetworks(userId string)

func (*DataStore) Init

func (ds *DataStore) Init(manager *ircbnc.Manager) error

func (*DataStore) LoadSalt

func (ds *DataStore) LoadSalt() error

func (*DataStore) SaveConnection

func (ds *DataStore) SaveConnection(connection *ircbnc.ServerConnection) error

func (*DataStore) SaveUser

func (ds *DataStore) SaveUser(user *ircbnc.User) error

func (*DataStore) SetUserPassword

func (ds *DataStore) SetUserPassword(user *ircbnc.User, newPassword string)

func (*DataStore) Setup

func (ds *DataStore) Setup() error

type ServerConnectionAddressMapping

type ServerConnectionAddressMapping struct {
	Host      string
	Port      int
	UseTLS    bool `json:"use-tls"`
	VerifyTLS bool `json:"verify-tls"`
}

ServerConnectionAddressMapping maps ServerConnectionAddress to its JSON structure

type ServerConnectionBufferMapping

type ServerConnectionBufferMapping struct {
	Channel  bool
	Name     string
	Key      string
	UseKey   bool  `json:"use_key"`
	LastSeen int64 `json:"last_seen"`
}

ServerConnectionBufferMapping maps ServerConnectionBuffer to its JSON structure

type ServerConnectionMapping

type ServerConnectionMapping struct {
	Name             string
	Enabled          bool
	ConnectPassword  string `json:"connect-password"`
	Nickname         string
	NicknameFallback string
	Username         string
	Realname         string
}

ServerConnectionMapping maps ServerConnection to its JSON structure

type UserInfo

type UserInfo struct {
	ID                  string
	Name                string `json:"username"`
	Role                string
	EncodedSalt         string `json:"salt"`
	EncodedPasswordHash string `json:"hash"`
	DefaultNick         string `json:"default-nick"`
	DefaultNickFallback string `json:"default-nick-fallback"`
	DefaultUsername     string `json:"default-username"`
	DefaultRealname     string `json:"default-realname"`
}

UserInfo stores information about the user in our database

type UserPermissions

type UserPermissions []string

UserPermissions is a list of permissions the user has access to

Jump to

Keyboard shortcuts

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