Evgeniy A. Dushistov
5a95f12c6d
refactoring/apply_mask: reduce number of usage of unsafe to 1
...
Plus it should be faster now:
apply_mask/fallback/0 time: [24.282 ns 24.727 ns 25.255 ns]
apply_mask/fast/0 time: [11.921 ns 11.963 ns 12.011 ns]
apply_mask/fast_safe/0 time: [7.9340 ns 7.9807 ns 8.0261 ns]
apply_mask/fallback/1 time: [25.284 ns 25.710 ns 26.124 ns]
apply_mask/fast/1 time: [20.433 ns 20.476 ns 20.511 ns]
apply_mask/fast_safe/1 time: [9.3208 ns 9.3833 ns 9.4470 ns]
apply_mask/fallback/2 time: [16.051 ns 16.160 ns 16.275 ns]
apply_mask/fast/2 time: [20.564 ns 20.569 ns 20.574 ns]
apply_mask/fast_safe/2 time: [9.1449 ns 9.1830 ns 9.2189 ns]
apply_mask/fallback/3 time: [15.386 ns 15.548 ns 15.715 ns]
apply_mask/fast/3 time: [18.836 ns 18.867 ns 18.917 ns]
apply_mask/fast_safe/3 time: [8.3092 ns 8.3566 ns 8.4076 ns]
5 years ago
Evgeniy A. Dushistov
9764ac13a1
infra/apply_mask: test more case for apply_mask
...
make sure that input with len 0,1,2,3 also tested
5 years ago
Evgeniy A. Dushistov
de80b9bced
Change Into to From for CloseCode to u16 conversation
...
As stated in standard library documentation:
> One should always prefer implementing From over Into because implementing From automatically
> provides one with an implementation of Into thanks to the blanket implementation in the standard library.
And this provides the way to use u16::from(close_code)
5 years ago
Mike Pedersen
1f744f1548
Make mask public on FrameHeader
...
Without the ability to get the mask, having the `FrameHeader` struct as a public type along with functions like `parse` is somewhat useless. I can't see any reason why it shouldn't be public.
5 years ago
Naja Melan
9c48226c8f
chore: Remove needless closing/opening of the impl block on WebSocketContext.
5 years ago
Naja Melan
1f407f1005
feat: Allow reading the configuration.
...
This allows wrapper types to correctly split data before creating websocket
messages, guaranteeing to respect the max size.
Notably when the WebSocket is provided by user code.
5 years ago
Alexey Galakhov
6b3423292f
trivial: fix clippy warning
...
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
5 years ago
Alexey Galakhov
85f211230a
websocket: add `can_read()` and `can_write()`
...
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
5 years ago
Alexey Galakhov
da3acc107e
protocol: handle "Connection reset by peer" in closing state
...
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
5 years ago
Sebastian Dröge
88760b8b59
Fix various clippy warnings
5 years ago
Sebastian Dröge
7a4779b6f6
Run everything through rustfmt
5 years ago
Alexey Galakhov
2903a02ef5
frame: correct possible infinite loop on sending
...
Closes : #83
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
5 years ago
Naja Melan
17fe7987eb
Make use of can_read
5 years ago
Naja Melan
1ee3f342aa
Consider remote sending a frame after sending a close frame a protocol error.
...
The websocket RFC explicitly states this is not allowed.
5 years ago
Naja Melan
2918eec1b3
No longer accept to send after close
5 years ago
Naja Melan
f818322a25
Add some documentation to WebSocket and Error.
5 years ago
Naja Melan
9379ebe47d
Don't swallow ping/pong while waiting for close acknowledgement
5 years ago
Naja Melan
bf63a71cd1
cleanup unnecessary dereference
5 years ago
Naja Melan
28579b567a
Improve WebSocketState interface with Copy, PartialEq, ...
5 years ago
Naja Melan
b923ec42c0
Keep processing incoming data even after we have initiated a close handshake.
5 years ago
Artem Vorotnikov
cbf80ecc76
Edition 2018, formatting, clippy fixes
5 years ago
Daniel Abramov
e2bec4b81f
Change the way we return `Err::ConnectionClosed`
...
This way will ensure that we only return this error once. The previous
solution fixed the problem, but it did not guarantee that ""connection
closed" is returned only once.
5 years ago
Daniel Abramov
dbc8bd7b71
Fix issue with hanging server connection
5 years ago
Alexey Galakhov
06308b1b3f
close: fix autobahn regression
...
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
6 years ago
Alexey Galakhov
b8f7d3668e
close: refine close semantics
...
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
6 years ago
Yusuke Sasaki
828eafd400
extract the context values from `WebSocket`
6 years ago
Daniel Abramov
c8c3d6290d
Make `Close` part of the `Message` enum
6 years ago
Evan Schwartz
da85989934
feat: impl Into<Vec<u8>> for Message
6 years ago
Alexey Galakhov
a7e87488c4
config: make config settable at runtime
...
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
6 years ago
Alexey Galakhov
9b0a2e0f11
trivial: split public and private impl
...
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
6 years ago
Alexey Galakhov
a2e122ab9e
refactor: mask: pass mask by value
...
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
6 years ago
Alexey Galakhov
e6ebf5ac76
trivial: style fixes
...
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
6 years ago
Alexey Galakhov
d2e3602170
frame: fix partial write
...
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
6 years ago
Alexey Galakhov
3772aaf163
chore: introduce frame size limit
...
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
6 years ago
Alexey Galakhov
50d1371e52
frame: cleanup frame API
...
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
6 years ago
Alexey Galakhov
75aa0d54f3
refactor: parse header separately from payload
...
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
6 years ago
Alexey Galakhov
20242d19f7
config: protocol: add message size limiting
...
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
6 years ago
Alexey Galakhov
a4f885f69f
protocol: improve write responsibility
...
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
6 years ago
Alexey Galakhov
e4a52cde05
mask: update for actual Rust version
...
Closes #35
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
6 years ago
Alexey Galakhov
cb671e1abc
trivial: improve documentation
...
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
6 years ago
Ran Benita
4cfe9a2be1
frame: eliminate an unsafe when reading message data into the buffer
...
The reason for the unsafe was presumably to avoid copying or
zero-initializing. This achieves the same but using only safe functions.
Note: there is no zero-initializing here because Cursor is "trusted" to
not read from the buffer and so skips the initialization:
https://github.com/rust-lang/rust/blob/master/src/libstd/io/cursor.rs#L241
(the Take wrapper delegates to its inner).
6 years ago
Alexey Galakhov
fdb1a0ed50
frame: reject bad opcodes early
...
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
6 years ago
Alexey Galakhov
9bd65feaeb
frame: reject frames that are too big for the RAM
...
Fixes #34 .
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
6 years ago
Alexey Galakhov
977c6e7c7a
refactor: remove transmute in favor of safe code
...
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
6 years ago
Alexey Galakhov
c0cde68999
frame: fix integer overflow
...
This is a security fix.
Fixes #33 .
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
6 years ago
Daniel Abramov
00303fa60c
Make the websocket configurable
7 years ago
Teddy DeRego
5742c822ee
WebSocket::write_message will no longer buffer unlimited messages - it will only buffer a configurable number of outbound messages. Needed for snapview/tokio-tungstenite#35 .
7 years ago
Sean Schwartz
66d2c15f2d
Derive Debugs
...
Deny missing debug and resolve resulting errors to satisfy:
https://rust-lang-nursery.github.io/api-guidelines/debuggability.html#all-public-types-implement-debug-c-debug
Requires updated input_buffer pushed to crates.io:
- Resolved build errors by using github version of code until new version available on crates.io
Upgrade env_logger dev-dependency to v0.5.3
- Removed unwrap call from env_logger::init() as it is no longer needed.
7 years ago
Alexey Galakhov
6f8c4e7034
Use input_buffer as separate crate.
...
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
7 years ago
Alex Crichton
9f6f42766e
Add `Ping` and `Pong` variants to `Message`
...
This'll allow removal/deprecation of the `send_ping` custom method but also
allow applications to react to `Pong` messages as appropriate.
Closes #16
7 years ago