database

package
v0.0.0-...-c683906 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2018 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package database handles all communication between software and the database

Index

Constants

View Source
const (
	DB_MAIN     = "datastore.db"
	DB_SETTINGS = "settings.db"
	DB_DOMAINS  = "domains.db"
)

Database constants

View Source
const (
	// DB_MAIN BUCKETS
	BUCKET_USERS        = "users"
	BUCKET_PORTS        = "ports"
	BUCKET_FILTERED_IPS = "filtered_ips"
	BUCKET_SUBDOMAINS   = "subdomains"

	// DB_SETTINGS BUCKETS
	BUCKET_GENERAL     = "general"
	BUCKET_NAMESERVERS = "nameservers"

	// DB_DOMAINS BUCKETS
	BUCKET_DOMAINS = "domains"
)

Bucket constants

Variables

View Source
var (
	ErrKeyNotExist = errors.New("key does not exist")
)

Error codes

Functions

func IDtoKey

func IDtoKey(id int) []byte

Types

type Datastore

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

func Open

func Open(filepath string) (*Datastore, error)

Open function will open the database and return a Datastore struct that has a handle within it for various datastore functions.

func (*Datastore) CheckAdminSettings

func (ds *Datastore) CheckAdminSettings() (rerr error)

Function CheckAdminSettings makes sure that the admin settings are set and are valid.

func (*Datastore) Close

func (ds *Datastore) Close() error

Close is a function attached to the Datastore struct that will close the current bolt instance

func (*Datastore) Count

func (ds *Datastore) Count(bucket string) (int, error)

func (*Datastore) Delete

func (ds *Datastore) Delete(bucket string, key []byte) error

Delete is a function attached to the Datastore struct that will delete data from the current bolt instance

func (*Datastore) Get

func (ds *Datastore) Get(bucket string, key []byte, result interface{}) error

Get is a function attached to the Datastore struct that will get data from the current bolt instance

func (*Datastore) GetFilteredIPs

func (ds *Datastore) GetFilteredIPs(iptype string) (map[int]Struct_Filtered_IP, error)

func (*Datastore) IsFiltered

func (ds *Datastore) IsFiltered(ip string, iptype string) (bool, error)

func (*Datastore) ListAllUsers

func (ds *Datastore) ListAllUsers() ([]string, error)

func (*Datastore) ListDomains

func (ds *Datastore) ListDomains(bundle string) (map[string]Struct_Domain, error)

func (*Datastore) ListNameservers

func (ds *Datastore) ListNameservers() ([]string, error)

func (*Datastore) ListSubdomains

func (ds *Datastore) ListSubdomains() (map[string]StructSubdomain, error)

func (*Datastore) NewFilteredIP

func (ds *Datastore) NewFilteredIP(newip *Struct_Filtered_IP) error

func (*Datastore) Put

func (ds *Datastore) Put(bucket string, key []byte, value interface{}) error

Put is a function attached to the Datastore struct that will put data into the current bolt instance

func (*Datastore) RemoveInstances

func (ds *Datastore) RemoveInstances(bundle string) error

type StructSubdomain

type StructSubdomain struct {
	Root string `json:"root"`
}

type Struct_Admin

type Struct_Admin struct {
	Name  string `json:"name"`
	Email string `json:"email"`
}

type Struct_Domain

type Struct_Domain struct {
	BundleName string `json:"name"`
	PublicPort int    `json:"port"`
}

type Struct_Filtered_IP

type Struct_Filtered_IP struct {
	ID   int    `json:"id"`
	Type string `json:"type"`
	IP   string `json:"ip"`
}

type Struct_Nameserver

type Struct_Nameserver struct {
	Nameserver string `json:"nameserver"`
}

type Struct_SMTP

type Struct_SMTP struct {
	Type     string `json:"type"`
	Username string `json:"username"`
	Password string `json:"password"`
	Server   string `json:"server"`
	Port     int    `json:"port"`
}

type Struct_Users

type Struct_Users struct {
	Pass   string `json:"pass"`
	Secret string `json:"secret"`
}

Jump to

Keyboard shortcuts

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