Repository navigation
Implement a TCP-based trampoline mechanism - #11510
Conversation
| env: await envForRemoteOperation(account, remoteUrl), | ||
| expectedErrors: new Set<DugiteError>([DugiteError.BranchDeletionFailed]), | ||
| }) | ||
| const result = await withTrampolineEnvForRemoteOperation( |
There was a problem hiding this comment.
All these files under app/src/lib/git just change a bit because of a design decision: just like we do in other parts of the app (withPushPullFetch or withIsCommitting), withTrampolineEnvForRemoteOperation will wrap a git operation that might need to use the trampoline. The purpose of withTrampolineEnvForRemoteOperation is to generate a trampoline token before invoking git, and revoking it right after that.
| env => { | ||
| return git(args, repository.path, 'checkoutBranch', { | ||
| ...opts, | ||
| env: merge(opts.env, env), |
There was a problem hiding this comment.
Commands that also have a progressCallback need this additional step of merging the env provided by withTrampolineEnvForRemoteOperation and the one coming from that progress callback.
| } | ||
|
|
||
| return undefined | ||
| } |
There was a problem hiding this comment.
The logic in this file is basically the same we have in https://github.com/desktop/desktop/blob/development/app/src/ask-pass/ask-pass.ts
| desktopTrampolineFile | ||
| ), | ||
| path.resolve(desktopTrampolineDir, desktopTrampolineFile) | ||
| ) |
There was a problem hiding this comment.
This snippet here makes sure the desktop-trampoline binary is copied from the node_modules folder to the app bundle.
There was a problem hiding this comment.
Will the exe binary need to be signed on Windows in order to be operational?
There was a problem hiding this comment.
Not sure if it's necessary, but definitely something we want (and it's required on macOS). It's in my TODO list for tomorrow 😄
There was a problem hiding this comment.
FYI @mislav I can confirm the new binary is signed for both macOS and Windows without any extra effort 😌 🎉
| this.close() | ||
| }) | ||
|
|
||
| this.server.listen(0, '127.0.0.1', async () => { |
There was a problem hiding this comment.
Will the TCP server be accessible to other computers on the network?
There was a problem hiding this comment.
We definitely don't want it to be, and that '127.0.0.1' should restrict it to connections in the same machine (or that's my hope, at least 😂 ).
There was a problem hiding this comment.
Let me test and see if it's really keeping the connections to local or if I can use vpn from my company to connect
367c243 to
0e3874d
Compare
2b19b62 to
636fbb0
Compare
It basically prevents forwarding the DESKTOP_PORT env variable, since it's not necessary.
|
@tidy-dev I updated the branch with the latest |
Description
This PR adds support for a replacement of our current
GIT_ASKPASStrampoline script, that not only is a bit slow, but also causes some issues on Windows.With this new trampoline, we get replace the old script with:
stdoutfor git to consume it.Trampoline server
Regarding the server side of this trampoline mechanism:
Right now, "it's needed" means whenever the user performs a remote git operation that needs authentication (i.e. that needs
GIT_ASKPASS).EADDRINUSEerrors when the port is already in use.DESKTOP_TRAMPOLINE_TOKEN) to the trampoline client, which will have to send it back to the server along with the rest of the info. The server will verify the token, compute the command output, and then revoke the token so it can't be reused.Trampoline client
The trampoline client basically receives the server port in a
DESKTOP_PORTenvironment variable, connects to that TCP port, and then sends the following (in the same order):argc - 1).argv, exceptargv[0]which is the program name).After that, the client will read all the data coming from the server until the connection is closed. Whatever is read at this point will be printed in
stdout, so git can consume it.For a more exhaustive review of this work, I'd recommend to take a look at the specific desktop-trampoline implementation, more specifically the files in https://github.com/desktop/desktop-trampoline/tree/main/src
Release notes
Notes: [Improved] Remote Git operations are now faster and less prone to errors on Windows.