-
Notifications
You must be signed in to change notification settings - Fork 21
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
query command overhaul #29
Conversation
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
I really dont know why the first test results in --edit |
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
There was a problem hiding this 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.
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. |
* alignment fixup
Would someone mind to review this? |
@stevenh would you mind to review my changes? |
There was a problem hiding this 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
* 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
There was a problem hiding this 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.
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
I just noticed that the |
* change ServerNickname to Nickname * change LogPermissions to boolean * fixed LogQuery to actually use virtualserver_log_query
MaxClients uint16 `ms:"virtualserver_maxclients"` | ||
ClientsOnline uint16 `ms:"virtualserver_clientsonline"` | ||
ChannelsOnline uint16 `ms:"virtualserver_channelsonline"` | ||
Uptime time.Duration `ms:"virtualserver_uptime"` |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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), |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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), |
There was a problem hiding this comment.
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"` |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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.
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
hostinfo
serverinfo