ts3

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2024 License: BSD-2-Clause Imports: 13 Imported by: 25

README

TeamSpeak 3 Go Report Card License GoDoc

go-ts3 is a Go client for the TeamSpeak 3 ServerQuery Protocol.

Features

Installation

go get -u github.com/multiplay/go-ts3

Examples

Using go-ts3 is simple just create a client, login and then send commands e.g.

package main

import (
	"log"

        "github.com/multiplay/go-ts3"
)

func main() {
        c, err := ts3.NewClient("192.168.1.102:10011")
	if err != nil {
		log.Fatal(err)
	}
	defer c.Close()

	if err := c.Login(user, pass); err != nil {
		log.Fatal(err)
	}

	if v, err := c.Version(); err != nil {
		log.Fatal(err)
	} else {
		log.Println("server is running:", v)
	}
}

Documentation

License

go-ts3 is available under the BSD 2-Clause License.

Documentation

Index

Constants

View Source
const (
	ClientNickname           = "client_nickname"
	ClientIsTalker           = "client_is_talker"
	ClientDescription        = "client_description"
	ClientIsChannelCommander = "client_is_channel_commander"
	ClientIconID             = "client_icon_id"
)

Properties that can be changed with ClientUpdate.

View Source
const (
	// MaxParseTokenSize is the maximum buffer size used to parse the
	// server responses.
	// It's relatively large to enable us to deal with the typical responses
	// to commands such as serversnapshotcreate.
	MaxParseTokenSize = 10 << 20

	// DefaultConnectHeader send by server on connect.
	DefaultConnectHeader = "TS3"
)
View Source
const (
	// DefaultPort is the default TeamSpeak 3 ServerQuery port.
	DefaultPort = 10011

	// DefaultSSHPort is the default TeamSpeak 3 ServerQuery SSH port.
	DefaultSSHPort = 10022
)
View Source
const (
	// ExtendedServerList can be passed to List to get extended server information.
	ExtendedServerList = "-extended"

	// ClientUID can be passed to ClientList to retrieve client UID information.
	ClientUID = "-uid"
	// ClientAway can be passed to ClientList to retrieve client away information.
	ClientAway = "-away"
	// ClientVoice can be passed to ClientList to retrieve client voice information.
	ClientVoice = "-voice"
	// ClientTimes can be passed to ClientList to retrieve client time information.
	ClientTimes = "-times"
	// ClientGroups can be passed to ClientList to retrieve client groups information.
	ClientGroups = "-groups"
	// ClientInfo can be passed to ClientList to retrieve client information.
	ClientInfo = "-info"
	// ClientIcon can be passed to ClientList to retrieve client icon information.
	ClientIcon = "-icon"
	// ClientCountry can be passed to ClientList to retrieve client country information.
	ClientCountry = "-country"
	// ClientIP can be passed to ClientList to retrieve client IP information.
	ClientIP = "-ip"
	// ClientBadges can be passed to ClientList to retrieve client badge information.
	ClientBadges = "-badges"
	// ClientListFull can be passed to ClientList to get all extended client information.
	ClientListFull = "-uid -away -voice -times -groups -info -icon -country -ip -badges"
)

Variables

View Source
var (

	// DefaultTimeout is the default read / write / dial timeout for Clients.
	DefaultTimeout = 10 * time.Second

	// DefaultKeepAlive is the default interval in which keepalive data is sent.
	DefaultKeepAlive = 200 * time.Second

	// DefaultNotifyBufSize is the default notification buffer size.
	DefaultNotifyBufSize = 5
)
View Source
var (
	// ErrInvalidConnectHeader is returned by NewClient if the server
	// doesn't respond with the required connection header.
	ErrInvalidConnectHeader = errors.New("invalid connect header")

	// ErrNilOption is returned by NewClient if an option is nil.
	ErrNilOption = errors.New("nil option")

	// ErrNotConnected is returned by Exec and ExecCmd if the client is not connected.
	ErrNotConnected = errors.New("not connected")

	// ErrTimeout is returned by Exec and ExecCmd if no response is received
	// within the specified timeout duration.
	ErrTimeout = errors.New("timeout")
)

Functions

func Buffer

func Buffer(buf []byte, max int) func(*Client) error

Buffer sets the initial buffer used to parse responses from the server and the maximum size of buffer that may be allocated. The maximum parsable token size is the larger of max and cap(buf). If max <= cap(buf), scanning will use this buffer only and do no allocation.

By default, parsing uses an internal buffer and sets the maximum token size to MaxParseTokenSize.

func ConnectHeader added in v1.0.1

func ConnectHeader(connectHeader string) func(*Client) error

ConnectHeader sets the header expected on connect.

Default is "TS3" which is sent by server query. For client query use "TS3 Client".

func Decode

func Decode(str string) string

Decode returns a decoded version of str.

func DecodeResponse

func DecodeResponse(lines []string, v interface{}) error

DecodeResponse decodes a response into a struct.

func KeepAlive added in v1.0.1

func KeepAlive(keepAlive time.Duration) func(*Client) error

KeepAlive sets the keepAlive interval.

func NotificationBuffer added in v1.0.1

func NotificationBuffer(size int) func(*Client) error

NotificationBuffer sets the notification buffer size.

func SSH added in v1.1.0

func SSH(config *ssh.ClientConfig) func(*Client) error

SSH tells the client to use SSH instead of insecure legacy TCP. A valid login has to be provided with ssh.ClientConfig.

Example config (missing host-key validation):

&ssh.ClientConfig{
	User: "serveradmin",
	Auth: []ssh.AuthMethod{
		ssh.Password("password"),
	},
}

func ScanLines

func ScanLines(data []byte, atEOF bool) (advance int, token []byte, err error)

ScanLines is a split function for a bytes.Scanner that returns each line of text, stripped of any trailing end-of-line marker. The returned line may be empty. The end-of-line marker is one newline followed by a carriage return. In regular expression notation, it is `\n\r`. The last non-empty line of input will be returned even if it has no newline.

func Timeout

func Timeout(timeout time.Duration) func(*Client) error

Timeout sets read / write / dial timeout for a TeamSpeak 3 Client.

Types

type Arg

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

Arg represents a TeamSpeak 3 ServerQuery command argument. Args automatically escape white space and special characters before being sent to the server.

func NewArg

func NewArg(key string, val interface{}) *Arg

NewArg returns a new Arg with key val.

func (*Arg) ArgString

func (a *Arg) ArgString() string

ArgString implements CmdArg.

type ArgGroup

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

ArgGroup represents a group of TeamSpeak 3 ServerQuery command arguments.

func NewArgGroup

func NewArgGroup(args ...CmdArg) *ArgGroup

NewArgGroup returns a new ArgGroup.

func (*ArgGroup) ArgString

func (ag *ArgGroup) ArgString() string

ArgString implements CmdArg.

type ArgSet

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

ArgSet represents a set of TeamSpeak 3 ServerQuery command arguments.

func NewArgSet

func NewArgSet(args ...CmdArg) *ArgSet

NewArgSet returns a new ArgSet.

func (*ArgSet) ArgString

func (ag *ArgSet) ArgString() string

ArgString implements CmdArg.

type Channel

type Channel struct {
	ID                   int    `ms:"cid"`
	ParentID             int    `ms:"pid"`
	ChannelOrder         int    `ms:"channel_order"`
	ChannelName          string `ms:"channel_name"`
	TotalClients         int    `ms:"total_clients"`
	NeededSubscribePower int    `ms:"channel_needed_subscribe_power"`
}

Channel represents a TeamSpeak 3 channel in a virtual server.

type Client

type Client struct {
	Server *ServerMethods
	// contains filtered or unexported fields
}

Client is a TeamSpeak 3 ServerQuery client.

func NewClient

func NewClient(addr string, options ...func(c *Client) error) (*Client, error)

NewClient returns a new TeamSpeak 3 client connected to addr. Use with SSH where possible for improved security.

func (*Client) ClientUpdate added in v1.0.1

func (c *Client) ClientUpdate(properties ...CmdArg) error

ClientUpdate changes properties of the client to a given value.

func (*Client) Close

func (c *Client) Close() error

Close closes the connection to the server.

func (*Client) Exec

func (c *Client) Exec(cmd string) ([]string, error)

Exec executes cmd on the server and returns the response.

func (*Client) ExecCmd

func (c *Client) ExecCmd(cmd *Cmd) ([]string, error)

ExecCmd executes cmd on the server and returns the response.

func (*Client) IsConnected added in v1.0.1

func (c *Client) IsConnected() bool

IsConnected returns true if the client is connected, false otherwise.

func (*Client) Login

func (c *Client) Login(user, passwd string) error

Login authenticates with the server.

func (*Client) Logout

func (c *Client) Logout() error

Logout deselect virtual server and log out.

func (*Client) Notifications added in v1.0.1

func (c *Client) Notifications() <-chan Notification

Notifications returns a read-only channel that outputs received notifications.

The channel will be closed when no more notifications will be sent so consumers should either range over the returned channel or use the multi value version of receive so they can detect when the channel is closed.

If you subscribe to server and channel events you will receive duplicate `cliententerview` and `clientleftview` notifications. Sending a private message from the client results in a `textmessage` Notification even if the client didn't subscribe to any events.

Notifications are not documented by TeamSpeak; A complete but unofficial documentation in German can be found here: http://yat.qa/ressourcen/server-query-notify/

func (*Client) Register added in v1.0.1

func (c *Client) Register(event NotifyCategory) error

Register registers for a NotifyCategory.

Subscriptions can be reset with `Unregister()` but will also be reset when calling `logout`, `login`, `use`.

func (*Client) RegisterChannel added in v1.0.1

func (c *Client) RegisterChannel(id uint) error

RegisterChannel registers for channel event notifications.

It's not possible to subscribe to multiple channels. To receive events for all channels the id can be set to 0.

func (*Client) SetChannelCommander added in v1.0.1

func (c *Client) SetChannelCommander(val bool) error

SetChannelCommander sets whether the client is a channel commander.

func (*Client) SetDescription added in v1.0.1

func (c *Client) SetDescription(description string) error

SetDescription sets the clients description.

func (*Client) SetIcon added in v1.0.1

func (c *Client) SetIcon(id int) error

SetIcon sets the clients icon based on the CRC32 checksum.

func (*Client) SetNick added in v1.0.1

func (c *Client) SetNick(nick string) error

SetNick sets the clients nickname.

func (*Client) SetTalker added in v1.0.1

func (c *Client) SetTalker(val bool) error

SetTalker sets whether the client is able to talk.

func (*Client) Unregister added in v1.0.1

func (c *Client) Unregister() error

Unregister unregisters all events previously registered.

func (*Client) Use

func (c *Client) Use(id int) error

Use selects a virtual server by id.

func (*Client) UsePort

func (c *Client) UsePort(port int) error

UsePort selects a virtual server by port.

func (*Client) Version

func (c *Client) Version() (*Version, error)

Version returns version information.

func (*Client) Whoami

func (c *Client) Whoami() (*ConnectionInfo, error)

Whoami returns information about the current connection including the currently selected virtual server.

type Cmd

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

Cmd represents a TeamSpeak 3 ServerQuery command.

func NewCmd

func NewCmd(cmd string) *Cmd

NewCmd creates a new Cmd.

func (*Cmd) String

func (c *Cmd) String() string

func (*Cmd) WithArgs

func (c *Cmd) WithArgs(args ...CmdArg) *Cmd

WithArgs sets the command Args.

func (*Cmd) WithOptions

func (c *Cmd) WithOptions(options ...string) *Cmd

WithOptions sets the command Options.

func (*Cmd) WithResponse

func (c *Cmd) WithResponse(r interface{}) *Cmd

WithResponse sets the command Response which will have the data returned from the server decoded into it.

type CmdArg

type CmdArg interface {
	ArgString() string
}

CmdArg is implemented by types which can be used as a command argument.

type Connection added in v1.1.0

type Connection interface {
	net.Conn

	// Connect connects to the server on addr with a timeout.
	Connect(addr string, timeout time.Duration) error
}

Connection is a connection to a TeamSpeak 3 server. It's a wrapper around net.Conn with a Connect method.

type ConnectionInfo

type ConnectionInfo struct {
	ServerStatus           string `ms:"virtualserver_status"`
	ServerID               int    `ms:"virtualserver_id"`
	ServerUniqueIdentifier string `ms:"virtualserver_unique_identifier"`
	ServerPort             int    `ms:"virtualserver_port"`
	ClientID               int    `ms:"client_id"`
	ClientChannelID        int    `ms:"client_channel_id"`
	ClientName             string `ms:"client_nickname"`
	ClientDatabaseID       int    `ms:"client_database_id"`
	ClientLoginName        string `ms:"client_login_name"`
	ClientUniqueIdentifier string `ms:"client_unique_identifier"`
	ClientOriginServerID   int    `ms:"client_origin_server_id"`
}

ConnectionInfo represents an answer of the whoami command.

type CreatedServer

type CreatedServer struct {
	ID    int    `ms:"sid"`
	Port  uint16 `ms:"virtualserver_port"`
	Token string
}

CreatedServer is the details returned by a server create.

type DBClient

type DBClient struct {
	ID               int       `ms:"cldbid"`
	UniqueIdentifier string    `ms:"client_unique_identifier"`
	Nickname         string    `ms:"client_nickname"`
	Created          time.Time `ms:"client_created"`
	LastConnected    time.Time `ms:"client_lastconnected"`
	Connections      int       `ms:"client_totalconnections"`
}

DBClient represents a client identity on a virtual server.

type Error

type Error struct {
	ID      int
	Msg     string
	Details map[string]interface{}
}

Error represents a error returned from the TeamSpeak 3 server.

func NewError

func NewError(matches []string) *Error

NewError returns a new Error parsed from TeamSpeak 3 server response.

func (*Error) Error

func (e *Error) Error() string

type Group

type Group struct {
	ID                int `ms:"sgid"`
	Name              string
	Type              int
	IconID            int
	Saved             bool `ms:"savedb"`
	SortID            int
	NameMode          int
	ModifyPower       int `ms:"n_modifyp"`
	MemberAddPower    int `ms:"n_member_addp"`
	MemberRemovePower int `ms:"n_member_addp"`
}

Group represents a virtual server group.

type Instance

type Instance struct {
	DatabaseVersion             int    `ms:"serverinstance_database_version"`
	FileTransferPort            int    `ms:"serverinstance_filetransfer_port"`
	MaxTotalDownloadBandwidth   uint64 `ms:"serverinstance_max_download_total_bandwidth"`
	MaxTotalUploadBandwidth     uint64 `ms:"serverinstance_max_upload_total_bandwidth"`
	GuestServerQueryGroup       int    `ms:"serverinstance_guest_serverquery_group"`
	ServerQueryFloodCommands    int    `ms:"serverinstance_serverquery_flood_commands"`
	ServerQueryFloodTime        int    `ms:"serverinstance_serverquery_flood_time"`
	ServerQueryBanTime          int    `ms:"serverinstance_serverquery_ban_time"`
	TemplateServerAdminGroup    int    `ms:"serverinstance_template_serveradmin_group"`
	TemplateServerDefaultGroup  int    `ms:"serverinstance_template_serverdefault_group"`
	TemplateChannelAdminGroup   int    `ms:"serverinstance_template_channeladmin_group"`
	TemplateChannelDefaultGroup int    `ms:"serverinstance_template_channeldefault_group"`
	PermissionsVersion          int    `ms:"serverinstance_permissions_version"`
	PendingConnectionsPerIP     int    `ms:"serverinstance_pending_connections_per_ip"`
}

Instance represents basic information for a TeamSpeak 3 instance.

type InvalidResponseError

type InvalidResponseError struct {
	Reason string
	Data   []string
}

InvalidResponseError is the error returned when the response data was invalid.

func NewInvalidResponseError

func NewInvalidResponseError(reason string, lines []string) *InvalidResponseError

NewInvalidResponseError returns a new InvalidResponseError from lines.

func (*InvalidResponseError) Error

func (e *InvalidResponseError) Error() string

type Notification added in v1.0.1

type Notification struct {
	Type string
	Data map[string]string
}

Notification contains the information of a notify event.

type NotifyCategory added in v1.0.1

type NotifyCategory string

NotifyCategory is an event category.

const (
	// ServerEvents registers the following events:
	// `cliententerview`, `clientleftview`, `serveredited`.
	ServerEvents NotifyCategory = "server"

	// ChannelEvents registers the following events:
	// `cliententerview`, `clientleftview`, `channeldescriptionchanged`, `channelpasswordchanged`
	// `channelmoved`, `channeledited`, `channelcreated`, `channeldeleted`, `clientmoved`.
	ChannelEvents NotifyCategory = "channel"

	// TextServerEvents registers the `textmessage` event with `targetmode = 3`.
	TextServerEvents NotifyCategory = "textserver"

	// TextChannelEvents registers the `textmessage` event with `targetmode = 2`.
	//
	// Notifications are only received for messages that are sent in the channel that the client is in.
	TextChannelEvents NotifyCategory = "textchannel"

	// TextPrivateEvents registers the `textmessage` event with `targetmode = 1`.
	TextPrivateEvents NotifyCategory = "textprivate"

	// TokenUsedEvents registers the `tokenused` event.
	TokenUsedEvents NotifyCategory = "tokenused"
)

type OnlineClient

type OnlineClient struct {
	// Following variables are always returned by ClientList().
	ID         int    `ms:"clid"`
	ChannelID  int    `ms:"cid"`
	DatabaseID int    `ms:"client_database_id"`
	Nickname   string `ms:"client_nickname"`
	Type       int    `ms:"client_type"`
	// Following variables are optional and can be requested in ClientList() to get extended client information.
	// note: Away and AwayMessage are currently optional but not using pointers for compatibility considerations.
	Away             bool           `ms:"client_away"`         // Only populated if ClientAway or ClientListFull is passed to ClientList.
	AwayMessage      string         `ms:"client_away_message"` // Only populated if ClientAway or ClientListFull is passed to ClientList.
	*OnlineClientExt `ms:",squash"` // Only populated if any of the options is passed to ClientList.
}

OnlineClient represents a client online on a virtual server.

type OnlineClientExt added in v1.2.0

type OnlineClientExt struct {
	UniqueIdentifier    *string        `ms:"client_unique_identifier"` // Only populated if ClientUID or ClientListFull is passed to ClientList.
	*OnlineClientVoice  `ms:",squash"` // Only populated if ClientVoice or ClientListFull is passed to ClientList.
	*OnlineClientTimes  `ms:",squash"` // Only populated if ClientTimes or ClientListFull is passed to ClientList.
	*OnlineClientGroups `ms:",squash"` // Only populated if ClientGroups or ClientListFull is passed to ClientList.
	*OnlineClientInfo   `ms:",squash"` // Only populated if ClientInfo or ClientListFull is passed to ClientList.
	Country             *string        `ms:"client_country"`       // Only populated if ClientCountry or ClientListFull is passed to ClientList.
	IP                  *string        `ms:"connection_client_ip"` // Only populated if ClientIP or ClientListFull is passed to ClientList.
	Badges              *string        `ms:"client_badges"`        // Only populated if ClientBadges or ClientListFull is passed to ClientList.
	IconID              *int           `ms:"client_icon_id"`       // Only populated if ClientIcon or ClientListFull is passed to ClientList.
}

OnlineClientExt represents all ClientList extensions.

type OnlineClientGroups added in v1.2.0

type OnlineClientGroups struct {
	ChannelGroupID                 *int   `ms:"client_channel_group_id"`
	ChannelGroupInheritedChannelID *int   `ms:"client_channel_group_inherited_channel_id"`
	ServerGroups                   *[]int `ms:"client_servergroups"`
}

OnlineClientGroups represents all ClientList extensions when the ClientGroups parameter is passed.

type OnlineClientInfo added in v1.2.0

type OnlineClientInfo struct {
	Version  *string `ms:"client_version"`
	Platform *string `ms:"client_platform"`
}

OnlineClientInfo represents all ClientList extensions when the ClientInfo parameter is passed.

type OnlineClientTimes added in v1.2.0

type OnlineClientTimes struct {
	IdleTime      *int `ms:"client_idle_time"`
	Created       *int `ms:"client_created"`
	LastConnected *int `ms:"client_lastconnected"`
}

OnlineClientTimes represents all ClientList extensions when the ClientTimes parameter is passed.

type OnlineClientVoice added in v1.2.0

type OnlineClientVoice struct {
	FlagTalking        *bool `ms:"client_flag_talking"`
	InputMuted         *bool `ms:"client_input_muted"`
	OutputMuted        *bool `ms:"client_output_muted"`
	InputHardware      *bool `ms:"client_input_hardware"`
	OutputHardware     *bool `ms:"client_output_hardware"`
	TalkPower          *int  `ms:"client_talk_power"`
	IsTalker           *bool `ms:"client_is_talker"`
	IsPrioritySpeaker  *bool `ms:"client_is_priority_speaker"`
	IsRecording        *bool `ms:"client_is_recording"`
	IsChannelCommander *bool `ms:"client_is_channel_commander"`
}

OnlineClientVoice represents all ClientList extensions when the ClientVoice parameter is passed.

type PrivilegeKey

type PrivilegeKey struct {
	Token       string
	Type        int    `ms:"token_type"`
	ID1         int    `ms:"token_id1"`
	ID2         int    `ms:"token_id2"`
	Created     int    `ms:"token_created"`
	Description string `ms:"token_description"`
}

PrivilegeKey represents a server privilege key.

type Server

type Server struct {
	AntiFloodPointsNeededCommandBlock      int     `ms:"virtualserver_antiflood_points_needed_command_block"`
	AntiFloodPointsNeededIPBlock           int     `ms:"virtualserver_antiflood_points_needed_ip_block"`
	AntiFloodPointsTickReduce              int     `ms:"virtualserver_antiflood_points_tick_reduce"`
	ChannelsOnline                         int     `ms:"virtualserver_channelsonline"`
	ClientsOnline                          int     `ms:"virtualserver_clientsonline"`
	CodecEncryptionMode                    int     `ms:"virtualserver_codec_encryption_mode"`
	ComplainAutoBanCount                   int     `ms:"virtualserver_complain_autoban_count"`
	ComplainAutoBanTime                    int     `ms:"virtualserver_complain_autoban_time"`
	ComplainRemoveTime                     int     `ms:"virtualserver_complain_remove_time"`
	Created                                int     `ms:"virtualserver_created"`
	DefaultChannelAdminGroup               int     `ms:"virtualserver_default_channel_admin_group"`
	DefaultChannelGroup                    int     `ms:"virtualserver_default_channel_group"`
	DefaultServerGroup                     int     `ms:"virtualserver_default_server_group"`
	HostBannerGFXInterval                  int     `ms:"virtualserver_hostbanner_gfx_interval"`
	HostMessageMode                        int     `ms:"virtualserver_hostmessage_mode"`
	ID                                     int     `ms:"virtualserver_id"`
	MachineID                              string  `ms:"virtualserver_machine_id"`
	MaxClients                             int     `ms:"virtualserver_maxclients"`
	MinClientsInChannelBeforeForcedSilence int     `ms:"virtualserver_min_clients_in_channel_before_forced_silence"`
	NeededIdentitySecurityLevel            int     `ms:"virtualserver_needed_identity_security_level"`
	Port                                   int     `ms:"virtualserver_port"`
	QueryClientsOnline                     int     `ms:"virtualserver_queryclientsonline"`
	Uptime                                 int     `ms:"virtualserver_uptime"` // TODO(steve): use time.Duration
	AskForPrivilegeKey                     bool    `ms:"virtualserver_ask_for_privilegekey"`
	AutoStart                              bool    `ms:"virtualserver_autostart"`
	FlagPassword                           bool    `ms:"virtualserver_flag_password"`
	LogChannel                             bool    `ms:"virtualserver_log_channel"`
	LogClient                              bool    `ms:"virtualserver_log_client"`
	LogFileTransfer                        bool    `ms:"virtualserver_log_filetransfer"`
	LogPermissions                         bool    `ms:"virtualserver_log_permissions"`
	LogQuery                               bool    `ms:"virtualserver_log_client"`
	LogServer                              bool    `ms:"virtualserver_log_server"`
	WebListEnabled                         bool    `ms:"virtualserver_web_list_enabled"`
	PrioritySpeakerDimmModificator         float32 `ms:"virtualserver_priority_speaker_dimm_modificator"`
	BandwidthReceivedLastMinuteTotal       int     `ms:"virtualserver_bandwidth_received_last_minute_total"`
	BandwidthReceivedLastSecondTotal       int     `ms:"virtualserver_bandwidth_received_last_second_total"`
	BandwidthSentLastMinuteTotal           int     `ms:"virtualserver_bandwidth_sent_last_minute_total"`
	BandwidthSentLastSecondTotal           int     `ms:"virtualserver_bandwidth_sent_last_second_total"`
	ChannelTempDeleteDelayDefault          int     `ms:"virtualserver_channel_temp_delete_delay_default"`
	HostBannerMode                         int     `ms:"virtualserver_hostbanner_mode"`
	IconID                                 int     `ms:"virtualserver_icon_id"`
	MinAndroidVersion                      int     `ms:"virtualserver_min_android_version"`
	MinClientVersion                       int     `ms:"virtualserver_min_client_version"`
	MiniOSVersion                          int     `ms:"virtualserver_min_ios_version"`
	ReservedSlots                          int     `ms:"virtualserver_reserved_slots"`
	TotalPing                              float32 `ms:"virtualserver_total_ping"`
	MaxDownloadTotalBandwidth              uint64  `ms:"virtualserver_max_download_total_bandwidth"`
	MaxUploadTotalBandwidth                uint64  `ms:"virtualserver_max_upload_total_bandwidth"`
	MonthBytesDownloaded                   int64   `ms:"virtualserver_month_bytes_downloaded"`
	MonthBytesUploaded                     int64   `ms:"virtualserver_month_bytes_uploaded"`
	TotalBytesDownloaded                   int64   `ms:"virtualserver_total_bytes_downloaded"`
	TotalBytesUploaded                     int64   `ms:"virtualserver_total_bytes_uploaded"`
	TotalPacketLossControl                 float64 `ms:"virtualserver_total_packetloss_control"`
	TotalPacketLossKeepalive               float64 `ms:"virtualserver_total_packetloss_keepalive"`
	TotalPacketLossSpeech                  float64 `ms:"virtualserver_total_packetloss_speech"`
	TotalPacketLossTotal                   float64 `ms:"virtualserver_total_packetloss_total"`
	VirtualServerDownloadQuota             uint64  `ms:"virtualserver_download_quota"`
	VirtualServerUploadQuota               uint64  `ms:"virtualserver_upload_quota"`
	FileBase                               string  `ms:"virtualserver_filebase"`
	HostBannerGFXURL                       string  `ms:"virtualserver_hostbanner_gfx_url"`
	HostBannerURL                          string  `ms:"virtualserver_hostbanner_url"`
	HostButtonGFXURL                       string  `ms:"virtualserver_hostbutton_gfx_url"`
	HostButtonToolTip                      string  `ms:"virtualserver_hostbutton_tooltip"`
	HostButtonURL                          string  `ms:"virtualserver_hostbutton_url"`
	HostMessage                            string  `ms:"virtualserver_hostmessage"`
	Name                                   string  `ms:"virtualserver_name"`
	NamePhonetic                           string  `ms:"virtualserver_name_phonetic"`
	Password                               string  `ms:"virtualserver_password"`
	Platform                               string  `ms:"virtualserver_platform"`
	Status                                 string  `ms:"virtualserver_status"`
	UniqueIdentifier                       string  `ms:"virtualserver_unique_identifier"`
	Version                                string  `ms:"virtualserver_version"`
	WelcomeMessage                         string  `ms:"virtualserver_welcomemessage"`
}

Server represents a TeamSpeak 3 virtual server.

type ServerConnectionInfo

type ServerConnectionInfo struct {
	FileTransferBandwidthSent     uint64  `ms:"connection_filetransfer_bandwidth_sent"`
	FileTransferBandwidthReceived uint64  `ms:"connection_filetransfer_bandwidth_received"`
	FileTransferTotalSent         uint64  `ms:"connection_filetransfer_bytes_sent_total"`
	FileTransferTotalReceived     uint64  `ms:"connection_filetransfer_bytes_received_total"`
	PacketsSentTotal              uint64  `ms:"connection_packets_sent_total"`
	PacketsReceivedTotal          uint64  `ms:"connection_packets_received_total"`
	BytesSentTotal                uint64  `ms:"connection_bytes_sent_total"`
	BytesReceivedTotal            uint64  `ms:"connection_bytes_received_total"`
	BandwidthSentLastSecond       uint64  `ms:"connection_bandwidth_sent_last_second_total"`
	BandwidthReceivedLastSecond   uint64  `ms:"connection_bandwidth_received_last_second_total"`
	BandwidthSentLastMinute       uint64  `ms:"connection_bandwidth_sent_last_minute_total"`
	BandwidthReceivedLastMinute   uint64  `ms:"connection_bandwidth_received_last_minute_total"`
	ConnectedTime                 uint32  `ms:"connection_connected_time"`
	PacketLossTotalAvg            float32 `ms:"connection_packetloss_total"`
	PingTotalAvg                  float32 `ms:"connection_ping"`
	PacketsSentSpeech             uint64  `ms:"connection_packets_sent_speech"`
	PacketsReceivedSpeech         uint64  `ms:"connection_packets_received_speech"`
	BytesSentSpeech               uint64  `ms:"connection_bytes_sent_speech"`
	BytesReceivedSpeech           uint64  `ms:"connection_bytes_received_speech"`
	PacketsSentKeepalive          uint64  `ms:"connection_packets_sent_keepalive"`
	PacketsReceivedKeepalive      uint64  `ms:"connection_packets_received_keepalive"`
	BytesSentKeepalive            uint64  `ms:"connection_bytes_sent_keepalive"`
	BytesReceivedKeepalive        uint64  `ms:"connection_bytes_received_keepalive"`
	PacketsSentControl            uint64  `ms:"connection_packets_sent_control"`
	PacketsReceivedControl        uint64  `ms:"connection_packets_received_control"`
	BytesSentControl              uint64  `ms:"connection_bytes_sent_control"`
	BytesReceivedControl          uint64  `ms:"connection_bytes_received_control"`
}

ServerConnectionInfo represents the connection info for a TeamSpeak 3 instance.

type ServerMethods

type ServerMethods struct {
	*Client
}

ServerMethods groups server methods.

func (*ServerMethods) ChannelList

func (s *ServerMethods) ChannelList() ([]*Channel, error)

ChannelList returns a list of channels for the selected server.

func (*ServerMethods) ClientDBList

func (s *ServerMethods) ClientDBList() ([]*DBClient, error)

ClientDBList returns a list of client identities known by the server.

func (*ServerMethods) ClientList

func (s *ServerMethods) ClientList(options ...string) ([]*OnlineClient, error)

ClientList returns a list of online clients.

func (*ServerMethods) Create

func (s *ServerMethods) Create(name string, args ...CmdArg) (*CreatedServer, error)

Create creates a new virtual server using the given properties and returns its ID, port and initial administrator privilege key. If virtualserver_port arg is not specified, the server will use the first unused UDP port.

func (*ServerMethods) Delete

func (s *ServerMethods) Delete(id int) error

Delete deletes the virtual server specified by id. Only virtual server in a stopped state can be deleted.

func (*ServerMethods) Edit

func (s *ServerMethods) Edit(args ...CmdArg) error

Edit changes the selected virtual servers configuration using the given args.

func (*ServerMethods) GroupList

func (s *ServerMethods) GroupList() ([]*Group, error)

GroupList returns a list of available groups for the selected server.

func (*ServerMethods) IDGetByPort

func (s *ServerMethods) IDGetByPort(port uint16) (int, error)

IDGetByPort returns the database id of the virtual server running on UDP port.

func (*ServerMethods) Info

func (s *ServerMethods) Info() (*Server, error)

Info returns detailed configuration information about the selected server.

func (*ServerMethods) InstanceInfo

func (s *ServerMethods) InstanceInfo() (*Instance, error)

InstanceInfo returns detailed information about the selected instance.

func (*ServerMethods) List

func (s *ServerMethods) List(options ...string) (servers []*Server, err error)

List lists virtual servers. In addition to the options supported by the Teamspeak 3 query protocol it also supports the ExtendedServerList option. If ExtendedServerList is specified in options then each server returned contain extended server information as returned by Info.

func (*ServerMethods) PrivilegeKeyAdd

func (s *ServerMethods) PrivilegeKeyAdd(ttype, id1, id2 int, options ...CmdArg) (string, error)

PrivilegeKeyAdd creates a new privilege token to the selected server and returns it. If tokentype is set to 0, the ID specified with id1 will be a server group ID. Otherwise, id1 is used as a channel group ID and you need to provide a valid channel ID using id2.

func (*ServerMethods) PrivilegeKeyList

func (s *ServerMethods) PrivilegeKeyList() ([]*PrivilegeKey, error)

PrivilegeKeyList returns a list of available privilege keys for the selected server, including their type and group IDs.

func (*ServerMethods) ServerConnectionInfo

func (s *ServerMethods) ServerConnectionInfo() (*ServerConnectionInfo, error)

ServerConnectionInfo returns detailed bandwidth and transfer information about the selected instance.

func (*ServerMethods) Start

func (s *ServerMethods) Start(id int) error

Start starts the virtual server specified by id.

func (*ServerMethods) Stop

func (s *ServerMethods) Stop(id int) error

Stop stops the virtual server specified by id.

type Version

type Version struct {
	Version  string
	Platform string
	Build    int
}

Version represents version information.

Jump to

Keyboard shortcuts

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