server

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2023 License: BSD-3-Clause Imports: 49 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ChannelInfoDescription int = iota
	ChannelInfoPosition
)
View Source
const (
	UserInfoName int = iota
	UserInfoEmail
	UserInfoComment
	UserInfoHash
	UserInfoPassword
	UserInfoLastActive
)
View Source
const (
	StateClientConnected = iota
	StateServerSentVersion
	StateClientSentVersion
	StateClientAuthenticated
	StateClientReady
	StateClientDead
)
View Source
const CeltCompatBitstream = -2147483637
View Source
const DefaultPort = 64738

The default port a Murmur server listens on

View Source
const DefaultWebPort = 443
View Source
const LogOpsBeforeSync = 100
View Source
const SQLiteSupport = true
View Source
const UDPPacketSize = 1024

Variables

View Source
var Args args

Functions

func FreezeACL

func FreezeACL(aclEntry acl.ACL) (*freezer.ACL, error)

Freeze a ChannelACL into it a flattened protobuf-based structure ready to be persisted to disk.

func FreezeBan

func FreezeBan(ban ban.Ban) (fb *freezer.Ban)

Freeze a ban into a flattened protobuf-based struct ready to be persisted to disk.

func FreezeGroup

func FreezeGroup(group acl.Group) (*freezer.Group, error)

Freeze a Group into a flattened protobuf-based structure ready to be persisted to disk.

func GenerateSelfSignedCert

func GenerateSelfSignedCert(certpath, keypath string) (err error)

Generate a 4096-bit RSA keypair and a Grumble auto-generated X509 certificate. Output PEM-encoded DER representations of the resulting certificate and private key to certpath and keypath.

func MurmurImport

func MurmurImport(filename string) (err error)

Import the structure of an existing Murmur SQLite database.

func SetBlobStore

func SetBlobStore(b blobstore.BlobStore)

func SetServers

func SetServers(s map[int64]*Server)

func SignalHandler

func SignalHandler()

func Usage

func Usage()

Types

type Channel

type Channel struct {
	Id       int
	Name     string
	Position int

	// ACL
	ACL acl.Context

	// Links
	Links map[int]*Channel

	// Blobs
	DescriptionBlob string
	// contains filtered or unexported fields
}

A Mumble channel

func NewChannel

func NewChannel(id int, name string) (channel *Channel)

func (*Channel) AddChild

func (channel *Channel) AddChild(child *Channel)

AddChild adds a child channel to a channel

func (*Channel) AddClient

func (channel *Channel) AddClient(client *Client)

AddClient adds client

func (channel *Channel) AllLinks() (seen map[int]*Channel)

AllLinks returns a slice of all channels in this channel's link chain.

func (*Channel) AllSubChannels

func (channel *Channel) AllSubChannels() (seen map[int]*Channel)

AllSubChannels returns a slice of all of this channel's subchannels.

func (*Channel) DescriptionBlobHashBytes

func (channel *Channel) DescriptionBlobHashBytes() (buf []byte)

DescriptionBlobHashBytes gets the channel's blob hash as a byte slice for sending via a protobuf message. Returns nil if there is no blob.

func (*Channel) Freeze

func (channel *Channel) Freeze() (fc *freezer.Channel, err error)

Freeze a channel into a flattened protobuf-based struct ready to be persisted to disk.

func (*Channel) HasDescription

func (channel *Channel) HasDescription() bool

HasDescription Does the channel have a description?

func (*Channel) IsEmpty

func (channel *Channel) IsEmpty() bool

IsEmpty checks whether the channel is temporary

func (*Channel) IsTemporary

func (channel *Channel) IsTemporary() bool

IsTemporary checks whether the channel is temporary

func (*Channel) RemoveChild

func (channel *Channel) RemoveChild(child *Channel)

RemoveChild removes a child channel from a parent

func (*Channel) RemoveClient

func (channel *Channel) RemoveClient(client *Client)

RemoveClient removes client

func (*Channel) Unfreeze

func (c *Channel) Unfreeze(fc *freezer.Channel)

Unfreeze unfreezes the contents of a freezer.Channel into a channel.

type Client

type Client struct {
	// Logging
	*log.Logger

	// Ping stats
	UdpPingAvg float32
	UdpPingVar float32
	UdpPackets uint32
	TcpPingAvg float32
	TcpPingVar float32
	TcpPackets uint32

	// Version
	Version    uint32
	ClientName string
	OSName     string
	OSVersion  string
	CryptoMode string

	// Personal
	Username string

	Email string

	Channel         *Channel
	SelfMute        bool
	SelfDeaf        bool
	Mute            bool
	Deaf            bool
	Suppress        bool
	PrioritySpeaker bool
	Recording       bool
	PluginContext   []byte
	PluginIdentity  string
	// contains filtered or unexported fields
}

A client connection

func (*Client) ACLContext

func (client *Client) ACLContext() *acl.Context

func (*Client) CertHash

func (client *Client) CertHash() string

func (*Client) ClearCaches

func (client *Client) ClearCaches()

ClearCaches clears the client's caches

func (*Client) Debugf

func (client *Client) Debugf(format string, v ...interface{})

Debugf implements debug-level printing for Clients.

func (*Client) Disconnect

func (client *Client) Disconnect()

Disconnect a client (client requested or server shutdown)

func (*Client) ForceDisconnect

func (client *Client) ForceDisconnect()

Disconnect a client (kick/ban)

func (*Client) HasCertificate

func (client *Client) HasCertificate() bool

HasCertificate Does the client have a certificate?

func (*Client) IsRegistered

func (client *Client) IsRegistered() bool

IsRegistered Is the client a registered user?

func (*Client) IsSuperUser

func (client *Client) IsSuperUser() bool

IsSuperUser Is the client the SuperUser?

func (*Client) IsVerified

func (client *Client) IsVerified() bool

IsVerified checks whether the client's certificate is verified.

func (*Client) Panic

func (client *Client) Panic(v ...interface{})

Log a panic and disconnect the client.

func (*Client) Panicf

func (client *Client) Panicf(format string, v ...interface{})

Log a formatted panic and disconnect the client.

func (*Client) RejectAuth

func (client *Client) RejectAuth(rejectType mumbleproto.Reject_RejectType, reason string)

Reject an authentication attempt

func (*Client) SendUDP

func (client *Client) SendUDP(buf []byte) error

Send buf as a UDP message. If the client does not have an established UDP connection, the datagram will be tunelled through the client's control channel (TCP).

func (*Client) Session

func (client *Client) Session() uint32

func (*Client) ShownName

func (client *Client) ShownName(suName string) string

ShownName gets the client's shown name.

func (*Client) Tokens

func (client *Client) Tokens() []string

func (*Client) UserId

func (client *Client) UserId() int

UserId gets the User ID of this client. Returns -1 if the client is not a registered user.

type ClientPredicate

type ClientPredicate func(client *Client) bool

type KeyValuePair

type KeyValuePair struct {
	Key   string
	Value string
	Reset bool
}

type Message

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

type Register

type Register struct {
	XMLName  xml.Name `xml:"server"`
	Version  string   `xml:"version"`
	Release  string   `xml:"release"`
	Name     string   `xml:"name"`
	Host     string   `xml:"host"`
	Password string   `xml:"password"`
	Port     int      `xml:"port"`
	Url      string   `xml:"url"`
	Digest   string   `xml:"digest"`
	Users    int      `xml:"users"`
	Channels int      `xml:"channels"`
	Location string   `xml:"location"`
}

type Server

type Server struct {
	Id int64

	// Codec information
	AlphaCodec       int32
	BetaCodec        int32
	PreferAlphaCodec bool
	Opus             bool

	// Channels
	Channels map[int]*Channel

	// Users
	Users       map[uint32]*User
	UserCertMap map[string]*User
	UserNameMap map[string]*User

	Bans []ban.Ban

	// Logging
	*log.Logger
	// contains filtered or unexported fields
}

A Murmur server instance

func NewServer

func NewServer(id int64) (s *Server, err error)

Allocate a new Murmur instance

func NewServerFromFrozen

func NewServerFromFrozen(name string) (s *Server, err error)

Create a new server from its on-disk representation.

This will read a full serialized server (typically stored in a file called 'main.fz') from disk. It will also check for a log file ('log.fz') and iterate through the entries of the log file and apply the updates incrementally to the server.

Once both the full server and the log file has been merged together in memory, a new full seralized server will be written and synced to disk, and the existing log file will be removed.

func NewServerFromSQLite

func NewServerFromSQLite(id int64, db *sql.DB) (s *Server, err error)

Create a new Server from a Murmur SQLite database

func (*Server) AddChannel

func (server *Server) AddChannel(name string) (channel *Channel)

AddChannel adds a new channel to the server. Automatically assign it a channel ID.

func (*Server) CheckSuperUserPassword

func (server *Server) CheckSuperUserPassword(password string) bool

CheckSuperUserPassword checks whether password matches the set SuperUser password.

func (*Server) ClearCaches

func (server *Server) ClearCaches()

ClearCaches clears the Server's caches

func (*Server) CurrentPort

func (server *Server) CurrentPort() int

CurrentPort returns the port the native server is currently listening on. If called when the server is not running, this function returns -1.

func (*Server) Debugf

func (server *Server) Debugf(format string, v ...interface{})

Debugf implements debug-level printing for Servers.

func (*Server) DeleteFrozenChannel

func (server *Server) DeleteFrozenChannel(channel *Channel)

Mark a channel as deleted in the datastore.

func (*Server) DeleteFrozenUser

func (server *Server) DeleteFrozenUser(user *User)

Mark a user as deleted in the datstore.

func (*Server) FilterText

func (server *Server) FilterText(text string) (filtered string, err error)

Filter incoming text according to the server's current rules.

func (*Server) Freeze

func (server *Server) Freeze() (fs *freezer.Server, err error)

Freeze a server to a flattened protobuf-based structure ready to persist to disk.

func (*Server) FreezeToFile

func (server *Server) FreezeToFile() error

Freeze a server to disk and closes the log file. This must be called from within the Server's synchronous handler.

func (*Server) GetSuperUserName

func (server *Server) GetSuperUserName() string

func (*Server) HostAddress

func (server *Server) HostAddress() string

HostAddress returns the host address the server will listen on when it is started. This must be an IP address, either IPv4 or IPv6.

func (*Server) IsCertHashBanned

func (server *Server) IsCertHashBanned(hash string) bool

IsCertHashBanned Is the certificate hash banned?

func (*Server) IsConnectionBanned

func (server *Server) IsConnectionBanned(conn net.Conn) bool

IsConnectionBanned Is the incoming connection conn banned?

func (*Server) IsPublic

func (server *Server) IsPublic() bool

Determines whether a server is public by checking whether the config values required for public registration are set.

This function is used to determine whether or not to periodically contact the master server list and update this server's metadata.

func (*Server) LinkChannels

func (server *Server) LinkChannels(channel *Channel, other *Channel)

Link two channels

func (*Server) Port

func (server *Server) Port() int

Port returns the port the native server will listen on when it is started.

func (*Server) RegisterClient

func (s *Server) RegisterClient(client *Client) (uid uint32, err error)

Register a client on the server.

func (*Server) RegisterPublicServer

func (server *Server) RegisterPublicServer()

Perform a public server registration update.

When a Mumble server connects to the master server for registration, it connects using its server certificate as a client certificate for authentication purposes.

func (*Server) RemoveChanel

func (server *Server) RemoveChanel(channel *Channel)

RemoveChanel removes a channel from the server.

func (*Server) RemoveChannel

func (server *Server) RemoveChannel(channel *Channel)

RemoveChannel removes a channel

func (*Server) RemoveClient

func (server *Server) RemoveClient(client *Client, kicked bool)

RemoveClient removes a disconnected client from the server's internal representation.

func (*Server) RemoveExpiredBans

func (server *Server) RemoveExpiredBans()

RemoveExpiredBans removes expired bans

func (*Server) RemoveRegistration

func (s *Server) RemoveRegistration(uid uint32) (err error)

RemoveRegistration removes a registered user.

func (*Server) ResetConfig

func (server *Server) ResetConfig(key string)

ResetConfig writes to the freezelog that the config with key has been reset to its default value.

func (*Server) RootChannel

func (server *Server) RootChannel() *Channel

RootChannel gets a pointer to the root channel

func (*Server) SendUDP

func (s *Server) SendUDP(buf []byte, addr *net.UDPAddr) (err error)

Send the content of buf as a UDP packet to addr.

func (*Server) Set

func (server *Server) Set(key string, value string)

SetConfig will set a configuration value

func (*Server) SetServerPassword

func (server *Server) SetServerPassword(password string)

Set password as the new Server password

func (*Server) SetSuperUserName

func (server *Server) SetSuperUserName(n string)

func (*Server) SetSuperUserPassword

func (server *Server) SetSuperUserPassword(password string)

Set password as the new SuperUser password

func (*Server) ShouldListenWebPort

func (server *Server) ShouldListenWebPort() bool

ShouldListenWebPort returns the port the web server will listen on when it is started.

func (*Server) Start

func (server *Server) Start() (err error)

Start the server.

func (*Server) Stop

func (server *Server) Stop() (err error)

Stop the server.

func (*Server) UnfreezeBanList

func (s *Server) UnfreezeBanList(fblist *freezer.BanList)

Merge the contents of a freezer.BanList into the server's ban list.

func (*Server) UnlinkChannels

func (server *Server) UnlinkChannels(channel *Channel, other *Channel)

Unlink two channels

func (*Server) UpdateConfig

func (server *Server) UpdateConfig(key, value string)

UpdateConfig writes an updated config value to the datastore.

func (*Server) UpdateFrozenBans

func (server *Server) UpdateFrozenBans(bans []ban.Ban)

UpdateFrozenBans writes the server's banlist to the datastore.

func (*Server) UpdateFrozenChannel

func (server *Server) UpdateFrozenChannel(channel *Channel, state *mumbleproto.ChannelState)

Given a target channel and a ChannelState protocol message, create a freezer.Channel that only includes the values changed by the given ChannelState message. When done, write that frozen.Channel to the datastore.

func (*Server) UpdateFrozenChannelACLs

func (server *Server) UpdateFrozenChannelACLs(channel *Channel)

UpdateFrozenChannelACLs writes a channel's ACL and Group data to disk. Mumble doesn't support incremental ACL updates and as such we must write all ACLs and groups to the datastore on each change.

func (*Server) UpdateFrozenUser

func (server *Server) UpdateFrozenUser(client *Client, state *mumbleproto.UserState)

Update the datastore with the user's current state.

func (*Server) UpdateFrozenUserLastChannel

func (server *Server) UpdateFrozenUserLastChannel(client *Client)

Update a user's last active channel

func (*Server) WebPort

func (server *Server) WebPort() int

WebPort returns the port the web server will listen on when it is started.

type UsageArgs

type UsageArgs struct {
	Version        string
	BuildDate      string
	OS             string
	Arch           string
	DefaultDataDir string
}

type User

type User struct {
	Id            uint32
	Name          string
	Password      string
	CertHash      string
	Email         string
	TextureBlob   string
	CommentBlob   string
	LastChannelId int
	LastActive    uint64
}

func NewUser

func NewUser(id uint32, name string) (user *User, err error)

Create a new User

func (*User) CommentBlobHashBytes

func (user *User) CommentBlobHashBytes() (buf []byte)

CommentBlobHashBytes gets the hash of the user's comment blob as a byte slice for transmitting via a protobuf message. Returns nil if there is no such blob.

func (*User) Freeze

func (user *User) Freeze() (fu *freezer.User, err error)

Freeze a User into a flattened protobuf-based structure ready to be persisted to disk.

func (*User) HasComment

func (user *User) HasComment() bool

HasComment Does the channel have comment?

func (*User) HasTexture

func (user *User) HasTexture() bool

HasTexture Does the user have a texture?

func (*User) TextureBlobHashBytes

func (user *User) TextureBlobHashBytes() (buf []byte)

TextureBlobHashBytes gets the hash of the user's texture blob as a byte slice for transmitting via a protobuf message. Returns nil if there is no such blob.

func (*User) Unfreeze

func (u *User) Unfreeze(fu *freezer.User)

Merge the contents of a frozen User into an existing user struct.

type VoiceBroadcast

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

type VoiceTarget

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

A VoiceTarget holds information about a single VoiceTarget entry of a Client.

func (*VoiceTarget) AddChannel

func (vt *VoiceTarget) AddChannel(id uint32, subchannels bool, links bool, group string)

AddChannel adds a channel to the VoiceTarget. If subchannels is true, any sent voice packets will also be sent to all subchannels. If links is true, any sent voice packets will also be sent to all linked channels. If group is a non-empty string, any sent voice packets will only be broadcast to members of that group who reside in the channel (or its children or linked channels).

func (*VoiceTarget) AddSession

func (vt *VoiceTarget) AddSession(session uint32)

Add's a client's session to the VoiceTarget

func (*VoiceTarget) ClearCache

func (vt *VoiceTarget) ClearCache()

ClearCache clears the VoiceTarget's cache.

func (*VoiceTarget) IsEmpty

func (vt *VoiceTarget) IsEmpty() bool

IsEmpty checks whether the VoiceTarget is empty (has no targets)

func (*VoiceTarget) SendVoiceBroadcast

func (vt *VoiceTarget) SendVoiceBroadcast(vb *VoiceBroadcast)

Send the contents of the VoiceBroadcast to all targets specified in the VoiceTarget.

Jump to

Keyboard shortcuts

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