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
This commit is contained in:
Connor Peet
2022-11-11 11:48:16 -08:00
parent b982536f83
commit ebfa4b0c3c
7 changed files with 317 additions and 72 deletions

View File

@@ -10,7 +10,13 @@ use lazy_static::lazy_static;
use crate::options::Quality;
pub const CONTROL_PORT: u16 = 31545;
pub const PROTOCOL_VERSION: u32 = 1;
/// Protocol version sent to clients. This can be used to indiciate new or
/// changed capabilities that clients may wish to leverage.
/// 1 - Initial protocol version
/// 2 - Addition of `serve.compressed` property to control whether servermsg's
/// are compressed bidirectionally.
pub const PROTOCOL_VERSION: u32 = 2;
pub const VSCODE_CLI_VERSION: Option<&'static str> = option_env!("VSCODE_CLI_VERSION");
pub const VSCODE_CLI_AI_KEY: Option<&'static str> = option_env!("VSCODE_CLI_AI_KEY");