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

Supporting Windows #34

Closed
Connoropolous opened this issue Jul 2, 2021 · 15 comments
Closed

Supporting Windows #34

Connoropolous opened this issue Jul 2, 2021 · 15 comments

Comments

@Connoropolous
Copy link
Contributor

Connoropolous commented Jul 2, 2021

Based on attempts to bring applications like Snapmail and Acorn out into the wild bundled as Electron apps, we have run in to the requirement that Windows users install wsl2 which is a big technical hurdle for ordinary users. We have been wanting to make these apps available at lower friction. When @ddd-mtl @guillemcordoba and I discussed recently with @zippy it was brought up that this "Unix Domain Socket for Lair" thing might be the main blocker for native Windows support.

We are thinking about investigating it and seeing what we can do to move this forward. I started a bit of digging and immediately found something interesting, which appears to be that an implementation (if not 100% feature complete) of Unix sockets was brought into Windows 10, with a release in 2017 first to Windows Insider, then it became generally available in version 1809 (aka the October 2018 Update).
Microsoft open source seems to have published a library that may suit:
https://github.com/Azure/tokio-uds-windows
There's also the Tokio UDS on Windows thread to add:
tokio-rs/tokio#2201
The new Deno language (like nodejs) is also pulling for this clearly.

Were we collectively unaware of this? I am assuming so, given these lines

#[cfg(not(windows))]
mod unix_ipc;
#[cfg(not(windows))]
use unix_ipc::*;
#[cfg(windows)]
mod win_ipc;
#[cfg(windows)]
use win_ipc::*;

and the comments in
//! windows version of ipc stream tools

The original post is here, from 2017
https://devblogs.microsoft.com/commandline/af_unix-comes-to-windows/
But there's more relevant comments here
microsoft/WSL#4240

I found looking at this commit which referred to that issue gave a bit of insight
MisterDA/ocaml@5855ce5

# @todo windows support
#windows-latest,

@thedavidmeister @neonphog

@Connoropolous Connoropolous changed the title Re. Windows Support, UNIX Sockets may be supported already in Windows 10 (build 17063) UNIX Sockets actually supported in the Windows 10 version 1809, October 2018 Update Jul 2, 2021
@Connoropolous Connoropolous changed the title UNIX Sockets actually supported in the Windows 10 version 1809, October 2018 Update UNIX Sockets are supported in the Windows 10 version 1809, October 2018 Update Jul 2, 2021
@Connoropolous Connoropolous changed the title UNIX Sockets are supported in the Windows 10 version 1809, October 2018 Update UNIX Sockets are supported in the Win 10 version 1809, October 2018 Update Jul 2, 2021
@Connoropolous Connoropolous changed the title UNIX Sockets are supported in the Win 10 version 1809, October 2018 Update UNIX Sockets are supported in the Win 10 version 1809, Oct. 2018 Update Jul 2, 2021
@ddd-mtl
Copy link
Contributor

ddd-mtl commented Jul 2, 2021 via email

@Connoropolous
Copy link
Contributor Author

I see, so you think it's a better solution to add it (do you estimate it to be more work?) because it adds broader compatibility?

@ddd-mtl
Copy link
Contributor

ddd-mtl commented Jul 2, 2021 via email

@Connoropolous
Copy link
Contributor Author

Connoropolous commented Jul 2, 2021

Cool cool. That's good and there might be one additional prospect here which is that Unix Sockets works on all of mac/linux/windows AND you could select via config to use TCP.
UnixStream for windows for tokio was implemented here by Microsoft devs themselves, so could be used:
https://github.com/Azure/tokio-uds-windows

3 birds with 2 stones?

@ddd-mtl
Copy link
Contributor

ddd-mtl commented Jul 2, 2021 via email

@Connoropolous
Copy link
Contributor Author

my thoughts exactly

@neonphog
Copy link
Collaborator

neonphog commented Jul 2, 2021

@Connoropolous @ddd-mtl - I hadn't been intending to introduce TCP to lair because of security concerns, although we could discuss it.

The original intention was to use tokio-named-pipes on windows.

@Connoropolous
Copy link
Contributor Author

Oh, I see. Different stories going around here then.

Sounds like the named pipes solution would be the number 1 preference for you @neonphog ?

It seems to be folded right into tokio nowadays:
https://docs.rs/tokio/1.8.0/tokio/net/windows/named_pipe/index.html

@neonphog
Copy link
Collaborator

neonphog commented Jul 5, 2021

@Connoropolous

It seems to be folded right into tokio nowadays:
https://docs.rs/tokio/1.8.0/tokio/net/windows/named_pipe/index.html

Oh nice, I hadn't realized that, awesome!

Sounds like the named pipes solution would be the number 1 preference for you @neonphog ?

Yeah, if this is part of core tokio, let's do that to start, and see if it covers our use-cases. It eliminates a whole set of concerns if we can guarantee only local processes have access, and can apply os security.

@Connoropolous
Copy link
Contributor Author

@neonphog
I'm glad it's a good surprise. Can you confirm a rough outline of the work @neonphog ?

My guess is that it involves writing in the win_rpc.rs file equivalent implementations of:
IpcRead, IpcWrite, ipc_connect, and IpcServer from unix_ipc.rs

Is UnixStream completely abstracted out?

@neonphog
Copy link
Collaborator

neonphog commented Jul 5, 2021

@Connoropolous

My guess is that it involves writing in the win_rpc.rs file equivalent implementations of:
IpcRead, IpcWrite, ipc_connect, and IpcServer from unix_ipc.rs

Is UnixStream completely abstracted out?

You got it. IpcRead must implement tokio::io::AsyncRead, IpcWrite tokio::io::AsyncWrite, and ipc_connect / IpcServer should have the same signatures. They're switched out at compile time with config directives here.

@Connoropolous Connoropolous changed the title UNIX Sockets are supported in the Win 10 version 1809, Oct. 2018 Update Supporting Windows Jul 5, 2021
@ddd-mtl
Copy link
Contributor

ddd-mtl commented Jul 5, 2021

Actually TCP was my extrapolation for the Holo use-case and the lair-shim thing, but now I see I could be totally wrong so nevermind the TcpStream solution I mentionned.

@Connoropolous
Copy link
Contributor Author

@ddd-mtl I have access to Windows on a laptop here dual booted from a Mac, so I can co-code, or also run and compile code you write, etc. Any preferences? :)

@thedavidmeister
Copy link
Contributor

this looks like a good thing that is happening here, but i don't have much to add so i'm taking myself off notifications :)

@neonphog
Copy link
Collaborator

v0.0.1-alpha.13 keystore / api / client published with #37 included. Closing this -- feel free to re-open if there's anything remaining to be addressed.

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

No branches or pull requests

4 participants