From b22edbb92ba99f3931dbb33595c4d098ca82cf10 Mon Sep 17 00:00:00 2001 From: SherkeyXD <253294679@qq.com> Date: Mon, 22 Jan 2024 13:22:08 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=BF=9C=E7=A8=8B=E6=8E=A7=E5=88=B6?= =?UTF-8?q?=E5=AF=B9=E9=9D=9E=20https=20=E8=BF=9E=E6=8E=A5=E4=BB=85?= =?UTF-8?q?=E6=8F=90=E5=87=BA=E8=AD=A6=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MaaWpfGui/Res/Localizations/en-us.xaml | 3 +- src/MaaWpfGui/Res/Localizations/ja-jp.xaml | 3 +- src/MaaWpfGui/Res/Localizations/ko-kr.xaml | 3 +- src/MaaWpfGui/Res/Localizations/zh-cn.xaml | 3 +- src/MaaWpfGui/Res/Localizations/zh-tw.xaml | 3 +- .../RemoteControl/RemoteControlService.cs | 48 +++++++++++++------ 6 files changed, 43 insertions(+), 20 deletions(-) diff --git a/src/MaaWpfGui/Res/Localizations/en-us.xaml b/src/MaaWpfGui/Res/Localizations/en-us.xaml index 192f28ac38..c5663767aa 100644 --- a/src/MaaWpfGui/Res/Localizations/en-us.xaml +++ b/src/MaaWpfGui/Res/Localizations/en-us.xaml @@ -730,7 +730,8 @@ The video aspect ratio needs to be 16:9 without interference factors such as bla Connection Test Successful! Connection Test Failed, reason: {0}. Connection Test Failed, Endpoint is empty. - Connection Test Failed. Endpoint is not an https address. + Connection Test Failed, Endpoint is not an http or https address. + Endpoint is using http, might be unsafe. Received remote task {0}, Task Id:{1}. Completed remote task {0}, Task Id:{1}. Caution: Entering addresses from unknown sources may result in the loss of your Arknights account. diff --git a/src/MaaWpfGui/Res/Localizations/ja-jp.xaml b/src/MaaWpfGui/Res/Localizations/ja-jp.xaml index 374b235670..6c8c91ab94 100644 --- a/src/MaaWpfGui/Res/Localizations/ja-jp.xaml +++ b/src/MaaWpfGui/Res/Localizations/ja-jp.xaml @@ -730,7 +730,8 @@ Bilibili: ログイン インターフェイスに表示されるアカウント 接続テスト成功! 接続テスト失敗、理由: {0}。 接続テスト失敗、エンドポイントが空です。 - 接続テスト失敗。エンドポイントはhttpsアドレスではありません。 + 接続テストに失敗しました。接続エンドポイントが http または https アドレスではありませんでした。 + 接続エンドポイントがhttpsに対応しておらず、安全でない可能性があります。 リモートタスク{0}を受信、タスクId:{1}。 リモートタスク{0}を完了、タスクId:{1}。 注意:知らない出所のアドレスを入力すると、あなたの明日方舟のアカウントが損失する可能性があります。 diff --git a/src/MaaWpfGui/Res/Localizations/ko-kr.xaml b/src/MaaWpfGui/Res/Localizations/ko-kr.xaml index 33ffb149d7..69f65e81ae 100644 --- a/src/MaaWpfGui/Res/Localizations/ko-kr.xaml +++ b/src/MaaWpfGui/Res/Localizations/ko-kr.xaml @@ -730,7 +730,8 @@ Bilibili: 로그인 인터페이스에 표시되는 계정 이름(예: 장산) 연결 테스트 성공! 연결 테스트 실패, 이유: {0}. 연결 테스트 실패, 엔드포인트가 비어 있습니다. - 연결 테스트 실패. 엔드포인트가 https 주소가 아닙니다. + 연결 테스트에 실패했습니다. 연결 엔드포인트가 http 또는 https 주소가 아닙니다. + 연결 엔드포인트가 https를 사용하도록 설정되어 있지 않으며 안전하지 않을 수 있습니다. 원격 작업 {0} 받음, 작업 Id:{1}. 원격 작업 {0} 완료, 작업 Id:{1}. 주의: 알려지지 않은 출처의 주소를 입력하면 당신의 아크나이츠 계정에 손실이 발생할 수 있습니다. diff --git a/src/MaaWpfGui/Res/Localizations/zh-cn.xaml b/src/MaaWpfGui/Res/Localizations/zh-cn.xaml index 6fbd5893f3..93d7d9d86b 100644 --- a/src/MaaWpfGui/Res/Localizations/zh-cn.xaml +++ b/src/MaaWpfGui/Res/Localizations/zh-cn.xaml @@ -729,7 +729,8 @@ 连接测试成功! 连接测试失败,原因: {0}。 连接测试失败,连接端点为空。 - 连接测试失败。端点不是https地址。 + 连接测试失败,连接端点不为http(s)地址。 + 连接端点未启用https,可能不安全。 收到远端任务{0},任务Id:{1}。 完成远端任务{0},任务Id:{1}。 注意:随意填入未知来源的地址可能会导致您的账户受到损失。 diff --git a/src/MaaWpfGui/Res/Localizations/zh-tw.xaml b/src/MaaWpfGui/Res/Localizations/zh-tw.xaml index 9c3f284230..3667bca55d 100644 --- a/src/MaaWpfGui/Res/Localizations/zh-tw.xaml +++ b/src/MaaWpfGui/Res/Localizations/zh-tw.xaml @@ -727,7 +727,8 @@ 連接測試成功! 連接測試失敗,原因: {0}。 連接測試失敗,連接端點為空。 - 連接測試失敗。端點非https地址。 + 連接測試失敗,連接端點不為http(s)地址。 + 連接端點未啟用https,可能不安全。 收到遠端任務{0},任務Id:{1}。 完成遠端任務{0},任務Id:{1}。 注意:隨意輸入未知來源的地址可能會導致您的明日方舟帳戶受到損失。 diff --git a/src/MaaWpfGui/Services/RemoteControl/RemoteControlService.cs b/src/MaaWpfGui/Services/RemoteControl/RemoteControlService.cs index 01603fd6d5..2b8f129a7d 100644 --- a/src/MaaWpfGui/Services/RemoteControl/RemoteControlService.cs +++ b/src/MaaWpfGui/Services/RemoteControl/RemoteControlService.cs @@ -247,7 +247,7 @@ namespace MaaWpfGui.Services.RemoteControl { var endpoint = Instances.SettingsViewModel.RemoteControlGetTaskEndpointUri; - if (string.IsNullOrWhiteSpace(endpoint) || !endpoint.ToLower().StartsWith("https://")) + if (!IsEndpointValid(endpoint)) { return; } @@ -435,7 +435,7 @@ namespace MaaWpfGui.Services.RemoteControl } var endpoint = Instances.SettingsViewModel.RemoteControlReportStatusUri; - if (!string.IsNullOrWhiteSpace(endpoint) && endpoint.ToLower().StartsWith("https://")) + if (IsEndpointValid(endpoint)) { var uid = Instances.SettingsViewModel.RemoteControlUserIdentity; var did = Instances.SettingsViewModel.RemoteControlDeviceIdentity; @@ -530,7 +530,7 @@ namespace MaaWpfGui.Services.RemoteControl } var endpoint = Instances.SettingsViewModel.RemoteControlReportStatusUri; - if (!string.IsNullOrWhiteSpace(endpoint) && endpoint.ToLower().StartsWith("https://")) + if (IsEndpointValid(endpoint)) { var uid = Instances.SettingsViewModel.RemoteControlUserIdentity; var did = Instances.SettingsViewModel.RemoteControlDeviceIdentity; @@ -694,19 +694,8 @@ namespace MaaWpfGui.Services.RemoteControl { var endpoint = Instances.SettingsViewModel.RemoteControlGetTaskEndpointUri; - if (string.IsNullOrWhiteSpace(endpoint)) + if (!IsEndpointValid(endpoint)) { - using var toastEmpty = new ToastNotification( - LocalizationHelper.GetString("RemoteControlConnectionTestFailEmpty")); - toastEmpty.Show(); - return; - } - - if (!endpoint.ToLower().StartsWith("https://")) - { - using var toastEmpty = new ToastNotification( - LocalizationHelper.GetString("RemoteControlConnectionTestFailNotHttps")); - toastEmpty.Show(); return; } @@ -765,5 +754,34 @@ namespace MaaWpfGui.Services.RemoteControl { Instances.SettingsViewModel.RemoteControlDeviceIdentity = Guid.NewGuid().ToString("N"); } + + public static bool IsEndpointValid(string endpoint) + { + if (string.IsNullOrWhiteSpace(endpoint)) + { + using var toast = new ToastNotification(LocalizationHelper.GetString("RemoteControlConnectionTestFailEmpty")); + toast.Show(); + return false; + } + + string lowerEndpoint = endpoint.ToLower(); + + if (lowerEndpoint.StartsWith("https://")) + { + return true; + } + else if (lowerEndpoint.StartsWith("http://")) + { + using var toast = new ToastNotification(LocalizationHelper.GetString("RemoteControlConnectionTestWarningHttpUnsafe")); + toast.Show(); + return true; + } + else + { + using var toast = new ToastNotification(LocalizationHelper.GetString("RemoteControlConnectionTestFailNotHttpOrHttps")); + toast.Show(); + return false; + } + } } }