Commit graph

7 commits

Author SHA1 Message Date
CosminPerRam
310b62664c
feat: http client and eco support (#175)
* feat: initial http and eco support

* http: Replace reqwest with ureq and add HTTPS support

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

* eco: Add generic impls

* eco: fixes

* http: Add headers to HttpSettings and rename from HTTPSettings

* eco: Add extra request settings

* http: Add support for querying raw bytes

* http: Add unit-tests

* http: Rename HttpProtocol

* crate: Make serde dependency non-optional

The serde feature now only enable serde derivations for our types that
don't need it for the library to function.

* http: Add helper for creating HttpClients to query APIs

Adds the from_url helper that should make working with master server web
APIs easier.

* Add/Update badge

* crate: Require games feature for eco example

* docs: Update changelog

---------

Co-authored-by: Douile <douile@douile.com>
2024-02-10 18:26:49 +00:00
Tom
89ed19f089
feat(protocols): Add more control over gathering additional information (#180)
* protocols: Add more control over gathering additional information

Adds GatherToggle which allows choosing the behaviour for how the query
handles fetching additional information. The choices are:
- DontGather - Don't attempt to fetch information
- AttemptGather - Try to fetch the information but ignore errors
- Required - Try to fetch information and fail if it errors

A handy macro was also added to utils to dispatch additional queries
based on a GatherToggle value.

* Add/Update badge

* protocols: Improve GatherToggle enum names

Co-Authored-By: Cain <75994858+cainthebest@users.noreply.github.com>
Co-Authored-By: CosminPerRam <cosmin.p@live.com>

* Add/Update badge

---------

Co-authored-by: GitHub Action <action@github.com>
Co-authored-by: Cain <75994858+cainthebest@users.noreply.github.com>
Co-authored-by: CosminPerRam <cosmin.p@live.com>
2024-01-22 13:36:17 +02:00
Tom
bd3727d7fe
chore: Tidy up some out of place types (#160)
* 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>
2024-01-02 00:17:43 +02:00
Tom
e3bdbc2a41
feat: Add connect timeout to TimeoutSettings (#158)
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.
2023-11-22 12:40:22 +02:00
CosminPerRam
7416d54b14
chore: Move minecraft protocol to games. (#153)
* 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
2023-11-18 19:44:09 +02:00
Cain
963040fb84 Merge branch 'main' into feat/cli 2023-11-08 20:42:07 +00:00
Cain
80f6b87991 refator: copy cli into mono 2023-10-16 23:20:47 +01:00