diff --git a/.gitignore b/.gitignore index fb1aaf1..aba871c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,26 @@ +# Created by https://www.gitignore.io/api/go +# Edit at https://www.gitignore.io/?templates=go + +### Go ### +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib + +# Test binary, built with `go test -c` +*.test + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out + + +# End of https://www.gitignore.io/api/go + +# temporary files *.swp *.tmp + +# GoLand +.idea diff --git a/basic_cmds.go b/basic_cmds.go index fcaa453..20acc19 100644 --- a/basic_cmds.go +++ b/basic_cmds.go @@ -49,7 +49,7 @@ type ConnectionInfo struct { ServerStatus string `ms:"virtualserver_status"` ServerID int `ms:"virtualserver_id"` ServerUniqueIdentifier string `ms:"virtualserver_unique_identifier"` - ServerPort int `ms:"virtualserver_port"` + ServerPort uint16 `ms:"virtualserver_port"` ClientID int `ms:"client_id"` ClientChannelID int `ms:"client_channel_id"` ClientName string `ms:"client_nickname"` diff --git a/mockserver_test.go b/mockserver_test.go index 4197d58..8278333 100644 --- a/mockserver_test.go +++ b/mockserver_test.go @@ -26,7 +26,7 @@ var ( "logout": "", "use": "", "serverlist": `virtualserver_id=1 virtualserver_port=10677 virtualserver_status=online virtualserver_clientsonline=1 virtualserver_queryclientsonline=1 virtualserver_maxclients=35 virtualserver_uptime=12345025 virtualserver_name=Server\s#1 virtualserver_autostart=1 virtualserver_machine_id=1 virtualserver_unique_identifier=uniq1|virtualserver_id=2 virtualserver_port=10617 virtualserver_status=online virtualserver_clientsonline=3 virtualserver_queryclientsonline=2 virtualserver_maxclients=10 virtualserver_uptime=3165117 virtualserver_name=Server\s#2 virtualserver_autostart=1 virtualserver_machine_id=1 virtualserver_unique_identifier=uniq2`, - "serverinfo": `virtualserver_antiflood_points_needed_command_block=150 virtualserver_antiflood_points_needed_ip_block=250 virtualserver_antiflood_points_tick_reduce=5 virtualserver_channel_temp_delete_delay_default=0 virtualserver_codec_encryption_mode=0 virtualserver_complain_autoban_count=5 virtualserver_complain_autoban_time=1200 virtualserver_complain_remove_time=3600 virtualserver_created=0 virtualserver_default_channel_admin_group=1 virtualserver_default_channel_group=4 virtualserver_default_server_group=5 virtualserver_download_quota=18446744073709551615 virtualserver_filebase=files virtualserver_flag_password=0 virtualserver_hostbanner_gfx_interval=0 virtualserver_hostbanner_gfx_url virtualserver_hostbanner_mode=0 virtualserver_hostbanner_url virtualserver_hostbutton_gfx_url virtualserver_hostbutton_tooltip=Multiplay\sGame\sServers virtualserver_hostbutton_url=http:\/\/www.multiplaygameservers.com virtualserver_hostmessage virtualserver_hostmessage_mode=0 virtualserver_icon_id=0 virtualserver_log_channel=0 virtualserver_log_client=0 virtualserver_log_filetransfer=0 virtualserver_log_permissions=1 virtualserver_log_query=0 virtualserver_log_server=0 virtualserver_max_download_total_bandwidth=18446744073709551615 virtualserver_max_upload_total_bandwidth=18446744073709551615 virtualserver_maxclients=32 virtualserver_min_android_version=0 virtualserver_min_client_version=0 virtualserver_min_clients_in_channel_before_forced_silence=100 virtualserver_min_ios_version=0 virtualserver_name=Test\sServer virtualserver_name_phonetic virtualserver_needed_identity_security_level=8 virtualserver_password virtualserver_priority_speaker_dimm_modificator=-18.0000 virtualserver_reserved_slots=0 virtualserver_status=template virtualserver_unique_identifier virtualserver_upload_quota=18446744073709551615 virtualserver_weblist_enabled=1 virtualserver_welcomemessage=Welcome\sto\sTeamSpeak,\scheck\s[URL]www.teamspeak.com[\/URL]\sfor\slatest\sinfos.`, + "serverinfo": `virtualserver_unique_identifier virtualserver_name=Test\sServer virtualserver_welcomemessage=Welcome\sto\sTeamSpeak,\scheck\s[URL]www.teamspeak.com[\/URL]\sfor\slatest\sinfos. virtualserver_maxclients=32 virtualserver_password virtualserver_clientsonline=0 virtualserver_channelsonline=0 virtualserver_created=2 virtualserver_uptime=6802178 virtualserver_codec_encryption_mode=0 virtualserver_hostmessage virtualserver_hostmessage_mode=0 virtualserver_filebase=files virtualserver_default_server_group=5 virtualserver_default_channel_group=4 virtualserver_flag_password=0 virtualserver_default_channel_admin_group=1 virtualserver_max_download_total_bandwidth=18446744073709551615 virtualserver_max_upload_total_bandwidth=18446744073709551615 virtualserver_hostbutton_url=http:\/\/www.multiplaygameservers.com virtualserver_hostbutton_gfx_url virtualserver_hostbanner_gfx_interval=0 virtualserver_complain_autoban_count=5 virtualserver_complain_autoban_time=1200 virtualserver_complain_remove_time=3600 virtualserver_min_clients_in_channel_before_forced_silence=100 virtualserver_priority_speaker_dimm_modificator=-18.0000 virtualserver_antiflood_points_tick_reduce=5 virtualserver_antiflood_points_needed_command_block=150 virtualserver_antiflood_points_needed_ip_block=250 virtualserver_client_connections=2556 virtualserver_query_client_connections=84223 virtualserver_hostbutton_tooltip=Multiplay\sGame\sServers virtualserver_queryclientsonline=0 virtualserver_download_quota=18446744073709551615 virtualserver_upload_quota=18446744073709551615 virtualserver_month_bytes_downloaded=0 virtualserver_month_bytes_uploaded=0 virtualserver_total_bytes_downloaded=17282863873 virtualserver_total_bytes_uploaded=8719954284 virtualserver_port=9987 virtualserver_autostart=1 virtualserver_needed_identity_security_level=8 virtualserver_log_channel=0 virtualserver_log_client=0 virtualserver_log_filetransfer=0 virtualserver_log_permissions=1 virtualserver_log_query=0 virtualserver_log_server=0 virtualserver_min_client_version=0 virtualserver_name_phonetic virtualserver_icon_id=0 virtualserver_reserved_slots=0 virtualserver_total_packetloss_speech=0.0000 virtualserver_total_packetloss_keepalive=0.0000 virtualserver_total_packetloss_control=0.0000 virtualserver_total_packetloss_total=0.0000 virtualserver_total_ping=0 virtualserver_weblist_enabled=1 virtualserver_hostbanner_mode=0 virtualserver_channel_temp_delete_delay_default=0 virtualserver_min_android_version=0 virtualserver_min_ios_version=0 virtualserver_status=online connection_filetransfer_bandwidth_sent=0 connection_filetransfer_bandwidth_received=0 connection_filetransfer_bytes_sent_total=1119299288 connection_filetransfer_bytes_received_total=383216474 connection_packets_sent_speech=323798306 connection_bytes_sent_speech=44239747535 connection_packets_received_speech=176899777 connection_bytes_received_speech=24384042693 connection_packets_sent_keepalive=55749607 connection_bytes_sent_keepalive=2285733887 connection_packets_received_keepalive=55668655 connection_bytes_received_keepalive=2338194933 connection_packets_sent_control=2392370 connection_bytes_sent_control=529512085 connection_packets_received_control=2392484 connection_bytes_received_control=228820306 connection_packets_sent_total=381940283 connection_bytes_sent_total=47054993507 connection_packets_received_total=234960916 connection_bytes_received_total=26951057932 connection_bandwidth_sent_last_second_total=24512 connection_bandwidth_sent_last_minute_total=10681 connection_bandwidth_received_last_second_total=12427 connection_bandwidth_received_last_minute_total=5527 virtualserver_hostbanner_gfx_url`, "servercreate": `sid=2 virtualserver_port=9988 token=eKnFZQ9EK7G7MhtuQB6+N2B1PNZZ6OZL3ycDp2OW`, "serveridgetbyport": `server_id=1`, "servergrouplist": `sgid=1 name=Guest\sServer\sQuery type=2 iconid=0 savedb=0 sortid=0 namemode=0 n_modifyp=0 n_member_addp=0 n_member_removep=0|sgid=2 name=Admin\sServer\sQuery type=2 iconid=500 savedb=1 sortid=0 namemode=0 n_modifyp=100 n_member_addp=100 n_member_removep=100`, @@ -36,8 +36,8 @@ var ( "serverstop": "", "serverstart": "", "serveredit": "", - "instanceinfo": "serverinstance_database_version=26 serverinstance_filetransfer_port=30033 serverinstance_max_download_total_bandwidth=18446744073709551615 serverinstance_max_upload_total_bandwidth=18446744073709551615 serverinstance_guest_serverquery_group=1 serverinstance_serverquery_flood_commands=50 serverinstance_serverquery_flood_time=3 serverinstance_serverquery_ban_time=600 serverinstance_template_serveradmin_group=3 serverinstance_template_serverdefault_group=5 serverinstance_template_channeladmin_group=1 serverinstance_template_channeldefault_group=4 serverinstance_permissions_version=19 serverinstance_pending_connections_per_ip=0", - "serverrequestconnectioninfo": "connection_filetransfer_bandwidth_sent=0 connection_filetransfer_bandwidth_received=0 connection_filetransfer_bytes_sent_total=617 connection_filetransfer_bytes_received_total=0 connection_packets_sent_total=926413 connection_bytes_sent_total=92911395 connection_packets_received_total=650335 connection_bytes_received_total=61940731 connection_bandwidth_sent_last_second_total=0 connection_bandwidth_sent_last_minute_total=0 connection_bandwidth_received_last_second_total=0 connection_bandwidth_received_last_minute_total=0 connection_connected_time=49408 connection_packetloss_total=0.0000 connection_ping=0.0000 connection_packets_sent_speech=320432180 connection_bytes_sent_speech=43805818511 connection_packets_received_speech=174885295 connection_bytes_received_speech=24127808273 connection_packets_sent_keepalive=55230363 connection_bytes_sent_keepalive=2264444883 connection_packets_received_keepalive=55149547 connection_bytes_received_keepalive=2316390993 connection_packets_sent_control=2376088 connection_bytes_sent_control=525691022 connection_packets_received_control=2376138 connection_bytes_received_control=227044870", + "instanceinfo": "serverinstance_database_version=26 serverinstance_filetransfer_port=30033 serverinstance_max_download_total_bandwidth=18446744073709551615 serverinstance_max_upload_total_bandwidth=18446744073709551615 serverinstance_guest_serverquery_group=1 serverinstance_serverquery_flood_commands=50 serverinstance_serverquery_flood_time=3 serverinstance_serverquery_ban_time=600 serverinstance_template_serveradmin_group=3 serverinstance_template_serverdefault_group=5 serverinstance_template_channeladmin_group=1 serverinstance_template_channeldefault_group=4 serverinstance_permissions_version=19 serverinstance_pending_connections_per_ip=0 serverinstance_serverquery_max_connections_per_ip=5", + "serverrequestconnectioninfo": "connection_filetransfer_bandwidth_sent=0 connection_filetransfer_bandwidth_received=0 connection_filetransfer_bytes_sent_total=617 connection_filetransfer_bytes_received_total=0 connection_packets_sent_total=926413 connection_bytes_sent_total=92911395 connection_packets_received_total=650335 connection_bytes_received_total=61940731 connection_bandwidth_sent_last_second_total=0 connection_bandwidth_sent_last_minute_total=0 connection_bandwidth_received_last_second_total=0 connection_bandwidth_received_last_minute_total=0 connection_connected_time=49408 connection_packetloss_total=0.0002 connection_ping=18.0000", "channellist": "cid=499 pid=0 channel_order=0 channel_name=Default\\sChannel total_clients=1 channel_needed_subscribe_power=0", "clientlist": "clid=5 cid=7 client_database_id=40 client_nickname=ScP client_type=0 client_away=1 client_away_message=not\\shere", "clientdblist": "cldbid=7 client_unique_identifier=DZhdQU58qyooEK4Fr8Ly738hEmc= client_nickname=MuhChy client_created=1259147468 client_lastconnected=1259421233", diff --git a/server_cmds.go b/server_cmds.go index 411af27..4e102f7 100644 --- a/server_cmds.go +++ b/server_cmds.go @@ -15,129 +15,156 @@ type ServerMethods struct { } // Instance represents basic information for a TeamSpeak 3 instance. +// This is the result of an instanceinfo call. 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"` + DatabaseVersion int `ms:"serverinstance_database_version"` + FileTransferPort uint16 `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"` + ServerQueryMaxConnectionsPerIP int `ms:"serverinstance_serverquery_max_connections_per_ip"` } // ServerConnectionInfo represents the connection info for a TeamSpeak 3 instance. +// This is the result of an serverrequestconnectioninfo call. 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"` + ConnectedTime time.Duration `ms:"connection_connected_time"` + Ping float64 `ms:"connection_ping"` + PacketlossTotal float64 `ms:"connection_packetloss_total"` + FileTransferBandwidthSent uint64 `ms:"connection_filetransfer_bandwidth_sent"` + FileTransferBandwidthReceived uint64 `ms:"connection_filetransfer_bandwidth_received"` + FileTransferBytesSentTotal uint64 `ms:"connection_filetransfer_bytes_sent_total"` + FileTransferBytesReceivedTotal 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"` +} + +// convert duration nanoseconds to seconds +func (obj *ServerConnectionInfo) Info() { + obj.ConnectedTime *= time.Second } // Server represents a TeamSpeak 3 virtual server. +// This is the result of an serverinfo call. 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"` + UniqueIdentifier string `ms:"virtualserver_unique_identifier"` + Name string `ms:"virtualserver_name"` + WelcomeMessage string `ms:"virtualserver_welcomemessage"` + Platform string `ms:"virtualserver_platform"` + Version string `ms:"virtualserver_version"` + Password string `ms:"virtualserver_password"` + HostMessage string `ms:"virtualserver_hostmessage"` + FileBase string `ms:"virtualserver_filebase"` + HostBannerURL string `ms:"virtualserver_hostbanner_url"` + HostBannerGFXURL string `ms:"virtualserver_hostbanner_gfx_url"` + HostButtonToolTip string `ms:"virtualserver_hostbutton_tooltip"` + HostButtonURL string `ms:"virtualserver_hostbutton_url"` + HostButtonGFXURL string `ms:"virtualserver_hostbutton_gfx_url"` + MachineID string `ms:"virtualserver_machine_id"` + NamePhonetic string `ms:"virtualserver_name_phonetic"` + IP string `ms:"virtualserver_ip"` + Nickname string `ms:"virtualserver_nickname"` + Status string `ms:"virtualserver_status"` + Created time.Time `ms:"virtualserver_created"` + MaxDownloadTotalBandwidth uint64 `ms:"virtualserver_max_download_total_bandwidth"` + MaxUploadTotalBandwidth uint64 `ms:"virtualserver_max_upload_total_bandwidth"` + ClientConnections uint64 `ms:"virtualserver_client_connections"` + QueryClientConnections uint64 `ms:"virtualserver_query_client_connections"` + DownloadQuota uint64 `ms:"virtualserver_download_quota"` + UploadQuota uint64 `ms:"virtualserver_upload_quota"` + FileTransferBandwidthSent uint64 `ms:"connection_filetransfer_bandwidth_sent"` + FileTransferBandwidthReceived uint64 `ms:"connection_filetransfer_bandwidth_received"` + FileTransferBytesSentTotal uint64 `ms:"connection_filetransfer_bytes_sent_total"` + FileTransferBytesReceivedTotal uint64 `ms:"connection_filetransfer_bytes_received_total"` + PacketsSentSpeech uint64 `ms:"connection_packets_sent_speech"` + BytesSentSpeech uint64 `ms:"connection_bytes_sent_speech"` + PacketsReceivedSpeech uint64 `ms:"connection_packets_received_speech"` + BytesReceivedSpeech uint64 `ms:"connection_bytes_received_speech"` + PacketsSentKeepalive uint64 `ms:"connection_packets_sent_keepalive"` + BytesSentKeepalive uint64 `ms:"connection_bytes_sent_keepalive"` + PacketsReceivedKeepalive uint64 `ms:"connection_packets_received_keepalive"` + BytesReceivedKeepalive uint64 `ms:"connection_bytes_received_keepalive"` + PacketsSentControl uint64 `ms:"connection_packets_sent_control"` + BytesSentControl uint64 `ms:"connection_bytes_sent_control"` + PacketsReceivedControl uint64 `ms:"connection_packets_received_control"` + BytesReceivedControl uint64 `ms:"connection_bytes_received_control"` + PacketsSentTotal uint64 `ms:"connection_packets_sent_total"` + BytesSentTotal uint64 `ms:"connection_bytes_sent_total"` + PacketsReceivedTotal uint64 `ms:"connection_packets_received_total"` + BytesReceivedTotal uint64 `ms:"connection_bytes_received_total"` + BandwidthSentLastSecondTotal uint64 `ms:"virtualserver_bandwidth_sent_last_second_total"` + BandwidthSentLastMinuteTotal uint64 `ms:"virtualserver_bandwidth_sent_last_minute_total"` + BandwidthReceivedLastSecondTotal uint64 `ms:"virtualserver_bandwidth_received_last_second_total"` + BandwidthReceivedLastMinuteTotal uint64 `ms:"virtualserver_bandwidth_received_last_minute_total"` + MonthBytesDownloaded uint64 `ms:"virtualserver_month_bytes_downloaded"` + MonthBytesUploaded uint64 `ms:"virtualserver_month_bytes_uploaded"` + TotalBytesDownloaded uint64 `ms:"virtualserver_total_bytes_downloaded"` + TotalBytesUploaded uint64 `ms:"virtualserver_total_bytes_uploaded"` + TotalPacketLossSpeech float64 `ms:"virtualserver_total_packetloss_speech"` + TotalPacketLossKeepalive float64 `ms:"virtualserver_total_packetloss_keepalive"` + TotalPacketLossControl float64 `ms:"virtualserver_total_packetloss_control"` + TotalPacketLossTotal float64 `ms:"virtualserver_total_packetloss_total"` + TotalPing float32 `ms:"virtualserver_total_ping"` + PrioritySpeakerDimmModificator float32 `ms:"virtualserver_priority_speaker_dimm_modificator"` + MaxClients uint16 `ms:"virtualserver_maxclients"` + ClientsOnline uint16 `ms:"virtualserver_clientsonline"` + ChannelsOnline uint16 `ms:"virtualserver_channelsonline"` + Uptime time.Duration `ms:"virtualserver_uptime"` + CodecEncryptionMode uint `ms:"virtualserver_codec_encryption_mode"` + HostMessageMode uint `ms:"virtualserver_hostmessage_mode"` + DefaultServerGroup uint `ms:"virtualserver_default_server_group"` + DefaultChannelGroup uint `ms:"virtualserver_default_channel_group"` + DefaultChannelAdminGroup uint `ms:"virtualserver_default_channel_admin_group"` + HostBannerGFXInterval uint `ms:"virtualserver_hostbanner_gfx_interval"` + ComplainAutoBanCount uint `ms:"virtualserver_complain_autoban_count"` + ComplainAutoBanTime uint `ms:"virtualserver_complain_autoban_time"` + ComplainRemoveTime uint `ms:"virtualserver_complain_remove_time"` + MinClientsInChannelBeforeForcedSilence uint `ms:"virtualserver_min_clients_in_channel_before_forced_silence"` + ID int `ms:"virtualserver_id"` + AntiFloodPointsTickReduce int `ms:"virtualserver_antiflood_points_tick_reduce"` + AntiFloodPointsNeededCommandBlock int `ms:"virtualserver_antiflood_points_needed_command_block"` + AntiFloodPointsNeededIPBlock int `ms:"virtualserver_antiflood_points_needed_ip_block"` + QueryClientsOnline uint16 `ms:"virtualserver_queryclientsonline"` + Port uint16 `ms:"virtualserver_port"` + FlagPassword bool `ms:"virtualserver_flag_password"` + AutoStart bool `ms:"virtualserver_autostart"` + WebListEnabled bool `ms:"virtualserver_web_list_enabled"` + LogPermissions bool `ms:"virtualserver_log_permissions"` + NeededIdentitySecurityLevel int `ms:"virtualserver_needed_identity_security_level"` + LogClient int `ms:"virtualserver_log_client"` + LogQuery int `ms:"virtualserver_log_query"` + LogChannel int `ms:"virtualserver_log_channel"` + LogServer int `ms:"virtualserver_log_server"` + LogFileTransfer int `ms:"virtualserver_log_filetransfer"` + MinClientVersion int `ms:"virtualserver_min_client_version"` + IconID int `ms:"virtualserver_icon_id"` + ReservedSlots int `ms:"virtualserver_reserved_slots"` + AskForPrivilegeKey int `ms:"virtualserver_ask_for_privilegekey"` + HostBannerMode int `ms:"virtualserver_hostbanner_mode"` + ChannelTempDeleteDelayDefault int `ms:"virtualserver_channel_temp_delete_delay_default"` + MinAndroidVersion int `ms:"virtualserver_min_android_version"` + MiniOSVersion int `ms:"virtualserver_min_ios_version"` + AntiFloodPointsNeededPluginBlock int `ms:"virtualserver_antiflood_points_needed_plugin_block"` +} + +// convert duration nanoseconds to seconds +func (obj *Server) Info() { + obj.Uptime *= time.Second } // List lists virtual servers. diff --git a/server_cmds_test.go b/server_cmds_test.go index 584fce5..1b0bba0 100644 --- a/server_cmds_test.go +++ b/server_cmds_test.go @@ -75,15 +75,19 @@ func TestCmdsServer(t *testing.T) { return } expected := &Server{ - Status: "template", + Status: "online", MaxClients: 32, Name: "Test Server", + Uptime: 6802178, + Port: 9987, + AutoStart: true, AntiFloodPointsNeededCommandBlock: 150, AntiFloodPointsNeededIPBlock: 250, AntiFloodPointsTickReduce: 5, ComplainAutoBanCount: 5, ComplainAutoBanTime: 1200, ComplainRemoveTime: 3600, + Created: time.Unix(2, 0), DefaultChannelAdminGroup: 1, DefaultChannelGroup: 4, DefaultServerGroup: 5, @@ -97,8 +101,37 @@ func TestCmdsServer(t *testing.T) { HostButtonToolTip: "Multiplay Game Servers", HostButtonURL: "http://www.multiplaygameservers.com", WelcomeMessage: "Welcome to TeamSpeak, check [URL]www.teamspeak.com[/URL] for latest infos.", - VirtualServerDownloadQuota: 18446744073709551615, - VirtualServerUploadQuota: 18446744073709551615, + DownloadQuota: 18446744073709551615, + UploadQuota: 18446744073709551615, + ClientConnections: 2556, + QueryClientConnections: 84223, + TotalBytesDownloaded: 17282863873, + TotalBytesUploaded: 8719954284, + TotalPacketLossSpeech: 0.0000, + TotalPacketLossKeepalive: 0.0000, + TotalPacketLossControl: 0.0000, + TotalPacketLossTotal: 0.0000, + TotalPing: 0.0000, + MinAndroidVersion: 0, + MiniOSVersion: 0, + FileTransferBytesSentTotal: 1119299288, + FileTransferBytesReceivedTotal: 383216474, + PacketsSentSpeech: 323798306, + BytesSentSpeech: 44239747535, + PacketsReceivedSpeech: 176899777, + BytesReceivedSpeech: 24384042693, + PacketsSentKeepalive: 55749607, + BytesSentKeepalive: 2285733887, + PacketsReceivedKeepalive: 55668655, + BytesReceivedKeepalive: 2338194933, + PacketsSentControl: 2392370, + BytesSentControl: 529512085, + PacketsReceivedControl: 2392484, + BytesReceivedControl: 228820306, + PacketsSentTotal: 381940283, + BytesSentTotal: 47054993507, + PacketsReceivedTotal: 234960916, + BytesReceivedTotal: 26951057932, } assert.Equal(t, expected, s) } @@ -188,33 +221,21 @@ func TestCmdsServer(t *testing.T) { return } expected := &ServerConnectionInfo{ - FileTransferBandwidthSent: 0, - FileTransferBandwidthReceived: 0, - FileTransferTotalSent: 617, - FileTransferTotalReceived: 0, - PacketsSentTotal: 926413, - PacketsReceivedTotal: 650335, - BytesSentTotal: 92911395, - BytesReceivedTotal: 61940731, - BandwidthSentLastSecond: 0, - BandwidthReceivedLastSecond: 0, - BandwidthSentLastMinute: 0, - BandwidthReceivedLastMinute: 0, - ConnectedTime: 49408, - PacketLossTotalAvg: 0.0, - PingTotalAvg: 0.0, - PacketsSentSpeech: 320432180, - PacketsReceivedSpeech: 174885295, - BytesSentSpeech: 43805818511, - BytesReceivedSpeech: 24127808273, - PacketsSentKeepalive: 55230363, - PacketsReceivedKeepalive: 55149547, - BytesSentKeepalive: 2264444883, - BytesReceivedKeepalive: 2316390993, - PacketsSentControl: 2376088, - PacketsReceivedControl: 2376138, - BytesSentControl: 525691022, - BytesReceivedControl: 227044870, + ConnectedTime: 49408, + Ping: 18.0000, + PacketlossTotal: 0.0002, + FileTransferBandwidthSent: 0, + FileTransferBandwidthReceived: 0, + FileTransferBytesSentTotal: 617, + FileTransferBytesReceivedTotal: 0, + PacketsSentTotal: 926413, + PacketsReceivedTotal: 650335, + BytesSentTotal: 92911395, + BytesReceivedTotal: 61940731, + BandwidthSentLastSecond: 0, + BandwidthReceivedLastSecond: 0, + BandwidthSentLastMinute: 0, + BandwidthReceivedLastMinute: 0, } assert.Equal(t, expected, ci) } @@ -225,20 +246,21 @@ func TestCmdsServer(t *testing.T) { return } expected := &Instance{ - DatabaseVersion: 26, - FileTransferPort: 30033, - MaxTotalDownloadBandwidth: 18446744073709551615, - MaxTotalUploadBandwidth: 18446744073709551615, - GuestServerQueryGroup: 1, - ServerQueryFloodCommands: 50, - ServerQueryFloodTime: 3, - ServerQueryBanTime: 600, - TemplateServerAdminGroup: 3, - TemplateServerDefaultGroup: 5, - TemplateChannelAdminGroup: 1, - TemplateChannelDefaultGroup: 4, - PermissionsVersion: 19, - PendingConnectionsPerIP: 0, + DatabaseVersion: 26, + FileTransferPort: 30033, + MaxTotalDownloadBandwidth: 18446744073709551615, + MaxTotalUploadBandwidth: 18446744073709551615, + GuestServerQueryGroup: 1, + ServerQueryFloodCommands: 50, + ServerQueryFloodTime: 3, + ServerQueryBanTime: 600, + TemplateServerAdminGroup: 3, + TemplateServerDefaultGroup: 5, + TemplateChannelAdminGroup: 1, + TemplateChannelDefaultGroup: 4, + PermissionsVersion: 19, + PendingConnectionsPerIP: 0, + ServerQueryMaxConnectionsPerIP: 5, } assert.Equal(t, expected, ii) }