ureq markets itself as a lightweight blocking HTTP client which might be
a good choice for rust-gamedig at the moment. However the main reason
for changing to ureq is that it allows setting a "resolver" function
which overrides the IP address to connect to. This is useful because it
allows us to pass a URL with the desired hostname without the HTTP
library doing an extra DNS lookup (this allows HTTPS to work when we
specify the exact IP and port to connect to external to the URL).
Other changes in this commit are:
- Feature gated things that depend on serde: this means that the eco
game won't be available if the library is compiled without serde
- Added the TLS feature to enable TLS support in the HTTP library
- Added HTTPSettings to set the protocol (HTTP/HTTPS) and the hostname
- Setting a user-agent string on HTTP requests (allows the server to see
what program is being used to query them)
- Store the address as a parsed Url so we don't re-parse it on every
request
- Add a method to POST JSON data and parse response
- Renamed the request() method to get_json() in anticipation of a future
method that will send a GET request and handle the raw bytes instead
of using serde
- Improved documentation
* tidy: Move TimeoutSettings out of protocol types
* tidy: Move game type to a types file
* tidy: Move generic query functions to own file
* tidy: Move ExtraRequestSettings to game types
* tidy: Move generic query functions into games module
* Revert "tidy: Move ExtraRequestSettings to game types"
This reverts commit aa0d23fc2acc12d68f03265a9caff6f98bf25054.
* Revert "tidy: Move TimeoutSettings out of protocol types"
This reverts commit 7ee10711ed11f17cc06565d4cc9102040d53a319.
* tidy: Re-export types needed for query at the root
* Add/Update badge
---------
Co-authored-by: GitHub Action <action@github.com>
* [Test] Add best effort test to validate game ID rules
An attempt to implement the rules specified in #108 as a programmatic
test.
* [Test] Refactor ID rules to check if a mod exists after - in game name
This allows fivem to pass the check following rule 8, but could also
cause a false pass in some cases.
* [Test] Add unit tests for ID rule checker
Adds unit tests based on the examples in CONTRIBUTING.md to confirm in
those cases we would allow ID to pass. However these tests don't check
any error cases.
* test/id: Correctly extract protocol names
* games/defs: Fix unreal tournament IDs
* tests: Require game definitions to run ID tests
* tests: Improve comments on ID tests
* tests/id: Combine - seperated numbers
* games/defs: Fix darkest hour ID
* Add/Update badge
---------
Co-authored-by: GitHub Action <action@github.com>
* feat: savage 2 support
* fix: add savage 2 to definitions
* chore: run rustfmt
* fix: config serde use
* fix: remove needless borrow
* docs: add savage 2 to protocols.md
* cli: Do DNS lookup if host is not an IP address
* cli: Add option to output as JSON
* cli: Pass hostname to ExtraRequestSettings if it isn't an IP
* cli: Add help docs to all arguments
* cli: Add options for all extra request settings
* cli: Use a CLI only error for DNS
* cli: Add option to set timeout settings
* docs: Update CHANGELOG
* cli: Add default values to TimeoutSettings
* cli: Refactor finding game definition into its own function
Co-Authored-By: Cain <75994858+cainthebest@users.noreply.github.com>
* cli: Refactor IP resolution into its own set of functions
Co-Authored-By: Cain <75994858+cainthebest@users.noreply.github.com>
* cli: Refactor output formatting into its own functions
Co-Authored-By: Cain <75994858+cainthebest@users.noreply.github.com>
* cli: Improve doc comments for CLI args and derive Debug
Co-Authored-By: Cain <75994858+cainthebest@users.noreply.github.com>
* protocols: Derive Serialize for versioned generic responses
This allows for serializing the output of as_original(). We cannot also
derive Deserialize here because the enums use references to the inner
types, which is unavoidable in the current implementation because
as_original() takes a reference to self.
* cli: Add the output mode options
This allows selected whether to use CommonResponse or the original
response struct when outputting.
* cli: Fix ExtraRequestSettings docs showing up in help output
* cli: Add help headings for timeouts and extra request settings
---------
Co-authored-by: Cain <75994858+cainthebest@users.noreply.github.com>
* protocols: Fix building without the "games" feature
* crate/lib: Add required features for examples
This prevents cargo from running the examples if the required features
aren't enabled.
* ci: Run if ANY Cargo.toml files are changed
* ci: Make sure to run unit tests
* ci: Separate checks for library and CLI
* ci: Add slightly better comments
* ci: Only run deeper tests for CLI or LIB when their files were changed
* ci: Improve act arguments for testing actions locally
* ci: Fix pre-commit not running tests
* ci: Only update shared cache after the initial build
* ci: Make sure that rustup downloads get cached
* tidy: Clean up file formatting
* ci: Fix issue with audit
* ci: Update node coverage badge to work without games.txt
Fixes#155 using a new node script that should be more robust than the
old shell script.
* ci: Change badge cron time to less common time
By doing at a less common time we should reduce action time usage as
the runners will be under less load.
* Add/Update badge
* ci: Improve node-badge script
Co-Authored-By: CosminPerRam <cosmin.p@live.com>
* ci: Run node badge action if script changes
* ci: Update node badge path for workspaces
* ci: Revert loading games from index in node badge script
---------
Co-authored-by: GitHub Action <action@github.com>
Co-authored-by: CosminPerRam <cosmin.p@live.com>
Because TcpSocket connects in Socket::new TimeoutSettings are now
required for Socket::new. Since we already have TimeoutSettings there
Sockets are now expected to apply timeout settings in Socket::new.
* chore: initial move and refactor of minecraft
* fix: glob re-exports
* fix: failing example sample
* docs: update changelog to note the mc protocol implementation to games
* docs: add back the reference query standard reference
* fix: minecraft id naming inconsistencies
* fix: minecraft legacy beta 1.8 being wrongly id named in definitions
* docs: Update CHANGELOG to document minecraft legacy renames
* docs: Update CHANGELOG to note removal of legacy versions game names being prefixed with 'v'