db

package
v0.0.0-...-97603b3 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2024 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdminHostBan

type AdminHostBan struct {
	Id      int64  `json:"id"`
	Host    string `json:"host"`
	Expires string `json:"expires,omitempty"`
	Active  bool   `json:"active"`
	Notes   string `json:"notes,omitempty"`
}

type AdminRole

type AdminRole struct {
	Id             int64  `json:"id"`
	Name           string `json:"name"`
	Admin          bool   `json:"admin"`
	AccessSessions int    `json:"accesssessions"`
	AccessHostBans int    `json:"accesshostbans"`
	AccessRoles    int    `json:"accessroles"`
	AccessUsers    int    `json:"accessusers"`
	Used           bool   `json:"used"`
}

type AdminSession

type AdminSession struct {
	Id                 int64    `json:"id"`
	Host               string   `json:"host"`
	Port               int      `json:"port"`
	SessionId          string   `json:"sessionid"`
	Protocol           string   `json:"protocol"`
	Title              string   `json:"title"`
	Users              int      `json:"users"`
	MaxUsers           int      `json:"maxusers,omitempty"`
	Usernames          []string `json:"usernames"`
	Password           bool     `json:"password"`
	Nsfm               bool     `json:"nsfm"`
	Owner              string   `json:"owner"`
	Started            string   `json:"started"`
	LastActive         string   `json:"lastactive"`
	Unlisted           bool     `json:"unlisted"`
	UpdateKey          string   `json:"updatekey"`
	ClientIp           string   `json:"clientip"`
	Alias              string   `json:"alias,omitempty"`
	UnlistReason       string   `json:"unlistreason,omitempty"`
	Kicked             bool     `json:"kicked"`
	TimedOut           bool     `json:"timedout"`
	Closed             bool     `json:"closed"`
	Included           bool     `json:"included"`
	Error              string   `json:"error,omitempty"`
	ActiveDrawingUsers int      `json:"activedrawingusers"`
	AllowWeb           bool     `json:"allowweb,omitempty"`
}

type AdminUser

type AdminUser struct {
	Id   int64  `json:"id"`
	Name string `json:"name"`
	Role string `json:"role"`
}

type AdminUserDetail

type AdminUserDetail struct {
	Id           int64     `json:"id"`
	Name         string    `json:"name"`
	Role         AdminRole `json:"role"`
	PasswordHash string    `json:"-"`
}

type Database

type Database interface {
	SessionTimeoutMinutes() int
	QuerySessionList(opts QueryOptions, ctx context.Context) ([]SessionInfo, error)
	IsActiveSession(host, id string, port int, ctx context.Context) (bool, error)
	GetHostSessionCount(host string, ctx context.Context) (int, error)
	IsBannedHost(host string, ctx context.Context) (bool, error)
	InsertSession(session SessionInfo, clientIp string, ctx context.Context) (NewSessionInfo, error)
	RefreshSession(refreshFields map[string]interface{}, listingId int64, updateKey string, ctx context.Context) error
	DeleteSession(listingId int64, updateKey string, ctx context.Context) (bool, error)
	AdminUpdateSessions(ids []int64, unlisted bool, unlistReason string, ctx context.Context) ([]int64, error)
	AdminQuerySessions(ctx context.Context) ([]AdminSession, error)
	AdminCreateHostBan(host string, expires string, notes string, ctx context.Context) (int64, error)
	AdminUpdateHostBan(id int64, host string, expires string, notes string, ctx context.Context) (bool, error)
	AdminDeleteHostBan(id int64, ctx context.Context) (bool, error)
	AdminQueryHostBans(ctx context.Context) ([]AdminHostBan, error)
	AdminCreateRole(name string, admin bool, accessSessions int64, accessHostbans int64,
		accessRoles int64, accessUsers int64, ctx context.Context) (int64, error)
	AdminUpdateRole(id int64, name string, admin bool, accessSessions int64, accessHostbans int64,
		accessRoles int64, accessUsers int64, ctx context.Context) (bool, error)
	AdminDeleteRole(id int64, ctx context.Context) (bool, error)
	AdminQueryRoles(ctx context.Context) ([]AdminRole, error)
	AdminQueryRoleByName(name string, ctx context.Context) (AdminRole, error)
	AdminCreateUser(name string, passwordHash string, role int64, ctx context.Context) (int64, error)
	AdminUpdateUser(id int64, name string, paswordHash string, role int64, ctx context.Context) (bool, error)
	AdminUpdateUserPassword(id int64, passwordHash string, ctx context.Context) (bool, error)
	AdminDeleteUser(id int64, ctx context.Context) (bool, error)
	AdminQueryUserByName(name string, ctx context.Context) (AdminUserDetail, error)
	AdminQueryUsers(ctx context.Context) ([]AdminUser, error)
	Close() error
}

func InitDatabase

func InitDatabase(dbname string, sessionTimeout int) Database

type JoinSessionInfo

type JoinSessionInfo struct {
	Host string `json:"host"`
	Port int    `json:"port"`
	Id   string `json:"id"`
}

Minimum info needed to join a session

type NewSessionInfo

type NewSessionInfo struct {
	ListingId int64  `json:"id"`
	UpdateKey string `json:"key"`
}

Info about a newly inserted session

type QueryOptions

type QueryOptions struct {
	Title    string // filter by title
	Nsfm     bool   // show NSFM sessions
	Protocol string // filter by protocol version (comma separated list accepted)
}

Session list querying options

type RefreshError

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

func (RefreshError) Error

func (e RefreshError) Error() string

type SessionInfo

type SessionInfo struct {
	Host               string   `json:"host"`
	Port               int      `json:"port"`
	Id                 string   `json:"id"`
	Protocol           string   `json:"protocol"`
	Title              string   `json:"title"`
	Users              int      `json:"users"`
	MaxUsers           int      `json:"maxusers,omitempty"`
	Usernames          []string `json:"usernames"`
	Password           bool     `json:"password"`
	Nsfm               bool     `json:"nsfm"`
	Owner              string   `json:"owner"`
	Started            string   `json:"started"`
	Private            bool     `json:"private,omitempty"`
	Closed             bool     `json:"closed,omitempty"`
	ActiveDrawingUsers int      `json:"activedrawingusers"`
	AllowWeb           bool     `json:"allowweb,omitempty"`
}

The SessionInfo struct represents a session announcement fetched from the database It is also used to insert new entries. When inserting, the "Started" field is ignored and the current timestamp is used

func (SessionInfo) HostAddress

func (info SessionInfo) HostAddress() string

func (*SessionInfo) UnmarshalJSON

func (info *SessionInfo) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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