Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove websocket dependency and replace it with async bridging code to tokio-tungstenite #146

Merged
merged 4 commits into from
Jan 28, 2022

Conversation

1c3t3a
Copy link
Owner

@1c3t3a 1c3t3a commented Jan 25, 2022

This PR replaces the current websocket code that uses the unmaintained websocket crate with tokio-tungstenite. tokio-tungstenite is async, so in order to get the current code to work I needed to use async-bridging. The idea is that the current websocket transport types hold a tokio::Runtime object where they spawn the futures with and then communicate the results like before.

This fixes #115 and does the work of pr #123.

The changes introduce tokio as an async runtime. The current version of the async clients are bound to tokio and it is apparently quite hard to not choose an async runtime, as the underlying connection with the server is currently opened by this crate and thus needs some sort of type (either tokio or async-std streams).

This introduces tokio and tokio_tungstenite as a dependency.
The asynchronous socket supports the same interface as the
normal socket with just async methods. The only way to execute
it is with the tokio runtime.
@1c3t3a 1c3t3a requested a review from ctrlaltf24 January 25, 2022 12:52
This commit removes the Websocket dependency completly.
Apparently the library was not maintained anymore and
introduced an old hyper version with a security vulnerability.
The new version uses async bridging with tokio in order to
execute the futures produced by the async client.
@1c3t3a
Copy link
Owner Author

1c3t3a commented Jan 25, 2022

Force pushed due to commit rewording.

@codecov
Copy link

codecov bot commented Jan 25, 2022

Codecov Report

Merging #146 (9db8676) into main (3196543) will increase coverage by 0.43%.
The diff coverage is 90.71%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #146      +/-   ##
==========================================
+ Coverage   87.83%   88.26%   +0.43%     
==========================================
  Files          20       24       +4     
  Lines        1644     1662      +18     
==========================================
+ Hits         1444     1467      +23     
+ Misses        200      195       -5     
Impacted Files Coverage Δ
engineio/src/async_transports/transport.rs 0.00% <0.00%> (ø)
engineio/src/error.rs 100.00% <ø> (ø)
engineio/src/lib.rs 100.00% <ø> (ø)
engineio/src/client/client.rs 94.60% <85.71%> (-0.02%) ⬇️
engineio/src/header.rs 87.50% <90.00%> (+6.41%) ⬆️
engineio/src/async_transports/websocket_secure.rs 92.30% <92.30%> (ø)
engineio/src/async_transports/mod.rs 94.59% <94.59%> (ø)
engineio/src/async_transports/websocket.rs 95.83% <95.83%> (ø)
engineio/src/transports/websocket.rs 94.64% <100.00%> (+1.70%) ⬆️
engineio/src/transports/websocket_secure.rs 95.00% <100.00%> (+8.00%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3196543...9db8676. Read the comment docs.

engineio/src/error.rs Outdated Show resolved Hide resolved
engineio/src/error.rs Outdated Show resolved Hide resolved
engineio/src/transport.rs Outdated Show resolved Hide resolved
engineio/src/transports/websocket.rs Outdated Show resolved Hide resolved
engineio/src/transports/websocket.rs Show resolved Hide resolved
engineio/src/transports_async/mod.rs Outdated Show resolved Hide resolved
engineio/src/transport.rs Outdated Show resolved Hide resolved
engineio/src/transports/websocket_secure.rs Outdated Show resolved Hide resolved
engineio/src/transports_async/websocket.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@ctrlaltf24 ctrlaltf24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: force-pushing makes it harder to see what changed.

engineio/src/async_transports/transport.rs Outdated Show resolved Hide resolved
engineio/src/transports/websocket.rs Show resolved Hide resolved
engineio/src/transports/websocket.rs Show resolved Hide resolved
engineio/src/transports/websocket_secure.rs Show resolved Hide resolved
@1c3t3a 1c3t3a merged commit 16fcdee into main Jan 28, 2022
@1c3t3a 1c3t3a deleted the remove-websocket branch January 28, 2022 08:44
@1c3t3a
Copy link
Owner Author

1c3t3a commented Jan 28, 2022

Thanks a lot for the review @nshaaban-cPacket!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Switch websocket library
2 participants