Skip to content

query command overhaul #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 16 commits into from
Closed

query command overhaul #29

wants to merge 16 commits into from

Conversation

mightyBroccoli
Copy link
Contributor

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

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
@mightyBroccoli mightyBroccoli marked this pull request as ready for review October 17, 2019 10:03
@mightyBroccoli
Copy link
Contributor Author

mightyBroccoli commented Oct 17, 2019

I really dont know why the first test results in
server_cmds.go:62:13: struct of size 880 bytes could be of size 856 bytes (maligned)

--edit
I can confirm that this pull request fully works and that the new field finally yield data :)

@stevenh
Copy link
Contributor

stevenh commented Oct 18, 2019

Your issue is the ordering of the fields, which means the struct is taking more space than it should.

This is caused by small types such as float32, bool etc.

You can download my pr from tyranron/golang-sizeof.tips#7 and run it locally which will allow you to visualise the issue.

* change bool to int

serverinfo does not provide any boolean info
Copy link
Contributor

@stevenh stevenh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switching the type is the wrong thing, see my detailed comment on the commit.

@mightyBroccoli
Copy link
Contributor Author

My last commit wasn't actually meant to fix the issue but fix an inherent issue. Those types I changed aren't actually booleans but integers.
Fixing the ordering issue is my next todo on the list.

* alignment fixup
@mightyBroccoli
Copy link
Contributor Author

Would someone mind to review this?

@mightyBroccoli
Copy link
Contributor Author

@stevenh would you mind to review my changes?

Copy link
Contributor

@stevenh stevenh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First off apologies for the delay in reviewing this, is saw the original notification but then forgot, I enabled the new slack reminders this week and it just popped up; so hopefully that will help me not loose them in the future :)

Anyway here's some feedback

+ add proper gitignore file
* 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
* fix naming inconsistancy
* ajust port types to uint16
* ajust "total" values to use uint16 instead of int
* ajust timestamps to use uint64 to give some headroom
Copy link
Contributor

@stevenh stevenh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Miss clicked, changes required.

mightyBroccoli and others added 5 commits April 3, 2020 21:00
Co-Authored-By: Steven Hartland <[email protected]>
* update code commentary to feature proper sentences
* change bytes downloaded/uploaded values to uint64
* change flags to use boolean reponses
* 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
@mightyBroccoli
Copy link
Contributor Author

I just noticed that the serverrequestconnectioninfo call was the incorrect call to retrieve the listed values. throughout the code the call hostinfo is used but not actually used.

* change ServerNickname to Nickname
* change LogPermissions to boolean
* fixed LogQuery to actually use virtualserver_log_query
@mightyBroccoli mightyBroccoli requested a review from stevenh April 6, 2020 11:00
MaxClients uint16 `ms:"virtualserver_maxclients"`
ClientsOnline uint16 `ms:"virtualserver_clientsonline"`
ChannelsOnline uint16 `ms:"virtualserver_channelsonline"`
Uptime time.Duration `ms:"virtualserver_uptime"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any custom unmarshaling or fix up so I think this will have the wrong value as uptime is reported in seconds not nano seconds, same for the other time.Duration fields.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am fairly new to Go, so would you mind to point me into a direction to fix this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am unsure if this method is "the" correct way to do this and I would love some feedback on this.
The good news is, it does work correctly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good question and truth be told there's no perfect way of doing it for a json unmarshal, but a good article which goes over the options is here:
https://blog.gopheracademy.com/advent-2016/advanced-encoding-decoding/

For ours however we're using mapstructure which has a custom decoding support.

I think we could extend the hook which is here:
https://github.com/multiplay/go-ts3/blob/master/helpers.go#L150

AntiFloodPointsNeededCommandBlock: 150,
AntiFloodPointsNeededIPBlock: 250,
AntiFloodPointsTickReduce: 5,
ComplainAutoBanCount: 5,
ComplainAutoBanTime: 1200,
ComplainRemoveTime: 3600,
Created: time.Unix(2, 0),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks wrong, I very much doubt it was created in 1970's

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aren't those values just for testing purposes only? I only increased the value to 2 to mitigate some weird boolean / integer mixup.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The values where real values from a real request, then confirmed to be the correct conversion where needed.

This helps avoid broken made up data.

* 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
+ add struct function to convert time.duration nanoseconds to seconds
AntiFloodPointsNeededCommandBlock: 150,
AntiFloodPointsNeededIPBlock: 250,
AntiFloodPointsTickReduce: 5,
ComplainAutoBanCount: 5,
ComplainAutoBanTime: 1200,
ComplainRemoveTime: 3600,
Created: time.Unix(2, 0),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The values where real values from a real request, then confirmed to be the correct conversion where needed.

This helps avoid broken made up data.

MaxClients uint16 `ms:"virtualserver_maxclients"`
ClientsOnline uint16 `ms:"virtualserver_clientsonline"`
ChannelsOnline uint16 `ms:"virtualserver_channelsonline"`
Uptime time.Duration `ms:"virtualserver_uptime"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good question and truth be told there's no perfect way of doing it for a json unmarshal, but a good article which goes over the options is here:
https://blog.gopheracademy.com/advent-2016/advanced-encoding-decoding/

For ours however we're using mapstructure which has a custom decoding support.

I think we could extend the hook which is here:
https://github.com/multiplay/go-ts3/blob/master/helpers.go#L150

BandwidthReceivedLastMinute uint64 `ms:"connection_bandwidth_received_last_minute_total"`
}

// convert duration nanoseconds to seconds
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would break if called multiple times, see the discussion on decoding below.

}

// convert duration nanoseconds to seconds
func (obj *Server) Info() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would break if called multiple times, see the discussion on decoding.

@mightyBroccoli mightyBroccoli closed this by deleting the head repository Aug 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants