database

package
v0.0.0-...-f67effe Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2019 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorNoBucket         = errors.New("Bucket not found of that name")
	ErrorValueNotFound    = errors.New("Cannot value with that key")
	ErrorNotExistToupdate = errors.New("key doesnot exist to update the value")
	ErrorAlreadyExist     = errors.New("key already exist to update the value")
)
View Source
var (
	AgentBucketName = []byte("agents")
)
View Source
var DB = &Boltdb{}
View Source
var ScriptBucketName = []byte("scripts")
View Source
var (
	UserBucketName = []byte("users")
)
View Source
var WebsiteBucketName = []byte("websites")

Functions

func AddapiKey

func AddapiKey(id, keytype string) error

func Close

func Close()

func CreateAgent

func CreateAgent(owner string) (string, error)

func CreateScript

func CreateScript(script *Script) error

func CreateUser

func CreateUser(user *User) error

func CreateWebsite

func CreateWebsite(website *Website) error

func Decode

func Decode(raw []byte, out interface{}) error

Decode opposite of encode

func DeleteAgent

func DeleteAgent(id, owner string) error

func DeleteScript

func DeleteScript(name string) error

func DeleteUser

func DeleteUser(id string) error

func DeleteWebsite

func DeleteWebsite(name string) error

func Encode

func Encode(v interface{}) ([]byte, error)

Encode is unified way to serilize data, this way it might be easier to change encoding(json to gob/msgpack or protobuf?) without having to huntdown and change all serilization code

func GetSysteminfo

func GetSysteminfo(id string) (map[string]string, error)

func GetapiKeys

func GetapiKeys(id string) ([]string, error)

func RemoveapiKey

func RemoveapiKey(id, key string) error

func Start

func Start()

func UpdateAgent

func UpdateAgent(agent *Agent) error

func UpdateScript

func UpdateScript(script *Script) error

func UpdateSystemInfo

func UpdateSystemInfo(id string, systeminfo map[string]string) error

func UpdateUser

func UpdateUser(userinfo map[string]string) error

func UpdateWebsite

func UpdateWebsite(website *Website) error

Types

type Agent

type Agent struct {
	ID           string            `json:"id"`
	Owner        string            `json:"owner"`
	LastLogin    time.Time         `json:"lastlogin,omitempty"`
	FirstAdded   time.Time         `json:"firstadded,omitempty"`
	SystemInfo   map[string]string `json:"systeminfo,omitempty"`
	Active       bool              `json:"active,omitempty"`
	ActiveConnid wire.UID          `json:"connid,omitempty`
}

func GetAgent

func GetAgent(id string) (*Agent, error)

func GetAllAgents

func GetAllAgents() ([]*Agent, error)

func GetAllUserAgents

func GetAllUserAgents(id string) ([]*Agent, error)

func NewAgent

func NewAgent(owner string) *Agent

type Boltdb

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

func (*Boltdb) Close

func (b *Boltdb) Close()

func (*Boltdb) Create

func (b *Boltdb) Create(key, value, bucket []byte) error

func (*Boltdb) Delete

func (b *Boltdb) Delete(key, bucket []byte) error

func (*Boltdb) Open

func (b *Boltdb) Open(path string) error

func (*Boltdb) Read

func (b *Boltdb) Read(key, bucket []byte) ([]byte, error)

func (*Boltdb) ReadAll

func (b *Boltdb) ReadAll(bucket []byte) ([][]byte, error)

func (*Boltdb) Update

func (b *Boltdb) Update(key, value, bucket []byte) error

type Script

type Script struct {
	Name     string `json:"name"`
	Code     string `json:"code"`
	Platform string `json:"platform"`
	Type     string `json:"type"`
	Agent    string `json:"agent"`
	User     string `json:"user"`
}

func GetAllScripts

func GetAllScripts() ([]*Script, error)

func GetScript

func GetScript(name string) (*Script, error)

func NewScript

func NewScript(user string, scriptInfo map[string]string, active bool) (*Script, error)

type User

type User struct {
	ID        string   `json:"id"`
	Password  string   `json:"password,omitempty"`
	FullName  string   `json:"fullname,omitempty"`
	Email     string   `json:"email,omitempty"`
	SuperUser bool     `json:"superuser,omitempty"`
	APIKeys   []string `json:"apikey"`
	Agents    []string `json:"agents"`
	Websites  []string `json:"websites"`
}

func GetAllUsers

func GetAllUsers() ([]*User, error)

func GetUser

func GetUser(id string) (*User, error)

func NewUser

func NewUser(userInfo map[string]string, superuser bool) (*User, error)

type Website

type Website struct {
	Url        string `json:"url"`
	Name       string `json:"name"`
	Active     bool   `json:"active"`
	Timestamp  int64  `json:timestamp`
	Subscriber string `json:subscribers`
}

func GetAllWebsites

func GetAllWebsites() ([]*Website, error)

func GetWebsite

func GetWebsite(name string) (*Website, error)

func NewWebsite

func NewWebsite(websiteInfo map[string]string, active bool) (*Website, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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