-
Notifications
You must be signed in to change notification settings - Fork 4
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
IPC communication between agent and client (CLI/GUI) #50
Comments
It turns out node grpc doe not support UDS: grpc/grpc-node#258 so I am going with the nodejs |
Does grpc-node generate marshaling code given proto files? |
@robert-cronin can you update this issue indicating that UDS does work, and how you achieved it. |
Clarification with grpc-node https://github.com/grpc/grpc-node/blob/master/PACKAGE-COMPARISON.md it seems to mean that it's not pure JS. Which means potential issues when deploying this on nativescript. |
Oh I see, grpc-node actually distributes 2 packages. One of them requires C and the other is pure JS. The C one might be able to be compiled to the nativescript platforms. But the pure JS one would be safer, but is missing only a few features. Do we need those and which one are you using? |
|
Yeah so it was actually quite simple. The nodejs net module allows one to specify a file path in |
Yeah I was originally using |
Make sure this is documented or auto generated by webpack?
…On 10 July 2020 13:05:33 GMT+10:00, Robbie Cronin ***@***.***> wrote:
> Does grpc-node generate marshaling code given proto files?
`protobufjs` has the ability to generate JavaScript code that encodes
and decodes protocol buffers. It also generates typescript definition
files. These are the commands I am using for a `proto` folder defined
at the root directory:
```
# Creates the JavaScript file
pbjs -t static-module -w commonjs -o proto/js/compiled.js proto/*.proto
# Generates the corresponding type definition files
pbts -o proto/js/compiled.d.ts proto/js/compiled.js
```
--
You are receiving this because you commented.
Reply to this email directly or view it on GitHub:
#50 (comment)
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
|
I am storing the proto files in a |
Just for future reference, it turns out the only way to import |
We don't need to synchronously start and stop the server.
You can still do RAII with async await. Just have a async main function.
See loja-api's server entry point.
…On 10 July 2020 13:14:17 GMT+10:00, Robbie Cronin ***@***.***> wrote:
> Oh I see, grpc-node actually distributes 2 packages. One of them
requires C and the other is pure JS. The C one might be able to be
compiled to the nativescript platforms. But the pure JS one would be
safer, but is missing only a few features. Do we need those and which
one are you using?
Yeah I was originally using `grpc-js` but discovered there was no way
to synchronously start the server and let it dynamically choose and
available port. In `grpc` you can do it by `const port =
server.bind('0.0.0.0:0')` but in `grpc-js` the `bind` function doesn't
return anything. The only way to do this is `const port = await
server.bindAsync('0.0.0.0:0')` and so its impossible to follow RAII. I
think the only way we will be able to use `grpc-js` is if we create
`stop` and `start` functions for the server so they can be async. I
don't mind this because there might be plenty of reasons why the user
wants to control the starting and stopping of the secure server.
--
You are receiving this because you commented.
Reply to this email directly or view it on GitHub:
#50 (comment)
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
|
Not sure what you mean, does loja have a dedicated If that's the case, I'm not sure what would be the difference to having a I think there is still a way we can follow RAII, we just start the server asynchronously in the constructor. It's just not guaranteed to be started by the time the class is finished initialising. |
Like this (
Notice the Also the main function is basically an IIFE. |
oh okay, I did notice this file, but thought it wasn't relevant to |
Oh right, so that's an issue. Some classes are not well "encapsulated" since they rely on "session" side-effects. For these things I usually abstract them out with dependency injection so that they are forced to be constructed at the top-level context. Thus that main function above, you see I am forced to create the database pool object there. |
So if we want to continue using gRPC between client and agent and not just agent to agent, then we would like to have gRPC support UDS because UDS inherits OS permissions whereas localhost can be sniffed by any program on the machine even executed by other users. However at the moment the node implementation of gRPC does not support UDS. It is possible to support if these 2 issues were to be resolved:
Therefore the only solution is to use mTLS between agent and client to secure communications locally. This can allow clients to exist on a different system to call into a PK agent. So it does have its own advantages. |
The next problem to figure out is how the client and agent, it looks like there are a couple of ways to achieve this:
Discovery between the agent and the client also needs to be figured out, here are some ideas:
/run/user/1000/polykey/socket
(this only exists on Linux, find equivalent on Mac/Windows).Using UDS is really about getting access to the OS security capabilities to securing the comms. The nodejs TLS module can also do UDS as its an abstraction over the net module, you just have to specify the path in tls.connect. I'm just not sure about the server and tls.
The text was updated successfully, but these errors were encountered: