db

package
v0.0.0-...-2e21d9c Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Database

authorities - store certificate authorities, private key, hostname regex group - store group, principal regex, principal validity user - store user special attributes, such as non-ldap user, groups certificates - store signed certificates, key by username/serial

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database interface {
	// migrate database schema
	Migrate() error

	// close opened database
	Close() error

	ListUsers() ([]*User, error)
	GetUser(string) (*User, error)
	PutUser(string, func(*User) error) (*User, error)
}

func Open

func Open(host string, port uint16, user, password, dbname string) (Database, error)

type Location

type Location struct {
	Latitude  float64 `json:"latitude,omitempty"`
	Longitude float64 `json:"longitude,omitempty"`
	TimeZone  string  `json:"timezone,omitempty"`
	Country   string  `json:"country,omitempty"`
	City      string  `json:"city,omitempty"`
}

shared location info

func (*Location) Scan

func (self *Location) Scan(value interface{}) error

func (Location) Value

func (self Location) Value() (driver.Value, error)

type Migration

type Migration struct {
	ID string `gorm:"primary_key:true"`

	Migrated time.Time
}

database model for migration records

func (*Migration) TableName

func (self *Migration) TableName() string

type Status

type Status json.RawMessage

func (Status) MarshalJSON

func (self Status) MarshalJSON() ([]byte, error)

func (*Status) Scan

func (self *Status) Scan(value interface{}) error

func (Status) Value

func (self Status) Value() (driver.Value, error)

type User

type User struct {
	ID string `json:"id,omitempty" gorm:"primary_key:true"`

	// meta data
	CreatedAt  time.Time `json:"createdAt,omitempty"`
	ModifiedAt time.Time `json:"modifiedAt,omitempty"`

	// comments about this user
	Comment string `json:"comment,omitempty"`

	// ip address
	IP string `json:"ip,omitempty"`

	// geo location
	Location Location `json:"location,omitempty" gorm:"type:jsonb"`

	// reported status
	Status Status `json:"status,omitempty"`

	// whether the user is an administrator
	Administrator bool `json:"administrator,omitempty"`

	// screenshot
	Screenshot []byte `json:"-" gorm:"type:bytea"`

	// whether the user account has been disabled
	Disabled bool `json:"disabled,omitempty"`

	// whether the user is online, not saved in database
	Online bool `json:"online,omitempty" gorm:"-"`

	// current connections, not saved in database
	Connections interface{} `json:"connections,omitempty" gorm:"-"`
}

represents a user connected to gateway

func (*User) TableName

func (self *User) TableName() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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