models

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Ban

type Ban struct {
	ID        uint           `gorm:"primaryKey" json:"id"`
	ServerID  uint           `gorm:"index;not null" json:"server_id"`
	Address   []byte         `gorm:"size:16" json:"-"` // IPv4 (4) or IPv6 (16)
	Mask      uint32         `gorm:"not null;default:32" json:"mask"`
	Name      string         `gorm:"size:255" json:"name"`
	Hash      string         `gorm:"size:40;index" json:"hash"` // SHA1 of cert in hex
	Reason    string         `gorm:"type:text" json:"reason"`
	Start     time.Time      `gorm:"not null" json:"start"`
	Duration  uint32         `gorm:"not null;default:0" json:"duration"` // 0 = permanent
	BannedBy  string         `gorm:"size:255" json:"banned_by"`
	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
}

Ban represents a server ban (IP or certificate hash).

func (Ban) TableName

func (Ban) TableName() string

TableName returns the table name.

type Channel

type Channel struct {
	ID          uint           `gorm:"primaryKey" json:"id"`
	ServerID    uint           `gorm:"index;not null" json:"server_id"`
	ParentID    *uint          `gorm:"index" json:"parent_id"`
	Parent      *Channel       `gorm:"foreignKey:ParentID" json:"-"`
	Children    []Channel      `gorm:"foreignKey:ParentID" json:"-"`
	Name        string         `gorm:"size:255;not null" json:"name"`
	Description string         `gorm:"type:text" json:"description"`
	Position    int32          `gorm:"not null;default:0" json:"position"`
	MaxUsers    uint32         `gorm:"not null;default:0" json:"max_users"`
	IsTemporary bool           `gorm:"not null;default:false" json:"is_temporary"`
	InheritACL  bool           `gorm:"not null;default:true" json:"inherit_acl"`
	Links       Uint32Slice    `gorm:"type:text" json:"links"` // JSON array of channel IDs
	CreatedAt   int64          `gorm:"autoCreateTime" json:"created_at"`
	UpdatedAt   int64          `gorm:"autoUpdateTime" json:"updated_at"`
	DeletedAt   gorm.DeletedAt `gorm:"index" json:"-"`
}

Channel represents a Mumble channel in the channel tree.

Root channel: The root (parent_id IS NULL) must have ID 0 per Mumble protocol. When creating the root, use db.Select("ID", ...).Create() so GORM includes ID 0. See docs/patterns/channel-tree-pattern.md.

func (Channel) TableName

func (Channel) TableName() string

TableName returns the table name.

type ChannelACL

type ChannelACL struct {
	ID          uint           `gorm:"primaryKey" json:"id"`
	ServerID    uint           `gorm:"index;not null" json:"server_id"`
	ChannelID   uint           `gorm:"index;not null" json:"channel_id"`
	Priority    int            `gorm:"not null;default:0" json:"priority"`
	ApplyHere   bool           `gorm:"not null;default:true" json:"apply_here"`
	ApplySubs   bool           `gorm:"not null;default:true" json:"apply_subs"`
	UserID      *int32         `json:"user_id,omitempty"`                       // nil = use group
	GroupName   string         `gorm:"size:255" json:"group_name"`              // @group, or meta: all, auth, in, out, sub
	AccessToken string         `gorm:"size:255" json:"access_token"`            // @# token groups
	EvalHere    bool           `gorm:"not null;default:false" json:"eval_here"` // ~ prefix: resolve in ACL-definition channel
	Invert      bool           `gorm:"not null;default:false" json:"invert"`    // ! prefix: invert selector
	Grant       uint32         `gorm:"not null;default:0" json:"grant"`
	Deny        uint32         `gorm:"not null;default:0" json:"deny"`
	CreatedAt   int64          `gorm:"autoCreateTime" json:"created_at"`
	UpdatedAt   int64          `gorm:"autoUpdateTime" json:"updated_at"`
	DeletedAt   gorm.DeletedAt `gorm:"index" json:"-"`
}

ChannelACL represents an ACL entry for a channel.

func (ChannelACL) TableName

func (ChannelACL) TableName() string

TableName returns the table name.

type ChannelGroup

type ChannelGroup struct {
	ID            uint           `gorm:"primaryKey" json:"id"`
	ServerID      uint           `gorm:"index;not null" json:"server_id"`
	ChannelID     uint           `gorm:"index;not null" json:"channel_id"`
	Name          string         `gorm:"size:255;not null" json:"name"`
	Inherit       bool           `gorm:"not null;default:true" json:"inherit"`
	Inheritable   bool           `gorm:"not null;default:true" json:"inheritable"`
	AddUserIDs    Uint32Slice    `gorm:"type:text" json:"add_user_ids"`
	RemoveUserIDs Uint32Slice    `gorm:"type:text" json:"remove_user_ids"`
	CreatedAt     int64          `gorm:"autoCreateTime" json:"created_at"`
	UpdatedAt     int64          `gorm:"autoUpdateTime" json:"updated_at"`
	DeletedAt     gorm.DeletedAt `gorm:"index" json:"-"`
}

ChannelGroup represents a group on a channel.

func (ChannelGroup) TableName

func (ChannelGroup) TableName() string

TableName returns the table name.

type MetaConfig

type MetaConfig struct {
	ID            uint   `gorm:"primaryKey" json:"id"`
	Host          string `gorm:"size:255;not null;default:0.0.0.0" json:"host"`
	MumblePort    int    `gorm:"not null;default:64738" json:"mumble_port"`
	RESTPort      int    `gorm:"not null;default:64730" json:"rest_port"`
	Bonjour       bool   `gorm:"not null;default:false" json:"bonjour"`
	RegisterName  string `gorm:"size:255" json:"register_name"`
	JWTIssuer     string `gorm:"size:255;not null;default:go-mumble-server" json:"-"`
	JWTAudience   string `gorm:"size:255;not null;default:go-mumble-server-api" json:"-"`
	JWTExpiryDays int    `gorm:"not null;default:30" json:"-"`
}

MetaConfig represents process-level (global) configuration. Single row (ID=1); used for bind addresses, bonjour, JWT.

func (MetaConfig) TableName

func (MetaConfig) TableName() string

TableName returns the table name.

type RegisteredUser

type RegisteredUser struct {
	ID            uint           `gorm:"primaryKey" json:"id"`
	ServerID      uint           `gorm:"index;not null" json:"server_id"`
	UserID        int32          `gorm:"not null" json:"user_id"` // Mumble user id
	Name          string         `gorm:"size:255;not null" json:"name"`
	CertHash      string         `gorm:"size:64;index" json:"-"` // SHA-256 of cert
	PasswordHash  string         `gorm:"size:255" json:"-"`      // Argon2id
	Email         string         `gorm:"size:255" json:"email"`
	LastChannelID uint32         `gorm:"default:0" json:"last_channel_id"`
	LastActive    *time.Time     `json:"last_active"`
	CreatedAt     time.Time      `json:"created_at"`
	UpdatedAt     time.Time      `json:"updated_at"`
	DeletedAt     gorm.DeletedAt `gorm:"index" json:"-"`
}

RegisteredUser represents a Mumble-registered user (cert-based identity).

func (RegisteredUser) TableName

func (RegisteredUser) TableName() string

TableName returns the table name.

type Role

type Role string

Role represents user role.

const (
	RoleAdmin Role = "admin"
	RoleUser  Role = "user"
)

type ServerConfig

type ServerConfig struct {
	ID                  uint   `gorm:"primaryKey" json:"id"`
	ServerID            uint   `gorm:"uniqueIndex;not null" json:"server_id"`
	WelcomeText         string `gorm:"type:text" json:"welcome_text"`
	MaxUsers            int    `gorm:"not null;default:100" json:"max_users"`
	MaxBandwidth        int    `gorm:"not null;default:72000" json:"max_bandwidth"`
	AllowHTML           bool   `gorm:"not null;default:true" json:"allow_html"`
	RegName             string `gorm:"size:255" json:"reg_name"`
	RegPassword         string `gorm:"size:255" json:"-"`
	RegURL              string `gorm:"type:text" json:"reg_url"`
	ChannelNestingLimit int    `gorm:"not null;default:10" json:"channel_nesting_limit"`
	ChannelCountLimit   int    `gorm:"not null;default:1000" json:"channel_count_limit"`
	DefaultChannel      int    `gorm:"not null;default:0" json:"default_channel"`
	CertRequired        bool   `gorm:"not null;default:false" json:"cert_required"`
	ServerPassword      string `gorm:"size:255" json:"-"` // hashed or plain per deployment
	VoiceDebug          bool   `gorm:"not null;default:false" json:"voice_debug"`
}

ServerConfig represents per-virtual-server configuration.

func (ServerConfig) TableName

func (ServerConfig) TableName() string

TableName returns the table name.

type Uint32Slice

type Uint32Slice []uint32

Uint32Slice for storing []uint32 in SQLite (JSON).

func (*Uint32Slice) Scan

func (s *Uint32Slice) Scan(value interface{}) error

func (Uint32Slice) Value

func (s Uint32Slice) Value() (driver.Value, error)

type User

type User struct {
	ID             uint           `gorm:"primaryKey" json:"id"`
	Username       string         `gorm:"uniqueIndex;size:255;not null" json:"username"`
	PasswordHash   string         `gorm:"size:255;not null" json:"-"`
	JWTSecret      string         `gorm:"size:64;not null" json:"-"`
	Role           Role           `gorm:"size:32;not null;default:user" json:"role"`
	TokenVersion   int            `gorm:"not null;default:0" json:"-"`
	LastActivityAt *time.Time     `json:"last_activity_at,omitempty"`
	CreatedAt      time.Time      `json:"created_at"`
	UpdatedAt      time.Time      `json:"updated_at"`
	DeletedAt      gorm.DeletedAt `gorm:"index" json:"-"`
}

User represents a management API user account.

func (User) TableName

func (User) TableName() string

TableName returns the table name.

type VirtualServer

type VirtualServer struct {
	ID          uint           `gorm:"primaryKey" json:"id"`
	Name        string         `gorm:"size:255" json:"name"`
	Host        string         `gorm:"size:255" json:"host"`
	Port        int            `gorm:"not null" json:"port"`
	MaxUsers    int            `gorm:"not null;default:100" json:"max_users"`
	WelcomeText string         `gorm:"type:text" json:"welcome_text"`
	Password    string         `gorm:"size:255" json:"-"`  // Server password (hashed or plain per config)
	CertPEM     string         `gorm:"type:text" json:"-"` // TLS certificate (PEM); not exposed via API
	KeyPEM      string         `gorm:"type:text" json:"-"` // TLS private key (PEM); not exposed via API
	CreatedAt   time.Time      `json:"created_at"`
	UpdatedAt   time.Time      `json:"updated_at"`
	DeletedAt   gorm.DeletedAt `gorm:"index" json:"-"`
}

VirtualServer represents a Mumble virtual server instance.

func (VirtualServer) TableName

func (VirtualServer) TableName() string

TableName returns the table name.

Jump to

Keyboard shortcuts

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