Allow setting custom server and key with env variables #2810

This commit is contained in:
rustdesk 2023-01-18 14:22:41 +08:00
parent 5dcc77cf7b
commit 8fb3c452be
6 changed files with 15 additions and 33 deletions

View File

@ -15,6 +15,8 @@ env:
# for multiarch gcc compatibility
VCPKG_COMMIT_ID: "14e7bb4ae24616ec54ff6b2f6ef4e8659434ea44"
VERSION: "1.2.0"
RS_PUB_KEY: '${{ secrets.RS_PUB_KEY }}'
RENDEZVOUS_SERVER: '${{ secrets.RENDEZVOUS_SERVER }}'
jobs:
build-for-windows:

View File

@ -49,7 +49,10 @@ lazy_static::lazy_static! {
static ref CONFIG2: Arc<RwLock<Config2>> = Arc::new(RwLock::new(Config2::load()));
static ref LOCAL_CONFIG: Arc<RwLock<LocalConfig>> = Arc::new(RwLock::new(LocalConfig::load()));
pub static ref ONLINE: Arc<Mutex<HashMap<String, i64>>> = Default::default();
pub static ref PROD_RENDEZVOUS_SERVER: Arc<RwLock<String>> = Default::default();
pub static ref PROD_RENDEZVOUS_SERVER: Arc<RwLock<String>> = Arc::new(RwLock::new(match option_env!("RENDEZVOUS_SERVER") {
Some(key) => key,
_ => "",
}.to_owned()));
pub static ref APP_NAME: Arc<RwLock<String>> = Arc::new(RwLock::new("RustDesk".to_owned()));
static ref KEY_PAIR: Arc<Mutex<Option<(Vec<u8>, Vec<u8>)>>> = Default::default();
static ref HW_CODEC_CONFIG: Arc<RwLock<HwCodecConfig>> = Arc::new(RwLock::new(HwCodecConfig::load()));
@ -77,12 +80,17 @@ const CHARS: &'static [char] = &[
'm', 'n', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
];
pub const RENDEZVOUS_SERVERS: &'static [&'static str] = &[
const RENDEZVOUS_SERVERS: &'static [&'static str] = &[
"rs-ny.rustdesk.com",
"rs-sg.rustdesk.com",
"rs-cn.rustdesk.com",
];
pub const RS_PUB_KEY: &'static str = "OeVuKk5nlHiXp+APNn0Y3pC1Iwpwn44JGqrQCsWqmBw=";
pub const RS_PUB_KEY: &'static str = match option_env!("RS_PUB_KEY") {
Some(key) => key,
None => "OeVuKk5nlHiXp+APNn0Y3pC1Iwpwn44JGqrQCsWqmBw=",
};
pub const RENDEZVOUS_PORT: i32 = 21116;
pub const RELAY_PORT: i32 = 21117;

View File

@ -1368,22 +1368,6 @@ pub fn get_license() -> Option<License> {
pub fn bootstrap() {
if let Some(lic) = get_license() {
*config::PROD_RENDEZVOUS_SERVER.write().unwrap() = lic.host.clone();
#[cfg(feature = "hbbs")]
{
if !is_win_server() {
return;
}
crate::hbbs::bootstrap(&lic.key, &lic.host);
std::thread::spawn(move || loop {
let tmp = Config::get_option("stop-rendezvous-service");
if tmp.is_empty() {
crate::hbbs::start();
} else {
crate::hbbs::stop();
}
std::thread::sleep(std::time::Duration::from_millis(100));
});
}
}
}

View File

@ -208,10 +208,6 @@ impl UI {
show_run_without_install()
}
fn has_rendezvous_service(&self) -> bool {
has_rendezvous_service()
}
fn get_license(&self) -> String {
get_license()
}
@ -599,7 +595,6 @@ impl sciter::EventHandler for UI {
fn peer_has_password(String);
fn forget_password(String);
fn set_peer_option(String, String, String);
fn has_rendezvous_service();
fn get_license();
fn test_if_valid_server(String);
fn get_sound_inputs();

View File

@ -310,7 +310,6 @@ class MyIdMenu: Reactor.Component {
{handler.is_rdp_service_open() ? <ShareRdp /> : ""}
<DirectServer />
{false && handler.using_public_server() && <li #allow-always-relay><span>{svg_checkmark}</span>{translate('Always connected via relay')}</li>}
{handler.has_rendezvous_service() ? <li #stop-rendezvous-service>{translate(rendezvous_service_stopped ? "Start ID/relay service" : "Stop ID/relay service")}</li> : ""}
{handler.is_ok_change_id() ? <div .separator /> : ""}
{username ?
<li #logout>{translate('Logout')} ({username})</li> :

View File

@ -134,13 +134,6 @@ pub fn show_run_without_install() -> bool {
false
}
#[inline]
pub fn has_rendezvous_service() -> bool {
#[cfg(all(windows, feature = "hbbs"))]
return crate::platform::is_win_server() && crate::platform::windows::get_license().is_some();
return false;
}
#[inline]
pub fn get_license() -> String {
#[cfg(windows)]
@ -243,7 +236,8 @@ pub fn set_peer_option(id: String, name: String, value: String) {
#[inline]
pub fn using_public_server() -> bool {
crate::get_custom_rendezvous_server(get_option_("custom-rendezvous-server")).is_empty()
option_env!("RENDEZVOUS_SERVER").is_none()
&& crate::get_custom_rendezvous_server(get_option_("custom-rendezvous-server")).is_empty()
}
#[inline]