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

WIP: Add Wasm compatibility and allow it to run async #69

Conversation

irvingoujAtDevolution
Copy link

@irvingoujAtDevolution irvingoujAtDevolution commented Jul 28, 2023

work still in progress, it now communicates with a remote ssh server through a websocket proxy using async_session and websocket stream.
As ring library does not support browser currently, we need to replace ring with[ this patch](https://github.com/irvingoujAtDevolution/ring-xous/tree/irving/wasm-support
you need wasm_bindgen and wasm_bindgen_future for it to run,

Currently, it fails at verifying server key. As I have limited knowledge of cryptography, I would love to receive some help from the community, it would be better if we could use encryption libraries built on pure rust. and I am willing to keep contributing after this is resolved.

usage:

 #[wasm_bindgen]
pub async fn async_ssh_test() {
        let ws = async_stream::WebSocketStream::new("ws://localhost:8000".to_string()).unwrap();
    let session = ssh::create_session()
        .username("test")
        .password("test")
        .connect_async(ws)
        .await
        .unwrap()
        .run_async()
        .await;
}

@HsuJv
Copy link
Collaborator

HsuJv commented Sep 7, 2023

Excellent work.
I'll have a look at it when I have time (probably a month from now).
By the way, we decided to keep this crate sync and create another async-ssh-rs crate for async scenarios.
But yes, the work is still in its infancy.
BRs.

@irvingoujAtDevolution
Copy link
Author

async-ssh-rs

Great, I would be eager to contribute to async-ssh-rs. Is it possible to limit the usage of ring-rs and tokio? or at lease flags it for targets that allows these library and keep it generic so I can contribute the to the code to make it works for wasm-unkown-unknown.

we currently using Golang for this purpose, even though it works, but it is not a great solution.

Please let me know when you have the repository ready. I am more than happy to contribute.

Best Regards,
Irving

@HsuJv
Copy link
Collaborator

HsuJv commented Sep 8, 2023

Sure. Glad to have your contribution!

But some questions about the limited usage of tokio here: Cuz from my pov tokio is more commonly used compared with async-std when it comes to an async context. And it is compatible enough for building wasm-unknown-unknon.
I used to write a async-vnc-rs and use it on wasm which works quite well.

Are there any necessary reasons that we must use async-std rather than tokio?

BRs.
Jovi.

@irvingoujAtDevolution
Copy link
Author

irvingoujAtDevolution commented Sep 11, 2023

Sure. Glad to have your contribution!

But some questions about the limited usage of tokio here: Cuz from my pov tokio is more commonly used compared with async-std when it comes to an async context. And it is compatible enough for building wasm-unknown-unknon. I used to write a async-vnc-rs and use it on wasm which works quite well.

Are there any necessary reasons that we must use async-std rather than tokio?

BRs. Jovi.

It does compile, but it does not necessarily work, here's more information about it, and they does not yet have plan to support it.
tokio-rs/tokio#1597
tokio-rs/tokio#888
I think it might now work for WASM-WASI as of 2023, but to my knowledge, it does not support and yet has a plan to support wasm32-unknown-unknown. While Async-std does have native support for wasm-unknown-unkown.

@HsuJv
Copy link
Collaborator

HsuJv commented Sep 12, 2023

Afaik, the async-std doesn't have native support either(async-rs/async-std#220).
Anyway, I can flag both of 'em so that the user can choose what they like.

@irvingoujAtDevolution
Copy link
Author

Afaik, the async-std doesn't have native support either(async-rs/async-std#220). Anyway, I can flag both of 'em so that the user can choose what they like.

That's true; I correct what I said. wasm32-unknown-unknown is only partially supported by async-std. In this case, please go ahead and implement it as you see fit. I'll contribute to make it more suitable for people who need to run it in a browser environment like myself.

Thank you very much, and please keep me updated.

By the way, could you please avoid using Ring-rs for cryptographic features? It's not compatible with any WebAssembly environment because it rely on native assembly code. If you absolutely need the functionalities that Ring-rs offers, consider creating an adapter layer. This way, I can plug in a pure Rust-implemented crypto library or Web Crypto API.

Thanks again.

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.

None yet

2 participants