Skip to content
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

Implement Query protocol #218

Merged
merged 26 commits into from
Nov 5, 2024
Merged

Implement Query protocol #218

merged 26 commits into from
Nov 5, 2024

Conversation

neeleshpoli
Copy link
Contributor

@neeleshpoli neeleshpoli commented Oct 31, 2024

Description

This implements the Query protocol, supported by the vanilla server, to allow for a different way to get information about the server.

More info at protocol docs

Testing

Send test query packets using services like

Checklist

Things need to be done before this Pull Request can be merged.

  • Add query options to config
  • Added packet data types
  • Correctly handle config options
  • Correctly parse a handshake packet
  • Correctly respond to handshake packet
  • Correctly parse basic status packet
  • Correctly respond to basic status packet
  • Correctly parse full status packet
  • Correctly respond full status packet
  • Handle errors correctly
  • Update docs and README (Update docs for new config options from implementing query protocol, added navigation bar #228)
  • Code is well-formatted and adheres to project style guidelines: cargo fmt
  • Code does not produce any clippy warnings cargo clippy

Added packet data types
Correctly parse a handshake packet
Add tokio to pumpkin protocol for `AsyncReadExt` convenience functions
@Snowiiii
Copy link
Owner

Snowiiii commented Nov 3, 2024

I think you don't need to save the clients into a HashMap, Your example we also don't save RCON Clients into a hashmap: https://github.com/Snowiiii/Pumpkin/blob/master/pumpkin/src/rcon/mod.rs#L33. I also very dislike to have a Struct named "QueryClients"

@neeleshpoli
Copy link
Contributor Author

neeleshpoli commented Nov 3, 2024

Looking at RCON, since it uses TCP each client can take a TcpStream and not have to be saved in a central place. The thing is UDP is stateless, so there is nothing like a UdpStream where each client can own their connection. This means that the clients need to be stored in a central place and all packets can only be read from the socket.

What should I rename QueryClients to then?

Copy link
Contributor

@StripedMonkey StripedMonkey left a comment

Choose a reason for hiding this comment

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

Overall this looks great! I appreciate how self-contained this PR is. I have a couple of requested changes, but it's mostly to try and clean things up.

I won't complain if you said no to the extra work, but I would truly appreciate it if you wrote a handful of tests for some of the (de)serialization to validate the format. Just something which can be used to verify that a packet gets read (or written) in a way that means if someone comes through "cleaning" up this code, we can know it matches what we expect from your original implementation.

pumpkin-protocol/src/query.rs Outdated Show resolved Hide resolved
pumpkin-protocol/src/query.rs Outdated Show resolved Hide resolved
pumpkin-protocol/src/query.rs Outdated Show resolved Hide resolved
pumpkin-protocol/src/query.rs Outdated Show resolved Hide resolved
pumpkin-protocol/src/query.rs Outdated Show resolved Hide resolved
pumpkin-protocol/src/query.rs Outdated Show resolved Hide resolved
pumpkin/src/query.rs Outdated Show resolved Hide resolved
pumpkin/src/query.rs Outdated Show resolved Hide resolved
pumpkin/src/query.rs Outdated Show resolved Hide resolved
@neeleshpoli neeleshpoli marked this pull request as draft November 3, 2024 23:25
Break up en/decoding for each packet
Reduce client tracking
Get rid of QueryClients struct
Stop storing of magic value and check during decoding
Added tests for all decoding and encoding
Fix all sugestions from @StripedMonkey
@neeleshpoli neeleshpoli marked this pull request as ready for review November 5, 2024 18:26
@Snowiiii
Copy link
Owner

Snowiiii commented Nov 5, 2024

Just tested and it works pretty well. I also like the new changed code much more (Thanks @StripedMonkey for helping reviewing).
Overall excellent work @neeleshpoli, Thank you

@Snowiiii Snowiiii merged commit 93c6da9 into Snowiiii:master Nov 5, 2024
9 checks passed
@Snowiiii
Copy link
Owner

Snowiiii commented Nov 5, 2024

@neeleshpoli I just noticed that for some reason Query is on by default. It should be off by default

@Snowiiii
Copy link
Owner

Snowiiii commented Nov 5, 2024

@neeleshpoli I just noticed that for some reason Query is on by default. It should be off by default

Currently don't have time, if you want you can make a PR, I think it should be pretty easy to fix

lokka30 pushed a commit to lokka30/Pumpkin that referenced this pull request Nov 7, 2024
* Add query options to config
Added packet data types
Correctly parse a handshake packet
Add tokio to pumpkin protocol for `AsyncReadExt` convenience functions

* Add repr(u8) so that PacketType is a byte

* Respond to handshake correctly

* Allow for proper decoding of status packets and properly handle errors in decoding

* Implement challange tokens and verify with token and address

* Encode Basic status packet
Switch to CString since its better to and null errors higher up the code

* Encode Full status packet

* Add forgotten fields to full status packet

* Correctly respond to query clients when requesting full status

* Return actual address and port of server
Respect config options
Remove uncessary debug derives

* Remove packet type as it is redundant/unnecssary

* Implement basic status request
Refactor code for better error handling

* Update README

* Show players correctly in full status packet

* Store all packets in structs instead of enums
Break up en/decoding for each packet
Reduce client tracking
Get rid of QueryClients struct
Stop storing of magic value and check during decoding
Added tests for all decoding and encoding
Fix all sugestions from @StripedMonkey
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.

3 participants