Commit Graph

255 Commits

Author SHA1 Message Date
Bartel Sielski 60c50cdea2
handshake(server): Make 'create_response_with_body' function more generic
This makes using it possible when the request and response body types differ.

Signed-off-by: bartel <bartel.sielski@gmail.com>
2024-04-23 16:45:36 +02:00
Félix Lescaudey de Maneville 0fa41973b4
Add builder for additional header values (#400)
* ADd builder for additional header values

* Update client.rs

* fix: docs

* feat: add test

* fix: typo

* add

---------

Co-authored-by: n4n5 <56606507+Its-Just-Nans@users.noreply.github.com>
Co-authored-by: n4n5 <its.just.n4n5@gmail.com>
2024-02-12 20:56:15 +01:00
Constantin Nickel bcd7f85e65 Update `rustls` to 0.22 2023-12-05 22:24:29 +01:00
Alex Butler 2d5b3e18de Fix auto pong responses not flushing after block
Retry pong flushes on read.
Add read_usage_auto_pong_flush scenario test
2023-12-05 22:23:31 +01:00
Alex Butler 866ce20dbe Update webpki-roots to 0.26 2023-12-02 20:30:48 +01:00
Alex Butler 0f6e6517e6 Fix FrameHeader::format write & other lints 2023-12-02 00:01:17 +01:00
Alexey Galakhov fc17f7341d
Merge pull request #373 from psychon/reduce-byteorder
Reduce use of byteorder crate
2023-11-17 19:38:27 +01:00
Constantin Nickel 6c61d54ad2 Update `webpki-roots` to 0.25 2023-11-15 19:56:28 +01:00
Daniel Abramov 272d83c430 doc: clarify the meaning of config values 2023-10-29 14:09:32 +01:00
Alexey Galakhov 2e5029284b Add checking for header sanity
Co-authored-by: Daniel Abramov <inetcrack2@gmail.com>
2023-09-23 02:16:09 +02:00
Alexey Galakhov f916b332a9 Add `AttackAttempt` error variant 2023-09-22 17:48:31 +02:00
Uli Schlachter e4224ed85a Reduce use of byteorder crate
The byteorder dependency is only used in protocol::frame::frame. I
thought this dependency could easily be removed and set out to replace
the use of byteorder with equivalent std methods.

NetworkEndian is an alias for BigEndian. Converting a number like u32 to
bytes can be done via the std lib via .to_be_bytes(). The opposite
direction is from_by_bytes(). These simple things thus to not need
byteorder.

There is one place in the code where byteorder actually helps, thus this
dependency is not actually fully removed. ByteOrder::read_uint() allows
to read 1 to 8 bytes of data and returns the result as u64. Doing this
with the standard library basically requires re-implementing byteorder.
Thus, I did not do that.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2023-08-18 10:35:33 +02:00
Daniel Abramov 8d8f0da204
Merge pull request #362 from alexheretic/config-asserts
Add assert panics for `WebSocketConfig`
2023-07-22 16:08:30 +02:00
Alex Butler 9567cc73f3 Add panics docs 2023-06-17 23:46:04 +01:00
Alex Butler 7869f11b41 Add assert panics for WebSocketConfig 2023-06-17 23:36:46 +01:00
Alex Butler 2345e28158 Clarify WebSocketConfig docs 2023-06-17 23:30:12 +01:00
Mark Doyle 9533c02280 return correct protocol error when missing http version 2023-06-12 13:19:13 +01:00
Mark T. B. Carroll 8901dcc535
remove [] enclosing IPv6 host address 2023-06-06 13:47:09 +01:00
Alex Butler dea67d6cca Fix doc typo 2023-05-30 18:26:59 +01:00
Alex Butler 41818166cf refactor WebSocketContext new 2023-05-30 18:26:59 +01:00
Alex Butler 0cada00fb5 Refactor write_one_frame -> buffer_frame 2023-05-30 18:26:59 +01:00
Alex Butler f33bb2cb97 Ensure out_buffer written when !can_read 2023-05-30 18:26:59 +01:00
Alex Butler 1b47964f18 split write and write_out_buffer internals
Fix internal method naming
2023-05-30 18:26:59 +01:00
Alex Butler 2ef5b9a5e2 Buffer writes before writing to the underlying stream
Add write_buffer_size
Set default 128 KiB
2023-05-30 18:26:59 +01:00
Alex Butler 06e55a4ef2 Refactor additional_send writing 2023-05-27 13:27:55 +01:00
Alex Butler 84a54b76e6 Rename methods to `read`, `send`, `write` & `flush`
Refine docs
Add `send` method
Add deprecated versions of write_message, write_pending,
read_message
Handle pong WriteBufferFull error
Add changelog
2023-05-27 13:19:13 +01:00
Alex Butler 0203a1849b Remove send_queue, use out_buffer instead 2023-05-24 18:42:09 +01:00
Alex Butler 483d229707 Remove implicit write flushing 2023-05-24 18:42:09 +01:00
Benoît CORTIER ee3ffc9e9d
Gracefully handle invalid native root certificates
Before this patch, the `rustls::RootCertStore::add` method was used
to add all the root certificates found by `rustls_native_certs` crate.
This is a problem when an ancient or invalid certificate is present
in the native root store. `rustls` documentation says the following:

> This is suitable for a small set of root certificates that
> are expected to parse successfully. For large collections of
> roots (for example from a system store) it is expected that
> some of them might not be valid according to the rules `rustls`
> implements. As long as a relatively limited number of certificates
> are affected, this should not be a cause for concern. Use
> `RootCertStore::add_parsable_certificates` in order to add as many
> valid roots as possible and to understand how many certificates have
> been diagnosed as malformed.

With this patch, `RootCertStore::add_parsable_certificates` is used
instead for maximal compability with system store.

> Parse the given DER-encoded certificates and add all that can be
> parsed in a best-effort fashion.
>
> This is because large collections of root certificates often include
> ancient or syntactically invalid certificates.
2023-05-17 11:49:28 -04:00
Constantin Nickel 8a436e7550 Remove unused `TlsError::Webpki` error variant
The error variant is no longer needed since `rustls` 0.21.
2023-04-25 22:22:36 +02:00
Daniel Abramov a4863d3f10 Make code compile with any feature set 2023-04-12 16:33:24 +02:00
Daniel Abramov 87e9f576af Make `cargo fmt` happy 2023-04-12 16:09:09 +02:00
Martin Lemesle 1f6c62d301 Fix not compiling features rustls-tls-native-roots and rustls-tls-webpki-roots 2023-04-07 10:11:53 +02:00
Daniel Abramov 42b8797e8b Revert "Add `permessage-deflate` support"
This reverts commit edb2377540.

See https://github.com/snapview/tungstenite-rs/pull/328#issuecomment-1480349206
2023-03-23 00:15:53 +01:00
kazk edb2377540 Add `permessage-deflate` support 2023-03-18 12:36:01 +01:00
EXPLOSION 5125c59dfa Display correct payload in Frame::fmt 2023-02-11 23:23:42 +00:00
Jack Wills 657faf427f docs: message.rs typo
Simple typo fix of is_close() method
2023-02-01 05:46:06 +01:00
Sebastian Dröge c6769e3dae Switch from base64 0.20 to data-encoding 2
base64 0.21 deprecated the simple API and requires quite a bit more code
for the simple usage here, while data-encoding provides exactly the API
needed and is also actively maintained.
2023-01-15 17:08:18 +01:00
ssrlive 3fc7fb412c
Mark some functions as public (#315)
Fixes #315.

Co-authored-by: Daniel Abramov <inetcrack2@gmail.com>
2022-12-02 15:35:22 +01:00
Yang Hau 984ad9d6c7 fix typos 2022-11-22 20:23:59 +08:00
Josiah Bull 1c657d4c6a
feat: switched response type from Vec<u8> to Option<Vec<u8>> to allow returning of differentiation of no body from empty body. 2022-10-19 12:30:46 +13:00
Josiah Bull 36ab770059
feat: error type returns `Vec<u8>` instead of `Option<String>` 2022-10-19 12:30:29 +13:00
Josiah Bull 4a7beaa897
feat: error responses return body upon non 101 status code
modified `client::Response` type to contain `String` instead of `()` to achieve this.
2022-10-19 12:29:45 +13:00
Icelk 4023390d38 Make handshake dependencies optional. 2022-08-30 09:22:38 +02:00
Daniel Abramov fd96a35300 tests: add a regression test for the queue logic 2022-08-03 16:13:03 +02:00
Alexey Galakhov 0b9d2a649b
Revert "add support for batching websocket messages" 2022-07-29 11:48:12 +02:00
RustUser246 68daa29b19 add support for batching websocket messages 2022-07-27 21:13:54 +01:00
n3oney 80d0547fab
fix: uppercase origin header 2022-06-18 23:31:42 +02:00
Daniel Abramov b8ccbcf2a1 chore: update the documentation
Fixes #280.
2022-04-19 19:39:19 +02:00
kangalioo fa70a370c8 Downgrade MSRV to 1.51 2022-03-19 23:46:51 +01:00