Skip to content

Commit 679bb96

Browse files
authored
cli: add stdio control server
* signing: implement signing service on the web * wip * cli: implement stdio service This is used to implement the exec server for WSL. Guarded behind a signed handshake. * update distro * rm debug * address pr comments
1 parent c125687 commit 679bb96

19 files changed

+556
-402
lines changed

cli/Cargo.lock

Lines changed: 0 additions & 55 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ flate2 = { version = "1.0.22" }
2222
zip = { version = "0.5.13", default-features = false, features = ["time", "deflate"] }
2323
regex = { version = "1.5.5" }
2424
lazy_static = { version = "1.4.0" }
25-
sysinfo = { version = "0.27.7" }
25+
sysinfo = { version = "0.27.7", default-features = false }
2626
serde = { version = "1.0", features = ["derive"] }
2727
serde_json = { version = "1.0" }
2828
rmp-serde = "1.0"

cli/src/bin/code/main.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::process::Command;
88

99
use clap::Parser;
1010
use cli::{
11-
commands::{args, internal_wsl, tunnels, update, version, CommandContext},
11+
commands::{args, tunnels, update, version, CommandContext},
1212
constants::get_default_user_agent,
1313
desktop, log,
1414
state::LauncherPaths,
@@ -65,9 +65,6 @@ async fn main() -> Result<(), std::convert::Infallible> {
6565
..
6666
}) => match cmd {
6767
args::StandaloneCommands::Update(args) => update::update(context!(), args).await,
68-
args::StandaloneCommands::Wsl(args) => match args.command {
69-
args::WslCommands::Serve => internal_wsl::serve(context!()).await,
70-
},
7168
},
7269
args::AnyCli::Standalone(args::StandaloneCli { core: c, .. })
7370
| args::AnyCli::Integrated(args::IntegratedCli { core: c, .. }) => match c.subcommand {
@@ -98,6 +95,8 @@ async fn main() -> Result<(), std::convert::Infallible> {
9895
args::VersionSubcommand::Show => version::show(context!()).await,
9996
},
10097

98+
Some(args::Commands::CommandShell) => tunnels::command_shell(context!()).await,
99+
101100
Some(args::Commands::Tunnel(tunnel_args)) => match tunnel_args.subcommand {
102101
Some(args::TunnelSubcommand::Prune) => tunnels::prune(context!()).await,
103102
Some(args::TunnelSubcommand::Unregister) => tunnels::unregister(context!()).await,

cli/src/commands.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
mod context;
77

88
pub mod args;
9-
pub mod internal_wsl;
109
pub mod tunnels;
1110
pub mod update;
1211
pub mod version;

cli/src/commands/args.rs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -146,22 +146,6 @@ impl<'a> From<&'a CliCore> for CodeServerArgs {
146146
pub enum StandaloneCommands {
147147
/// Updates the CLI.
148148
Update(StandaloneUpdateArgs),
149-
150-
/// Internal commands for WSL serving.
151-
#[clap(hide = true)]
152-
Wsl(WslArgs),
153-
}
154-
155-
#[derive(Args, Debug, Clone)]
156-
pub struct WslArgs {
157-
#[clap(subcommand)]
158-
pub command: WslCommands,
159-
}
160-
161-
#[derive(Subcommand, Debug, Clone)]
162-
pub enum WslCommands {
163-
/// Runs the WSL server on stdin/out
164-
Serve,
165149
}
166150

167151
#[derive(Args, Debug, Clone)]
@@ -187,6 +171,10 @@ pub enum Commands {
187171

188172
/// Changes the version of the editor you're using.
189173
Version(VersionArgs),
174+
175+
/// Runs the control server on process stdin/stdout
176+
#[clap(hide = true)]
177+
CommandShell,
190178
}
191179

192180
#[derive(Args, Debug, Clone)]

cli/src/commands/internal_wsl.rs

Lines changed: 0 additions & 32 deletions
This file was deleted.

cli/src/commands/tunnels.rs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ use crate::{
2525
code_server::CodeServerArgs,
2626
create_service_manager, dev_tunnels, legal,
2727
paths::get_all_servers,
28-
protocol,
28+
protocol, serve_stream,
2929
shutdown_signal::ShutdownRequest,
3030
singleton_client::do_single_rpc_call,
3131
singleton_server::{
3232
make_singleton_server, start_singleton_server, BroadcastLogSink, SingletonServerArgs,
3333
},
34-
Next, ServiceContainer, ServiceManager,
34+
Next, ServeStreamParams, ServiceContainer, ServiceManager,
3535
},
3636
util::{
3737
app_lock::AppMutex,
@@ -107,6 +107,25 @@ impl ServiceContainer for TunnelServiceContainer {
107107
}
108108
}
109109

110+
pub async fn command_shell(ctx: CommandContext) -> Result<i32, AnyError> {
111+
let platform = PreReqChecker::new().verify().await?;
112+
serve_stream(
113+
tokio::io::stdin(),
114+
tokio::io::stderr(),
115+
ServeStreamParams {
116+
log: ctx.log,
117+
launcher_paths: ctx.paths,
118+
platform,
119+
requires_auth: true,
120+
exit_barrier: ShutdownRequest::create_rx([ShutdownRequest::CtrlC]),
121+
code_server_args: (&ctx.args).into(),
122+
},
123+
)
124+
.await;
125+
126+
Ok(0)
127+
}
128+
110129
pub async fn service(
111130
ctx: CommandContext,
112131
service_args: TunnelServiceSubCommands,

cli/src/constants.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ pub const CONTROL_PORT: u16 = 31545;
1818
/// 2 - Addition of `serve.compressed` property to control whether servermsg's
1919
/// are compressed bidirectionally.
2020
/// 3 - The server's connection token is set to a SHA256 hash of the tunnel ID
21-
pub const PROTOCOL_VERSION: u32 = 3;
21+
/// 4 - The server's msgpack messages are no longer length-prefixed
22+
pub const PROTOCOL_VERSION: u32 = 4;
2223

2324
/// Prefix for the tunnel tag that includes the version.
2425
pub const PROTOCOL_VERSION_TAG_PREFIX: &str = "protocolv";

0 commit comments

Comments
 (0)