From d3cbc0824867f92d43df89bf21318f1a0e4055df Mon Sep 17 00:00:00 2001 From: nico Date: Thu, 17 Oct 2019 03:46:15 +0200 Subject: [PATCH 01/16] query command overhaul cleared up serverinfo and hostinfo mixup some parameters where attached to the wrong argument eg. connection_packets_* parameter, which are not part of the hostinfo output instanceinfo + add ServerQueryMaxConnectionsPerIP hostinfo + add InstanceUptime + add HostTimestamp + add VirtualServersRunning serverinfo * order parameters + add connection_packets parameter to serverinfo group + add connection_bytes parameter to serverinfo group * add new mockserver values --- mockserver_test.go | 6 +- server_cmds.go | 216 ++++++++++++++++++++++++-------------------- server_cmds_test.go | 104 ++++++++++++--------- 3 files changed, 184 insertions(+), 142 deletions(-) diff --git a/mockserver_test.go b/mockserver_test.go index 4197d58..941fb5b 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_uptime=6802178 virtualserver_client_connections=2556 virtualserver_query_client_connections=84223 virtualserver_total_bytes_downloaded=17282863873 virtualserver_total_bytes_uploaded=8719954284 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 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 virtualserver_welcomemessage=Welcome\sto\sTeamSpeak,\scheck\s[URL]www.teamspeak.com[\/URL]\sfor\slatest\sinfos.`, "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.0000 connection_ping=0.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..d537672 100644 --- a/server_cmds.go +++ b/server_cmds.go @@ -15,129 +15,149 @@ type ServerMethods struct { } // Instance represents basic information for a TeamSpeak 3 instance. +// instanceinfo 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 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"` + ServerQueryMaxConnectionsPerIP int `ms:"serverinstance_serverquery_max_connections_per_ip"` } // ServerConnectionInfo represents the connection info for a TeamSpeak 3 instance. +// hostinfo 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"` + InstanceUptime uint64 `ms:"instance_uptime"` + HostTimestamp uint64 `ms:"host_timestamp_utc"` + VirtualServersRunning int `ms:"virtualservers_running_total"` + VirtualServersTotalMaxClients int `ms:"virtualservers_total_maxclients"` + VirtualServersTotalClientsOnline int `ms:"virtualservers_total_clients_online"` + VirtualServersTotalChannelsOnline int `ms:"virtualservers_total_channels_online"` + 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"` } // Server represents a TeamSpeak 3 virtual server. +// serverinfo 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"` + 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"` + MaxClients int `ms:"virtualserver_maxclients"` + Password string `ms:"virtualserver_password"` ClientsOnline int `ms:"virtualserver_clientsonline"` + ChannelsOnline int `ms:"virtualserver_channelsonline"` + Created int `ms:"virtualserver_created"` + Uptime int `ms:"virtualserver_uptime"` // TODO(steve): use time.Duration CodecEncryptionMode int `ms:"virtualserver_codec_encryption_mode"` + HostMessage string `ms:"virtualserver_hostmessage"` + HostMessageMode int `ms:"virtualserver_hostmessage_mode"` + FileBase string `ms:"virtualserver_filebase"` + DefaultServerGroup int `ms:"virtualserver_default_server_group"` + DefaultChannelGroup int `ms:"virtualserver_default_channel_group"` + FlagPassword bool `ms:"virtualserver_flag_password"` + DefaultChannelAdminGroup int `ms:"virtualserver_default_channel_admin_group"` + MaxDownloadTotalBandwidth uint64 `ms:"virtualserver_max_download_total_bandwidth"` + MaxUploadTotalBandwidth uint64 `ms:"virtualserver_max_upload_total_bandwidth"` + HostBannerURL string `ms:"virtualserver_hostbanner_url"` + HostBannerGFXURL string `ms:"virtualserver_hostbanner_gfx_url"` + HostBannerGFXInterval int `ms:"virtualserver_hostbanner_gfx_interval"` 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"` + PrioritySpeakerDimmModificator float32 `ms:"virtualserver_priority_speaker_dimm_modificator"` + 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"` + ClientConnections uint64 `ms:"virtualserver_client_connections"` + QueryClientConnections uint64 `ms:"virtualserver_query_client_connections"` + HostButtonToolTip string `ms:"virtualserver_hostbutton_tooltip"` + HostButtonURL string `ms:"virtualserver_hostbutton_url"` + HostButtonGFXURL string `ms:"virtualserver_hostbutton_gfx_url"` QueryClientsOnline int `ms:"virtualserver_queryclientsonline"` - Uptime int `ms:"virtualserver_uptime"` // TODO(steve): use time.Duration - AskForPrivilegeKey bool `ms:"virtualserver_ask_for_privilegekey"` + VirtualServerDownloadQuota uint64 `ms:"virtualserver_download_quota"` + VirtualServerUploadQuota uint64 `ms:"virtualserver_upload_quota"` + 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"` + Port int `ms:"virtualserver_port"` AutoStart bool `ms:"virtualserver_autostart"` - FlagPassword bool `ms:"virtualserver_flag_password"` - LogChannel bool `ms:"virtualserver_log_channel"` + MachineID string `ms:"virtualserver_machine_id"` + NeededIdentitySecurityLevel int `ms:"virtualserver_needed_identity_security_level"` LogClient bool `ms:"virtualserver_log_client"` - LogFileTransfer bool `ms:"virtualserver_log_filetransfer"` - LogPermissions bool `ms:"virtualserver_log_permissions"` LogQuery bool `ms:"virtualserver_log_client"` + LogChannel bool `ms:"virtualserver_log_channel"` + LogPermissions bool `ms:"virtualserver_log_permissions"` 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"` + LogFileTransfer bool `ms:"virtualserver_log_filetransfer"` MinClientVersion int `ms:"virtualserver_min_client_version"` - MiniOSVersion int `ms:"virtualserver_min_ios_version"` + NamePhonetic string `ms:"virtualserver_name_phonetic"` + IconID int `ms:"virtualserver_icon_id"` 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"` + TotalPacketLossKeepalive float64 `ms:"virtualserver_total_packetloss_keepalive"` + TotalPacketLossControl float64 `ms:"virtualserver_total_packetloss_control"` 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"` + TotalPing float32 `ms:"virtualserver_total_ping"` + IP string `ms:"virtualserver_ip"` + WebListEnabled bool `ms:"virtualserver_web_list_enabled"` + AskForPrivilegeKey bool `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"` + ServerNickname string `ms:"virtualserver_nickname"` + AntiFloodPointsNeededPluginBlock int `ms:"virtualserver_antiflood_points_needed_plugin_block"` Status string `ms:"virtualserver_status"` - UniqueIdentifier string `ms:"virtualserver_unique_identifier"` - Version string `ms:"virtualserver_version"` - WelcomeMessage string `ms:"virtualserver_welcomemessage"` + 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 int `ms:"virtualserver_bandwidth_sent_last_second_total"` + BandwidthSentLastMinuteTotal int `ms:"virtualserver_bandwidth_sent_last_minute_total"` + BandwidthReceivedLastSecondTotal int `ms:"virtualserver_bandwidth_received_last_second_total"` + BandwidthReceivedLastMinuteTotal int `ms:"virtualserver_bandwidth_received_last_minute_total"` } // List lists virtual servers. diff --git a/server_cmds_test.go b/server_cmds_test.go index 584fce5..d6ec404 100644 --- a/server_cmds_test.go +++ b/server_cmds_test.go @@ -78,6 +78,7 @@ func TestCmdsServer(t *testing.T) { Status: "template", MaxClients: 32, Name: "Test Server", + Uptime: 6802178, AntiFloodPointsNeededCommandBlock: 150, AntiFloodPointsNeededIPBlock: 250, AntiFloodPointsTickReduce: 5, @@ -99,6 +100,35 @@ func TestCmdsServer(t *testing.T) { WelcomeMessage: "Welcome to TeamSpeak, check [URL]www.teamspeak.com[/URL] for latest infos.", VirtualServerDownloadQuota: 18446744073709551615, VirtualServerUploadQuota: 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 +218,24 @@ 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, + InstanceUptime: 0, + HostTimestamp: 0, + VirtualServersRunning: 0, + VirtualServersTotalMaxClients: 0, + VirtualServersTotalClientsOnline: 0, + VirtualServersTotalChannelsOnline: 0, + 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) } From 33395138f42e43fdf16f2d11657a8d6f132695ca Mon Sep 17 00:00:00 2001 From: nico Date: Fri, 18 Oct 2019 10:18:38 +0200 Subject: [PATCH 02/16] * change bool to int serverinfo does not provide any boolean info --- server_cmds.go | 20 ++++++++++---------- server_cmds_test.go | 6 +++--- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/server_cmds.go b/server_cmds.go index d537672..3230981 100644 --- a/server_cmds.go +++ b/server_cmds.go @@ -77,7 +77,7 @@ type Server struct { FileBase string `ms:"virtualserver_filebase"` DefaultServerGroup int `ms:"virtualserver_default_server_group"` DefaultChannelGroup int `ms:"virtualserver_default_channel_group"` - FlagPassword bool `ms:"virtualserver_flag_password"` + FlagPassword int `ms:"virtualserver_flag_password"` DefaultChannelAdminGroup int `ms:"virtualserver_default_channel_admin_group"` MaxDownloadTotalBandwidth uint64 `ms:"virtualserver_max_download_total_bandwidth"` MaxUploadTotalBandwidth uint64 `ms:"virtualserver_max_upload_total_bandwidth"` @@ -106,15 +106,15 @@ type Server struct { TotalBytesDownloaded int64 `ms:"virtualserver_total_bytes_downloaded"` TotalBytesUploaded int64 `ms:"virtualserver_total_bytes_uploaded"` Port int `ms:"virtualserver_port"` - AutoStart bool `ms:"virtualserver_autostart"` + AutoStart int `ms:"virtualserver_autostart"` MachineID string `ms:"virtualserver_machine_id"` NeededIdentitySecurityLevel int `ms:"virtualserver_needed_identity_security_level"` - LogClient bool `ms:"virtualserver_log_client"` - LogQuery bool `ms:"virtualserver_log_client"` - LogChannel bool `ms:"virtualserver_log_channel"` - LogPermissions bool `ms:"virtualserver_log_permissions"` - LogServer bool `ms:"virtualserver_log_server"` - LogFileTransfer bool `ms:"virtualserver_log_filetransfer"` + LogClient int `ms:"virtualserver_log_client"` + LogQuery int `ms:"virtualserver_log_client"` + LogChannel int `ms:"virtualserver_log_channel"` + LogPermissions int `ms:"virtualserver_log_permissions"` + LogServer int `ms:"virtualserver_log_server"` + LogFileTransfer int `ms:"virtualserver_log_filetransfer"` MinClientVersion int `ms:"virtualserver_min_client_version"` NamePhonetic string `ms:"virtualserver_name_phonetic"` IconID int `ms:"virtualserver_icon_id"` @@ -125,8 +125,8 @@ type Server struct { TotalPacketLossTotal float64 `ms:"virtualserver_total_packetloss_total"` TotalPing float32 `ms:"virtualserver_total_ping"` IP string `ms:"virtualserver_ip"` - WebListEnabled bool `ms:"virtualserver_web_list_enabled"` - AskForPrivilegeKey bool `ms:"virtualserver_ask_for_privilegekey"` + WebListEnabled int `ms:"virtualserver_web_list_enabled"` + 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"` diff --git a/server_cmds_test.go b/server_cmds_test.go index d6ec404..0962232 100644 --- a/server_cmds_test.go +++ b/server_cmds_test.go @@ -40,7 +40,7 @@ func TestCmdsServer(t *testing.T) { MaxClients: 35, Uptime: 12345025, Name: "Server #1", - AutoStart: true, + AutoStart: 1, MachineID: "1", UniqueIdentifier: "uniq1", }, @@ -53,7 +53,7 @@ func TestCmdsServer(t *testing.T) { MaxClients: 10, Uptime: 3165117, Name: "Server #2", - AutoStart: true, + AutoStart: 1, MachineID: "1", UniqueIdentifier: "uniq2", }, @@ -90,7 +90,7 @@ func TestCmdsServer(t *testing.T) { DefaultServerGroup: 5, MinClientsInChannelBeforeForcedSilence: 100, NeededIdentitySecurityLevel: 8, - LogPermissions: true, + LogPermissions: 1, PrioritySpeakerDimmModificator: -18, MaxDownloadTotalBandwidth: 18446744073709551615, MaxUploadTotalBandwidth: 18446744073709551615, From 1603b8c67f616f4c2be9ef4d19c3d337c1ca0264 Mon Sep 17 00:00:00 2001 From: nico Date: Mon, 10 Feb 2020 14:58:55 +0100 Subject: [PATCH 03/16] fix malaligned struct * alignment fixup --- server_cmds.go | 120 ++++++++++++++++++++++++------------------------- 1 file changed, 60 insertions(+), 60 deletions(-) diff --git a/server_cmds.go b/server_cmds.go index 3230981..b206d26 100644 --- a/server_cmds.go +++ b/server_cmds.go @@ -65,75 +65,26 @@ type Server struct { WelcomeMessage string `ms:"virtualserver_welcomemessage"` Platform string `ms:"virtualserver_platform"` Version string `ms:"virtualserver_version"` - MaxClients int `ms:"virtualserver_maxclients"` Password string `ms:"virtualserver_password"` - ClientsOnline int `ms:"virtualserver_clientsonline"` - ChannelsOnline int `ms:"virtualserver_channelsonline"` - Created int `ms:"virtualserver_created"` - Uptime int `ms:"virtualserver_uptime"` // TODO(steve): use time.Duration - CodecEncryptionMode int `ms:"virtualserver_codec_encryption_mode"` HostMessage string `ms:"virtualserver_hostmessage"` - HostMessageMode int `ms:"virtualserver_hostmessage_mode"` FileBase string `ms:"virtualserver_filebase"` - DefaultServerGroup int `ms:"virtualserver_default_server_group"` - DefaultChannelGroup int `ms:"virtualserver_default_channel_group"` - FlagPassword int `ms:"virtualserver_flag_password"` - DefaultChannelAdminGroup int `ms:"virtualserver_default_channel_admin_group"` - MaxDownloadTotalBandwidth uint64 `ms:"virtualserver_max_download_total_bandwidth"` - MaxUploadTotalBandwidth uint64 `ms:"virtualserver_max_upload_total_bandwidth"` HostBannerURL string `ms:"virtualserver_hostbanner_url"` HostBannerGFXURL string `ms:"virtualserver_hostbanner_gfx_url"` - HostBannerGFXInterval int `ms:"virtualserver_hostbanner_gfx_interval"` - ComplainAutoBanCount int `ms:"virtualserver_complain_autoban_count"` - ComplainAutoBanTime int `ms:"virtualserver_complain_autoban_time"` - ComplainRemoveTime int `ms:"virtualserver_complain_remove_time"` - MinClientsInChannelBeforeForcedSilence int `ms:"virtualserver_min_clients_in_channel_before_forced_silence"` - PrioritySpeakerDimmModificator float32 `ms:"virtualserver_priority_speaker_dimm_modificator"` - 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"` - ClientConnections uint64 `ms:"virtualserver_client_connections"` - QueryClientConnections uint64 `ms:"virtualserver_query_client_connections"` HostButtonToolTip string `ms:"virtualserver_hostbutton_tooltip"` HostButtonURL string `ms:"virtualserver_hostbutton_url"` HostButtonGFXURL string `ms:"virtualserver_hostbutton_gfx_url"` - QueryClientsOnline int `ms:"virtualserver_queryclientsonline"` - VirtualServerDownloadQuota uint64 `ms:"virtualserver_download_quota"` - VirtualServerUploadQuota uint64 `ms:"virtualserver_upload_quota"` - 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"` - Port int `ms:"virtualserver_port"` - AutoStart int `ms:"virtualserver_autostart"` MachineID string `ms:"virtualserver_machine_id"` - NeededIdentitySecurityLevel int `ms:"virtualserver_needed_identity_security_level"` - LogClient int `ms:"virtualserver_log_client"` - LogQuery int `ms:"virtualserver_log_client"` - LogChannel int `ms:"virtualserver_log_channel"` - LogPermissions int `ms:"virtualserver_log_permissions"` - LogServer int `ms:"virtualserver_log_server"` - LogFileTransfer int `ms:"virtualserver_log_filetransfer"` - MinClientVersion int `ms:"virtualserver_min_client_version"` NamePhonetic string `ms:"virtualserver_name_phonetic"` - IconID int `ms:"virtualserver_icon_id"` - ReservedSlots int `ms:"virtualserver_reserved_slots"` - 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"` IP string `ms:"virtualserver_ip"` - WebListEnabled int `ms:"virtualserver_web_list_enabled"` - 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"` ServerNickname string `ms:"virtualserver_nickname"` - AntiFloodPointsNeededPluginBlock int `ms:"virtualserver_antiflood_points_needed_plugin_block"` Status string `ms:"virtualserver_status"` + Created uint64 `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"` + VirtualServerDownloadQuota uint64 `ms:"virtualserver_download_quota"` + VirtualServerUploadQuota 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"` @@ -154,10 +105,59 @@ type Server struct { BytesSentTotal uint64 `ms:"connection_bytes_sent_total"` PacketsReceivedTotal uint64 `ms:"connection_packets_received_total"` BytesReceivedTotal uint64 `ms:"connection_bytes_received_total"` - BandwidthSentLastSecondTotal int `ms:"virtualserver_bandwidth_sent_last_second_total"` - BandwidthSentLastMinuteTotal int `ms:"virtualserver_bandwidth_sent_last_minute_total"` - BandwidthReceivedLastSecondTotal int `ms:"virtualserver_bandwidth_received_last_second_total"` - BandwidthReceivedLastMinuteTotal int `ms:"virtualserver_bandwidth_received_last_minute_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 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"` + 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 int `ms:"virtualserver_uptime"` // TODO(steve): use time.Duration + 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"` + FlagPassword uint `ms:"virtualserver_flag_password"` + 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 int `ms:"virtualserver_queryclientsonline"` + Port int `ms:"virtualserver_port"` + AutoStart int `ms:"virtualserver_autostart"` + NeededIdentitySecurityLevel int `ms:"virtualserver_needed_identity_security_level"` + LogClient int `ms:"virtualserver_log_client"` + LogQuery int `ms:"virtualserver_log_client"` + LogChannel int `ms:"virtualserver_log_channel"` + LogPermissions int `ms:"virtualserver_log_permissions"` + 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"` + WebListEnabled int `ms:"virtualserver_web_list_enabled"` + 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"` } // List lists virtual servers. From 2b59f75d2db791f1d7d8be8b67a957526838b0fd Mon Sep 17 00:00:00 2001 From: nico Date: Fri, 3 Apr 2020 12:15:11 +0200 Subject: [PATCH 04/16] gitignore + add proper gitignore file --- .gitignore | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/.gitignore b/.gitignore index fb1aaf1..4a9c6f3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,32 @@ +# 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 + +# Dependency directories (remove the comment below to include it) +# vendor/ + +### Go Patch ### +/vendor/ +/Godeps/ + +# End of https://www.gitignore.io/api/go + +# temporary files *.swp *.tmp + +# GoLand +.idea From de416ee22c221954ee591fa06c476f8399e15ab1 Mon Sep 17 00:00:00 2001 From: nico Date: Fri, 3 Apr 2020 12:15:29 +0200 Subject: [PATCH 05/16] ajust to the change requests * update mockserver command output to better represent the latest server version * changed any uptime variable to use time.duration * update server_cmds_test file to represent the changes done to server_cmds.go --- mockserver_test.go | 2 +- server_cmds.go | 232 ++++++++++++++++++++++---------------------- server_cmds_test.go | 4 +- 3 files changed, 120 insertions(+), 118 deletions(-) diff --git a/mockserver_test.go b/mockserver_test.go index 941fb5b..4cf1ef6 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_uptime=6802178 virtualserver_client_connections=2556 virtualserver_query_client_connections=84223 virtualserver_total_bytes_downloaded=17282863873 virtualserver_total_bytes_uploaded=8719954284 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 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 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=0 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`, diff --git a/server_cmds.go b/server_cmds.go index b206d26..3b31bc4 100644 --- a/server_cmds.go +++ b/server_cmds.go @@ -37,127 +37,127 @@ type Instance struct { // ServerConnectionInfo represents the connection info for a TeamSpeak 3 instance. // hostinfo type ServerConnectionInfo struct { - InstanceUptime uint64 `ms:"instance_uptime"` - HostTimestamp uint64 `ms:"host_timestamp_utc"` - VirtualServersRunning int `ms:"virtualservers_running_total"` - VirtualServersTotalMaxClients int `ms:"virtualservers_total_maxclients"` - VirtualServersTotalClientsOnline int `ms:"virtualservers_total_clients_online"` - VirtualServersTotalChannelsOnline int `ms:"virtualservers_total_channels_online"` - 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"` + InstanceUptime time.Duration `ms:"instance_uptime"` + HostTimestamp uint64 `ms:"host_timestamp_utc"` + VirtualServersRunning int `ms:"virtualservers_running_total"` + VirtualServersTotalMaxClients int `ms:"virtualservers_total_maxclients"` + VirtualServersTotalClientsOnline int `ms:"virtualservers_total_clients_online"` + VirtualServersTotalChannelsOnline int `ms:"virtualservers_total_channels_online"` + 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"` } // Server represents a TeamSpeak 3 virtual server. // serverinfo type Server struct { - 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"` - ServerNickname string `ms:"virtualserver_nickname"` - Status string `ms:"virtualserver_status"` - Created uint64 `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"` - VirtualServerDownloadQuota uint64 `ms:"virtualserver_download_quota"` - VirtualServerUploadQuota 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 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"` - 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 int `ms:"virtualserver_uptime"` // TODO(steve): use time.Duration - 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"` - FlagPassword uint `ms:"virtualserver_flag_password"` - 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 int `ms:"virtualserver_queryclientsonline"` - Port int `ms:"virtualserver_port"` - AutoStart int `ms:"virtualserver_autostart"` - NeededIdentitySecurityLevel int `ms:"virtualserver_needed_identity_security_level"` - LogClient int `ms:"virtualserver_log_client"` - LogQuery int `ms:"virtualserver_log_client"` - LogChannel int `ms:"virtualserver_log_channel"` - LogPermissions int `ms:"virtualserver_log_permissions"` - 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"` - WebListEnabled int `ms:"virtualserver_web_list_enabled"` - 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"` + 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"` + ServerNickname string `ms:"virtualserver_nickname"` + Status string `ms:"virtualserver_status"` + Created uint64 `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"` + VirtualServerDownloadQuota uint64 `ms:"virtualserver_download_quota"` + VirtualServerUploadQuota 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 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"` + 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"` + FlagPassword uint `ms:"virtualserver_flag_password"` + 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 int `ms:"virtualserver_queryclientsonline"` + Port int `ms:"virtualserver_port"` + AutoStart int `ms:"virtualserver_autostart"` + NeededIdentitySecurityLevel int `ms:"virtualserver_needed_identity_security_level"` + LogClient int `ms:"virtualserver_log_client"` + LogQuery int `ms:"virtualserver_log_client"` + LogChannel int `ms:"virtualserver_log_channel"` + LogPermissions int `ms:"virtualserver_log_permissions"` + 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"` + WebListEnabled int `ms:"virtualserver_web_list_enabled"` + 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"` } // List lists virtual servers. diff --git a/server_cmds_test.go b/server_cmds_test.go index 0962232..09232b8 100644 --- a/server_cmds_test.go +++ b/server_cmds_test.go @@ -75,10 +75,12 @@ func TestCmdsServer(t *testing.T) { return } expected := &Server{ - Status: "template", + Status: "online", MaxClients: 32, Name: "Test Server", Uptime: 6802178, + Port: 9987, + AutoStart: 1, AntiFloodPointsNeededCommandBlock: 150, AntiFloodPointsNeededIPBlock: 250, AntiFloodPointsTickReduce: 5, From 6300cdedde5fcb5c712542dfbc6e85eb973afd35 Mon Sep 17 00:00:00 2001 From: nico Date: Fri, 3 Apr 2020 20:22:56 +0200 Subject: [PATCH 06/16] naming inconsistency * fix naming inconsistancy --- server_cmds.go | 4 ++-- server_cmds_test.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/server_cmds.go b/server_cmds.go index 3b31bc4..3a50b1f 100644 --- a/server_cmds.go +++ b/server_cmds.go @@ -83,8 +83,8 @@ type Server struct { MaxUploadTotalBandwidth uint64 `ms:"virtualserver_max_upload_total_bandwidth"` ClientConnections uint64 `ms:"virtualserver_client_connections"` QueryClientConnections uint64 `ms:"virtualserver_query_client_connections"` - VirtualServerDownloadQuota uint64 `ms:"virtualserver_download_quota"` - VirtualServerUploadQuota uint64 `ms:"virtualserver_upload_quota"` + 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"` diff --git a/server_cmds_test.go b/server_cmds_test.go index 09232b8..9bcf378 100644 --- a/server_cmds_test.go +++ b/server_cmds_test.go @@ -100,8 +100,8 @@ 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, From aef3073aca08f2e5b2158418e3a13d56c891d89d Mon Sep 17 00:00:00 2001 From: nico Date: Fri, 3 Apr 2020 20:30:43 +0200 Subject: [PATCH 07/16] type changes * ajust port types to uint16 --- basic_cmds.go | 2 +- server_cmds.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) 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/server_cmds.go b/server_cmds.go index 3a50b1f..5f1dcfc 100644 --- a/server_cmds.go +++ b/server_cmds.go @@ -18,7 +18,7 @@ type ServerMethods struct { // instanceinfo type Instance struct { DatabaseVersion int `ms:"serverinstance_database_version"` - FileTransferPort int `ms:"serverinstance_filetransfer_port"` + 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"` @@ -138,8 +138,8 @@ type Server struct { 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 int `ms:"virtualserver_queryclientsonline"` - Port int `ms:"virtualserver_port"` + QueryClientsOnline uint16 `ms:"virtualserver_queryclientsonline"` + Port uint16 `ms:"virtualserver_port"` AutoStart int `ms:"virtualserver_autostart"` NeededIdentitySecurityLevel int `ms:"virtualserver_needed_identity_security_level"` LogClient int `ms:"virtualserver_log_client"` From a7f6d12162a3888f81f7657493b0e5f0bc726d53 Mon Sep 17 00:00:00 2001 From: nico Date: Fri, 3 Apr 2020 20:48:27 +0200 Subject: [PATCH 08/16] even more typing * ajust "total" values to use uint16 instead of int * ajust timestamps to use uint64 to give some headroom --- server_cmds.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/server_cmds.go b/server_cmds.go index 5f1dcfc..c37c856 100644 --- a/server_cmds.go +++ b/server_cmds.go @@ -38,11 +38,11 @@ type Instance struct { // hostinfo type ServerConnectionInfo struct { InstanceUptime time.Duration `ms:"instance_uptime"` - HostTimestamp uint64 `ms:"host_timestamp_utc"` - VirtualServersRunning int `ms:"virtualservers_running_total"` - VirtualServersTotalMaxClients int `ms:"virtualservers_total_maxclients"` - VirtualServersTotalClientsOnline int `ms:"virtualservers_total_clients_online"` - VirtualServersTotalChannelsOnline int `ms:"virtualservers_total_channels_online"` + HostTimestamp int64 `ms:"host_timestamp_utc"` + VirtualServersRunning uint `ms:"virtualservers_running_total"` + VirtualServersTotalMaxClients uint16 `ms:"virtualservers_total_maxclients"` + VirtualServersTotalClientsOnline uint16 `ms:"virtualservers_total_clients_online"` + VirtualServersTotalChannelsOnline uint16 `ms:"virtualservers_total_channels_online"` FileTransferBandwidthSent uint64 `ms:"connection_filetransfer_bandwidth_sent"` FileTransferBandwidthReceived uint64 `ms:"connection_filetransfer_bandwidth_received"` FileTransferBytesSentTotal uint64 `ms:"connection_filetransfer_bytes_sent_total"` @@ -78,7 +78,7 @@ type Server struct { IP string `ms:"virtualserver_ip"` ServerNickname string `ms:"virtualserver_nickname"` Status string `ms:"virtualserver_status"` - Created uint64 `ms:"virtualserver_created"` + Created int64 `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"` From 45a609b1209af3e839ce2d37365d3dcdfe18f236 Mon Sep 17 00:00:00 2001 From: nico Date: Fri, 3 Apr 2020 21:00:40 +0200 Subject: [PATCH 09/16] Update .gitignore Co-Authored-By: Steven Hartland --- .gitignore | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.gitignore b/.gitignore index 4a9c6f3..aba871c 100644 --- a/.gitignore +++ b/.gitignore @@ -15,12 +15,6 @@ # Output of the go coverage tool, specifically when used with LiteIDE *.out -# Dependency directories (remove the comment below to include it) -# vendor/ - -### Go Patch ### -/vendor/ -/Godeps/ # End of https://www.gitignore.io/api/go From aba917450e8ba97625f9e8638c1cdd38c84025d4 Mon Sep 17 00:00:00 2001 From: nico Date: Fri, 3 Apr 2020 21:04:38 +0200 Subject: [PATCH 10/16] proper code comments * update code commentary to feature proper sentences --- server_cmds.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server_cmds.go b/server_cmds.go index c37c856..3b82c76 100644 --- a/server_cmds.go +++ b/server_cmds.go @@ -15,7 +15,7 @@ type ServerMethods struct { } // Instance represents basic information for a TeamSpeak 3 instance. -// instanceinfo +// This is the result of an instanceinfo call. type Instance struct { DatabaseVersion int `ms:"serverinstance_database_version"` FileTransferPort uint16 `ms:"serverinstance_filetransfer_port"` @@ -35,7 +35,7 @@ type Instance struct { } // ServerConnectionInfo represents the connection info for a TeamSpeak 3 instance. -// hostinfo +// This is the result of an hostinfo call. type ServerConnectionInfo struct { InstanceUptime time.Duration `ms:"instance_uptime"` HostTimestamp int64 `ms:"host_timestamp_utc"` @@ -58,7 +58,7 @@ type ServerConnectionInfo struct { } // Server represents a TeamSpeak 3 virtual server. -// serverinfo +// This is the result of an serverinfo call. type Server struct { UniqueIdentifier string `ms:"virtualserver_unique_identifier"` Name string `ms:"virtualserver_name"` From 4e5e81d9af97fbb966d21e8f384c74e86a1c342e Mon Sep 17 00:00:00 2001 From: nico Date: Fri, 3 Apr 2020 21:05:50 +0200 Subject: [PATCH 11/16] tpying changes * change bytes downloaded/uploaded values to uint64 --- server_cmds.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server_cmds.go b/server_cmds.go index 3b82c76..debe445 100644 --- a/server_cmds.go +++ b/server_cmds.go @@ -109,10 +109,10 @@ type Server struct { 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 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"` + 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"` From 6985b1227dc456bcc75c2615a298323fa7469e72 Mon Sep 17 00:00:00 2001 From: nico Date: Fri, 3 Apr 2020 21:27:54 +0200 Subject: [PATCH 12/16] change flags * change flags to use boolean reponses --- server_cmds.go | 6 +++--- server_cmds_test.go | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/server_cmds.go b/server_cmds.go index debe445..174623a 100644 --- a/server_cmds.go +++ b/server_cmds.go @@ -127,7 +127,6 @@ type Server struct { HostMessageMode uint `ms:"virtualserver_hostmessage_mode"` DefaultServerGroup uint `ms:"virtualserver_default_server_group"` DefaultChannelGroup uint `ms:"virtualserver_default_channel_group"` - FlagPassword uint `ms:"virtualserver_flag_password"` DefaultChannelAdminGroup uint `ms:"virtualserver_default_channel_admin_group"` HostBannerGFXInterval uint `ms:"virtualserver_hostbanner_gfx_interval"` ComplainAutoBanCount uint `ms:"virtualserver_complain_autoban_count"` @@ -140,7 +139,9 @@ type Server struct { AntiFloodPointsNeededIPBlock int `ms:"virtualserver_antiflood_points_needed_ip_block"` QueryClientsOnline uint16 `ms:"virtualserver_queryclientsonline"` Port uint16 `ms:"virtualserver_port"` - AutoStart int `ms:"virtualserver_autostart"` + FlagPassword bool `ms:"virtualserver_flag_password"` + AutoStart bool `ms:"virtualserver_autostart"` + WebListEnabled bool `ms:"virtualserver_web_list_enabled"` NeededIdentitySecurityLevel int `ms:"virtualserver_needed_identity_security_level"` LogClient int `ms:"virtualserver_log_client"` LogQuery int `ms:"virtualserver_log_client"` @@ -151,7 +152,6 @@ type Server struct { MinClientVersion int `ms:"virtualserver_min_client_version"` IconID int `ms:"virtualserver_icon_id"` ReservedSlots int `ms:"virtualserver_reserved_slots"` - WebListEnabled int `ms:"virtualserver_web_list_enabled"` AskForPrivilegeKey int `ms:"virtualserver_ask_for_privilegekey"` HostBannerMode int `ms:"virtualserver_hostbanner_mode"` ChannelTempDeleteDelayDefault int `ms:"virtualserver_channel_temp_delete_delay_default"` diff --git a/server_cmds_test.go b/server_cmds_test.go index 9bcf378..2d996ca 100644 --- a/server_cmds_test.go +++ b/server_cmds_test.go @@ -40,7 +40,7 @@ func TestCmdsServer(t *testing.T) { MaxClients: 35, Uptime: 12345025, Name: "Server #1", - AutoStart: 1, + AutoStart: true, MachineID: "1", UniqueIdentifier: "uniq1", }, @@ -53,7 +53,7 @@ func TestCmdsServer(t *testing.T) { MaxClients: 10, Uptime: 3165117, Name: "Server #2", - AutoStart: 1, + AutoStart: true, MachineID: "1", UniqueIdentifier: "uniq2", }, @@ -80,7 +80,7 @@ func TestCmdsServer(t *testing.T) { Name: "Test Server", Uptime: 6802178, Port: 9987, - AutoStart: 1, + AutoStart: true, AntiFloodPointsNeededCommandBlock: 150, AntiFloodPointsNeededIPBlock: 250, AntiFloodPointsTickReduce: 5, From 26218033a3465ca4c01dcc158080d3d6262590d0 Mon Sep 17 00:00:00 2001 From: nico Date: Fri, 3 Apr 2020 23:19:33 +0200 Subject: [PATCH 13/16] proper timestamping * ajusted values that return a timestamp to prase as a timestamp * replaced the serverrequestconnectioninfo with hostinfo as the correct request in that place serverrequestconnectioninfo does not feature values like the hosttimestamp or virtualservers_running * ajusted the testcode to now feature hostinfo calls and not serverrequestconnectioninfo calls --- mockserver_test.go | 3 ++- server_cmds.go | 6 +++--- server_cmds_test.go | 35 ++++++++++++++++++----------------- 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/mockserver_test.go b/mockserver_test.go index 4cf1ef6..146f17c 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_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=0 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`, + "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`, @@ -38,6 +38,7 @@ var ( "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 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.0000 connection_ping=0.0000", + "hostinfo": "connection_bandwidth_received_last_minute_total=21937 connection_bandwidth_received_last_second_total=15808 connection_bandwidth_sent_last_minute_total=34812 connection_bandwidth_sent_last_second_total=21658 connection_bytes_received_total=225042194 connection_bytes_sent_total=364806232 connection_filetransfer_bandwidth_received=0 connection_filetransfer_bandwidth_sent=0 connection_filetransfer_bytes_received_total=0 connection_filetransfer_bytes_sent_total=161567 connection_packets_received_total=2120792 connection_packets_sent_total=3174950 host_timestamp_utc=1585943585 instance_uptime=29201 virtualservers_running_total=1 virtualservers_total_channels_online=70 virtualservers_total_clients_online=118 virtualservers_total_maxclients=512", "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 174623a..34b3d04 100644 --- a/server_cmds.go +++ b/server_cmds.go @@ -38,7 +38,7 @@ type Instance struct { // This is the result of an hostinfo call. type ServerConnectionInfo struct { InstanceUptime time.Duration `ms:"instance_uptime"` - HostTimestamp int64 `ms:"host_timestamp_utc"` + HostTimestamp time.Time `ms:"host_timestamp_utc"` VirtualServersRunning uint `ms:"virtualservers_running_total"` VirtualServersTotalMaxClients uint16 `ms:"virtualservers_total_maxclients"` VirtualServersTotalClientsOnline uint16 `ms:"virtualservers_total_clients_online"` @@ -78,7 +78,7 @@ type Server struct { IP string `ms:"virtualserver_ip"` ServerNickname string `ms:"virtualserver_nickname"` Status string `ms:"virtualserver_status"` - Created int64 `ms:"virtualserver_created"` + 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"` @@ -239,7 +239,7 @@ func (s *ServerMethods) InstanceInfo() (*Instance, error) { // ServerConnectionInfo returns detailed bandwidth and transfer information about the selected instance. func (s *ServerMethods) ServerConnectionInfo() (*ServerConnectionInfo, error) { r := &ServerConnectionInfo{} - if _, err := s.ExecCmd(NewCmd("serverrequestconnectioninfo").WithResponse(&r)); err != nil { + if _, err := s.ExecCmd(NewCmd("hostinfo").WithResponse(&r)); err != nil { return nil, err } diff --git a/server_cmds_test.go b/server_cmds_test.go index 2d996ca..9287794 100644 --- a/server_cmds_test.go +++ b/server_cmds_test.go @@ -87,6 +87,7 @@ func TestCmdsServer(t *testing.T) { ComplainAutoBanCount: 5, ComplainAutoBanTime: 1200, ComplainRemoveTime: 3600, + Created: time.Unix(2, 0), DefaultChannelAdminGroup: 1, DefaultChannelGroup: 4, DefaultServerGroup: 5, @@ -214,30 +215,30 @@ func TestCmdsServer(t *testing.T) { assert.Equal(t, "zTfamFVhiMEzhTl49KrOVYaMilHPDQEBQOJFh6qX", token) } - serverrequestconnectioninfo := func(t *testing.T) { + hostinfo := func(t *testing.T) { ci, err := c.Server.ServerConnectionInfo() if !assert.NoError(t, err) { return } expected := &ServerConnectionInfo{ - InstanceUptime: 0, - HostTimestamp: 0, - VirtualServersRunning: 0, - VirtualServersTotalMaxClients: 0, - VirtualServersTotalClientsOnline: 0, - VirtualServersTotalChannelsOnline: 0, + InstanceUptime: 29201, + HostTimestamp: time.Unix(1585943585, 0), + VirtualServersRunning: 1, + VirtualServersTotalMaxClients: 512, + VirtualServersTotalClientsOnline: 118, + VirtualServersTotalChannelsOnline: 70, FileTransferBandwidthSent: 0, FileTransferBandwidthReceived: 0, - FileTransferBytesSentTotal: 617, + FileTransferBytesSentTotal: 161567, FileTransferBytesReceivedTotal: 0, - PacketsSentTotal: 926413, - PacketsReceivedTotal: 650335, - BytesSentTotal: 92911395, - BytesReceivedTotal: 61940731, - BandwidthSentLastSecond: 0, - BandwidthReceivedLastSecond: 0, - BandwidthSentLastMinute: 0, - BandwidthReceivedLastMinute: 0, + PacketsSentTotal: 3174950, + PacketsReceivedTotal: 2120792, + BytesSentTotal: 364806232, + BytesReceivedTotal: 225042194, + BandwidthSentLastSecond: 21658, + BandwidthReceivedLastSecond: 15808, + BandwidthSentLastMinute: 34812, + BandwidthReceivedLastMinute: 21937, } assert.Equal(t, expected, ci) } @@ -342,7 +343,7 @@ func TestCmdsServer(t *testing.T) { {"grouplist", grouplist}, {"privilegekeylist", privilegekeylist}, {"privilegekeyadd", privilegekeyadd}, - {"serverrequestconnectioninfo", serverrequestconnectioninfo}, + {"hostinfo", hostinfo}, {"instanceinfo", instanceinfo}, {"channellist", channellist}, {"clientlist", clientlist}, From 0ba8e34377c97da07917b7349d27cb5f0ddeebc1 Mon Sep 17 00:00:00 2001 From: nico Date: Fri, 3 Apr 2020 23:27:47 +0200 Subject: [PATCH 14/16] final fixup * change ServerNickname to Nickname * change LogPermissions to boolean * fixed LogQuery to actually use virtualserver_log_query --- server_cmds.go | 6 +++--- server_cmds_test.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/server_cmds.go b/server_cmds.go index 34b3d04..07082ff 100644 --- a/server_cmds.go +++ b/server_cmds.go @@ -76,7 +76,7 @@ type Server struct { MachineID string `ms:"virtualserver_machine_id"` NamePhonetic string `ms:"virtualserver_name_phonetic"` IP string `ms:"virtualserver_ip"` - ServerNickname string `ms:"virtualserver_nickname"` + Nickname string `ms:"virtualserver_nickname"` Status string `ms:"virtualserver_status"` Created time.Time `ms:"virtualserver_created"` MaxDownloadTotalBandwidth uint64 `ms:"virtualserver_max_download_total_bandwidth"` @@ -142,11 +142,11 @@ type Server struct { 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_client"` + LogQuery int `ms:"virtualserver_log_query"` LogChannel int `ms:"virtualserver_log_channel"` - LogPermissions int `ms:"virtualserver_log_permissions"` LogServer int `ms:"virtualserver_log_server"` LogFileTransfer int `ms:"virtualserver_log_filetransfer"` MinClientVersion int `ms:"virtualserver_min_client_version"` diff --git a/server_cmds_test.go b/server_cmds_test.go index 9287794..5b6bfe5 100644 --- a/server_cmds_test.go +++ b/server_cmds_test.go @@ -93,7 +93,7 @@ func TestCmdsServer(t *testing.T) { DefaultServerGroup: 5, MinClientsInChannelBeforeForcedSilence: 100, NeededIdentitySecurityLevel: 8, - LogPermissions: 1, + LogPermissions: true, PrioritySpeakerDimmModificator: -18, MaxDownloadTotalBandwidth: 18446744073709551615, MaxUploadTotalBandwidth: 18446744073709551615, From 8d25ba5af5d3b8118808b7edceb573a673db525d Mon Sep 17 00:00:00 2001 From: nico Date: Mon, 6 Apr 2020 16:35:17 +0200 Subject: [PATCH 15/16] correcting mistakes * partly reverse 0d3d6262590d0 serverrequestconnectioninfo was actually the correct call but the array I assign wasn't this fixes the array and correcty my rookie mistake --- mockserver_test.go | 3 +-- server_cmds.go | 37 +++++++++++++++++-------------------- server_cmds_test.go | 37 +++++++++++++++++-------------------- 3 files changed, 35 insertions(+), 42 deletions(-) diff --git a/mockserver_test.go b/mockserver_test.go index 146f17c..8278333 100644 --- a/mockserver_test.go +++ b/mockserver_test.go @@ -37,8 +37,7 @@ var ( "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 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.0000 connection_ping=0.0000", - "hostinfo": "connection_bandwidth_received_last_minute_total=21937 connection_bandwidth_received_last_second_total=15808 connection_bandwidth_sent_last_minute_total=34812 connection_bandwidth_sent_last_second_total=21658 connection_bytes_received_total=225042194 connection_bytes_sent_total=364806232 connection_filetransfer_bandwidth_received=0 connection_filetransfer_bandwidth_sent=0 connection_filetransfer_bytes_received_total=0 connection_filetransfer_bytes_sent_total=161567 connection_packets_received_total=2120792 connection_packets_sent_total=3174950 host_timestamp_utc=1585943585 instance_uptime=29201 virtualservers_running_total=1 virtualservers_total_channels_online=70 virtualservers_total_clients_online=118 virtualservers_total_maxclients=512", + "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 07082ff..fc7cc9e 100644 --- a/server_cmds.go +++ b/server_cmds.go @@ -35,26 +35,23 @@ type Instance struct { } // ServerConnectionInfo represents the connection info for a TeamSpeak 3 instance. -// This is the result of an hostinfo call. +// This is the result of an serverrequestconnectioninfo call. type ServerConnectionInfo struct { - InstanceUptime time.Duration `ms:"instance_uptime"` - HostTimestamp time.Time `ms:"host_timestamp_utc"` - VirtualServersRunning uint `ms:"virtualservers_running_total"` - VirtualServersTotalMaxClients uint16 `ms:"virtualservers_total_maxclients"` - VirtualServersTotalClientsOnline uint16 `ms:"virtualservers_total_clients_online"` - VirtualServersTotalChannelsOnline uint16 `ms:"virtualservers_total_channels_online"` - 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"` + 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"` } // Server represents a TeamSpeak 3 virtual server. @@ -239,7 +236,7 @@ func (s *ServerMethods) InstanceInfo() (*Instance, error) { // ServerConnectionInfo returns detailed bandwidth and transfer information about the selected instance. func (s *ServerMethods) ServerConnectionInfo() (*ServerConnectionInfo, error) { r := &ServerConnectionInfo{} - if _, err := s.ExecCmd(NewCmd("hostinfo").WithResponse(&r)); err != nil { + if _, err := s.ExecCmd(NewCmd("serverrequestconnectioninfo").WithResponse(&r)); err != nil { return nil, err } diff --git a/server_cmds_test.go b/server_cmds_test.go index 5b6bfe5..1b0bba0 100644 --- a/server_cmds_test.go +++ b/server_cmds_test.go @@ -215,30 +215,27 @@ func TestCmdsServer(t *testing.T) { assert.Equal(t, "zTfamFVhiMEzhTl49KrOVYaMilHPDQEBQOJFh6qX", token) } - hostinfo := func(t *testing.T) { + serverrequestconnectioninfo := func(t *testing.T) { ci, err := c.Server.ServerConnectionInfo() if !assert.NoError(t, err) { return } expected := &ServerConnectionInfo{ - InstanceUptime: 29201, - HostTimestamp: time.Unix(1585943585, 0), - VirtualServersRunning: 1, - VirtualServersTotalMaxClients: 512, - VirtualServersTotalClientsOnline: 118, - VirtualServersTotalChannelsOnline: 70, - FileTransferBandwidthSent: 0, - FileTransferBandwidthReceived: 0, - FileTransferBytesSentTotal: 161567, - FileTransferBytesReceivedTotal: 0, - PacketsSentTotal: 3174950, - PacketsReceivedTotal: 2120792, - BytesSentTotal: 364806232, - BytesReceivedTotal: 225042194, - BandwidthSentLastSecond: 21658, - BandwidthReceivedLastSecond: 15808, - BandwidthSentLastMinute: 34812, - BandwidthReceivedLastMinute: 21937, + 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) } @@ -343,7 +340,7 @@ func TestCmdsServer(t *testing.T) { {"grouplist", grouplist}, {"privilegekeylist", privilegekeylist}, {"privilegekeyadd", privilegekeyadd}, - {"hostinfo", hostinfo}, + {"serverrequestconnectioninfo", serverrequestconnectioninfo}, {"instanceinfo", instanceinfo}, {"channellist", channellist}, {"clientlist", clientlist}, From bb0a67561336c09832335ca60a74da96d2e053ad Mon Sep 17 00:00:00 2001 From: nico Date: Mon, 6 Apr 2020 23:30:50 +0200 Subject: [PATCH 16/16] durations ns 2 s + add struct function to convert time.duration nanoseconds to seconds --- server_cmds.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/server_cmds.go b/server_cmds.go index fc7cc9e..4e102f7 100644 --- a/server_cmds.go +++ b/server_cmds.go @@ -54,6 +54,11 @@ type ServerConnectionInfo struct { 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 { @@ -157,6 +162,11 @@ type Server struct { 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. // 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.