db

package
v0.0.0-...-5efa5bd Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2017 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LocalAuthType represents the local auth
	LocalAuthType = "local"
	// AdminUser is the default admin user
	AdminUser = "admin"
)
View Source
const DefaultGroup = "default"

DefaultGroup is the default group

Variables

View Source
var (
	// ErrNotFound key not found error
	ErrNotFound = errors.New("db: key not found")
	// ErrExists key exists error
	ErrExists = errors.New("db: key already exists")
)

Functions

This section is empty.

Types

type BoltStore

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

BoltStore database store

var DB *BoltStore

DB is the globally shared database object

func NewBoltStore

func NewBoltStore(file string) (*BoltStore, error)

NewBoltStore returns a new BoltStore of the given file

func (*BoltStore) AddAudit

func (bs *BoltStore) AddAudit(host, user, action string) error

AddAudit adds a new autid entry in the database

func (*BoltStore) Admin

func (bs *BoltStore) Admin(user string) (admin bool)

Admin checks if the given user has admin privileges

func (*BoltStore) Audit

func (bs *BoltStore) Audit(date string) (a []core.Audit, err error)

Audit returns the audit entrys of the given date

func (*BoltStore) Client

func (bs *BoltStore) Client(host string) (c core.Client, err error)

Client returns the given client

func (*BoltStore) ClientConns

func (bs *BoltStore) ClientConns() (all int, conn int)

ClientConns returns the number of all clients and all connected clients

func (*BoltStore) ClientExists

func (bs *BoltStore) ClientExists(host string) (exists bool)

ClientExists checks if the given client already exists

func (*BoltStore) ClientGroups

func (bs *BoltStore) ClientGroups(host string) (gr []core.Group, err error)

ClientGroups returns all groups of the given client

func (*BoltStore) Clients

func (bs *BoltStore) Clients() (cl []core.Client, err error)

Clients returns all clients

func (*BoltStore) Close

func (bs *BoltStore) Close() error

Close closes the BoltStore

func (*BoltStore) CreateClient

func (bs *BoltStore) CreateClient(c *core.Client) (err error)

CreateClient creates a new client

func (*BoltStore) CreateGroup

func (bs *BoltStore) CreateGroup(g *core.Group) error

CreateGroup creates a new group

func (*BoltStore) CreateUser

func (bs *BoltStore) CreateUser(u *core.User) error

CreateUser creates a new user

func (*BoltStore) DeleteClient

func (bs *BoltStore) DeleteClient(host string) (err error)

DeleteClient deletes the given client

func (*BoltStore) DeleteGroup

func (bs *BoltStore) DeleteGroup(name string) error

DeleteGroup deletes the given group

func (*BoltStore) DeleteUser

func (bs *BoltStore) DeleteUser(user string) (err error)

DeleteUser deletes the given user and removes it from all associated groups

func (*BoltStore) Group

func (bs *BoltStore) Group(name string) (g core.Group, err error)

Group returns the given group

func (*BoltStore) GroupClients

func (bs *BoltStore) GroupClients(name string) (cl []core.Client, err error)

GroupClients returns all clients of the given group

func (*BoltStore) GroupExists

func (bs *BoltStore) GroupExists(name string) (exists bool)

GroupExists checks if the given group already exists

func (*BoltStore) GroupMember

func (bs *BoltStore) GroupMember(name, user string) (member bool)

GroupMember checks if the given user is a member of the given group

func (*BoltStore) GroupMemberClients

func (bs *BoltStore) GroupMemberClients(name string) (cm map[string]bool, err error)

GroupMemberClients returns all clients and if they are a member of the given group

func (*BoltStore) GroupMemberUsers

func (bs *BoltStore) GroupMemberUsers(name string) (um map[string]bool, err error)

GroupMemberUsers returns all users and if they are a member of the given group

func (*BoltStore) Groups

func (bs *BoltStore) Groups() (gr []core.Group, err error)

Groups returns all groups

func (*BoltStore) Init

func (bs *BoltStore) Init() error

Init dummy function for implementing the api/auth interface

func (*BoltStore) Login

func (bs *BoltStore) Login(user, password string) error

Login checks the given credentials

func (*BoltStore) NoPWUser

func (bs *BoltStore) NoPWUser(user string) (u core.User, err error)

NoPWUser returns the given user without the password hash

func (*BoltStore) ResetClients

func (bs *BoltStore) ResetClients() error

ResetClients resets some basic client stats

func (*BoltStore) ReverseAudit

func (bs *BoltStore) ReverseAudit(date string) (a []core.Audit, err error)

ReverseAudit returns the audit entrys of the given date in reverse order

func (*BoltStore) SetComment

func (bs *BoltStore) SetComment(host, comment string) error

SetComment changes the comment for the given client

func (*BoltStore) Stats

func (bs *BoltStore) Stats() bolt.Stats

Stats returns bolt.Stats

func (*BoltStore) Type

func (bs *BoltStore) Type() string

Type for implementing the api/auth interface

func (*BoltStore) Unlock

func (bs *BoltStore) Unlock(user string) error

Unlock unlocks the given user

func (*BoltStore) UpdateClient

func (bs *BoltStore) UpdateClient(c *core.Client, setinfo, conn bool) error

UpdateClient updates client information

func (*BoltStore) UpdateClientPackages

func (bs *BoltStore) UpdateClientPackages(host string, pa []core.Package) error

UpdateClientPackages updates the given clients package list

func (*BoltStore) UpdateGroup

func (bs *BoltStore) UpdateGroup(g *core.Group) error

UpdateGroup updates group information

func (*BoltStore) UpdateLastLogin

func (bs *BoltStore) UpdateLastLogin(user string) error

UpdateLastLogin updates the users LastLogin field

func (*BoltStore) UpdatePassword

func (bs *BoltStore) UpdatePassword(u *core.User) error

UpdatePassword updates the users password hash

func (*BoltStore) UpdateUser

func (bs *BoltStore) UpdateUser(u *core.User) error

UpdateUser updates the given user information

func (*BoltStore) User

func (bs *BoltStore) User(user string) (u core.User, err error)

User returns the given user

func (*BoltStore) UserClient

func (bs *BoltStore) UserClient(user, host string) (bool, error)

UserClient checks if the given client is associated with the given user

func (*BoltStore) UserClients

func (bs *BoltStore) UserClients(user string) (uc map[string]bool, err error)

UserClients returns all clients associated with the given user

func (*BoltStore) UserExists

func (bs *BoltStore) UserExists(user string) (exists bool)

UserExists checks if the given user exists

func (*BoltStore) UserGroups

func (bs *BoltStore) UserGroups(user string) (gr []core.Group, err error)

UserGroups returns all groups of the given user

func (*BoltStore) Users

func (bs *BoltStore) Users() (us []core.User, err error)

Users returns all users without their passowrd hashes

Jump to

Keyboard shortcuts

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