handler

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: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ACLEntryResp

type ACLEntryResp struct {
	ID          uint   `json:"id"`
	Priority    int    `json:"priority"`
	ApplyHere   bool   `json:"apply_here"`
	ApplySubs   bool   `json:"apply_subs"`
	UserID      *int32 `json:"user_id,omitempty"`
	GroupName   string `json:"group_name"`
	AccessToken string `json:"access_token"`
	EvalHere    bool   `json:"eval_here"`
	Invert      bool   `json:"invert"`
	Grant       uint32 `json:"grant"`
	Deny        uint32 `json:"deny"`
}

type ACLGroupResp

type ACLGroupResp struct {
	ID            uint     `json:"id"`
	Name          string   `json:"name"`
	Inherit       bool     `json:"inherit"`
	Inheritable   bool     `json:"inheritable"`
	AddUserIDs    []uint32 `json:"add_user_ids"`
	RemoveUserIDs []uint32 `json:"remove_user_ids"`
}

type ACLHandler

type ACLHandler struct {
	OnACLChange func(serverID uint) // called after PUT to invalidate cache
	// contains filtered or unexported fields
}

ACLHandler handles ACL and group REST endpoints.

func NewACLHandler

func NewACLHandler(db *gorm.DB, onACLChange func(serverID uint)) *ACLHandler

NewACLHandler creates an ACLHandler.

func (*ACLHandler) Get

func (h *ACLHandler) Get(w http.ResponseWriter, r *http.Request)

Get returns ACL and groups for a channel.

func (*ACLHandler) Put

func (h *ACLHandler) Put(w http.ResponseWriter, r *http.Request)

Put replaces ACL and groups for a channel.

type ACLResponse

type ACLResponse struct {
	Groups []ACLGroupResp `json:"groups"`
	ACLs   []ACLEntryResp `json:"acls"`
}

ACLResponse is the GET response for channel ACL.

type AuthHandler

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

AuthHandler handles auth endpoints.

func NewAuthHandler

func NewAuthHandler(user *service.UserService, db *gorm.DB, cfg *config.Config) *AuthHandler

NewAuthHandler creates an AuthHandler.

func (*AuthHandler) Login

func (h *AuthHandler) Login(w http.ResponseWriter, r *http.Request)

Login handles POST /auth/login.

func (*AuthHandler) Register

func (h *AuthHandler) Register(w http.ResponseWriter, r *http.Request)

Register handles POST /auth/register.

func (*AuthHandler) Status

func (h *AuthHandler) Status(w http.ResponseWriter, r *http.Request)

Status handles GET /auth/status. With valid Authorization: returns { user: { id, username, role } } or 401. Without auth: returns { hasUsers: bool }.

type BanHandler

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

BanHandler handles ban REST endpoints.

func NewBanHandler

func NewBanHandler(db *gorm.DB, onBanChange OnBanChange) *BanHandler

NewBanHandler creates a BanHandler. onBanChange may be nil.

func (*BanHandler) Create

func (h *BanHandler) Create(w http.ResponseWriter, r *http.Request)

Create adds a ban.

func (*BanHandler) Delete

func (h *BanHandler) Delete(w http.ResponseWriter, r *http.Request)

Delete removes a ban.

func (*BanHandler) List

func (h *BanHandler) List(w http.ResponseWriter, r *http.Request)

List returns all bans for a server.

type ChannelCryptoLister

type ChannelCryptoLister interface {
	ChannelCryptoModes(serverID uint) map[uint32]string
}

ChannelCryptoLister returns per-channel crypto mode strings for a virtual server.

type ChannelNode

type ChannelNode struct {
	ID          uint          `json:"id"`
	ServerID    uint          `json:"server_id"`
	ParentID    *uint         `json:"parent_id,omitempty"`
	Name        string        `json:"name"`
	Description string        `json:"description"`
	Position    int32         `json:"position"`
	MaxUsers    uint32        `json:"max_users"`
	IsTemporary bool          `json:"is_temporary"`
	CryptoMode  string        `json:"crypto_mode,omitempty"`
	Children    []ChannelNode `json:"children,omitempty"`
}

ChannelNode is a channel with nested children for tree display.

type ConnectedUserActioner

type ConnectedUserActioner interface {
	Kick(serverID uint, sessionID uint32, reason string) (ok bool)
	Mute(serverID uint, sessionID uint32, mute bool) (ok bool)
	BanAndKick(serverID uint, sessionID uint32, reason string) (ok bool)
}

ConnectedUserActioner performs kick, mute, ban on connected users (REST-initiated).

type ConnectedUserLister

type ConnectedUserLister interface {
	ListConnected(serverID uint, db *gorm.DB, includeSensitive bool) interface{}
}

ConnectedUserLister lists connected Mumble users; used by GetUsers.

type LoginRequest

type LoginRequest struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

LoginRequest is the request body for login.

type OnBanChange

type OnBanChange func(serverID uint)

OnBanChange is called when bans are created or deleted via REST (to reload Mumble's in-memory cache).

type OnChannelMutated

type OnChannelMutated func(serverID uint, ch interface{}, channelID uint32, removed bool)

OnChannelMutated is called when channels are created, updated, or deleted via REST. ch is the channel for create/update; for delete, ch is nil and channelID is the removed ID.

type OnConfigChange

type OnConfigChange func(serverID uint)

OnConfigChange is called when per-server config is updated via REST (e.g. voice_debug).

type RegisterRequest

type RegisterRequest struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

RegisterRequest is the request body for register.

type RegisteredUserHandler

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

RegisteredUserHandler handles Mumble registered-user REST endpoints.

func NewRegisteredUserHandler

func NewRegisteredUserHandler(db *gorm.DB) *RegisteredUserHandler

NewRegisteredUserHandler creates a RegisteredUserHandler.

func (*RegisteredUserHandler) Create

Create registers a new user.

func (*RegisteredUserHandler) Delete

Delete unregisters a user.

func (*RegisteredUserHandler) List

List returns registered users for a server.

func (*RegisteredUserHandler) Update

Update updates a registered user.

type ServerHandler

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

ServerHandler handles server and channel REST endpoints.

func NewServerHandler

func NewServerHandler(db *gorm.DB, cfg *config.Config, connectedUsers ConnectedUserLister, userActioner ConnectedUserActioner, channelCrypto ChannelCryptoLister, getChanMgr func(serverID uint) *channel.Manager, onChannelMutated OnChannelMutated, onConfigChange OnConfigChange) *ServerHandler

NewServerHandler creates a ServerHandler.

func (*ServerHandler) BanUser

func (h *ServerHandler) BanUser(w http.ResponseWriter, r *http.Request)

BanUser bans and kicks a connected user.

func (*ServerHandler) Create

func (h *ServerHandler) Create(w http.ResponseWriter, r *http.Request)

Create creates a new virtual server.

func (*ServerHandler) CreateChannel

func (h *ServerHandler) CreateChannel(w http.ResponseWriter, r *http.Request)

CreateChannel creates a channel under a parent.

func (*ServerHandler) Delete

func (h *ServerHandler) Delete(w http.ResponseWriter, r *http.Request)

Delete removes a virtual server.

func (*ServerHandler) DeleteChannel

func (h *ServerHandler) DeleteChannel(w http.ResponseWriter, r *http.Request)

DeleteChannel removes a channel.

func (*ServerHandler) Get

Get returns a single virtual server by ID.

func (*ServerHandler) GetChannels

func (h *ServerHandler) GetChannels(w http.ResponseWriter, r *http.Request)

GetChannels returns the channel tree for a server. Seeds root channel if none exist.

func (*ServerHandler) GetConfig

func (h *ServerHandler) GetConfig(w http.ResponseWriter, r *http.Request)

GetConfig returns per-server config.

func (*ServerHandler) GetMetaConfig

func (h *ServerHandler) GetMetaConfig(w http.ResponseWriter, r *http.Request)

GetMetaConfig returns global (meta) config.

func (*ServerHandler) GetUsers

func (h *ServerHandler) GetUsers(w http.ResponseWriter, r *http.Request)

GetUsers returns connected Mumble users for a server.

func (*ServerHandler) KickUser

func (h *ServerHandler) KickUser(w http.ResponseWriter, r *http.Request)

KickUser kicks a connected user.

func (*ServerHandler) List

func (h *ServerHandler) List(w http.ResponseWriter, r *http.Request)

List returns all virtual servers. Seeds a default server if none exist.

func (*ServerHandler) MuteUser

func (h *ServerHandler) MuteUser(w http.ResponseWriter, r *http.Request)

MuteUser mutes or unmutes a connected user.

func (*ServerHandler) Status

func (h *ServerHandler) Status(w http.ResponseWriter, r *http.Request)

Status returns overall server statistics.

func (*ServerHandler) Update

func (h *ServerHandler) Update(w http.ResponseWriter, r *http.Request)

Update updates a virtual server.

func (*ServerHandler) UpdateChannel

func (h *ServerHandler) UpdateChannel(w http.ResponseWriter, r *http.Request)

UpdateChannel updates a channel.

func (*ServerHandler) UpdateConfig

func (h *ServerHandler) UpdateConfig(w http.ResponseWriter, r *http.Request)

UpdateConfig updates per-server config.

func (*ServerHandler) UpdateMetaConfig

func (h *ServerHandler) UpdateMetaConfig(w http.ResponseWriter, r *http.Request)

UpdateMetaConfig updates global (meta) config.

type UserHandler

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

UserHandler handles user management endpoints (admin only).

func NewUserHandler

func NewUserHandler(user *service.UserService) *UserHandler

NewUserHandler creates a UserHandler.

func (*UserHandler) Delete

func (h *UserHandler) Delete(w http.ResponseWriter, r *http.Request)

Delete handles DELETE /users/{id}.

func (*UserHandler) List

func (h *UserHandler) List(w http.ResponseWriter, r *http.Request)

List handles GET /users.

func (*UserHandler) Update

func (h *UserHandler) Update(w http.ResponseWriter, r *http.Request)

Update handles PATCH /users/{id}.

Jump to

Keyboard shortcuts

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