mirror of
https://github.com/leiurayer/downkyi.git
synced 2025-04-27 05:30:47 +08:00
add the aria2cNet sources
This commit is contained in:
parent
e821385638
commit
587fcfb777
src/Core/aria2cNet
AriaManager.cs
client
AriaClient.cs
entity
AriaAddMetalink.csAriaAddTorrent.csAriaAddUri.csAriaChangeOption.csAriaChangePosition.csAriaChangeUri.csAriaError.csAriaGetFiles.csAriaGetGlobalStat.csAriaGetOption.csAriaGetPeers.csAriaGetServers.csAriaGetSessionInfo.csAriaGetUris.csAriaOption.csAriaPause.csAriaRemove.csAriaSaveSession.csAriaSendData.csAriaShutdown.csAriaTellStatus.csAriaUri.csAriaVersion.csSystemListMethods.csSystemListNotifications.csSystemMulticall.csSystemMulticallMathod.cs
server
92
src/Core/aria2cNet/AriaManager.cs
Normal file
92
src/Core/aria2cNet/AriaManager.cs
Normal file
@ -0,0 +1,92 @@
|
||||
using Core.aria2cNet.client;
|
||||
using System;
|
||||
using System.Threading;
|
||||
|
||||
namespace Core.aria2cNet
|
||||
{
|
||||
public class AriaManager
|
||||
{
|
||||
// gid对应项目的状态
|
||||
public delegate void TellStatusHandler(long totalLength, long completedLength, long speed, string gid);
|
||||
public event TellStatusHandler TellStatus;
|
||||
protected virtual void OnTellStatus(long totalLength, long completedLength, long speed, string gid)
|
||||
{
|
||||
TellStatus?.Invoke(totalLength, completedLength, speed, gid);
|
||||
}
|
||||
|
||||
// 全局下载状态
|
||||
public delegate void GetGlobalStatusHandler(long speed);
|
||||
public event GetGlobalStatusHandler GetGlobalStatus;
|
||||
protected virtual void OnGetGlobalStatus(long speed)
|
||||
{
|
||||
GetGlobalStatus?.Invoke(speed);
|
||||
}
|
||||
|
||||
// 下载结果回调
|
||||
public delegate void DownloadFinishHandler(bool isSuccess, string downloadPath, string gid, string msg = null);
|
||||
public event DownloadFinishHandler DownloadFinish;
|
||||
protected virtual void OnDownloadFinish(bool isSuccess, string downloadPath, string gid, string msg = null)
|
||||
{
|
||||
DownloadFinish?.Invoke(isSuccess, downloadPath, gid, msg);
|
||||
}
|
||||
|
||||
public DownloadStatus GetDownloadStatus(string gid)
|
||||
{
|
||||
string filePath = "";
|
||||
while (true)
|
||||
{
|
||||
var status = AriaClient.TellStatus(gid);
|
||||
if (status == null || status.Result == null) { continue; }
|
||||
|
||||
if (status.Result.Result == null && status.Result.Error != null)
|
||||
{
|
||||
if (status.Result.Error.Message.Contains("is not found"))
|
||||
{
|
||||
OnDownloadFinish(false, null, gid, status.Result.Error.Message);
|
||||
return DownloadStatus.ABORT;
|
||||
}
|
||||
}
|
||||
|
||||
if (status.Result.Result.Files != null && status.Result.Result.Files.Count >= 1)
|
||||
{
|
||||
filePath = status.Result.Result.Files[0].Path;
|
||||
}
|
||||
|
||||
long totalLength = long.Parse(status.Result.Result.TotalLength);
|
||||
long completedLength = long.Parse(status.Result.Result.CompletedLength);
|
||||
long speed = long.Parse(status.Result.Result.DownloadSpeed);
|
||||
// 回调
|
||||
OnTellStatus(totalLength, completedLength, speed, gid);
|
||||
|
||||
if (status.Result.Result.Status == "complete")
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (status.Result.Result.ErrorCode != null && status.Result.Result.ErrorCode != "0")
|
||||
{
|
||||
Console.WriteLine(status.Result.Result.ErrorMessage);
|
||||
OnDownloadFinish(false, null, gid, status.Result.Result.ErrorMessage);
|
||||
return DownloadStatus.FAILED;
|
||||
}
|
||||
|
||||
// 降低CPU占用
|
||||
Thread.Sleep(500);
|
||||
}
|
||||
OnDownloadFinish(true, filePath, gid, null);
|
||||
return DownloadStatus.SUCCESS;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 下载状态
|
||||
/// </summary>
|
||||
public enum DownloadStatus
|
||||
{
|
||||
SUCCESS = 1,
|
||||
FAILED,
|
||||
ABORT
|
||||
}
|
||||
|
||||
}
|
1137
src/Core/aria2cNet/client/AriaClient.cs
Normal file
1137
src/Core/aria2cNet/client/AriaClient.cs
Normal file
File diff suppressed because it is too large
Load Diff
25
src/Core/aria2cNet/client/entity/AriaAddMetalink.cs
Normal file
25
src/Core/aria2cNet/client/entity/AriaAddMetalink.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Core.aria2cNet.client.entity
|
||||
{
|
||||
[JsonObject]
|
||||
public class AriaAddMetalink
|
||||
{
|
||||
[JsonProperty("id")]
|
||||
public string Id { get; set; }
|
||||
|
||||
[JsonProperty("jsonrpc")]
|
||||
public string Jsonrpc { get; set; }
|
||||
|
||||
[JsonProperty("result")]
|
||||
public string Result { get; set; }
|
||||
|
||||
[JsonProperty("error")]
|
||||
public AriaError Error { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this);
|
||||
}
|
||||
}
|
||||
}
|
25
src/Core/aria2cNet/client/entity/AriaAddTorrent.cs
Normal file
25
src/Core/aria2cNet/client/entity/AriaAddTorrent.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Core.aria2cNet.client.entity
|
||||
{
|
||||
[JsonObject]
|
||||
public class AriaAddTorrent
|
||||
{
|
||||
[JsonProperty("id")]
|
||||
public string Id { get; set; }
|
||||
|
||||
[JsonProperty("jsonrpc")]
|
||||
public string Jsonrpc { get; set; }
|
||||
|
||||
[JsonProperty("result")]
|
||||
public string Result { get; set; }
|
||||
|
||||
[JsonProperty("error")]
|
||||
public AriaError Error { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this);
|
||||
}
|
||||
}
|
||||
}
|
30
src/Core/aria2cNet/client/entity/AriaAddUri.cs
Normal file
30
src/Core/aria2cNet/client/entity/AriaAddUri.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Core.aria2cNet.client.entity
|
||||
{
|
||||
//{
|
||||
//"id": "downkyi",
|
||||
//"jsonrpc": "2.0",
|
||||
//"result": "1aac102a4875c8cd"
|
||||
//}
|
||||
[JsonObject]
|
||||
public class AriaAddUri
|
||||
{
|
||||
[JsonProperty("id")]
|
||||
public string Id { get; set; }
|
||||
|
||||
[JsonProperty("jsonrpc")]
|
||||
public string Jsonrpc { get; set; }
|
||||
|
||||
[JsonProperty("result")]
|
||||
public string Result { get; set; }
|
||||
|
||||
[JsonProperty("error")]
|
||||
public AriaError Error { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this);
|
||||
}
|
||||
}
|
||||
}
|
25
src/Core/aria2cNet/client/entity/AriaChangeOption.cs
Normal file
25
src/Core/aria2cNet/client/entity/AriaChangeOption.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Core.aria2cNet.client.entity
|
||||
{
|
||||
[JsonObject]
|
||||
public class AriaChangeOption
|
||||
{
|
||||
[JsonProperty("id")]
|
||||
public string Id { get; set; }
|
||||
|
||||
[JsonProperty("jsonrpc")]
|
||||
public string Jsonrpc { get; set; }
|
||||
|
||||
[JsonProperty("result")]
|
||||
public string Result { get; set; }
|
||||
|
||||
[JsonProperty("error")]
|
||||
public AriaError Error { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this);
|
||||
}
|
||||
}
|
||||
}
|
25
src/Core/aria2cNet/client/entity/AriaChangePosition.cs
Normal file
25
src/Core/aria2cNet/client/entity/AriaChangePosition.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Core.aria2cNet.client.entity
|
||||
{
|
||||
[JsonObject]
|
||||
public class AriaChangePosition
|
||||
{
|
||||
[JsonProperty("id")]
|
||||
public string Id { get; set; }
|
||||
|
||||
[JsonProperty("jsonrpc")]
|
||||
public string Jsonrpc { get; set; }
|
||||
|
||||
[JsonProperty("result")]
|
||||
public int Result { get; set; }
|
||||
|
||||
[JsonProperty("error")]
|
||||
public AriaError Error { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this);
|
||||
}
|
||||
}
|
||||
}
|
26
src/Core/aria2cNet/client/entity/AriaChangeUri.cs
Normal file
26
src/Core/aria2cNet/client/entity/AriaChangeUri.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Core.aria2cNet.client.entity
|
||||
{
|
||||
[JsonObject]
|
||||
public class AriaChangeUri
|
||||
{
|
||||
[JsonProperty("id")]
|
||||
public string Id { get; set; }
|
||||
|
||||
[JsonProperty("jsonrpc")]
|
||||
public string Jsonrpc { get; set; }
|
||||
|
||||
[JsonProperty("result")]
|
||||
public List<int> Result { get; set; }
|
||||
|
||||
[JsonProperty("error")]
|
||||
public AriaError Error { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this);
|
||||
}
|
||||
}
|
||||
}
|
23
src/Core/aria2cNet/client/entity/AriaError.cs
Normal file
23
src/Core/aria2cNet/client/entity/AriaError.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Core.aria2cNet.client.entity
|
||||
{
|
||||
//"error": {
|
||||
// "code": 1,
|
||||
// "message": "Unauthorized"
|
||||
//}
|
||||
[JsonObject]
|
||||
public class AriaError
|
||||
{
|
||||
[JsonProperty("code")]
|
||||
public int Code { get; set; }
|
||||
|
||||
[JsonProperty("message")]
|
||||
public string Message { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this);
|
||||
}
|
||||
}
|
||||
}
|
54
src/Core/aria2cNet/client/entity/AriaGetFiles.cs
Normal file
54
src/Core/aria2cNet/client/entity/AriaGetFiles.cs
Normal file
@ -0,0 +1,54 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Core.aria2cNet.client.entity
|
||||
{
|
||||
[JsonObject]
|
||||
public class AriaGetFiles
|
||||
{
|
||||
[JsonProperty("id")]
|
||||
public string Id { get; set; }
|
||||
|
||||
[JsonProperty("jsonrpc")]
|
||||
public string Jsonrpc { get; set; }
|
||||
|
||||
[JsonProperty("result")]
|
||||
public List<AriaUri> Result { get; set; }
|
||||
|
||||
[JsonProperty("error")]
|
||||
public AriaError Error { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this);
|
||||
}
|
||||
}
|
||||
|
||||
[JsonObject]
|
||||
public class AriaGetFilesResult
|
||||
{
|
||||
[JsonProperty("completedLength")]
|
||||
public string CompletedLength { get; set; }
|
||||
|
||||
[JsonProperty("index")]
|
||||
public string Index { get; set; }
|
||||
|
||||
[JsonProperty("length")]
|
||||
public string Length { get; set; }
|
||||
|
||||
[JsonProperty("path")]
|
||||
public string Path { get; set; }
|
||||
|
||||
[JsonProperty("selected")]
|
||||
public string Selected { get; set; }
|
||||
|
||||
[JsonProperty("uris")]
|
||||
public List<AriaUri> Uris { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
67
src/Core/aria2cNet/client/entity/AriaGetGlobalStat.cs
Normal file
67
src/Core/aria2cNet/client/entity/AriaGetGlobalStat.cs
Normal file
@ -0,0 +1,67 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Core.aria2cNet.client.entity
|
||||
{
|
||||
/*
|
||||
{
|
||||
"id": "qwer",
|
||||
"jsonrpc": "2.0",
|
||||
"result": {
|
||||
"downloadSpeed": "0",
|
||||
"numActive": "0",
|
||||
"numStopped": "0",
|
||||
"numStoppedTotal": "0",
|
||||
"numWaiting": "0",
|
||||
"uploadSpeed": "0"
|
||||
}
|
||||
}
|
||||
*/
|
||||
[JsonObject]
|
||||
public class AriaGetGlobalStat
|
||||
{
|
||||
[JsonProperty("id")]
|
||||
public string Id { get; set; }
|
||||
|
||||
[JsonProperty("jsonrpc")]
|
||||
public string Jsonrpc { get; set; }
|
||||
|
||||
[JsonProperty("result")]
|
||||
public AriaGetGlobalStatResult Result { get; set; }
|
||||
|
||||
[JsonProperty("error")]
|
||||
public AriaError Error { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this);
|
||||
}
|
||||
}
|
||||
|
||||
[JsonObject]
|
||||
public class AriaGetGlobalStatResult
|
||||
{
|
||||
[JsonProperty("downloadSpeed")]
|
||||
public string DownloadSpeed { get; set; }
|
||||
|
||||
[JsonProperty("numActive")]
|
||||
public string NumActive { get; set; }
|
||||
|
||||
[JsonProperty("numStopped")]
|
||||
public string NumStopped { get; set; }
|
||||
|
||||
[JsonProperty("numStoppedTotal")]
|
||||
public string NumStoppedTotal { get; set; }
|
||||
|
||||
[JsonProperty("numWaiting")]
|
||||
public string NumWaiting { get; set; }
|
||||
|
||||
[JsonProperty("uploadSpeed")]
|
||||
public string UploadSpeed { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
25
src/Core/aria2cNet/client/entity/AriaGetOption.cs
Normal file
25
src/Core/aria2cNet/client/entity/AriaGetOption.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Core.aria2cNet.client.entity
|
||||
{
|
||||
[JsonObject]
|
||||
public class AriaGetOption
|
||||
{
|
||||
[JsonProperty("id")]
|
||||
public string Id { get; set; }
|
||||
|
||||
[JsonProperty("jsonrpc")]
|
||||
public string Jsonrpc { get; set; }
|
||||
|
||||
[JsonProperty("result")]
|
||||
public AriaOption Result { get; set; }
|
||||
|
||||
[JsonProperty("error")]
|
||||
public AriaError Error { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this);
|
||||
}
|
||||
}
|
||||
}
|
63
src/Core/aria2cNet/client/entity/AriaGetPeers.cs
Normal file
63
src/Core/aria2cNet/client/entity/AriaGetPeers.cs
Normal file
@ -0,0 +1,63 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Core.aria2cNet.client.entity
|
||||
{
|
||||
[JsonObject]
|
||||
public class AriaGetPeers
|
||||
{
|
||||
[JsonProperty("id")]
|
||||
public string Id { get; set; }
|
||||
|
||||
[JsonProperty("jsonrpc")]
|
||||
public string Jsonrpc { get; set; }
|
||||
|
||||
[JsonProperty("result")]
|
||||
public List<AriaPeer> Result { get; set; }
|
||||
|
||||
[JsonProperty("error")]
|
||||
public AriaError Error { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this);
|
||||
}
|
||||
}
|
||||
|
||||
[JsonObject]
|
||||
public class AriaPeer
|
||||
{
|
||||
[JsonProperty("amChoking")]
|
||||
public string AmChoking { get; set; }
|
||||
|
||||
[JsonProperty("bitfield")]
|
||||
public string Bitfield { get; set; }
|
||||
|
||||
[JsonProperty("downloadSpeed")]
|
||||
public string DownloadSpeed { get; set; }
|
||||
|
||||
[JsonProperty("ip")]
|
||||
public string Ip { get; set; }
|
||||
|
||||
[JsonProperty("peerChoking")]
|
||||
public string PeerChoking { get; set; }
|
||||
|
||||
[JsonProperty("peerId")]
|
||||
public string PeerId { get; set; }
|
||||
|
||||
[JsonProperty("port")]
|
||||
public string Port { get; set; }
|
||||
|
||||
[JsonProperty("seeder")]
|
||||
public string Seeder { get; set; }
|
||||
|
||||
[JsonProperty("uploadSpeed")]
|
||||
public string UploadSpeed { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
60
src/Core/aria2cNet/client/entity/AriaGetServers.cs
Normal file
60
src/Core/aria2cNet/client/entity/AriaGetServers.cs
Normal file
@ -0,0 +1,60 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Core.aria2cNet.client.entity
|
||||
{
|
||||
[JsonObject]
|
||||
public class AriaGetServers
|
||||
{
|
||||
[JsonProperty("id")]
|
||||
public string Id { get; set; }
|
||||
|
||||
[JsonProperty("jsonrpc")]
|
||||
public string Jsonrpc { get; set; }
|
||||
|
||||
[JsonProperty("result")]
|
||||
public List<AriaGetServersResult> Result { get; set; }
|
||||
|
||||
[JsonProperty("error")]
|
||||
public AriaError Error { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this);
|
||||
}
|
||||
}
|
||||
|
||||
[JsonObject]
|
||||
public class AriaGetServersResult
|
||||
{
|
||||
[JsonProperty("index")]
|
||||
public string Index { get; set; }
|
||||
|
||||
[JsonProperty("servers")]
|
||||
public List<AriaResultServer> Servers { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this);
|
||||
}
|
||||
}
|
||||
|
||||
[JsonObject]
|
||||
public class AriaResultServer
|
||||
{
|
||||
[JsonProperty("currentUri")]
|
||||
public string CurrentUri { get; set; }
|
||||
|
||||
[JsonProperty("downloadSpeed")]
|
||||
public string DownloadSpeed { get; set; }
|
||||
|
||||
[JsonProperty("uri")]
|
||||
public string Uri { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
38
src/Core/aria2cNet/client/entity/AriaGetSessionInfo.cs
Normal file
38
src/Core/aria2cNet/client/entity/AriaGetSessionInfo.cs
Normal file
@ -0,0 +1,38 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Core.aria2cNet.client.entity
|
||||
{
|
||||
[JsonObject]
|
||||
public class AriaGetSessionInfo
|
||||
{
|
||||
[JsonProperty("id")]
|
||||
public string Id { get; set; }
|
||||
|
||||
[JsonProperty("jsonrpc")]
|
||||
public string Jsonrpc { get; set; }
|
||||
|
||||
[JsonProperty("result")]
|
||||
public AriaGetSessionInfoResult Result { get; set; }
|
||||
|
||||
[JsonProperty("error")]
|
||||
public AriaError Error { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this);
|
||||
}
|
||||
}
|
||||
|
||||
[JsonObject]
|
||||
public class AriaGetSessionInfoResult
|
||||
{
|
||||
[JsonProperty("sessionId")]
|
||||
public string SessionId { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
26
src/Core/aria2cNet/client/entity/AriaGetUris.cs
Normal file
26
src/Core/aria2cNet/client/entity/AriaGetUris.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Core.aria2cNet.client.entity
|
||||
{
|
||||
[JsonObject]
|
||||
public class AriaGetUris
|
||||
{
|
||||
[JsonProperty("id")]
|
||||
public string Id { get; set; }
|
||||
|
||||
[JsonProperty("jsonrpc")]
|
||||
public string Jsonrpc { get; set; }
|
||||
|
||||
[JsonProperty("result")]
|
||||
public List<AriaUri> Result { get; set; }
|
||||
|
||||
[JsonProperty("error")]
|
||||
public AriaError Error { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this);
|
||||
}
|
||||
}
|
||||
}
|
244
src/Core/aria2cNet/client/entity/AriaOption.cs
Normal file
244
src/Core/aria2cNet/client/entity/AriaOption.cs
Normal file
@ -0,0 +1,244 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Core.aria2cNet.client.entity
|
||||
{
|
||||
[JsonObject]
|
||||
public class AriaOption
|
||||
{
|
||||
[JsonProperty("all-proxy")]
|
||||
public string AllProxy { get; set; }
|
||||
|
||||
[JsonProperty("allow-overwrite")]
|
||||
public string AllowOverwrite { get; set; }
|
||||
|
||||
[JsonProperty("allow-piece-length-change")]
|
||||
public string AllowPieceLengthChange { get; set; }
|
||||
|
||||
[JsonProperty("always-resume")]
|
||||
public string AlwaysResume { get; set; }
|
||||
|
||||
[JsonProperty("async-dns")]
|
||||
public string AsyncDns { get; set; }
|
||||
|
||||
[JsonProperty("auto-file-renaming")]
|
||||
public string AutoFileRenaming { get; set; }
|
||||
|
||||
[JsonProperty("bt-enable-hook-after-hash-check")]
|
||||
public string BtEnableHookAfterHashCheck { get; set; }
|
||||
|
||||
[JsonProperty("bt-enable-lpd")]
|
||||
public string BtEnableLpd { get; set; }
|
||||
|
||||
[JsonProperty("bt-force-encryption")]
|
||||
public string BtForceEncryption { get; set; }
|
||||
|
||||
[JsonProperty("bt-hash-check-seed")]
|
||||
public string BtHashCheckSeed { get; set; }
|
||||
|
||||
[JsonProperty("bt-load-saved-metadata")]
|
||||
public string BtLoadSavedMetadata { get; set; }
|
||||
|
||||
[JsonProperty("bt-max-peers")]
|
||||
public string BtMaxPeers { get; set; }
|
||||
|
||||
[JsonProperty("bt-metadata-only")]
|
||||
public string BtMetadataOnly { get; set; }
|
||||
|
||||
[JsonProperty("bt-min-crypto-level")]
|
||||
public string BtMinCryptoLevel { get; set; }
|
||||
|
||||
[JsonProperty("bt-remove-unselected-file")]
|
||||
public string BtRemoveUnselectedFile { get; set; }
|
||||
|
||||
[JsonProperty("bt-request-peer-speed-limit")]
|
||||
public string BtRequestPeerSpeedLimit { get; set; }
|
||||
|
||||
[JsonProperty("bt-require-crypto")]
|
||||
public string BtRequireCrypto { get; set; }
|
||||
|
||||
[JsonProperty("bt-save-metadata")]
|
||||
public string BtSaveMetadata { get; set; }
|
||||
|
||||
[JsonProperty("bt-seed-unverified")]
|
||||
public string BtSeedUnverified { get; set; }
|
||||
|
||||
[JsonProperty("bt-stop-timeout")]
|
||||
public string BtStopTimeout { get; set; }
|
||||
|
||||
[JsonProperty("bt-tracker-connect-timeout")]
|
||||
public string BtTrackerConnectTimeout { get; set; }
|
||||
|
||||
[JsonProperty("bt-tracker-interval")]
|
||||
public string BtTrackerInterval { get; set; }
|
||||
|
||||
[JsonProperty("bt-tracker-timeout")]
|
||||
public string BtTrackerTimeout { get; set; }
|
||||
|
||||
[JsonProperty("check-integrity")]
|
||||
public string CheckIntegrity { get; set; }
|
||||
|
||||
[JsonProperty("conditional-get")]
|
||||
public string ConditionalGet { get; set; }
|
||||
|
||||
[JsonProperty("connect-timeout")]
|
||||
public string ConnectTimeout { get; set; }
|
||||
|
||||
[JsonProperty("content-disposition-default-utf8")]
|
||||
public string ContentDispositionDefaultUtf8 { get; set; }
|
||||
|
||||
[JsonProperty("continue")]
|
||||
public string Continue { get; set; }
|
||||
|
||||
[JsonProperty("dir")]
|
||||
public string Dir { get; set; }
|
||||
|
||||
[JsonProperty("dry-run")]
|
||||
public string DryRun { get; set; }
|
||||
|
||||
[JsonProperty("enable-http-keep-alive")]
|
||||
public string EnableHttpKeepAlive { get; set; }
|
||||
|
||||
[JsonProperty("enable-http-pipelining")]
|
||||
public string EnableHttpPipelining { get; set; }
|
||||
|
||||
[JsonProperty("enable-mmap")]
|
||||
public string EnableMmap { get; set; }
|
||||
|
||||
[JsonProperty("enable-peer-exchange")]
|
||||
public string EnablePeerExchange { get; set; }
|
||||
|
||||
[JsonProperty("file-allocation")]
|
||||
public string FileAllocation { get; set; }
|
||||
|
||||
[JsonProperty("follow-metalink")]
|
||||
public string FollowMetalink { get; set; }
|
||||
|
||||
[JsonProperty("follow-torrent")]
|
||||
public string FollowTorrent { get; set; }
|
||||
|
||||
[JsonProperty("force-save")]
|
||||
public string ForceSave { get; set; }
|
||||
|
||||
[JsonProperty("ftp-pasv")]
|
||||
public string FtpPasv { get; set; }
|
||||
|
||||
[JsonProperty("ftp-reuse-connection")]
|
||||
public string FtpReuseConnection { get; set; }
|
||||
|
||||
[JsonProperty("ftp-type")]
|
||||
public string FtpType { get; set; }
|
||||
|
||||
[JsonProperty("hash-check-only")]
|
||||
public string HashCheckOnly { get; set; }
|
||||
|
||||
[JsonProperty("http-accept-gzip")]
|
||||
public string HttpAcceptGzip { get; set; }
|
||||
|
||||
[JsonProperty("http-auth-challenge")]
|
||||
public string HttpAuthChallenge { get; set; }
|
||||
|
||||
[JsonProperty("http-no-cache")]
|
||||
public string HttpNoCache { get; set; }
|
||||
|
||||
[JsonProperty("lowest-speed-limit")]
|
||||
public string LowestSpeedLimit { get; set; }
|
||||
|
||||
[JsonProperty("max-connection-per-server")]
|
||||
public string MaxConnectionPerServer { get; set; }
|
||||
|
||||
[JsonProperty("max-download-limit")]
|
||||
public string MaxDownloadLimit { get; set; }
|
||||
|
||||
[JsonProperty("max-file-not-found")]
|
||||
public string MaxFileNotFound { get; set; }
|
||||
|
||||
[JsonProperty("max-mmap-limit")]
|
||||
public string MaxMmapLimit { get; set; }
|
||||
|
||||
[JsonProperty("max-resume-failure-tries")]
|
||||
public string MaxResumeFailureTries { get; set; }
|
||||
|
||||
[JsonProperty("max-tries")]
|
||||
public string MaxTries { get; set; }
|
||||
|
||||
[JsonProperty("max-upload-limit")]
|
||||
public string MaxUploadLimit { get; set; }
|
||||
|
||||
[JsonProperty("metalink-enable-unique-protocol")]
|
||||
public string MetalinkEnableUniqueProtocol { get; set; }
|
||||
|
||||
[JsonProperty("metalink-preferred-protocol")]
|
||||
public string MetalinkPreferredProtocol { get; set; }
|
||||
|
||||
[JsonProperty("min-split-size")]
|
||||
public string MinSplitSize { get; set; }
|
||||
|
||||
[JsonProperty("no-file-allocation-limit")]
|
||||
public string NoFileAllocationLimit { get; set; }
|
||||
|
||||
[JsonProperty("no-netrc")]
|
||||
public string NoNetrc { get; set; }
|
||||
|
||||
[JsonProperty("out")]
|
||||
public string Out { get; set; }
|
||||
|
||||
[JsonProperty("parameterized-uri")]
|
||||
public string ParameterizedUri { get; set; }
|
||||
|
||||
[JsonProperty("pause-metadata")]
|
||||
public string PauseMetadata { get; set; }
|
||||
|
||||
[JsonProperty("piece-length")]
|
||||
public string PieceLength { get; set; }
|
||||
|
||||
[JsonProperty("proxy-method")]
|
||||
public string ProxyMethod { get; set; }
|
||||
|
||||
[JsonProperty("realtime-chunk-checksum")]
|
||||
public string RealtimeChunkChecksum { get; set; }
|
||||
|
||||
[JsonProperty("remote-time")]
|
||||
public string RemoteTime { get; set; }
|
||||
|
||||
[JsonProperty("remove-control-file")]
|
||||
public string RemoveControlFile { get; set; }
|
||||
|
||||
[JsonProperty("retry-wait")]
|
||||
public string RetryWait { get; set; }
|
||||
|
||||
[JsonProperty("reuse-uri")]
|
||||
public string ReuseUri { get; set; }
|
||||
|
||||
[JsonProperty("rpc-save-upload-metadata")]
|
||||
public string RpcSaveUploadMetadata { get; set; }
|
||||
|
||||
[JsonProperty("save-not-found")]
|
||||
public string SaveNotFound { get; set; }
|
||||
|
||||
[JsonProperty("seed-ratio")]
|
||||
public string SeedRatio { get; set; }
|
||||
|
||||
[JsonProperty("split")]
|
||||
public string Split { get; set; }
|
||||
|
||||
[JsonProperty("stream-piece-selector")]
|
||||
public string StreamPieceSelector { get; set; }
|
||||
|
||||
[JsonProperty("timeout")]
|
||||
public string Timeout { get; set; }
|
||||
|
||||
[JsonProperty("uri-selector")]
|
||||
public string UriSelector { get; set; }
|
||||
|
||||
[JsonProperty("use-head")]
|
||||
public string UseHead { get; set; }
|
||||
|
||||
[JsonProperty("user-agent")]
|
||||
public string UserAgent { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this);
|
||||
}
|
||||
}
|
||||
}
|
25
src/Core/aria2cNet/client/entity/AriaPause.cs
Normal file
25
src/Core/aria2cNet/client/entity/AriaPause.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Core.aria2cNet.client.entity
|
||||
{
|
||||
[JsonObject]
|
||||
public class AriaPause
|
||||
{
|
||||
[JsonProperty("id")]
|
||||
public string Id { get; set; }
|
||||
|
||||
[JsonProperty("jsonrpc")]
|
||||
public string Jsonrpc { get; set; }
|
||||
|
||||
[JsonProperty("result")]
|
||||
public string Result { get; set; }
|
||||
|
||||
[JsonProperty("error")]
|
||||
public AriaError Error { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this);
|
||||
}
|
||||
}
|
||||
}
|
25
src/Core/aria2cNet/client/entity/AriaRemove.cs
Normal file
25
src/Core/aria2cNet/client/entity/AriaRemove.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Core.aria2cNet.client.entity
|
||||
{
|
||||
[JsonObject]
|
||||
public class AriaRemove
|
||||
{
|
||||
[JsonProperty("id")]
|
||||
public string Id { get; set; }
|
||||
|
||||
[JsonProperty("jsonrpc")]
|
||||
public string Jsonrpc { get; set; }
|
||||
|
||||
[JsonProperty("result")]
|
||||
public string Result { get; set; }
|
||||
|
||||
[JsonProperty("error")]
|
||||
public AriaError Error { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this);
|
||||
}
|
||||
}
|
||||
}
|
25
src/Core/aria2cNet/client/entity/AriaSaveSession.cs
Normal file
25
src/Core/aria2cNet/client/entity/AriaSaveSession.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Core.aria2cNet.client.entity
|
||||
{
|
||||
[JsonObject]
|
||||
public class AriaSaveSession
|
||||
{
|
||||
[JsonProperty("id")]
|
||||
public string Id { get; set; }
|
||||
|
||||
[JsonProperty("jsonrpc")]
|
||||
public string Jsonrpc { get; set; }
|
||||
|
||||
[JsonProperty("result")]
|
||||
public string Result { get; set; }
|
||||
|
||||
[JsonProperty("error")]
|
||||
public AriaError Error { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this);
|
||||
}
|
||||
}
|
||||
}
|
45
src/Core/aria2cNet/client/entity/AriaSendData.cs
Normal file
45
src/Core/aria2cNet/client/entity/AriaSendData.cs
Normal file
@ -0,0 +1,45 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Core.aria2cNet.client.entity
|
||||
{
|
||||
[JsonObject]
|
||||
public class AriaSendData
|
||||
{
|
||||
[JsonProperty("id")]
|
||||
public string Id { get; set; }
|
||||
|
||||
[JsonProperty("jsonrpc")]
|
||||
public string Jsonrpc { get; set; }
|
||||
|
||||
[JsonProperty("method")]
|
||||
public string Method { get; set; }
|
||||
|
||||
[JsonProperty("params")]
|
||||
public List<object> Params { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this);
|
||||
}
|
||||
}
|
||||
|
||||
[JsonObject]
|
||||
public class AriaSendOption
|
||||
{
|
||||
[JsonProperty("all-proxy")]
|
||||
public string HttpProxy { get; set; }
|
||||
|
||||
[JsonProperty("out")]
|
||||
public string Out { get; set; }
|
||||
|
||||
[JsonProperty("dir")]
|
||||
public string Dir { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
25
src/Core/aria2cNet/client/entity/AriaShutdown.cs
Normal file
25
src/Core/aria2cNet/client/entity/AriaShutdown.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Core.aria2cNet.client.entity
|
||||
{
|
||||
[JsonObject]
|
||||
public class AriaShutdown
|
||||
{
|
||||
[JsonProperty("id")]
|
||||
public string Id { get; set; }
|
||||
|
||||
[JsonProperty("jsonrpc")]
|
||||
public string Jsonrpc { get; set; }
|
||||
|
||||
[JsonProperty("result")]
|
||||
public string Result { get; set; }
|
||||
|
||||
[JsonProperty("error")]
|
||||
public AriaError Error { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this);
|
||||
}
|
||||
}
|
||||
}
|
170
src/Core/aria2cNet/client/entity/AriaTellStatus.cs
Normal file
170
src/Core/aria2cNet/client/entity/AriaTellStatus.cs
Normal file
@ -0,0 +1,170 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Core.aria2cNet.client.entity
|
||||
{
|
||||
/*
|
||||
{
|
||||
"id": "qwer",
|
||||
"jsonrpc": "2.0",
|
||||
"result": {
|
||||
"bitfield": "80",
|
||||
"completedLength": "118188",
|
||||
"connections": "0",
|
||||
"dir": "D:\\home",
|
||||
"downloadSpeed": "0",
|
||||
"errorCode": "0",
|
||||
"errorMessage": "",
|
||||
"files": [
|
||||
{
|
||||
"completedLength": "118188",
|
||||
"index": "1",
|
||||
"length": "118188",
|
||||
"path": "D:/home/ariaTest.html",
|
||||
"selected": "true",
|
||||
"uris": [
|
||||
{
|
||||
"status": "used",
|
||||
"uri": "https://www.bilibili.com/"
|
||||
},
|
||||
{
|
||||
"status": "waiting",
|
||||
"uri": "https://www.bilibili.com/"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"gid": "4e7f671a6134b5ac",
|
||||
"numPieces": "1",
|
||||
"pieceLength": "1048576",
|
||||
"status": "complete",
|
||||
"totalLength": "118188",
|
||||
"uploadLength": "0",
|
||||
"uploadSpeed": "0"
|
||||
}
|
||||
}
|
||||
*/
|
||||
[JsonObject]
|
||||
public class AriaTellStatus
|
||||
{
|
||||
[JsonProperty("id")]
|
||||
public string Id { get; set; }
|
||||
|
||||
[JsonProperty("jsonrpc")]
|
||||
public string Jsonrpc { get; set; }
|
||||
|
||||
[JsonProperty("result")]
|
||||
public AriaTellStatusResult Result { get; set; }
|
||||
|
||||
[JsonProperty("error")]
|
||||
public AriaError Error { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this);
|
||||
}
|
||||
}
|
||||
|
||||
[JsonObject]
|
||||
public class AriaTellStatusList
|
||||
{
|
||||
[JsonProperty("id")]
|
||||
public string Id { get; set; }
|
||||
|
||||
[JsonProperty("jsonrpc")]
|
||||
public string Jsonrpc { get; set; }
|
||||
|
||||
[JsonProperty("result")]
|
||||
public List<AriaTellStatusResult> Result { get; set; }
|
||||
|
||||
[JsonProperty("error")]
|
||||
public AriaError Error { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this);
|
||||
}
|
||||
}
|
||||
|
||||
[JsonObject]
|
||||
public class AriaTellStatusResult
|
||||
{
|
||||
[JsonProperty("bitfield")]
|
||||
public string Bitfield { get; set; }
|
||||
|
||||
[JsonProperty("completedLength")]
|
||||
public string CompletedLength { get; set; }
|
||||
|
||||
[JsonProperty("connections")]
|
||||
public string Connections { get; set; }
|
||||
|
||||
[JsonProperty("dir")]
|
||||
public string Dir { get; set; }
|
||||
|
||||
[JsonProperty("downloadSpeed")]
|
||||
public string DownloadSpeed { get; set; }
|
||||
|
||||
[JsonProperty("errorCode")]
|
||||
public string ErrorCode { get; set; }
|
||||
|
||||
[JsonProperty("errorMessage")]
|
||||
public string ErrorMessage { get; set; }
|
||||
|
||||
[JsonProperty("files")]
|
||||
public List<AriaTellStatusResultFile> Files { get; set; }
|
||||
|
||||
[JsonProperty("gid")]
|
||||
public string Gid { get; set; }
|
||||
|
||||
[JsonProperty("numPieces")]
|
||||
public string NumPieces { get; set; }
|
||||
|
||||
[JsonProperty("pieceLength")]
|
||||
public string PieceLength { get; set; }
|
||||
|
||||
[JsonProperty("status")]
|
||||
public string Status { get; set; }
|
||||
|
||||
[JsonProperty("totalLength")]
|
||||
public string TotalLength { get; set; }
|
||||
|
||||
[JsonProperty("uploadLength")]
|
||||
public string UploadLength { get; set; }
|
||||
|
||||
[JsonProperty("uploadSpeed")]
|
||||
public string UploadSpeed { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this);
|
||||
}
|
||||
}
|
||||
|
||||
[JsonObject]
|
||||
public class AriaTellStatusResultFile
|
||||
{
|
||||
[JsonProperty("completedLength")]
|
||||
public string CompletedLength { get; set; }
|
||||
|
||||
[JsonProperty("index")]
|
||||
public string Index { get; set; }
|
||||
|
||||
[JsonProperty("length")]
|
||||
public string Length { get; set; }
|
||||
|
||||
[JsonProperty("path")]
|
||||
public string Path { get; set; }
|
||||
|
||||
[JsonProperty("selected")]
|
||||
public string Selected { get; set; }
|
||||
|
||||
[JsonProperty("uris")]
|
||||
public List<AriaUri> Uris { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
19
src/Core/aria2cNet/client/entity/AriaUri.cs
Normal file
19
src/Core/aria2cNet/client/entity/AriaUri.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Core.aria2cNet.client.entity
|
||||
{
|
||||
[JsonObject]
|
||||
public class AriaUri
|
||||
{
|
||||
[JsonProperty("status")]
|
||||
public string Status { get; set; }
|
||||
|
||||
[JsonProperty("uri")]
|
||||
public string Uri { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this);
|
||||
}
|
||||
}
|
||||
}
|
42
src/Core/aria2cNet/client/entity/AriaVersion.cs
Normal file
42
src/Core/aria2cNet/client/entity/AriaVersion.cs
Normal file
@ -0,0 +1,42 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Core.aria2cNet.client.entity
|
||||
{
|
||||
[JsonObject]
|
||||
public class AriaVersion
|
||||
{
|
||||
[JsonProperty("id")]
|
||||
public string Id { get; set; }
|
||||
|
||||
[JsonProperty("jsonrpc")]
|
||||
public string Jsonrpc { get; set; }
|
||||
|
||||
[JsonProperty("result")]
|
||||
public AriaVersionResult Result { get; set; }
|
||||
|
||||
[JsonProperty("error")]
|
||||
public AriaError Error { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this);
|
||||
}
|
||||
}
|
||||
|
||||
[JsonObject]
|
||||
public class AriaVersionResult
|
||||
{
|
||||
[JsonProperty("enabledFeatures")]
|
||||
public List<string> EnabledFeatures { get; set; }
|
||||
|
||||
[JsonProperty("version")]
|
||||
public string Version { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
26
src/Core/aria2cNet/client/entity/SystemListMethods.cs
Normal file
26
src/Core/aria2cNet/client/entity/SystemListMethods.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Core.aria2cNet.client.entity
|
||||
{
|
||||
[JsonObject]
|
||||
public class SystemListMethods
|
||||
{
|
||||
[JsonProperty("id")]
|
||||
public string Id { get; set; }
|
||||
|
||||
[JsonProperty("jsonrpc")]
|
||||
public string Jsonrpc { get; set; }
|
||||
|
||||
[JsonProperty("result")]
|
||||
public List<string> Result { get; set; }
|
||||
|
||||
[JsonProperty("error")]
|
||||
public AriaError Error { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this);
|
||||
}
|
||||
}
|
||||
}
|
26
src/Core/aria2cNet/client/entity/SystemListNotifications.cs
Normal file
26
src/Core/aria2cNet/client/entity/SystemListNotifications.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Core.aria2cNet.client.entity
|
||||
{
|
||||
[JsonObject]
|
||||
public class SystemListNotifications
|
||||
{
|
||||
[JsonProperty("id")]
|
||||
public string Id { get; set; }
|
||||
|
||||
[JsonProperty("jsonrpc")]
|
||||
public string Jsonrpc { get; set; }
|
||||
|
||||
[JsonProperty("result")]
|
||||
public List<string> Result { get; set; }
|
||||
|
||||
[JsonProperty("error")]
|
||||
public AriaError Error { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this);
|
||||
}
|
||||
}
|
||||
}
|
25
src/Core/aria2cNet/client/entity/SystemMulticall.cs
Normal file
25
src/Core/aria2cNet/client/entity/SystemMulticall.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Core.aria2cNet.client.entity
|
||||
{
|
||||
[JsonObject]
|
||||
public class SystemMulticall
|
||||
{
|
||||
[JsonProperty("id")]
|
||||
public string Id { get; set; }
|
||||
|
||||
[JsonProperty("jsonrpc")]
|
||||
public string Jsonrpc { get; set; }
|
||||
|
||||
[JsonProperty("result")]
|
||||
public string Result { get; set; }
|
||||
|
||||
[JsonProperty("error")]
|
||||
public AriaError Error { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this);
|
||||
}
|
||||
}
|
||||
}
|
15
src/Core/aria2cNet/client/entity/SystemMulticallMathod.cs
Normal file
15
src/Core/aria2cNet/client/entity/SystemMulticallMathod.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Core.aria2cNet.client.entity
|
||||
{
|
||||
[JsonObject]
|
||||
public class SystemMulticallMathod
|
||||
{
|
||||
[JsonProperty("method")]
|
||||
public string Method { get; set; }
|
||||
|
||||
[JsonProperty("params")]
|
||||
public List<object> Params { get; set; }
|
||||
}
|
||||
}
|
45
src/Core/aria2cNet/server/AriaConfig.cs
Normal file
45
src/Core/aria2cNet/server/AriaConfig.cs
Normal file
@ -0,0 +1,45 @@
|
||||
namespace Core.aria2cNet.server
|
||||
{
|
||||
/// <summary>
|
||||
/// Aria服务器的启动配置
|
||||
/// </summary>
|
||||
public class AriaConfig
|
||||
{
|
||||
public int ListenPort { get; set; } // 服务器端口号,取值:1024-65535
|
||||
public string Token { get; set; } // 连接服务器的token
|
||||
public AriaConfigLogLevel LogLevel { get; set; } // 日志等级,debug info notice warn error
|
||||
public int MaxConcurrentDownloads { get; set; } // 最大同时下载数(任务数),取值:1-*
|
||||
public int MaxConnectionPerServer { get; set; } // 同服务器连接数,取值:1-16
|
||||
public int Split { get; set; } // 单文件最大线程数,取值:1-*
|
||||
public int MinSplitSize { get; set; } // 最小文件分片大小, 下载线程数上限取决于能分出多少片, 对于小文件重要,单位MB
|
||||
public long MaxOverallDownloadLimit { get; set; } // 下载速度限制,取值:1-*
|
||||
public long MaxDownloadLimit { get; set; } // 下载单文件速度限制,取值:1-*
|
||||
public long MaxOverallUploadLimit { get; set; } // 上传速度限制,取值:1-*
|
||||
public long MaxUploadLimit { get; set; } // 上传单文件速度限制,取值:1-*
|
||||
public bool ContinueDownload { get; set; } // 断点续传
|
||||
public AriaConfigFileAllocation FileAllocation { get; set; } // 文件预分配, none prealloc
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 日志等级
|
||||
/// </summary>
|
||||
public enum AriaConfigLogLevel
|
||||
{
|
||||
DEBUG = 1,
|
||||
INFO,
|
||||
NOTICE,
|
||||
WARN,
|
||||
ERROR
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 文件预分配
|
||||
/// </summary>
|
||||
public enum AriaConfigFileAllocation
|
||||
{
|
||||
NONE = 1, // 没有预分配
|
||||
PREALLOC, // 预分配,默认
|
||||
FALLOC // NTFS建议使用
|
||||
}
|
||||
|
||||
}
|
193
src/Core/aria2cNet/server/AriaServer.cs
Normal file
193
src/Core/aria2cNet/server/AriaServer.cs
Normal file
@ -0,0 +1,193 @@
|
||||
using Core.aria2cNet.client;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace Core.aria2cNet.server
|
||||
{
|
||||
public static class AriaServer
|
||||
{
|
||||
public static int ListenPort; // 服务器端口
|
||||
private static Process Server;
|
||||
|
||||
/// <summary>
|
||||
/// 启动aria2c服务器
|
||||
/// </summary>
|
||||
/// <param name="listenPort"></param>
|
||||
/// <param name="output"></param>
|
||||
/// <param name="window"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<bool> StartServerAsync(AriaConfig config, TextBox output = null, Window window = null)
|
||||
{
|
||||
ListenPort = config.ListenPort;
|
||||
string ariaDir = Environment.CurrentDirectory + "\\aria\\"; // aria目录
|
||||
string sessionFile = ariaDir + "aira.session.gz"; // 会话文件
|
||||
string logFile = ariaDir + "aira.log"; // 日志文件
|
||||
int saveSessionInterval = 30; // 自动保存会话文件的时间间隔
|
||||
|
||||
// --enable-rpc --rpc-listen-all=true --rpc-allow-origin-all=true --continue=true
|
||||
await Task.Run(() =>
|
||||
{
|
||||
// 创建目录和文件
|
||||
if (!Directory.Exists(ariaDir))
|
||||
{
|
||||
Directory.CreateDirectory(ariaDir);
|
||||
}
|
||||
if (!File.Exists(sessionFile))
|
||||
{
|
||||
var stream = File.Create(sessionFile);
|
||||
stream.Close();
|
||||
}
|
||||
if (!File.Exists(logFile))
|
||||
{
|
||||
var stream = File.Create(logFile);
|
||||
stream.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
// 日志文件存在,如果大于100M,则删除
|
||||
try
|
||||
{
|
||||
var stream = File.Open(logFile, FileMode.Open);
|
||||
if (stream.Length >= 1024 * 1024 * 1024L)
|
||||
{
|
||||
stream.SetLength(0);
|
||||
}
|
||||
stream.Close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine("StartServerAsync()发生其他异常: {0}", e);
|
||||
}
|
||||
}
|
||||
|
||||
ExcuteProcess("aria2c.exe",
|
||||
$"--enable-rpc --rpc-listen-all=true --rpc-allow-origin-all=true " +
|
||||
$"--rpc-listen-port={config.ListenPort} " +
|
||||
$"--rpc-secret={config.Token} " +
|
||||
$"--input-file=\"{sessionFile}\" --save-session=\"{sessionFile}\" " +
|
||||
$"--save-session-interval={saveSessionInterval} " +
|
||||
$"--log=\"{logFile}\" --log-level={config.LogLevel.ToString("G").ToLower()} " + // log-level: 'debug' 'info' 'notice' 'warn' 'error'
|
||||
$"--max-concurrent-downloads={config.MaxConcurrentDownloads} " + // 最大同时下载数(任务数)
|
||||
$"--max-connection-per-server={config.MaxConnectionPerServer} " + // 同服务器连接数
|
||||
$"--split={config.Split} " + // 单文件最大线程数
|
||||
$"--min-split-size={config.MinSplitSize}M " + // 最小文件分片大小, 下载线程数上限取决于能分出多少片, 对于小文件重要
|
||||
$"--max-overall-download-limit={config.MaxOverallDownloadLimit} " + // 下载速度限制
|
||||
$"--max-download-limit={config.MaxDownloadLimit} " + // 下载单文件速度限制
|
||||
$"--max-overall-upload-limit={config.MaxOverallUploadLimit} " + // 上传速度限制
|
||||
$"--max-upload-limit={config.MaxUploadLimit} " + // 上传单文件速度限制
|
||||
$"--continue {config.ContinueDownload.ToString().ToLower()} " + // 断点续传
|
||||
$"--allow-overwrite true " + // 允许复写文件
|
||||
$"--file-allocation={config.FileAllocation.ToString("G").ToLower()} " + // 文件预分配, none prealloc
|
||||
"",
|
||||
null, (s, e) =>
|
||||
{
|
||||
if (e.Data == null || e.Data == "" || e.Data.Replace(" ", "") == "") { return; }
|
||||
Console.WriteLine(e.Data);
|
||||
if (output != null && window != null)
|
||||
{
|
||||
window.Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
output.Text += e.Data + "\n";
|
||||
output.ScrollToEnd();
|
||||
}));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 关闭aria2c服务器,异步方法
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static async Task<bool> CloseServerAsync()
|
||||
{
|
||||
await AriaClient.ShutdownAsync();
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 强制关闭aria2c服务器,异步方法
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static async Task<bool> ForceCloseServerAsync()
|
||||
{
|
||||
//await Task.Run(() =>
|
||||
//{
|
||||
// if (Server == null) { return; }
|
||||
|
||||
// Server.Kill();
|
||||
// Server = null; // 将Server指向null
|
||||
//});
|
||||
//return true;
|
||||
await AriaClient.ForceShutdownAsync();
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 关闭aria2c服务器
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static bool CloseServer()
|
||||
{
|
||||
var task = AriaClient.ShutdownAsync();
|
||||
if (task.Result != null && task.Result.Result != null && task.Result.Result == "OK")
|
||||
{ return true; }
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 强制关闭aria2c服务器
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static bool ForceCloseServer()
|
||||
{
|
||||
var task = AriaClient.ForceShutdownAsync();
|
||||
if (task.Result != null && task.Result.Result != null && task.Result.Result == "OK")
|
||||
{ return true; }
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private static void ExcuteProcess(string exe, string arg, string workingDirectory, DataReceivedEventHandler output)
|
||||
{
|
||||
using (var p = new Process())
|
||||
{
|
||||
Server = p;
|
||||
|
||||
p.StartInfo.FileName = exe;
|
||||
p.StartInfo.Arguments = arg;
|
||||
|
||||
// 工作目录
|
||||
if (workingDirectory != null)
|
||||
{
|
||||
p.StartInfo.WorkingDirectory = workingDirectory;
|
||||
}
|
||||
|
||||
p.StartInfo.UseShellExecute = false; //输出信息重定向
|
||||
p.StartInfo.CreateNoWindow = true;
|
||||
p.StartInfo.RedirectStandardError = true;
|
||||
p.StartInfo.RedirectStandardOutput = true;
|
||||
|
||||
// 将 StandardErrorEncoding 改为 UTF-8 才不会出现中文乱码
|
||||
p.StartInfo.StandardOutputEncoding = Encoding.UTF8;
|
||||
p.StartInfo.StandardErrorEncoding = Encoding.UTF8;
|
||||
|
||||
p.OutputDataReceived += output;
|
||||
p.ErrorDataReceived += output;
|
||||
|
||||
p.Start(); //启动线程
|
||||
p.BeginOutputReadLine();
|
||||
p.BeginErrorReadLine();
|
||||
p.WaitForExit(); //等待进程结束
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user