细化分类数据模型,更改部分service名称
This commit is contained in:
parent
86e41f6afb
commit
1f1f714f5a
43 changed files with 412 additions and 332 deletions
|
@ -1,4 +1,5 @@
|
||||||
using iFileProxy.Models;
|
using iFileProxy.Models.Response;
|
||||||
|
using iFileProxy.Models.Other;
|
||||||
using iFileProxy.Services;
|
using iFileProxy.Services;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.Mvc.Filters;
|
using Microsoft.AspNetCore.Mvc.Filters;
|
||||||
|
|
|
@ -1,20 +1,22 @@
|
||||||
using iFileProxy.Config;
|
using iFileProxy.Config;
|
||||||
using iFileProxy.Models;
|
using iFileProxy.Models.Other;
|
||||||
using iFileProxy.Services;
|
using iFileProxy.Services;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using iFileProxy.Attributes;
|
using iFileProxy.Attributes;
|
||||||
using Serilog.Events;
|
using Serilog.Events;
|
||||||
|
using iFileProxy.Models.Task;
|
||||||
|
using iFileProxy.Models.Response;
|
||||||
|
|
||||||
namespace iFileProxy.Controllers
|
namespace iFileProxy.Controllers
|
||||||
{
|
{
|
||||||
[Authorize(UserMask.Admin,UserMask.SuperAdmin)]
|
[Authorize(UserMask.Admin,UserMask.SuperAdmin)]
|
||||||
[Route("[controller]")]
|
[Route("[controller]")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
public class ManagementController(TaskManager taskManager, DatabaseGateService dbGateService, Dictionary<string, Dictionary<string, uint>> ipAccessLimitData) : ControllerBase
|
public class ManagementController(TaskManagementService taskManager, DatabaseGateService dbGateService, Dictionary<string, Dictionary<string, uint>> ipAccessLimitData) : ControllerBase
|
||||||
{
|
{
|
||||||
public TaskManager _taskManager = taskManager;
|
public TaskManagementService _taskManager = taskManager;
|
||||||
public DatabaseGateService _dbGateService = dbGateService;
|
public DatabaseGateService _dbGateService = dbGateService;
|
||||||
private readonly Serilog.ILogger _logger = Log.Logger.ForContext<ManagementController>();
|
private readonly Serilog.ILogger _logger = Log.Logger.ForContext<ManagementController>();
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
using iFileProxy.Config;
|
using iFileProxy.Config;
|
||||||
using iFileProxy.Models;
|
using iFileProxy.Models.Task;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
using System.Web;
|
using System.Web;
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
using iFileProxy.Attributes;
|
using iFileProxy.Attributes;
|
||||||
using iFileProxy.Config;
|
using iFileProxy.Config;
|
||||||
using iFileProxy.Helpers;
|
using iFileProxy.Helpers;
|
||||||
using iFileProxy.Models;
|
using iFileProxy.Models.Response;
|
||||||
|
using iFileProxy.Models.Request;
|
||||||
|
using iFileProxy.Models.Other;
|
||||||
using iFileProxy.Services;
|
using iFileProxy.Services;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
@ -572,27 +574,6 @@ namespace iFileProxy.Controllers
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class UpdateUserMaskRequest
|
|
||||||
{
|
|
||||||
public UserMask NewMask { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class UpdateNicknameRequest
|
|
||||||
{
|
|
||||||
public string NewNickname { get; set; } = string.Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
public class UpdatePasswordRequest
|
|
||||||
{
|
|
||||||
public string OldPassword { get; set; } = string.Empty;
|
|
||||||
public string NewPassword { get; set; } = string.Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
public class ResetPasswordRequest
|
|
||||||
{
|
|
||||||
public string NewPassword { get; set; } = string.Empty;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,10 +1,10 @@
|
||||||
using iFileProxy.Helpers;
|
using iFileProxy.Helpers;
|
||||||
using iFileProxy.Services;
|
using iFileProxy.Services;
|
||||||
using iFileProxy.Models;
|
using iFileProxy.Models.Response;
|
||||||
using iFileProxy.Config;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
|
using iFileProxy.Models.Task;
|
||||||
|
|
||||||
namespace iFileProxy.Controllers
|
namespace iFileProxy.Controllers
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
using iFileProxy.Config;
|
using iFileProxy.Config;
|
||||||
using iFileProxy.Helpers;
|
using iFileProxy.Helpers;
|
||||||
using iFileProxy.Models;
|
using iFileProxy.Models.Task;
|
||||||
|
using iFileProxy.Models.Response;
|
||||||
|
|
||||||
using iFileProxy.Services;
|
using iFileProxy.Services;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
@ -10,14 +12,14 @@ namespace iFileProxy.Controllers
|
||||||
{
|
{
|
||||||
public class iProxyController : ControllerBase
|
public class iProxyController : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly TaskManager _taskManager;
|
private readonly TaskManagementService _taskManager;
|
||||||
private AppConfig _appConfig;
|
private AppConfig _appConfig;
|
||||||
private readonly DatabaseGateService _dbGate;
|
private readonly DatabaseGateService _dbGate;
|
||||||
|
|
||||||
private readonly static Serilog.ILogger _logger = Log.Logger.ForContext<iProxyController>();
|
private readonly static Serilog.ILogger _logger = Log.Logger.ForContext<iProxyController>();
|
||||||
|
|
||||||
|
|
||||||
public iProxyController(TaskManager taskManager, AppConfigService appConfigService, DatabaseGateService databaseGateService)
|
public iProxyController(TaskManagementService taskManager, AppConfigService appConfigService, DatabaseGateService databaseGateService)
|
||||||
{
|
{
|
||||||
_taskManager = taskManager;
|
_taskManager = taskManager;
|
||||||
_appConfig = appConfigService.AppConfig;
|
_appConfig = appConfigService.AppConfig;
|
||||||
|
|
13
src/Handlers/CommandLine/CorsPolicy.cs
Normal file
13
src/Handlers/CommandLine/CorsPolicy.cs
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
using iFileProxy.Attributes;
|
||||||
|
using iFileProxy.Interfaces;
|
||||||
|
|
||||||
|
namespace iFileProxy.Handlers.CommandLine
|
||||||
|
{
|
||||||
|
[CommandLineArgument(FullArgumentName = "--cors-allowed-domains", ShortArgumentName = "-A", Description = "自定义Cors跨域策略,参数为url格式,使用英文分号分割多个url", NeedValue = true)]
|
||||||
|
public class CorsPolicy(string[] args) : ICommandLineHandler
|
||||||
|
{
|
||||||
|
public void Process()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,7 +8,7 @@ namespace iFileProxy.Handlers.CommandLine
|
||||||
{
|
{
|
||||||
public void Process()
|
public void Process()
|
||||||
{
|
{
|
||||||
Console.WriteLine("dev level logging is enabled.");
|
Console.WriteLine("dev level logging has enabled.");
|
||||||
// 具体的实现在SerilogConfig.cs中 此处仅作提示
|
// 具体的实现在SerilogConfig.cs中 此处仅作提示
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,13 +21,21 @@ namespace iFileProxy.Handlers.CommandLine
|
||||||
int maxKeyLength = helpText.Keys.Max(key => key.Length);
|
int maxKeyLength = helpText.Keys.Max(key => key.Length);
|
||||||
|
|
||||||
// 打印表头
|
// 打印表头
|
||||||
Console.WriteLine("参数(短参数, 长参数)\t解释");
|
Console.WriteLine("参数: ");
|
||||||
|
|
||||||
// 打印每一行的帮助信息,确保对齐
|
// 打印每一行的帮助信息,确保对齐
|
||||||
foreach (var ht in helpText)
|
foreach (var ht in helpText)
|
||||||
{
|
{
|
||||||
Console.WriteLine($" {ht.Key}{new string(' ', maxKeyLength - ht.Key.Length)}\t{ht.Value}");
|
Console.WriteLine($" {ht.Key}{new string(' ', maxKeyLength - ht.Key.Length)}\t{ht.Value}");
|
||||||
}
|
}
|
||||||
|
Console.WriteLine();
|
||||||
|
|
||||||
|
Console.WriteLine("示例: ");
|
||||||
|
|
||||||
|
Console.WriteLine($" --cors-allowed-domains=https://www.example.com;http://api.example.com:4433");
|
||||||
|
Console.WriteLine($" -B=http://0.0.0.0:5000");
|
||||||
|
|
||||||
|
|
||||||
Console.WriteLine(new string('\n',2));
|
Console.WriteLine(new string('\n',2));
|
||||||
|
|
||||||
Console.WriteLine($"程序编译日期(UTC+8): {MasterHelper.GetBuildTime(Assembly.GetExecutingAssembly())}");
|
Console.WriteLine($"程序编译日期(UTC+8): {MasterHelper.GetBuildTime(Assembly.GetExecutingAssembly())}");
|
||||||
|
|
|
@ -68,9 +68,9 @@ namespace iFileProxy.Handlers
|
||||||
{
|
{
|
||||||
throw new ArgumentException("该参数长短参数名均为空 请联系软件开发者反馈");
|
throw new ArgumentException("该参数长短参数名均为空 请联系软件开发者反馈");
|
||||||
}
|
}
|
||||||
else if (!attribute.NeedValue && attribute.FullArgumentName.Trim() == string.Empty)
|
else if (!attribute.NeedValue && attribute.FullArgumentName.Trim() == string.Empty) // 只有短参且不需要值
|
||||||
return attribute.ShortArgumentName ;
|
return attribute.ShortArgumentName ;
|
||||||
else if (!attribute.NeedValue && attribute.ShortArgumentName.Trim() == string.Empty)
|
else if (!attribute.NeedValue && attribute.ShortArgumentName.Trim() == string.Empty)// 只有长参且不需要值
|
||||||
return $"{attribute.ShortArgumentName} {attribute.FullArgumentName}";
|
return $"{attribute.ShortArgumentName} {attribute.FullArgumentName}";
|
||||||
else
|
else
|
||||||
return $"{attribute.ShortArgumentName},{attribute.FullArgumentName}";
|
return $"{attribute.ShortArgumentName},{attribute.FullArgumentName}";
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
using iFileProxy.Models;
|
using iFileProxy.Models.Task;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
using System.Net.Http.Headers;
|
using System.Net.Http.Headers;
|
||||||
using System.Text.Json;
|
|
||||||
|
|
||||||
namespace iFileProxy.Helpers
|
namespace iFileProxy.Helpers
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
using iFileProxy.Config;
|
using iFileProxy.Config;
|
||||||
using iFileProxy.Models;
|
using iFileProxy.Models.Other;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
using iFileProxy.Helpers;
|
using iFileProxy.Helpers;
|
||||||
using iFileProxy.Models;
|
using iFileProxy.Models.Response;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
using iFileProxy.Config;
|
using iFileProxy.Helpers;
|
||||||
using iFileProxy.Helpers;
|
using iFileProxy.Models.Response;
|
||||||
using iFileProxy.Models;
|
|
||||||
using iFileProxy.Services;
|
using iFileProxy.Services;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
using iFileProxy.Helpers;
|
using iFileProxy.Helpers;
|
||||||
using iFileProxy.Models;
|
using iFileProxy.Models.Response;
|
||||||
using Microsoft.IdentityModel.Tokens;
|
using Microsoft.IdentityModel.Tokens;
|
||||||
using System.IdentityModel.Tokens.Jwt;
|
using System.IdentityModel.Tokens.Jwt;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
public class ClientInfo
|
|
||||||
{
|
|
||||||
public string IP { get; set; } = string.Empty;
|
|
||||||
public string UserAgent { get; set; } = string.Empty;
|
|
||||||
public string Fingerprint { get; set; } = string.Empty; // 浏览器指纹
|
|
||||||
}
|
|
9
src/Models/Other/ClientInfo.cs
Normal file
9
src/Models/Other/ClientInfo.cs
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
namespace iFileProxy.Models.Other
|
||||||
|
{
|
||||||
|
public class ClientInfo
|
||||||
|
{
|
||||||
|
public string IP { get; set; } = string.Empty;
|
||||||
|
public string UserAgent { get; set; } = string.Empty;
|
||||||
|
public string Fingerprint { get; set; } = string.Empty; // 浏览器指纹
|
||||||
|
}
|
||||||
|
}
|
33
src/Models/Other/ConnectionPoolInfo.cs
Normal file
33
src/Models/Other/ConnectionPoolInfo.cs
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
namespace iFileProxy.Models.Other
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 数据库连接池信息
|
||||||
|
/// </summary>
|
||||||
|
public class ConnectionPoolInfo
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 当前总连接数
|
||||||
|
/// </summary>
|
||||||
|
public long TotalConnections { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 活跃连接数
|
||||||
|
/// </summary>
|
||||||
|
public long ActiveConnections { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 空闲连接数
|
||||||
|
/// </summary>
|
||||||
|
public long SleepingConnections { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 连接池最大连接数
|
||||||
|
/// </summary>
|
||||||
|
public uint MaxPoolSize { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 连接详情列表
|
||||||
|
/// </summary>
|
||||||
|
public List<ProcessListInfo> Connections { get; set; } = [];
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
|
||||||
namespace iFileProxy.Models
|
namespace iFileProxy.Models.Other
|
||||||
{
|
{
|
||||||
public class HttpContextDebugInfo
|
public class HttpContextDebugInfo
|
||||||
{
|
{
|
||||||
|
@ -84,10 +84,10 @@ namespace iFileProxy.Models
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return JsonSerializer.Serialize(this, new JsonSerializerOptions
|
return JsonSerializer.Serialize(this, new JsonSerializerOptions
|
||||||
{
|
{
|
||||||
WriteIndented = true
|
WriteIndented = true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
48
src/Models/Other/MysqlProcessListInfo.cs
Normal file
48
src/Models/Other/MysqlProcessListInfo.cs
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
namespace iFileProxy.Models.Other
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// MySQL 进程列表信息
|
||||||
|
/// </summary>
|
||||||
|
public class ProcessListInfo
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 连接ID
|
||||||
|
/// </summary>
|
||||||
|
public long Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用户名
|
||||||
|
/// </summary>
|
||||||
|
public string User { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 主机信息
|
||||||
|
/// </summary>
|
||||||
|
public string Host { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 数据库名
|
||||||
|
/// </summary>
|
||||||
|
public string Db { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 命令类型
|
||||||
|
/// </summary>
|
||||||
|
public string Command { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 执行时间(秒)
|
||||||
|
/// </summary>
|
||||||
|
public long Time { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 连接状态
|
||||||
|
/// </summary>
|
||||||
|
public string State { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 执行的SQL
|
||||||
|
/// </summary>
|
||||||
|
public string Info { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using ThreadState = System.Diagnostics.ThreadState;
|
using ThreadState = System.Diagnostics.ThreadState;
|
||||||
|
|
||||||
namespace iFileProxy.Models
|
namespace iFileProxy.Models.Other
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 进程详细信息模型
|
/// 进程详细信息模型
|
||||||
|
@ -74,4 +74,4 @@ namespace iFileProxy.Models
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ThreadPriorityLevel Priority { get; set; }
|
public ThreadPriorityLevel Priority { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
namespace iFileProxy.Models
|
namespace iFileProxy.Models.Other
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 计算文件Hash类型
|
/// 计算文件Hash类型
|
17
src/Models/Other/ServerTaskLoadInfo.cs
Normal file
17
src/Models/Other/ServerTaskLoadInfo.cs
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
namespace iFileProxy.Models.Other
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 任务负载信息
|
||||||
|
/// </summary>
|
||||||
|
public class ServerTaskLoadInfo
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 正在运行的任务数
|
||||||
|
/// </summary>
|
||||||
|
public int Running { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 正在队列中的任务数
|
||||||
|
/// </summary>
|
||||||
|
public int Queuing { get; set; }
|
||||||
|
}
|
||||||
|
}
|
25
src/Models/Other/SystemLog.cs
Normal file
25
src/Models/Other/SystemLog.cs
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
namespace iFileProxy.Models.Other
|
||||||
|
{
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
public class SystemLog
|
||||||
|
{
|
||||||
|
[JsonProperty("log_id")]
|
||||||
|
public string LogId { get; set; } = Guid.NewGuid().ToString();
|
||||||
|
|
||||||
|
[JsonProperty("level")]
|
||||||
|
public string Level { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[JsonProperty("message")]
|
||||||
|
public string Message { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[JsonProperty("exception")]
|
||||||
|
public string? Exception { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("properties")]
|
||||||
|
public string Properties { get; set; } = "{}";
|
||||||
|
|
||||||
|
[JsonProperty("timestamp")]
|
||||||
|
public DateTime Timestamp { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace iFileProxy.Models
|
namespace iFileProxy.Models.Other
|
||||||
{
|
{
|
||||||
public enum UserMask
|
public enum UserMask
|
||||||
{
|
{
|
||||||
|
@ -139,29 +139,4 @@ namespace iFileProxy.Models
|
||||||
[JsonProperty("nickname")]
|
[JsonProperty("nickname")]
|
||||||
public string Nickname { get; set; } = string.Empty;
|
public string Nickname { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 注册请求数据结构
|
|
||||||
/// </summary>
|
|
||||||
public class RegisterRequest
|
|
||||||
{
|
|
||||||
public string Username { get; set; } = string.Empty;
|
|
||||||
public string Password { get; set; } = string.Empty;
|
|
||||||
public string NickName { get; set; } = string.Empty;
|
|
||||||
public string Email { get; set; } = string.Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 登录请求数据结构
|
|
||||||
/// </summary>
|
|
||||||
public class LoginRequest
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 用户名或邮箱
|
|
||||||
/// </summary>
|
|
||||||
public string Username { get; set; } = string.Empty;
|
|
||||||
public string Account { get; set; } = string.Empty;
|
|
||||||
public string Password { get; set; } = string.Empty;
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -1,31 +0,0 @@
|
||||||
/// <summary>
|
|
||||||
/// 通用分页结果模型
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T">数据项类型</typeparam>
|
|
||||||
public class PagedResult<T>
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 总记录数
|
|
||||||
/// </summary>
|
|
||||||
public long Total { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 每页数量
|
|
||||||
/// </summary>
|
|
||||||
public int PageSize { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 当前页码
|
|
||||||
/// </summary>
|
|
||||||
public int CurrentPage { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 总页数
|
|
||||||
/// </summary>
|
|
||||||
public int TotalPages { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 当前页的数据列表
|
|
||||||
/// </summary>
|
|
||||||
public List<T> Data { get; set; } = new();
|
|
||||||
}
|
|
49
src/Models/Request/User.cs
Normal file
49
src/Models/Request/User.cs
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
using iFileProxy.Models.Other;
|
||||||
|
|
||||||
|
namespace iFileProxy.Models.Request
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 注册请求数据结构
|
||||||
|
/// </summary>
|
||||||
|
public class RegisterRequest
|
||||||
|
{
|
||||||
|
public string Username { get; set; } = string.Empty;
|
||||||
|
public string Password { get; set; } = string.Empty;
|
||||||
|
public string NickName { get; set; } = string.Empty;
|
||||||
|
public string Email { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 登录请求数据结构
|
||||||
|
/// </summary>
|
||||||
|
public class LoginRequest
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 用户名或邮箱
|
||||||
|
/// </summary>
|
||||||
|
public string Username { get; set; } = string.Empty;
|
||||||
|
public string Account { get; set; } = string.Empty;
|
||||||
|
public string Password { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class UpdateUserMaskRequest
|
||||||
|
{
|
||||||
|
public UserMask NewMask { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class UpdateNicknameRequest
|
||||||
|
{
|
||||||
|
public string NewNickname { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class UpdatePasswordRequest
|
||||||
|
{
|
||||||
|
public string OldPassword { get; set; } = string.Empty;
|
||||||
|
public string NewPassword { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ResetPasswordRequest
|
||||||
|
{
|
||||||
|
public string NewPassword { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace iFileProxy.Models
|
namespace iFileProxy.Models.Response
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 通用Http Response
|
/// 通用Http Response
|
35
src/Models/Response/PagedResult.cs
Normal file
35
src/Models/Response/PagedResult.cs
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
namespace iFileProxy.Models.Response
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 通用分页结果模型
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">数据项类型</typeparam>
|
||||||
|
public class PagedResult<T>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 总记录数
|
||||||
|
/// </summary>
|
||||||
|
public long Total { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 每页数量
|
||||||
|
/// </summary>
|
||||||
|
public int PageSize { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 当前页码
|
||||||
|
/// </summary>
|
||||||
|
public int CurrentPage { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 总页数
|
||||||
|
/// </summary>
|
||||||
|
public int TotalPages { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 当前页的数据列表
|
||||||
|
/// </summary>
|
||||||
|
public List<T> Data { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
using Newtonsoft.Json;
|
|
||||||
|
|
||||||
public class SystemLog
|
|
||||||
{
|
|
||||||
[JsonProperty("log_id")]
|
|
||||||
public string LogId { get; set; } = Guid.NewGuid().ToString();
|
|
||||||
|
|
||||||
[JsonProperty("level")]
|
|
||||||
public string Level { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
[JsonProperty("message")]
|
|
||||||
public string Message { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
[JsonProperty("exception")]
|
|
||||||
public string? Exception { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("properties")]
|
|
||||||
public string Properties { get; set; } = "{}";
|
|
||||||
|
|
||||||
[JsonProperty("timestamp")]
|
|
||||||
public DateTime Timestamp { get; set; }
|
|
||||||
}
|
|
14
src/Models/Task/DownloadFileInfo.cs
Normal file
14
src/Models/Task/DownloadFileInfo.cs
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
namespace iFileProxy.Models.Task
|
||||||
|
{
|
||||||
|
public class DownloadFileInfo
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 文件名
|
||||||
|
/// </summary>
|
||||||
|
public string FileName { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 文件大小
|
||||||
|
/// </summary>
|
||||||
|
public long Size { get; set; }
|
||||||
|
}
|
||||||
|
}
|
16
src/Models/Task/DownloadHistory.cs
Normal file
16
src/Models/Task/DownloadHistory.cs
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace iFileProxy.Models.Task
|
||||||
|
{
|
||||||
|
public class DownloadHistory
|
||||||
|
{
|
||||||
|
[JsonProperty("tid")]
|
||||||
|
public string TaskId { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[JsonProperty("time")]
|
||||||
|
public DateTime Time { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("client_ip")]
|
||||||
|
public string ClientIP { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,54 +1,11 @@
|
||||||
namespace iFileProxy.Models
|
namespace iFileProxy.Models.Task
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// 任务状态
|
|
||||||
/// </summary>
|
|
||||||
public enum TaskState {
|
|
||||||
/// <summary>
|
|
||||||
/// 还未初始化
|
|
||||||
/// </summary>
|
|
||||||
NoInit = 0,
|
|
||||||
/// <summary>
|
|
||||||
/// 正在进行
|
|
||||||
/// </summary>
|
|
||||||
Running = 1,
|
|
||||||
/// <summary>
|
|
||||||
/// 任务执行时候发生错误 已经结束
|
|
||||||
/// </summary>
|
|
||||||
Error = 2,
|
|
||||||
/// <summary>
|
|
||||||
/// 任务正常结束
|
|
||||||
/// </summary>
|
|
||||||
End = 3,
|
|
||||||
/// <summary>
|
|
||||||
/// 要下载的内容已经缓存
|
|
||||||
/// </summary>
|
|
||||||
Cached = 4,
|
|
||||||
/// <summary>
|
|
||||||
/// 内容过期已被清理
|
|
||||||
/// </summary>
|
|
||||||
Cleaned = 5,
|
|
||||||
/// <summary>
|
|
||||||
/// 正在排队
|
|
||||||
/// </summary>
|
|
||||||
Queuing = 6,
|
|
||||||
/// <summary>
|
|
||||||
/// 任务因为各种原因被取消
|
|
||||||
/// </summary>
|
|
||||||
Canceled = 7,
|
|
||||||
/// <summary>
|
|
||||||
/// 流任务
|
|
||||||
/// </summary>
|
|
||||||
Stream = 8,
|
|
||||||
/// <summary>
|
|
||||||
/// 其他
|
|
||||||
/// </summary>
|
|
||||||
Other = 999
|
|
||||||
}
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 任务添加状态
|
/// 任务添加状态
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public enum TaskAddState {
|
public enum TaskAddState
|
||||||
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 成功
|
/// 成功
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -114,28 +71,4 @@
|
||||||
/// </summary>
|
/// </summary>
|
||||||
ErrKeywordForbidden = 15,
|
ErrKeywordForbidden = 15,
|
||||||
}
|
}
|
||||||
public class DownloadFileInfo {
|
}
|
||||||
/// <summary>
|
|
||||||
/// 文件名
|
|
||||||
/// </summary>
|
|
||||||
public string FileName { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 文件大小
|
|
||||||
/// </summary>
|
|
||||||
public long Size { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 任务负载信息
|
|
||||||
/// </summary>
|
|
||||||
public class ServerTaskLoadInfo {
|
|
||||||
/// <summary>
|
|
||||||
/// 正在运行的任务数
|
|
||||||
/// </summary>
|
|
||||||
public int Running { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 正在队列中的任务数
|
|
||||||
/// </summary>
|
|
||||||
public int Queuing { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -2,7 +2,7 @@
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
namespace iFileProxy.Models
|
namespace iFileProxy.Models.Task
|
||||||
{
|
{
|
||||||
public class TaskInfo
|
public class TaskInfo
|
||||||
{
|
{
|
||||||
|
@ -106,93 +106,4 @@ namespace iFileProxy.Models
|
||||||
public static string iFileProxy = "iFileProxy_Db";
|
public static string iFileProxy = "iFileProxy_Db";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 数据库连接池信息
|
|
||||||
/// </summary>
|
|
||||||
public class ConnectionPoolInfo
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 当前总连接数
|
|
||||||
/// </summary>
|
|
||||||
public long TotalConnections { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 活跃连接数
|
|
||||||
/// </summary>
|
|
||||||
public long ActiveConnections { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 空闲连接数
|
|
||||||
/// </summary>
|
|
||||||
public long SleepingConnections { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 连接池最大连接数
|
|
||||||
/// </summary>
|
|
||||||
public uint MaxPoolSize { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 连接详情列表
|
|
||||||
/// </summary>
|
|
||||||
public List<ProcessListInfo> Connections { get; set; } = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// MySQL 进程列表信息
|
|
||||||
/// </summary>
|
|
||||||
public class ProcessListInfo
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 连接ID
|
|
||||||
/// </summary>
|
|
||||||
public long Id { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 用户名
|
|
||||||
/// </summary>
|
|
||||||
public string User { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 主机信息
|
|
||||||
/// </summary>
|
|
||||||
public string Host { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 数据库名
|
|
||||||
/// </summary>
|
|
||||||
public string Db { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 命令类型
|
|
||||||
/// </summary>
|
|
||||||
public string Command { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 执行时间(秒)
|
|
||||||
/// </summary>
|
|
||||||
public long Time { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 连接状态
|
|
||||||
/// </summary>
|
|
||||||
public string State { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 执行的SQL
|
|
||||||
/// </summary>
|
|
||||||
public string Info { get; set; } = string.Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
public class DownloadHistory
|
|
||||||
{
|
|
||||||
[JsonProperty("tid")]
|
|
||||||
public string TaskId { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
[JsonProperty("time")]
|
|
||||||
public DateTime Time { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("client_ip")]
|
|
||||||
public string ClientIP { get; set; } = string.Empty;
|
|
||||||
}
|
|
||||||
}
|
}
|
49
src/Models/Task/TaskState.cs
Normal file
49
src/Models/Task/TaskState.cs
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
namespace iFileProxy.Models.Task
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 任务状态
|
||||||
|
/// </summary>
|
||||||
|
public enum TaskState
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 还未初始化
|
||||||
|
/// </summary>
|
||||||
|
NoInit = 0,
|
||||||
|
/// <summary>
|
||||||
|
/// 正在进行
|
||||||
|
/// </summary>
|
||||||
|
Running = 1,
|
||||||
|
/// <summary>
|
||||||
|
/// 任务执行时候发生错误 已经结束
|
||||||
|
/// </summary>
|
||||||
|
Error = 2,
|
||||||
|
/// <summary>
|
||||||
|
/// 任务正常结束
|
||||||
|
/// </summary>
|
||||||
|
End = 3,
|
||||||
|
/// <summary>
|
||||||
|
/// 要下载的内容已经缓存
|
||||||
|
/// </summary>
|
||||||
|
Cached = 4,
|
||||||
|
/// <summary>
|
||||||
|
/// 内容过期已被清理
|
||||||
|
/// </summary>
|
||||||
|
Cleaned = 5,
|
||||||
|
/// <summary>
|
||||||
|
/// 正在排队
|
||||||
|
/// </summary>
|
||||||
|
Queuing = 6,
|
||||||
|
/// <summary>
|
||||||
|
/// 任务因为各种原因被取消
|
||||||
|
/// </summary>
|
||||||
|
Canceled = 7,
|
||||||
|
/// <summary>
|
||||||
|
/// 流任务
|
||||||
|
/// </summary>
|
||||||
|
Stream = 8,
|
||||||
|
/// <summary>
|
||||||
|
/// 其他
|
||||||
|
/// </summary>
|
||||||
|
Other = 999
|
||||||
|
}
|
||||||
|
}
|
|
@ -22,12 +22,12 @@ namespace iFileProxy
|
||||||
|
|
||||||
Serilog.ILogger logger = Log.Logger.ForContext<Program>();
|
Serilog.ILogger logger = Log.Logger.ForContext<Program>();
|
||||||
|
|
||||||
CommandLineArgsHelper argsHelper = new(args);
|
CommandLineArgsHelper cmdlineArgsHelper = new(args);
|
||||||
|
|
||||||
// 解析命令行参数
|
// 解析命令行参数
|
||||||
CommandLineArgumentDispatcher.Parse(args);
|
CommandLineArgumentDispatcher.Parse(args);
|
||||||
|
|
||||||
if (argsHelper.GetBooleanValue("--version") || argsHelper.GetBooleanValue("-v"))
|
if (cmdlineArgsHelper.GetBooleanValue("--version") || cmdlineArgsHelper.GetBooleanValue("-v"))
|
||||||
{
|
{
|
||||||
var buildTime = MasterHelper.GetBuildTime(Assembly.GetEntryAssembly());
|
var buildTime = MasterHelper.GetBuildTime(Assembly.GetEntryAssembly());
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
@ -43,6 +43,15 @@ namespace iFileProxy
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder();
|
var builder = WebApplication.CreateBuilder();
|
||||||
|
|
||||||
|
string[] allowDomains = [];
|
||||||
|
string? arg = cmdlineArgsHelper.GetStringValue("--cors-allowed-domains|-A");
|
||||||
|
|
||||||
|
if (arg != null)
|
||||||
|
{
|
||||||
|
allowDomains =arg.Split(";", StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
|
||||||
|
logger.Information($"当前正使用自定义Cors策略, Allowed: {string.Join(',',allowDomains)}");
|
||||||
|
}
|
||||||
|
|
||||||
// CORS配置
|
// CORS配置
|
||||||
builder.Services.AddCors(options =>
|
builder.Services.AddCors(options =>
|
||||||
{
|
{
|
||||||
|
@ -50,7 +59,7 @@ namespace iFileProxy
|
||||||
builder =>
|
builder =>
|
||||||
{
|
{
|
||||||
builder
|
builder
|
||||||
.WithOrigins("http://localhost:3000", "http://admin.gitdl.cn", "https://admin.gitdl.cn", "https://github.linxi.info", "http://github.linxi.info/", "http://localhost:4173")
|
.WithOrigins(allowDomains)
|
||||||
.AllowAnyMethod()
|
.AllowAnyMethod()
|
||||||
.AllowAnyHeader()
|
.AllowAnyHeader()
|
||||||
.AllowCredentials();
|
.AllowCredentials();
|
||||||
|
@ -69,7 +78,7 @@ namespace iFileProxy
|
||||||
builder.Services.AddSingleton<AppConfigService>();
|
builder.Services.AddSingleton<AppConfigService>();
|
||||||
builder.Services.AddSingleton(AppConfig.GetCurrConfig());
|
builder.Services.AddSingleton(AppConfig.GetCurrConfig());
|
||||||
builder.Services.AddSingleton<DatabaseGateService>();
|
builder.Services.AddSingleton<DatabaseGateService>();
|
||||||
builder.Services.AddSingleton<TaskManager>();
|
builder.Services.AddSingleton<TaskManagementService>();
|
||||||
builder.Services.AddSingleton<Dictionary<string, Dictionary<string, uint>>>();
|
builder.Services.AddSingleton<Dictionary<string, Dictionary<string, uint>>>();
|
||||||
|
|
||||||
// 添加验证服务
|
// 添加验证服务
|
||||||
|
@ -95,13 +104,13 @@ namespace iFileProxy
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
// 初始化缓存管理服务
|
// 初始化缓存管理服务
|
||||||
LocalCacheManager localCacheManager = new(app.Services);
|
LocalCacheLifeManagementService localCacheManager = new(app.Services);
|
||||||
|
|
||||||
// 开启配置热重载
|
// 开启配置热重载
|
||||||
app.Services.GetRequiredService<AppConfigService>().EnableHotReload();
|
app.Services.GetRequiredService<AppConfigService>().EnableHotReload();
|
||||||
|
|
||||||
|
|
||||||
if (!argsHelper.GetBooleanValue("--disable-startup-check|-D"))
|
if (!cmdlineArgsHelper.GetBooleanValue("--disable-startup-check|-D"))
|
||||||
// 初始化验证配置文件
|
// 初始化验证配置文件
|
||||||
AppConfig.CheckAppConfig(app.Services);
|
AppConfig.CheckAppConfig(app.Services);
|
||||||
|
|
||||||
|
@ -154,13 +163,13 @@ namespace iFileProxy
|
||||||
var dbGateService = app.Services.GetRequiredService<DatabaseGateService>();
|
var dbGateService = app.Services.GetRequiredService<DatabaseGateService>();
|
||||||
SerilogConfig.CreateLogger(dbGateService, args);
|
SerilogConfig.CreateLogger(dbGateService, args);
|
||||||
|
|
||||||
if (!argsHelper.GetStringValue("--bind-url|-B").IsNullOrEmpty())
|
if (!cmdlineArgsHelper.GetStringValue("--bind-url|-B").IsNullOrEmpty())
|
||||||
app.Run(argsHelper.GetStringValue("--bind-url|-B"));
|
app.Run(cmdlineArgsHelper.GetStringValue("--bind-url|-B"));
|
||||||
else
|
else
|
||||||
app.Run();
|
app.Run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region 全局异常处理
|
||||||
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
|
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
|
||||||
{
|
{
|
||||||
var logger = Log.ForContext<AppDomain>();
|
var logger = Log.ForContext<AppDomain>();
|
||||||
|
@ -192,5 +201,6 @@ namespace iFileProxy
|
||||||
// 优雅退出应用程序
|
// 优雅退出应用程序
|
||||||
Environment.Exit(1);
|
Environment.Exit(1);
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||||
<_TargetId>Folder</_TargetId>
|
<_TargetId>Folder</_TargetId>
|
||||||
<SiteUrlToLaunchAfterPublish />
|
<SiteUrlToLaunchAfterPublish />
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
|
||||||
<ProjectGuid>e343bd8a-27ed-47e2-b50d-e3000730e65e</ProjectGuid>
|
<ProjectGuid>e343bd8a-27ed-47e2-b50d-e3000730e65e</ProjectGuid>
|
||||||
<SelfContained>false</SelfContained>
|
<SelfContained>false</SelfContained>
|
||||||
<PublishSingleFile>true</PublishSingleFile>
|
<PublishSingleFile>true</PublishSingleFile>
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
using iFileProxy.Sinks;
|
using iFileProxy.Sinks;
|
||||||
using iFileProxy.Services;
|
using iFileProxy.Services;
|
||||||
using iFileProxy.Helpers;
|
using iFileProxy.Helpers;
|
||||||
using Microsoft.IdentityModel.Tokens;
|
|
||||||
|
|
||||||
public static class SerilogConfig
|
public static class SerilogConfig
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,8 +28,10 @@ namespace iFileProxy.Services
|
||||||
|
|
||||||
public AppConfigService(string configFilePath = "iFileProxy.json")
|
public AppConfigService(string configFilePath = "iFileProxy.json")
|
||||||
{
|
{
|
||||||
|
_logger.Debug($"initializing {this.GetType().Name}...");
|
||||||
_appConfigPath = configFilePath;
|
_appConfigPath = configFilePath;
|
||||||
LoadAppConfig();
|
LoadAppConfig();
|
||||||
|
_logger.Debug($"{this.GetType().Name} init successful.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
using BCrypt.Net;
|
|
||||||
using iFileProxy.Models;
|
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
using System.IdentityModel.Tokens.Jwt;
|
using System.IdentityModel.Tokens.Jwt;
|
||||||
using Microsoft.IdentityModel.Tokens;
|
using Microsoft.IdentityModel.Tokens;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using Serilog;
|
||||||
|
using iFileProxy.Models.Other;
|
||||||
|
using iFileProxy.Models.Request;
|
||||||
|
|
||||||
|
|
||||||
namespace iFileProxy.Services
|
namespace iFileProxy.Services
|
||||||
{
|
{
|
||||||
|
@ -11,13 +13,15 @@ namespace iFileProxy.Services
|
||||||
{
|
{
|
||||||
private readonly DatabaseGateService _dbGateService;
|
private readonly DatabaseGateService _dbGateService;
|
||||||
private readonly IConfiguration _configuration;
|
private readonly IConfiguration _configuration;
|
||||||
private readonly ILogger<AuthService> _logger;
|
private readonly Serilog.ILogger _logger = Log.Logger.ForContext<AuthService>();
|
||||||
|
|
||||||
public AuthService(DatabaseGateService dbGateService, IConfiguration configuration, ILogger<AuthService> logger)
|
|
||||||
|
public AuthService(DatabaseGateService dbGateService, IConfiguration configuration)
|
||||||
{
|
{
|
||||||
|
_logger.Debug($"{GetType().Name} initializing...");
|
||||||
_dbGateService = dbGateService;
|
_dbGateService = dbGateService;
|
||||||
_configuration = configuration;
|
_configuration = configuration;
|
||||||
_logger = logger;
|
_logger.Debug($"{this.GetType().Name} init successful.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<(bool success, string message)> RegisterAsync(RegisterRequest request, string ipAddr)
|
public async Task<(bool success, string message)> RegisterAsync(RegisterRequest request, string ipAddr)
|
||||||
|
@ -62,7 +66,7 @@ namespace iFileProxy.Services
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "用户注册失败");
|
_logger.Warning(ex, "用户注册失败");
|
||||||
return (false, "注册失败");
|
return (false, "注册失败");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,7 +118,7 @@ namespace iFileProxy.Services
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "用户登录失败");
|
_logger.Warning(ex, "用户登录失败");
|
||||||
return (false, string.Empty, "登录失败");
|
return (false, string.Empty, "登录失败");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,10 +3,13 @@ using Serilog;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using iFileProxy.Helpers;
|
using iFileProxy.Helpers;
|
||||||
using MySql.Data.MySqlClient;
|
using MySql.Data.MySqlClient;
|
||||||
using iFileProxy.Models;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Serilog.Events;
|
using Serilog.Events;
|
||||||
|
using iFileProxy.Models.Task;
|
||||||
|
using iFileProxy.Models.Other;
|
||||||
|
using iFileProxy.Models.Response;
|
||||||
|
|
||||||
|
|
||||||
namespace iFileProxy.Services
|
namespace iFileProxy.Services
|
||||||
{
|
{
|
||||||
|
@ -28,13 +31,13 @@ namespace iFileProxy.Services
|
||||||
|
|
||||||
public DatabaseGateService(AppConfigService appConfigService)
|
public DatabaseGateService(AppConfigService appConfigService)
|
||||||
{
|
{
|
||||||
_logger.Information("Initializing DatabaseGateService...");
|
_logger.Debug($"Initializing {this.GetType().Name}...");
|
||||||
_appConfig = appConfigService.AppConfig;
|
_appConfig = appConfigService.AppConfig;
|
||||||
_db = _appConfig.Database;
|
_db = _appConfig.Database;
|
||||||
appConfigService.AppConfigurationChanged += AppConfigService_AppConfigurationChanged;
|
appConfigService.AppConfigurationChanged += AppConfigService_AppConfigurationChanged;
|
||||||
|
|
||||||
LoadDbDict();
|
LoadDbDict();
|
||||||
_logger.Information("Done.");
|
_logger.Debug($"{this.GetType().Name} init successful.");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,18 +5,19 @@ using Newtonsoft.Json;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
using MySql.Data.MySqlClient;
|
using MySql.Data.MySqlClient;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
|
using iFileProxy.Models.Task;
|
||||||
|
|
||||||
namespace iFileProxy.Services
|
namespace iFileProxy.Services
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 本地缓存管理器
|
/// 本地缓存管理器
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class LocalCacheManager
|
public class LocalCacheLifeManagementService
|
||||||
{
|
{
|
||||||
// 禁用空警告 因为初始化的时候就已经检查过相关的内容了
|
// 禁用空警告 因为初始化的时候就已经检查过相关的内容了
|
||||||
#pragma warning disable CS8601
|
#pragma warning disable CS8601
|
||||||
private readonly AppConfig _appConfig = AppConfig.GetCurrConfig();
|
private readonly AppConfig _appConfig = AppConfig.GetCurrConfig();
|
||||||
private readonly static Serilog.ILogger _logger = Log.Logger.ForContext<LocalCacheManager>();
|
private readonly static Serilog.ILogger _logger = Log.Logger.ForContext<LocalCacheLifeManagementService>();
|
||||||
|
|
||||||
private readonly object _lock = new ();
|
private readonly object _lock = new ();
|
||||||
private readonly Timer _timer;
|
private readonly Timer _timer;
|
||||||
|
@ -26,9 +27,9 @@ namespace iFileProxy.Services
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 缓存管理器
|
/// 缓存管理器
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public LocalCacheManager(IServiceProvider serviceProvider)
|
public LocalCacheLifeManagementService(IServiceProvider serviceProvider)
|
||||||
{
|
{
|
||||||
_logger.Information("Initializing LocalCacheManager.");
|
_logger.Debug($"Initializing {this.GetType().Name}...");
|
||||||
CACHE_LIFETIME = _appConfig.DownloadOptions.CacheLifetime;
|
CACHE_LIFETIME = _appConfig.DownloadOptions.CacheLifetime;
|
||||||
_dbGateService = serviceProvider.GetRequiredService<DatabaseGateService>();
|
_dbGateService = serviceProvider.GetRequiredService<DatabaseGateService>();
|
||||||
|
|
||||||
|
@ -42,7 +43,7 @@ namespace iFileProxy.Services
|
||||||
CheckAndCleanCache();
|
CheckAndCleanCache();
|
||||||
}
|
}
|
||||||
}, null, TimeSpan.FromSeconds(6), TimeSpan.FromSeconds(60));
|
}, null, TimeSpan.FromSeconds(6), TimeSpan.FromSeconds(60));
|
||||||
_logger.Information("succ.");
|
_logger.Debug($"{this.GetType().Name} init successful.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LocalCacheManager_AppConfigurationChange(object sender, AppConfig appConfig)
|
private void LocalCacheManager_AppConfigurationChange(object sender, AppConfig appConfig)
|
|
@ -1,6 +1,7 @@
|
||||||
using iFileProxy.Config;
|
using iFileProxy.Config;
|
||||||
using iFileProxy.Helpers;
|
using iFileProxy.Helpers;
|
||||||
using iFileProxy.Models;
|
using iFileProxy.Models.Other;
|
||||||
|
using iFileProxy.Models.Task;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
@ -10,7 +11,7 @@ namespace iFileProxy.Services
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 下载任务管理器
|
/// 下载任务管理器
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class TaskManager
|
public class TaskManagementService
|
||||||
{
|
{
|
||||||
// 定义事件
|
// 定义事件
|
||||||
public event EventHandler<TaskInfo>? TaskCompleted;
|
public event EventHandler<TaskInfo>? TaskCompleted;
|
||||||
|
@ -60,16 +61,16 @@ namespace iFileProxy.Services
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private readonly static Serilog.ILogger _logger = Log.Logger.ForContext<TaskManager>();
|
private readonly static Serilog.ILogger _logger = Log.Logger.ForContext<TaskManagementService>();
|
||||||
private AppConfig _appConfig = AppConfig.GetCurrConfig("iFileProxy.json");
|
private AppConfig _appConfig = AppConfig.GetCurrConfig("iFileProxy.json");
|
||||||
private readonly DatabaseGateService _dbGateService;
|
private readonly DatabaseGateService _dbGateService;
|
||||||
private Dictionary<string, TaskInfo> _runningTasks = [];
|
private Dictionary<string, TaskInfo> _runningTasks = [];
|
||||||
private Queue<TaskInfo> _pendingTasks = new();
|
private Queue<TaskInfo> _pendingTasks = new();
|
||||||
private readonly object _taskLock = new();
|
private readonly object _taskLock = new();
|
||||||
|
|
||||||
public TaskManager(DatabaseGateService dbGateService, AppConfigService appConfigService)
|
public TaskManagementService(DatabaseGateService dbGateService, AppConfigService appConfigService)
|
||||||
{
|
{
|
||||||
_logger.Information("Initializing TaskManager...");
|
_logger.Debug($"Initializing {this.GetType().Name}...");
|
||||||
if (_appConfig != null)
|
if (_appConfig != null)
|
||||||
{
|
{
|
||||||
_dbGateService = dbGateService;
|
_dbGateService = dbGateService;
|
||||||
|
@ -88,7 +89,7 @@ namespace iFileProxy.Services
|
||||||
appConfigService.AppConfigurationChanged += AppConfigService_AppConfigurationChanged;
|
appConfigService.AppConfigurationChanged += AppConfigService_AppConfigurationChanged;
|
||||||
|
|
||||||
|
|
||||||
_logger.Information("TaskManager init succ.");
|
_logger.Debug($"{this.GetType().Name} init successful.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AppConfigService_AppConfigurationChanged(object sender, AppConfig appConfig)
|
private void AppConfigService_AppConfigurationChanged(object sender, AppConfig appConfig)
|
Loading…
Reference in a new issue