fix #3328
This commit is contained in:
		
							parent
							
								
									4d827708c3
								
							
						
					
					
						commit
						706e080071
					
				| @ -799,3 +799,22 @@ pub fn decode64<T: AsRef<[u8]>>(input: T) -> Result<Vec<u8>, base64::DecodeError | |||||||
|     #[allow(deprecated)] |     #[allow(deprecated)] | ||||||
|     base64::decode(input) |     base64::decode(input) | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | pub async fn get_key(sync: bool) -> String { | ||||||
|  |     let mut key = if sync { | ||||||
|  |         Config::get_option("key") | ||||||
|  |     } else { | ||||||
|  |         let mut options = crate::ipc::get_options_async().await; | ||||||
|  |         options.remove("key").unwrap_or_default() | ||||||
|  |     }; | ||||||
|  |     if key.is_empty() { | ||||||
|  |         #[cfg(windows)] | ||||||
|  |         if let Some(lic) = windows::get_license() { | ||||||
|  |             return lic.key; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |     if key.is_empty() && !option_env!("RENDEZVOUS_SERVER").unwrap_or("").is_empty() { | ||||||
|  |         key = config::RS_PUB_KEY.to_owned(); | ||||||
|  |     } | ||||||
|  |     key | ||||||
|  | } | ||||||
|  | |||||||
| @ -22,14 +22,6 @@ use hbb_common::{message_proto::CursorData, ResultType}; | |||||||
| #[cfg(not(target_os = "macos"))] | #[cfg(not(target_os = "macos"))] | ||||||
| const SERVICE_INTERVAL: u64 = 300; | const SERVICE_INTERVAL: u64 = 300; | ||||||
| 
 | 
 | ||||||
| pub fn get_license_key() -> String { |  | ||||||
|     #[cfg(windows)] |  | ||||||
|     if let Some(lic) = windows::get_license() { |  | ||||||
|         return lic.key; |  | ||||||
|     } |  | ||||||
|     Default::default() |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| pub fn is_xfce() -> bool { | pub fn is_xfce() -> bool { | ||||||
|     #[cfg(target_os = "linux")] |     #[cfg(target_os = "linux")] | ||||||
|     { |     { | ||||||
|  | |||||||
| @ -262,10 +262,7 @@ async fn create_relay_connection_( | |||||||
|     ) |     ) | ||||||
|     .await?; |     .await?; | ||||||
|     let mut msg_out = RendezvousMessage::new(); |     let mut msg_out = RendezvousMessage::new(); | ||||||
|     let mut licence_key = Config::get_option("key"); |     let licence_key = crate::get_key(true).await; | ||||||
|     if licence_key.is_empty() { |  | ||||||
|         licence_key = crate::platform::get_license_key(); |  | ||||||
|     } |  | ||||||
|     msg_out.set_request_relay(RequestRelay { |     msg_out.set_request_relay(RequestRelay { | ||||||
|         licence_key, |         licence_key, | ||||||
|         uuid, |         uuid, | ||||||
|  | |||||||
| @ -13,7 +13,7 @@ use bytes::Bytes; | |||||||
| use rdev::{Event, EventType::*}; | use rdev::{Event, EventType::*}; | ||||||
| use uuid::Uuid; | use uuid::Uuid; | ||||||
| 
 | 
 | ||||||
| use hbb_common::config::{Config, LocalConfig, PeerConfig, RS_PUB_KEY}; | use hbb_common::config::{Config, LocalConfig, PeerConfig}; | ||||||
| use hbb_common::rendezvous_proto::ConnType; | use hbb_common::rendezvous_proto::ConnType; | ||||||
| use hbb_common::tokio::{self, sync::mpsc}; | use hbb_common::tokio::{self, sync::mpsc}; | ||||||
| use hbb_common::{allow_err, message_proto::*}; | use hbb_common::{allow_err, message_proto::*}; | ||||||
| @ -1055,15 +1055,8 @@ impl<T: InvokeUiSession> Session<T> { | |||||||
| pub async fn io_loop<T: InvokeUiSession>(handler: Session<T>) { | pub async fn io_loop<T: InvokeUiSession>(handler: Session<T>) { | ||||||
|     let (sender, mut receiver) = mpsc::unbounded_channel::<Data>(); |     let (sender, mut receiver) = mpsc::unbounded_channel::<Data>(); | ||||||
|     *handler.sender.write().unwrap() = Some(sender.clone()); |     *handler.sender.write().unwrap() = Some(sender.clone()); | ||||||
|     let mut options = crate::ipc::get_options_async().await; |  | ||||||
|     let mut key = options.remove("key").unwrap_or("".to_owned()); |  | ||||||
|     let token = LocalConfig::get_option("access_token"); |     let token = LocalConfig::get_option("access_token"); | ||||||
|     if key.is_empty() { |     let key = crate::get_key(false).await; | ||||||
|         key = crate::platform::get_license_key(); |  | ||||||
|     } |  | ||||||
|     if key.is_empty() && !option_env!("RENDEZVOUS_SERVER").unwrap_or("").is_empty() { |  | ||||||
|         key = RS_PUB_KEY.to_owned(); |  | ||||||
|     } |  | ||||||
|     #[cfg(not(any(target_os = "android", target_os = "ios")))] |     #[cfg(not(any(target_os = "android", target_os = "ios")))] | ||||||
|     if handler.is_port_forward() { |     if handler.is_port_forward() { | ||||||
|         if handler.is_rdp() { |         if handler.is_rdp() { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user