From 6b7fb239add03a2e1b291b97b4b05379d080c783 Mon Sep 17 00:00:00 2001 From: leiurayer <1432593898@qq.com> Date: Sun, 16 Oct 2022 14:55:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=87=AA=E5=AE=9A=E4=B9=89ar?= =?UTF-8?q?ia=E6=9C=8D=E5=8A=A1=E5=99=A8=E7=9B=91=E5=90=AC=E7=AB=AF?= =?UTF-8?q?=E5=8F=A3=E8=AE=BE=E7=BD=AE=E6=97=A0=E6=95=88=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/DownKyi.Core/Aria2cNet/Client/AriaClient.cs | 13 ++++++++++--- .../Services/Download/AriaDownloadService.cs | 2 ++ .../Services/Download/CustomAriaDownloadService.cs | 2 ++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/DownKyi.Core/Aria2cNet/Client/AriaClient.cs b/src/DownKyi.Core/Aria2cNet/Client/AriaClient.cs index dd1b5fa..86bf74a 100644 --- a/src/DownKyi.Core/Aria2cNet/Client/AriaClient.cs +++ b/src/DownKyi.Core/Aria2cNet/Client/AriaClient.cs @@ -18,8 +18,10 @@ namespace DownKyi.Core.Aria2cNet.Client private static readonly string JSONRPC = "2.0"; private const string LOCAL_HOST = "http://localhost"; private const string TOKEN = "downkyi"; + private const int LISTEN_PORT = 6800; private static string host = LOCAL_HOST; - private static string token = TOKEN; + private static string token = TOKEN; + private static int listenPort = LISTEN_PORT; /// /// This method adds a new download. @@ -1039,13 +1041,18 @@ namespace DownKyi.Core.Aria2cNet.Client AriaClient.host = host; } + public static void SetListenPort(int listenPort = LISTEN_PORT) + { + AriaClient.listenPort = listenPort; + } + /// /// 获取jsonrpc的地址 /// /// - private static string GetRpcUri(int listenPort = 6800) + private static string GetRpcUri() { - return $"{host}:{listenPort}/jsonrpc"; + return $"{host}:{AriaClient.listenPort}/jsonrpc"; } /// diff --git a/src/DownKyi/Services/Download/AriaDownloadService.cs b/src/DownKyi/Services/Download/AriaDownloadService.cs index 57ede1b..03925b2 100644 --- a/src/DownKyi/Services/Download/AriaDownloadService.cs +++ b/src/DownKyi/Services/Download/AriaDownloadService.cs @@ -236,6 +236,8 @@ namespace DownKyi.Services.Download AriaClient.SetToken(); // 设置aria host AriaClient.SetHost(); + // 设置aria listenPort + AriaClient.SetListenPort(); // 启动Aria服务器 StartAriaServer(); diff --git a/src/DownKyi/Services/Download/CustomAriaDownloadService.cs b/src/DownKyi/Services/Download/CustomAriaDownloadService.cs index d30e429..5dbf0c4 100644 --- a/src/DownKyi/Services/Download/CustomAriaDownloadService.cs +++ b/src/DownKyi/Services/Download/CustomAriaDownloadService.cs @@ -235,6 +235,8 @@ namespace DownKyi.Services.Download AriaClient.SetToken(SettingsManager.GetInstance().GetAriaToken()); // 设置aria host AriaClient.SetHost(SettingsManager.GetInstance().GetAriaHost()); + // 设置aria listenPort + AriaClient.SetListenPort(SettingsManager.GetInstance().GetAriaListenPort()); // 启动基本服务 BaseStart();