Commit graph

32 commits

Author SHA1 Message Date
Tom
c3281be419
[Protocol] Retry failed requests (#95)
* Add retry count to TimeoutSettings

This can be used to specify how many times to re-send requests that
fail. The default value is "1" so the if the first request fails, 1 more
attempt will be made.

* Add retries to valve queries

* [Protocol] &Optional<TimeoutSettings> add get_retries_or_default

Allow fetching the number of retries or the default retries value from a
borrowed optional TimeoutSettings.

* [Protocol] Add retries to minecraft protocol

* [Protocol] Add retries to quake

* [Protocol] Add retries to gamespy

* [Protocol] Update TimeoutSettings docs, and change default retries to 0

* Remove logging from retry_on_timeout

* [Protocol] TimeoutSettings make retries non-optional

* [Protocol] Move retry logic into lower level query functions

Retries are now implemented as wrappers on the single function that
would need to be retried on timeout.

In order to avoid cloning of TimeoutSettings, Socket::apply_timeouts()
was changed to accept a borrowed TimeoutSettings. And extra helpers were
added to the TimeoutSettings impl to reduce repetition.

* [Examples] Add retries to the generic example

* Also retry on PacketSend error

Sending packets could also timeout and until error_generic_member_access
is stable we have no way of determining the type of the underlying
`std::error::Error`.

* Add retry unit tests

* [Docs] Update changelog
2023-09-25 22:12:54 +03:00
CosminPerRam
f50c50f0f1 [Protocol] Apply many nursery clippy lints 2023-08-17 22:37:17 +03:00
Tom
5e7e010d24
[Crate] Add rich error type (#80)
* Add rich error type with source and backtrace

Adds a rich error type that will take a backtrace and allow capturing
the source of the error. The best way to use this is with the included
helpers that will automatically capture the backtrace and convert the
source error:

```
GDRichError::packet_bad_from_into("Reason packet was bad")
```

* [Crate] Bump MSRV to 1.65.0

This is required for backtraces in rich errors.

* Remove leftover debug logging

* [Errors] Replace variant overloads with single .rich method on kind enum

This overhaul replaces the exhaustive impls of each variant as multiple
methods on the rich error type with a singular .rich() method on the
kind enum. This consumes the variant and converts it to a rich error
with a source (.into() can be used if a source is not needed).

I also took the liberty of replacing all usages with the this new method
as I saw fit (adding various error messages) and converting a few
PacketBad errors to TypeParse errors when they are the result of parse
failing.

* Fix problem with rustdoc

* Remove BadGame's owned string

* Rename GDError to GDErrorKind

* Rename GDRichError to GDError

* Remove error impl from GDErrorKind

* Fix tests not passing

* Use error context everywhere map_err is used

* Improve GDError display formatter

* Add tests for new error type
2023-08-05 12:36:48 +03:00
CosminPerRam
e0830bdae5
[Protocol] Replace IpAddr with SocketAddr in protocols (#44)
* [Crate] Replace IpAddr with SocketAddr in protocols

* [Crate] Remove usage of address.to_string in socket

* [Crate] Update CHANGELOG.md
2023-06-02 01:06:24 +03:00
Tom
3f654e0dfd
[Protocol] Enable the use of Ipv6 addresses (#41)
Replace usages of Ipv4Addr with IpAddr which allows the use of either Ipv4 or Ipv6.

This patch essentially consists of running:
"sed -i 's/Ipv4Addr/IpAddr/g' src/**/*.rs examples/*"
and fixing the errors.
2023-05-29 11:10:21 +03:00
CosminPerRam
e620398615 [Crate] Changed all address &str to &Ipv4Addr 2023-05-27 00:41:41 +03:00
Cain
1b13d39856
[Crate] Add formatting (#22)
* chore: add standard for formatting

* chore: manually tidy up imports and format

* chore: remove vscode and add to gitignore

* chore: alphabetically order and fix

* chore: format

* chore: fix format issue with payload

* chore: format as merge had unformatted code

* [format] Fix comments, change max width and binop operator

---------

Co-authored-by: CosminPerRam <cosmin.p@live.com>
2023-03-14 10:31:37 +02:00
CosminPerRam
3dacc09173 [Utils] Replace address and port as string string and additions to format! 2023-03-11 00:20:09 +02:00
CosminPerRam
e163774685 [Protocols] Cargo clippy optimizations 2023-03-09 01:30:28 +02:00
CosminPerRam
c263b17651 Remove errors details as they were quite useless 2023-01-13 00:11:04 +02:00
CosminPerRam
b09fa4ada5
Change buffer reading implementation (#8)
* Add new implementation an valve protocol refactor

* Refactor minecraft protocol with new bufferer
2022-12-29 16:30:24 +02:00
CosminPerRam
91f8bbb9fe
Minecraft bedrock support (#7)
* Added needed ground stuff

* Minecraft bedrock support!

* Documentation acknowledgements!

* Added utf8_le_undended test, some docs and modified master_querant

* Modified query function to comply with the others

Before: game query -> protocol query (get port or default port)
After: game query (get port or default port) -> protocol query

* Modified md files
2022-12-05 18:47:35 +02:00
CosminPerRam
1ad5031c6f Added u8_lower_upper test 2022-11-28 01:56:46 +02:00
CosminPerRam
2e8aa50c3a Fixed tests and removed dns error 2022-11-28 01:22:59 +02:00
CosminPerRam
3d95f08ef4 Removed DNS resolving as it was not needed 2022-11-28 01:13:08 +02:00
CosminPerRam
ed681025b4 Added error_by_expected_size test. 2022-11-27 23:45:48 +02:00
CosminPerRam
645582868d More tests and fixed (?) utf16 be string reading 2022-11-26 17:09:34 +02:00
CosminPerRam
7b44c5f7eb Reverter errors from taking a &'static str to String 2022-11-25 18:42:10 +02:00
CosminPerRam
304b8340d2 Better, faster and stronger errors. 2022-11-24 23:38:51 +02:00
CosminPerRam
ee0223a7a3
Minecraft implementation (#6)
* Initial minecraft support

* Made previews_chat an option

* Better error handling and removed version structure

* Minecraft Server types

* Fixed compilation and renamed stuff

* 'extract till you drop!' extracted sockets

* extracted java version and fixed socket udp receive

* Legacy 1.4 and 1.6 implementation (incomplete)

* Furter implementation

* Implementations work

* Protocol beta v1.8+ implemented

* Removed bedrock support

* Added auto query

* Renamed minecraft to mc and added to md's

* Docs, renames and small optimization changes

* Changed java version to be able to return None on players sample
2022-11-24 22:52:54 +02:00
CosminPerRam
d3a1dba3c1
Restructured app format, goldsrc full support and added implementation for Day of Defeat and Counter-Strike: Condition Zero (#5)
* [valve_app_restructure] Initial change

* [valve_app_restructure] Some GoldSrc split packet changes

* [valve_app_restructure] Counter-Strike: Condition Zero implementation.

* [valve_app_restructure] Docs changes

* [valve_app_restructure] Added obsolete gold src response

* [valve_app_restructure] Day of Defeat implementation.
2022-10-27 01:01:11 +03:00
CosminPerRam
e8cbe7b9f5
DNS Resolver Implementation (#4)
* [dns-resolver] Added trust-dns-resolver and restored cargo.lock

* [dns_resolver] Implemented feature
2022-10-22 14:58:59 +03:00
CosminPerRam
e621a9aedd
Better packet structure (#3)
* [packet_structure] Initial implementation

* [packet_structure] Fixed on tf2

* [packet_structure] Fixed info request
2022-10-22 01:22:09 +03:00
CosminPerRam
15e6ad5892 Replaced Result<T, GDError> with GDResult<T> 2022-10-20 23:19:57 +03:00
CosminPerRam
92d9649008 Valve PLAYERS and RULES request first implementations 2022-10-18 01:40:37 +03:00
CosminPerRam
9ab4b8a7fd Error handling and better structure 2022-10-17 23:22:46 +03:00
CosminPerRam
544ce897c5 Better protocol parameters and utils tests 2022-10-17 11:11:40 +03:00
CosminPerRam
3a83588802 Much more readable code! 2022-10-16 17:55:48 +03:00
CosminPerRam
c2742fbcf0 More readable code 2022-10-16 16:14:10 +03:00
CosminPerRam
73c8ade3a2 Modified public presentation files 2022-10-16 03:23:18 +03:00
CosminPerRam
c9eb725a51 Almost completed the valve protocol 2022-10-16 02:42:17 +03:00
CosminPerRam
8098136d09 Initial valve setup and tf2 game setup 2022-10-15 22:20:01 +03:00