mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-27 03:54:24 +01:00
move cli to top level
This commit is contained in:
43
cli/src/constants.rs
Normal file
43
cli/src/constants.rs
Normal file
@@ -0,0 +1,43 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
use lazy_static::lazy_static;
|
||||
|
||||
pub const CONTROL_PORT: u16 = 31545;
|
||||
pub const PROTOCOL_VERSION: u32 = 1;
|
||||
|
||||
pub const LAUNCHER_VERSION: Option<&'static str> = option_env!("LAUNCHER_VERSION");
|
||||
pub const LAUNCHER_ASSET_NAME: Option<&'static str> =
|
||||
if cfg!(all(target_os = "macos", target_arch = "x86_64")) {
|
||||
Some("x86_64-apple-darwin-signed")
|
||||
} else if cfg!(all(target_os = "macos", target_arch = "aarch64")) {
|
||||
Some("aarch64-apple-darwin-signed")
|
||||
} else if cfg!(all(target_os = "windows", target_arch = "x86_64")) {
|
||||
Some("x86_64-pc-windows-msvc-signed")
|
||||
} else if cfg!(all(target_os = "windows", target_arch = "aarch64")) {
|
||||
Some("aarch64-pc-windows-msvc-signed")
|
||||
} else {
|
||||
option_env!("LAUNCHER_ASSET_NAME")
|
||||
};
|
||||
|
||||
pub const LAUNCHER_AI_KEY: Option<&'static str> = option_env!("LAUNCHER_AI_KEY");
|
||||
pub const LAUNCHER_AI_ENDPOINT: Option<&'static str> = option_env!("LAUNCHER_AI_ENDPOINT");
|
||||
|
||||
pub const TUNNEL_SERVICE_USER_AGENT_ENV_VAR: &str = "TUNNEL_SERVICE_USER_AGENT";
|
||||
|
||||
pub fn get_default_user_agent() -> String {
|
||||
format!(
|
||||
"vscode-server-launcher/{}",
|
||||
LAUNCHER_VERSION.unwrap_or("dev")
|
||||
)
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
pub static ref TUNNEL_SERVICE_USER_AGENT: String =
|
||||
match std::env::var(TUNNEL_SERVICE_USER_AGENT_ENV_VAR) {
|
||||
Ok(ua) if !ua.is_empty() => format!("{} {}", ua, get_default_user_agent()),
|
||||
_ => get_default_user_agent(),
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user