feat: 远程控制对非 https 连接仅提出警告

This commit is contained in:
SherkeyXD
2024-01-22 13:22:08 +08:00
parent 8e90f981fb
commit b22edbb92b
6 changed files with 43 additions and 20 deletions

View File

@@ -730,7 +730,8 @@ The video aspect ratio needs to be 16:9 without interference factors such as bla
<system:String x:Key="RemoteControlConnectionTestSuccess">Connection Test Successful!</system:String>
<system:String x:Key="RemoteControlConnectionTestFail">Connection Test Failed, reason: {0}.</system:String>
<system:String x:Key="RemoteControlConnectionTestFailEmpty">Connection Test Failed, Endpoint is empty.</system:String>
<system:String x:Key="RemoteControlConnectionTestFailNotHttps">Connection Test Failed. Endpoint is not an https address.</system:String>
<system:String x:Key="RemoteControlConnectionTestFailNotHttpOrHttpsOrHttps">Connection Test Failed, Endpoint is not an http or https address.</system:String>
<system:String x:Key="RemoteControlConnectionTestWarningHttpUnsafe">Endpoint is using http, might be unsafe.</system:String>
<system:String x:Key="RemoteControlReceivedTask">Received remote task {0}, Task Id:{1}.</system:String>
<system:String x:Key="RemoteControlCompletedTask">Completed remote task {0}, Task Id:{1}.</system:String>
<system:String x:Key="RemoteControlTooltips">Caution: Entering addresses from unknown sources may result in the loss of your Arknights account.</system:String>

View File

@@ -730,7 +730,8 @@ Bilibili: ログイン インターフェイスに表示されるアカウント
<system:String x:Key="RemoteControlConnectionTestSuccess">接続テスト成功!</system:String>
<system:String x:Key="RemoteControlConnectionTestFail">接続テスト失敗、理由: {0}。</system:String>
<system:String x:Key="RemoteControlConnectionTestFailEmpty">接続テスト失敗、エンドポイントが空です。</system:String>
<system:String x:Key="RemoteControlConnectionTestFailNotHttps">接続テスト失敗。エンドポイントはhttpsアドレスではありません。</system:String>
<system:String x:Key="RemoteControlConnectionTestFailNotHttpOrHttps">接続テスト失敗しました。接続エンドポイントが http または https アドレスではありませんでした。</system:String>
<system:String x:Key="RemoteControlConnectionTestWarningHttpUnsafe">接続エンドポイントがhttpsに対応しておらず、安全でない可能性があります。</system:String>
<system:String x:Key="RemoteControlReceivedTask">リモートタスク{0}を受信、タスクId:{1}。</system:String>
<system:String x:Key="RemoteControlCompletedTask">リモートタスク{0}を完了、タスクId:{1}。</system:String>
<system:String x:Key="RemoteControlTooltips">注意:知らない出所のアドレスを入力すると、あなたの明日方舟のアカウントが損失する可能性があります。</system:String>

View File

@@ -730,7 +730,8 @@ Bilibili: 로그인 인터페이스에 표시되는 계정 이름(예: 장산)
<system:String x:Key="RemoteControlConnectionTestSuccess">연결 테스트 성공!</system:String>
<system:String x:Key="RemoteControlConnectionTestFail">연결 테스트 실패, 이유: {0}.</system:String>
<system:String x:Key="RemoteControlConnectionTestFailEmpty">연결 테스트 실패, 엔드포인트가 비어 있습니다.</system:String>
<system:String x:Key="RemoteControlConnectionTestFailNotHttps">연결 테스트 실패. 엔드포인트가 https 주소가 아닙니다.</system:String>
<system:String x:Key="RemoteControlConnectionTestFailNotHttpOrHttps(s)">연결 테스트 실패했습니다. 연결 엔드포인트가 http 또는 https 주소가 아닙니다.</system:String>
<system:String x:Key="RemoteControlConnectionTestWarningHttpUnsafe">연결 엔드포인트가 https를 사용하도록 설정되어 있지 않으며 안전하지 않을 수 있습니다.</system:String>
<system:String x:Key="RemoteControlReceivedTask">원격 작업 {0} 받음, 작업 Id:{1}.</system:String>
<system:String x:Key="RemoteControlCompletedTask">원격 작업 {0} 완료, 작업 Id:{1}.</system:String>
<system:String x:Key="RemoteControlTooltips">주의: 알려지지 않은 출처의 주소를 입력하면 당신의 아크나이츠 계정에 손실이 발생할 수 있습니다.</system:String>

View File

@@ -729,7 +729,8 @@
<system:String x:Key="RemoteControlConnectionTestSuccess">连接测试成功!</system:String>
<system:String x:Key="RemoteControlConnectionTestFail">连接测试失败,原因: {0}。</system:String>
<system:String x:Key="RemoteControlConnectionTestFailEmpty">连接测试失败,连接端点为空。</system:String>
<system:String x:Key="RemoteControlConnectionTestFailNotHttps">连接测试失败端点不https地址。</system:String>
<system:String x:Key="RemoteControlConnectionTestFailNotHttpOrHttps">连接测试失败,连接端点不http(s)地址。</system:String>
<system:String x:Key="RemoteControlConnectionTestWarningHttpUnsafe">连接端点未启用https可能不安全。</system:String>
<system:String x:Key="RemoteControlReceivedTask">收到远端任务{0}任务Id:{1}。</system:String>
<system:String x:Key="RemoteControlCompletedTask">完成远端任务{0}任务Id:{1}。</system:String>
<system:String x:Key="RemoteControlTooltips">注意:随意填入未知来源的地址可能会导致您的账户受到损失。</system:String>

View File

@@ -727,7 +727,8 @@
<system:String x:Key="RemoteControlConnectionTestSuccess">連接測試成功!</system:String>
<system:String x:Key="RemoteControlConnectionTestFail">連接測試失敗,原因: {0}。</system:String>
<system:String x:Key="RemoteControlConnectionTestFailEmpty">連接測試失敗,連接端點為空。</system:String>
<system:String x:Key="RemoteControlConnectionTestFailNotHttps">連接測試失敗。端點非https地址。</system:String>
<system:String x:Key="RemoteControlConnectionTestFailNotHttpOrHttps">連接測試失敗,連接端點不為http(s)地址。</system:String>
<system:String x:Key="RemoteControlConnectionTestWarningHttpUnsafe">連接端點未啟用https可能不安全。</system:String>
<system:String x:Key="RemoteControlReceivedTask">收到遠端任務{0}任務Id:{1}。</system:String>
<system:String x:Key="RemoteControlCompletedTask">完成遠端任務{0}任務Id:{1}。</system:String>
<system:String x:Key="RemoteControlTooltips">注意:隨意輸入未知來源的地址可能會導致您的明日方舟帳戶受到損失。</system:String>

View File

@@ -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;
}
}
}
}