mirror of
				https://github.com/snltty/linker.git
				synced 2025-10-31 04:26:45 +08:00 
			
		
		
		
	167
This commit is contained in:
		| @@ -31,12 +31,10 @@ namespace linker.messenger.updater | |||||||
|         { |         { | ||||||
|             return updaterClientStore.SecretKey; |             return updaterClientStore.SecretKey; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         public void SetSecretKey(ApiControllerParamsInfo param) |         public void SetSecretKey(ApiControllerParamsInfo param) | ||||||
|         { |         { | ||||||
|             updaterClientStore.SetSecretKey(param.Content); |             updaterClientStore.SetSecretKey(param.Content); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         public void SetInterval(ApiControllerParamsInfo param) |         public void SetInterval(ApiControllerParamsInfo param) | ||||||
|         { |         { | ||||||
|             updaterCommonTransfer.SetInterval(int.Parse(param.Content)); |             updaterCommonTransfer.SetInterval(int.Parse(param.Content)); | ||||||
| @@ -56,7 +54,6 @@ namespace linker.messenger.updater | |||||||
|             } |             } | ||||||
|             return new UpdaterInfo(); |             return new UpdaterInfo(); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         public async Task ConfirmServer(ApiControllerParamsInfo param) |         public async Task ConfirmServer(ApiControllerParamsInfo param) | ||||||
|         { |         { | ||||||
|             await messengerSender.SendOnly(new MessageRequestWrap |             await messengerSender.SendOnly(new MessageRequestWrap | ||||||
| @@ -66,7 +63,6 @@ namespace linker.messenger.updater | |||||||
|                 Payload = serializer.Serialize(new UpdaterConfirmServerInfo { SecretKey = updaterClientStore.SecretKey, Version = param.Content }) |                 Payload = serializer.Serialize(new UpdaterConfirmServerInfo { SecretKey = updaterClientStore.SecretKey, Version = param.Content }) | ||||||
|             }); |             }); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         public async Task ExitServer(ApiControllerParamsInfo param) |         public async Task ExitServer(ApiControllerParamsInfo param) | ||||||
|         { |         { | ||||||
|             await messengerSender.SendOnly(new MessageRequestWrap |             await messengerSender.SendOnly(new MessageRequestWrap | ||||||
| @@ -142,7 +138,6 @@ namespace linker.messenger.updater | |||||||
|             return true; |             return true; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |  | ||||||
|         public async Task Subscribe(ApiControllerParamsInfo param) |         public async Task Subscribe(ApiControllerParamsInfo param) | ||||||
|         { |         { | ||||||
|             await messengerSender.SendOnly(new MessageRequestWrap |             await messengerSender.SendOnly(new MessageRequestWrap | ||||||
|   | |||||||
| @@ -1,7 +1,6 @@ | |||||||
| using linker.libs; | using linker.libs; | ||||||
| using System.Collections.Concurrent; | using System.Collections.Concurrent; | ||||||
| using linker.messenger.signin; | using linker.messenger.signin; | ||||||
| using linker.libs.extends; |  | ||||||
|  |  | ||||||
| namespace linker.messenger.updater | namespace linker.messenger.updater | ||||||
| { | { | ||||||
| @@ -34,7 +33,7 @@ namespace linker.messenger.updater | |||||||
|         } |         } | ||||||
|         private void Init() |         private void Init() | ||||||
|         { |         { | ||||||
|             LoadTask(); |             CheckTask(); | ||||||
|             UpdateTask(); |             UpdateTask(); | ||||||
|             updateInfo.Update(); |             updateInfo.Update(); | ||||||
|         } |         } | ||||||
| @@ -88,14 +87,6 @@ namespace linker.messenger.updater | |||||||
|                 updateInfo.Update(); |                 updateInfo.Update(); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         public void Check() |  | ||||||
|         { |  | ||||||
|             if (LoggerHelper.Instance.LoggerLevel <= LoggerTypes.DEBUG) |  | ||||||
|                 LoggerHelper.Instance.Info($"check update"); |  | ||||||
|             _ = updaterHelper.GetUpdateInfo(updateInfo); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         private void UpdateTask() |         private void UpdateTask() | ||||||
|         { |         { | ||||||
|             TimerHelper.SetInterval(async () => |             TimerHelper.SetInterval(async () => | ||||||
| @@ -119,19 +110,44 @@ namespace linker.messenger.updater | |||||||
|             }, () => lastTicksManager.DiffLessEqual(5000) ? 1000 : 15000); |             }, () => lastTicksManager.DiffLessEqual(5000) ? 1000 : 15000); | ||||||
|  |  | ||||||
|         } |         } | ||||||
|         private void LoadTask() |  | ||||||
|  |         public void Check() | ||||||
|  |         { | ||||||
|  |             if (LoggerHelper.Instance.LoggerLevel <= LoggerTypes.DEBUG) | ||||||
|  |                 LoggerHelper.Instance.Info($"check update"); | ||||||
|  |             _ = GetUpdateInfo(); | ||||||
|  |         } | ||||||
|  |         private void CheckTask() | ||||||
|         { |         { | ||||||
|             TimerHelper.SetInterval(async () => |             TimerHelper.SetInterval(async () => | ||||||
|             { |             { | ||||||
|                 if (updaterCommonTransfer.CheckUpdate) |                 if (updaterCommonTransfer.CheckUpdate) | ||||||
|                 { |                 { | ||||||
|                     await updaterHelper.GetUpdateInfo(updateInfo); |                     await GetUpdateInfo(); | ||||||
|                 } |                 } | ||||||
|                 return true; |                 return true; | ||||||
|             }, () => updaterCommonTransfer.UpdateIntervalSeconds * 1000); |             }, () => updaterCommonTransfer.UpdateIntervalSeconds * 1000); | ||||||
|         } |         } | ||||||
|  |         private async Task GetUpdateInfo() | ||||||
|  |         { | ||||||
|  |             if (updateInfo.Status > UpdaterStatus.Checked) return; | ||||||
|  |  | ||||||
|  |             MessageResponeInfo resp = await messengerSender.SendReply(new MessageRequestWrap | ||||||
|  |             { | ||||||
|  |                 Connection = signInClientState.Connection, | ||||||
|  |                 MessengerId = (ushort)UpdaterMessengerIds.UpdateServer, | ||||||
|  |             }); | ||||||
|  |             if (resp.Code == MessageResponeCodes.OK && resp.Data.Length > 0) | ||||||
|  |             { | ||||||
|  |                 UpdaterInfo info = serializer.Deserialize<UpdaterInfo>(resp.Data.Span); | ||||||
|  |                 if (info.Status <= UpdaterStatus.Checked && updateInfo.Status <= UpdaterStatus.Checked) | ||||||
|  |                 { | ||||||
|  |                     updateInfo.Status = info.Status; | ||||||
|  |                     updateInfo.Version = info.Version; | ||||||
|  |                     updateInfo.DateTime = info.DateTime; | ||||||
|  |                     updateInfo.Msg = info.Msg; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -33,8 +33,9 @@ namespace linker.messenger.updater | |||||||
|             try |             try | ||||||
|             { |             { | ||||||
|                 updateInfo.Status = UpdaterStatus.Checking; |                 updateInfo.Status = UpdaterStatus.Checking; | ||||||
|  |                 using HttpClientHandler handler = new HttpClientHandler(); | ||||||
|                 using HttpClient httpClient = new HttpClient(); |                 handler.ServerCertificateCustomValidationCallback = (sender, cert, chain, sslPolicyErrors) => true; | ||||||
|  |                 using HttpClient httpClient = new HttpClient(handler); | ||||||
|                 string str = await httpClient.GetStringAsync($"{updaterCommonTransfer.UpdateUrl}/version.txt").WaitAsync(TimeSpan.FromSeconds(15)); |                 string str = await httpClient.GetStringAsync($"{updaterCommonTransfer.UpdateUrl}/version.txt").WaitAsync(TimeSpan.FromSeconds(15)); | ||||||
|  |  | ||||||
|                 string[] arr = str.Split(Environment.NewLine).Select(c => c.Trim('\r').Trim('\n')).ToArray(); |                 string[] arr = str.Split(Environment.NewLine).Select(c => c.Trim('\r').Trim('\n')).ToArray(); | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| v1.6.7 | v1.6.7 | ||||||
| 2025-02-18 10:38:06 | 2025-02-18 11:10:37 | ||||||
| 1. 修复首次启动网卡未启动bug | 1. 修复首次启动网卡未启动bug | ||||||
| 2. 自定义网卡名 | 2. 自定义网卡名 | ||||||
| 3. 可禁用NAT | 3. 可禁用NAT | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 snltty
					snltty