Commit Graph

269 Commits

Author SHA1 Message Date
Connor Peet
a4585b072e dep: bump the bumpalo 🦬 (#171651)
Fixes https://github.com/microsoft/vscode-internalbacklog/issues/3426
2023-01-18 16:40:11 -08:00
Connor Peet
8965c48d30 wip 2023-01-18 16:15:43 -08:00
Connor Peet
2c2ead679b cli: initial wsl control server
Adds an stdin/out json rpc server for wsl.

Exposes a singular install_local command to install+boot the vscode server on a port from a local archive.

Also refines the common rpc layer some more. I'm decently happy with it now.
2023-01-18 08:23:04 -08:00
Connor Peet
2aecc85c22 cli: update help text of cli for standalone differentiation 2023-01-17 08:19:36 -08:00
Connor Peet
4d882322ca cli: start to extract a generic rpc interface (#171299)
I want to use the rpc interface for communication via stdin/out in wsl,
but currently RPC is tightly coupled to the control server. The control
server also speaks msgpack instead of JSON, since it deals with binary
messages. WSL won't, and we'll want to use JSON to interact with VS
Code, so some separation is needed.

This pulls out a base set of RPC types for use in both scenarios.
Currently these are only 'helper' structs that don't actually do any
i/o, but once I figure out the model I would like to have a cleaner way
to do i/o in a unified way as well.

For the control server, previously we basically handled all methods in
one big `switch` block with nasty macros, whereas now there's
nicer `register_a/sync` functions.

Some additional small refactors were needed to preserve the strict
ordering of server messages, since they need to be order else we get
decompression errors. This is the `start_bridge_write_loop`. As a small
benefit, this means we can avoid the relatively expensive async Tokio
mutex that we were using, and instead use the standard library mutex.
2023-01-16 21:43:41 -08:00
dependabot[bot]
2584c4b68b Bump tokio from 1.21.2 to 1.23.1 in /cli (#170729)
Bumps [tokio](https://github.com/tokio-rs/tokio) from 1.21.2 to 1.23.1.
- [Release notes](https://github.com/tokio-rs/tokio/releases)
- [Commits](https://github.com/tokio-rs/tokio/compare/tokio-1.21.2...tokio-1.23.1)

---
updated-dependencies:
- dependency-name: tokio
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-09 08:18:25 -08:00
logica
dda26d34a8 cli: enable code-tunnel systemd service to start when the machine booted (#170015)
fix [Install] section of systemd service file

change WhantedBy from multi-user.target to default.target
2023-01-05 21:02:22 +00:00
Connor Peet
b5ad508dfb cli: cleanup some process querying code (#170306)
Avoid pulling system info we don't have to.

Minor cleanups while working on https://github.com/microsoft/vscode/pull/170305
2022-12-30 12:55:57 -08:00
Connor Peet
84d2eac2fc cli: output full version (#170057)
Fixes #169635
2022-12-26 20:47:13 +01:00
Connor Peet
82b239204c cli: print oauth errors better, respect slow_down (#169164)
For diagnosing https://github.com/microsoft/vscode/issues/169066
2022-12-14 14:06:24 -05:00
Connor Peet
25cfb20ec9 tunnels: add preview dialog for turning on tunnel access 2022-12-02 09:36:23 -08:00
Connor Peet
c87fa19f79 cli: avoid interactions when running integrated (#167780)
Fixes https://github.com/microsoft/vscode/issues/167760

The VS Code CLI gets run from a bash/shell script. This prevents interactions--in the former case, it doesn't look like a tty, and in the latter case batch scripts don't seem to support having interactive subprocesses.

This PR avoids interactions if stdin is not a tty, prompting the user to use the flag instead. Use of the flag is also persisted like an interactive agreement prompt.
2022-11-30 23:15:08 +00:00
Connor Peet
a315da7910 cli: fix service failing to install on older systemd (#167672)
Fixes https://github.com/microsoft/vscode/issues/167671

In newer systemd, enablement is apparently implicit with 'link', but it must be called for older setups.
2022-11-30 00:34:05 +00:00
Connor Peet
adcffbdce9 cli: use connection token for CLI connections (#167426)
This uses a hash of the tunnel ID to create the connection token, which
should be sufficient to resolve the issues.

We also now publish the protocol version in the tunnel tags, since the
connection token must be supplied in the resolver, which is before we
start connecting to the tunnel.

See https://github.com/microsoft/vscode-internalbacklog/issues/3287
2022-11-28 18:03:15 +01:00
Connor Peet
fb53973c5f cli: pull documentation url from product.json (#166993)
Fixes https://github.com/microsoft/vscode-cli/issues/560
2022-11-22 11:21:41 -08:00
Connor Peet
94ee5f5861 cli: automatically use distro qualities if available (#166961)
A fully-functioning CLI with tunnel capabilities requires product-specific
configuration that is not included in the OSS. This change has the CLI's build
script automatically look for a peer `vscode-distro` folder and, in a debug
build, set its build variables based on that.

It also works to set correct variables if vscode-distro is not found, based on
the OSS product.json (though this is not sufficient to run a fully fledged
tunnel.)
2022-11-22 06:13:16 -08:00
Connor Peet
796ee2bf3c chore: pull more strings from the product.json (#166769)
Fixes the bulk of https://github.com/microsoft/vscode-cli/issues/560
2022-11-18 18:52:52 -08:00
Connor Peet
384ba2454f cli: don't allow/check for updates when integrated (#166759)
Fixes https://github.com/microsoft/vscode-cli/issues/564
2022-11-18 16:29:55 -08:00
Connor Peet
03798c3b1d cli: look for ldconfig in the right location for 32 bit installs (#166723)
See https://github.com/microsoft/vscode-remote-release/issues/7495\#issuecomment-1320331537
2022-11-18 13:34:34 -05:00
Connor Peet
9dd6dc2874 cli: check glibc version more correctly on gnu (#166622)
Fixes https://github.com/microsoft/vscode-remote-release/issues/7495
2022-11-17 11:16:30 -08:00
Connor Peet
707f91aaa6 cli: fix 'failed to lookup tunnel' with a name given (#166507)
Fixes https://github.com/microsoft/vscode-cli/issues/563

If a new tunnel `--name` was provided but the existing tunnel was deleted,
the CLI would error out with a lookup failed message. Instead it now
recreates it like it normally would.
2022-11-16 14:10:49 -08:00
Connor Peet
4c251676ef clippy fixes 2022-11-16 08:51:47 -08:00
Connor Peet
e996746b14 add observability for windows 2022-11-15 20:38:18 -08:00
Connor Peet
1bf3323015 cli: add service integration for macos, observability
Adds support for running the tunnel as a service on macOS via launchservices.

It also hooks up observability (`code tunnel service log`) on macOS and Linux.
On macOS--and later Windows, hence the manual implementation of `tail`--it
saves output to a log file and watches it. On Linux, it simply delegates to
journalctl.

The "tailing" is implemented via simple polling of the file size. I didn't want
to pull in a giant set of dependencies for inotify/kqueue/etc just for this use
case; performance when polling a single log file is not a huge concern.
2022-11-15 15:39:58 -08:00
Connor Peet
c47751948c cli: add service integration for systemd (#166328)
systemd, like most 'modern' linux components, has a nice dbus API. This uses
that API to register the tunnel as a service of the calling user.

The dbus dependency is temporarily duplicated, until secret-service 3 is
released, where they update to the latest version (should be a week or two).

For https://github.com/microsoft/vscode-cli/issues/367. Next up, macOS,
then it's done :)
2022-11-14 21:39:05 -08:00
Connor Peet
aa60836c16 Merge pull request #166139 from microsoft/connor4312/cli-server-message-compression
cli: enable server message compression
2022-11-12 14:40:34 -08:00
Connor Peet
0cd1422809 cli: skip glibc check for nixos
Fixes https://github.com/microsoft/vscode-remote-release/issues/7129
2022-11-11 13:32:41 -08:00
Connor Peet
0f9c86ec84 fixup! windows compilation 2022-11-11 13:16:20 -08:00
Connor Peet
ebfa4b0c3c cli: enable server message compression
This is the CLI side of enabling compression of servermsg's sent
over the socket. It is feature-detected by the CLI sending
protocolVersion=2. If present, the consumer can request compression by
passing `compress:true` when setting up the server.

In this mode, servermsg's are an inflate/deflate stream. Not a ton of
code here, but was lots of fun tweaking to get it right :)

Fixes https://github.com/microsoft/vscode/issues/163688
2022-11-11 11:51:09 -08:00
Connor Peet
446be2cd8b fixup! clippy suggestion 2022-11-10 09:30:50 -08:00
Connor Peet
d31573550f cli: implement local download fallback
Implements an automatic local download fallback, similar to SSH
(cc @roblourens). If the initial download results in an error, either
in making the request or a 5xx, it'll try to fall back to making the
request locally and streaming it over the tunnel.

This abstracts the request client behing a "SimpleHttp" trait which
either uses to the native reqwest or uses the 'delegated' mode over the
socket.
2022-11-09 15:27:47 -08:00
Connor Peet
161418296b cli: allow handling control server requests in parallel
Previously the control server could only handle a single request at a
time. To enable local download mode, this needs to change as the client
will be sending data to the CLI as it downloads the vscode server zip.

This does that. There's a little mess since things that async handlers
need to use are cloned out of the previously unified "context" (we
could try and clone the whole context each time, but this is more work
than needed.) We still keep the fast things as "blocking" since that
avoids the need for clones and separate tasks.
2022-11-08 12:06:49 -08:00
Connor Peet
52804bf2f5 cli: allow passing direct path to the vscode cli in --install-dir
Fixes #164622
2022-11-07 13:19:47 -08:00
Connor Peet
ddb025c979 cli: fix install on windows arm64 not working
Fixes #164573
2022-11-07 09:05:04 -08:00
Joyce Er
fe5f564db1 Attempt to fix Rust clippy lint errors (#165377) 2022-11-03 11:19:58 -04:00
Martin Aeschlimann
70998c096d tunnel --name should rename previous tunnel (#164753)
* tunnel --name should rename old tunnel

* fix clippy warning
2022-10-26 14:44:57 -07:00
Martin Aeschlimann
5a4be3b8a8 tunnel: Generate vanity URL (#164710) 2022-10-26 09:13:29 -04:00
Connor Peet
ae45b3ca2c cli: static link the crt on windows (#164532)
Fixes #164427
2022-10-25 09:59:05 +02:00
Martin Aeschlimann
f10e84118b ci: use tunnelApplicationName (#164257)
fix location of tunnel command in CI and in code
2022-10-23 20:12:23 +03:00
Martin Aeschlimann
66953830a2 tunnel cli: fix windows build (#164141)
* tunnel cli: fix windows build

* remove async
2022-10-23 15:44:56 +02:00
Connor Peet
6c5803b59b Merge pull request #164160 from microsoft/connor4312/standalone-cli-to-deskop
cli: fallback to system installs in the standalone CLI
2022-10-20 14:39:45 -07:00
Connor Peet
a08ec5ce16 fix tests 2022-10-20 11:58:26 -07:00
Connor Peet
c536595a7f cli: fallback to system installs in the standalone CLI
The standalone CLI should detect and fall back to using and
system-installed VS Code instance, rather than trying to download zips
and manage its own VS Code instances.

There are three approaches used for discovery:

- On Windows, we can easily and quickly read the register to find
  installed versions based on their app ID.
- On macOS, we initially look in `/Applications` and fall back to the
  slow `system_profiler` command to list app .app's if that fails.
- On Linux, we just look in the PATH. I believe all Linux installers
  (snap, dep, rpm) automatically add VS Code to the user's PATH.

Failing this, the user can also manually specify their installation dir,
using the command `code version use stable --install-dir /path/to/vscode`.

Fixes #164159
2022-10-20 10:54:13 -07:00
Martin Aeschlimann
1b3bf4a550 Support starting tunnel with a given name (#163818)
* Support starting tunnel with a given name

* improve error message
2022-10-19 23:26:20 +02:00
Martin Aeschlimann
c6188602f4 tunnel cli: add --parent-process-id option (#163935)
* tunnel cli: add --parent-process-id option

* Update cli/src/commands/args.rs

Co-authored-by: Connor Peet <connor@peet.io>

* Change parent process check interval to 2s

Co-authored-by: Connor Peet <connor@peet.io>
2022-10-18 11:52:10 -07:00
Connor Peet
ca1766cee4 rm debug code 2022-10-17 14:45:59 -07:00
Connor Peet
1b17ff429b fix clippy errors 2022-10-17 14:35:20 -07:00
Connor Peet
b987cb47f4 fix integrated cli check 2022-10-17 13:53:06 -07:00
Connor Peet
4e9bdbd44f make self-update work on Linux 2022-10-17 13:38:52 -07:00
Connor Peet
7c3740a7e7 update prepare scripts, license, lockfile 2022-10-17 11:50:49 -07:00