Documentation
¶
Overview ¶
Database
user - store user special attributes, such as non-ldap user, groups node - store gateway nodes participating in the mesh
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(context.Context) error
// close opened database
Close() error
ListUsers(context.Context) ([]*User, error)
ListOnlineUsers(context.Context, time.Time) ([]*User, error)
GetUsers(context.Context, []string) ([]*User, error)
MarkUsersOnline(context.Context, []string, string, time.Duration) error
ClearUserNodeID(context.Context, string, string) error
GetUser(context.Context, string) (*User, error)
GetUserNodeID(context.Context, string) (string, error)
GetUserScreenshot(context.Context, string) ([]byte, error)
UpsertUserOnConnect(context.Context, string, string, Location, string) (*User, error)
UpdateUserStatus(context.Context, string, Status) error
UpdateUserScreenshot(context.Context, string, []byte) error
PutUser(context.Context, string, func(*User) error) (*User, error)
ListNodes(context.Context) ([]*Node, error)
GetNode(context.Context, string) (*Node, error)
PutNode(context.Context, string, func(*Node) error) (*Node, 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
type Node ¶ added in v0.5.0
type Node struct {
ID string `json:"id,omitempty" gorm:"primary_key:true"`
// meta data
CreatedAt time.Time `json:"createdAt,omitempty"`
ModifiedAt time.Time `json:"modifiedAt,omitempty"`
// address where peer nodes can reach this node
Address string `json:"address,omitempty"`
// host public key of this node in authorized key format, pinned by
// dialing peers to verify the remote host
HostPublicKey string `json:"hostPublicKey,omitempty"`
// whether the node is online; cleared on clean shutdown, but a crashed
// node leaves it set, so liveness also requires a fresh OnlineAt
Online bool `json:"online,omitempty"`
// the last online heartbeat, refreshed while the node is running, so a
// stale value marks a node that went away without marking itself offline
OnlineAt time.Time `json:"onlineAt,omitempty"`
}
represents a gateway node participating in the mesh
type Settings ¶ added in v0.5.0
type Settings struct {
// postgres connection settings
Host string
Port uint16
User string
Password string
DatabaseName string
SSLMode string
// optional peer tunnel settings, for reaching a remote postgres through
// a peer node's ssh service port instead of connecting directly
PeerAddress string // peer ssh address, empty = direct connection
PeerSigner ssh.Signer // node certificate signer, required if PeerAddress is set
PeerHostPublicKey ssh.PublicKey // pinned host public key of the peer, required if PeerAddress is set
}
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"`
// the node the user last connected to, used for mesh tunneling
NodeID string `json:"nodeId,omitempty"`
// the last time the user was seen connected on any node; refreshed on a
// heartbeat while connected, so a fresh value means online mesh-wide
OnlineAt time.Time `json:"onlineAt,omitempty"`
// whether the user is online, derived from OnlineAt, 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
Directories
¶
| Path | Synopsis |
|---|---|
|
Package dbtest provides helpers for database integration tests.
|
Package dbtest provides helpers for database integration tests. |
Click to show internal directories.
Click to hide internal directories.