Merge pull request #5483 from sahilyeole/master

Using github latest release url to check for software update
This commit is contained in:
RustDesk 2023-08-23 12:02:45 +08:00 committed by GitHub
commit fb5a6c20de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 23 deletions

View File

@ -831,30 +831,19 @@ pub fn check_software_update() {
#[tokio::main(flavor = "current_thread")]
async fn check_software_update_() -> hbb_common::ResultType<()> {
sleep(3.).await;
let url = "https://github.com/rustdesk/rustdesk/releases/latest";
let latest_release_response = reqwest::get(url).await?;
let latest_release_version = latest_release_response
.url()
.path()
.rsplit('/')
.next()
.unwrap();
let rendezvous_server = format!("rs-sg.rustdesk.com:{}", config::RENDEZVOUS_PORT);
let (mut socket, rendezvous_server) =
socket_client::new_udp_for(&rendezvous_server, CONNECT_TIMEOUT).await?;
let response_url = latest_release_response.url().to_string();
let mut msg_out = RendezvousMessage::new();
msg_out.set_software_update(SoftwareUpdate {
url: crate::VERSION.to_owned(),
..Default::default()
});
socket.send(&msg_out, rendezvous_server).await?;
use hbb_common::protobuf::Message;
for _ in 0..2 {
if let Some(Ok((bytes, _))) = socket.next_timeout(READ_TIMEOUT).await {
if let Ok(msg_in) = RendezvousMessage::parse_from_bytes(&bytes) {
if let Some(rendezvous_message::Union::SoftwareUpdate(su)) = msg_in.union {
let version = hbb_common::get_version_from_url(&su.url);
if get_version_number(&version) > get_version_number(crate::VERSION) {
*SOFTWARE_UPDATE_URL.lock().unwrap() = su.url;
}
}
}
}
if get_version_number(&latest_release_version) > get_version_number(crate::VERSION) {
*SOFTWARE_UPDATE_URL.lock().unwrap() = response_url;
}
Ok(())
}

View File

@ -594,7 +594,8 @@ pub fn current_is_wayland() -> bool {
#[inline]
pub fn get_new_version() -> String {
hbb_common::get_version_from_url(&*SOFTWARE_UPDATE_URL.lock().unwrap())
// hbb_common::get_version_from_url(&*SOFTWARE_UPDATE_URL.lock().unwrap())
(*SOFTWARE_UPDATE_URL.lock().unwrap().rsplit('/').next().unwrap_or("")).to_string()
}
#[inline]