XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFEExtension.NetCore.ServerInteractive

[DLL] Server interaction extension, including user identity verification and querying in conjunction with AutoConfig

公开
关注 0 Fork 0 Star 0
返回提交历史

XFEstudio/XFEExtension.NetCore.ServerInteractive

优化结构框架

9e9a2a0
XFE工作室室长 <mail@xfegzs.com>
提交于

代码差异

11 个文件 +42 -48
Modified XFEExtension.NetCore.ServerInteractive.TServer/Profiles/UserProfile.cs +1 -1
@@ -1,7 +1,7 @@
1 1 using XFEExtension.NetCore.AutoConfig;
2 2 using XFEExtension.NetCore.ServerInteractive.Models.UserModels;
3 3
4 namespace XFEExtension.NetCore.ServerInteractive.TServer;
4 namespace XFEExtension.NetCore.ServerInteractive.TServer.Profiles;
5 5
6 6 public partial class UserProfile : XFEProfile
7 7 {
Modified XFEExtension.NetCore.ServerInteractive.TServer/Program.cs +1 -0
@@ -7,6 +7,7 @@ using XFEExtension.NetCore.ServerInteractive.TServer.Services;
7 7 using XFEExtension.NetCore.ServerInteractive.Utilities.DataTable;
8 8 using XFEExtension.NetCore.ServerInteractive.Utilities.Extensions;
9 9 using XFEExtension.NetCore.ServerInteractive.Utilities.Server;
10 using UserProfile = XFEExtension.NetCore.ServerInteractive.TServer.Profiles.UserProfile;
10 11
11 12 var server = XFEServerBuilder.CreateBuilder() // 创建服务器构建器
12 13 .UseXFEServer() // 使用XFE服务器架构
Modified XFEExtension.NetCore.ServerInteractive/Implements/CoreService/XFEServerCoreServiceBase.cs +1 -1
@@ -46,7 +46,7 @@ public abstract class XFEServerCoreServiceBase : IXFEStandardServerCoreServiceBa
46 46 public async Task Close(Stream stream) => await ReturnArgs.Close(stream);
47 47
48 48 /// <inheritdoc/>
49 public void OK() => ReturnArgs?.OK();
49 public void OK() => ReturnArgs.OK();
50 50
51 51 /// <inheritdoc/>
52 52 public async Task CloseWithError(string message, HttpStatusCode code) => await ReturnArgs.CloseWithError(message, code);
Modified XFEExtension.NetCore.ServerInteractive/Interfaces/CoreService/IXFEStandardServerCoreServiceBase.cs +0 -1
@@ -1,5 +1,4 @@
1 1 using System.Net;
2 using XFEExtension.NetCore.CyberComm;
3 2 using XFEExtension.NetCore.ServerInteractive.Models.ServerModels;
4 3 using XFEExtension.NetCore.XFETransform.JsonConverter;
5 4
Modified XFEExtension.NetCore.ServerInteractive/Models/UserFaceInfo.cs +1 -1
@@ -7,7 +7,7 @@ namespace XFEExtension.NetCore.ServerInteractive.Models;
7 7 /// </summary>
8 8 public class UserFaceInfo : IUserFaceInfo
9 9 {
10 /// <inheritdoc/>
10 /// <inheritdoc cref="IUserFaceInfo" />
11 11 public string Id { get; set; } = string.Empty;
12 12 /// <inheritdoc/>
13 13 public string NickName { get; set; } = string.Empty;
Modified XFEExtension.NetCore.ServerInteractive/Profiles/ServerBaseProfile.cs +0 -7
@@ -17,11 +17,4 @@ public partial class ServerBaseProfile : XFEProfile
17 17 [ProfilePropertyAddGet("Current._bannedIPAddressList.CurrentProfile = Current")]
18 18 [ProfilePropertyAddGet("return Current._bannedIPAddressList")]
19 19 private ProfileList<IPAddressInfo> _bannedIPAddressList = [];
20 /// <summary>
21 /// 服务器上次绑定的IP地址字典
22 /// </summary>
23 [ProfileProperty]
24 [ProfilePropertyAddGet("Current._serverLastBindingAddressDictionary.CurrentProfile = Current")]
25 [ProfilePropertyAddGet("return Current._serverLastBindingAddressDictionary")]
26 private ProfileDictionary<string, string> _serverLastBindingAddressDictionary = [];
27 20 }
Modified XFEExtension.NetCore.ServerInteractive/Utilities/Helpers/InteractiveHelper.cs +3 -2
@@ -9,6 +9,8 @@ namespace XFEExtension.NetCore.ServerInteractive.Utilities.Helpers;
9 9 /// </summary>
10 10 public static class InteractiveHelper
11 11 {
12 private static readonly HttpClient s_client = new();
13
12 14 /// <summary>
13 15 /// 获取响应
14 16 /// </summary>
@@ -17,8 +19,7 @@ public static class InteractiveHelper
17 19 /// <returns></returns>
18 20 public static async Task<(string, HttpStatusCode)> GetServerResponse(string requestAddress, string postBody)
19 21 {
20 using var client = new HttpClient();
21 var result = await client.PostAsync(requestAddress, new StringContent(postBody));
22 var result = await s_client.PostAsync(requestAddress, new StringContent(postBody));
22 23 try
23 24 {
24 25 return (await result.Content.ReadAsStringAsync(), result.StatusCode);
Modified XFEExtension.NetCore.ServerInteractive/Utilities/Server/Services/CoreService/ServerCoreUserServiceBase.cs +2 -2
@@ -6,7 +6,7 @@ using XFEExtension.NetCore.ServerInteractive.Utilities.JsonConverter;
6 6
7 7 namespace XFEExtension.NetCore.ServerInteractive.Utilities.Server.Services.CoreService;
8 8
9 /// <inheritdoc/>
9 /// <inheritdoc cref="ServerCoreStandardServiceBase" />
10 10 public abstract class ServerCoreUserServiceBase : ServerCoreStandardServiceBase, IUserServiceBase
11 11 {
12 12 /// <inheritdoc/>
@@ -25,5 +25,5 @@ public abstract class ServerCoreUserServiceBase : ServerCoreStandardServiceBase,
25 25 public Action<EncryptedUserLoginModel> RemoveEncryptedUserLoginModelFunction { get; set; } = _ => { };
26 26
27 27 /// <inheritdoc/>
28 public ServerCoreUserServiceBase() => JsonSerializerOptions.Converters.Add(new JsonDateTimeConverter());
28 protected ServerCoreUserServiceBase() => JsonSerializerOptions.Converters.Add(new JsonDateTimeConverter());
29 29 }
Modified XFEExtension.NetCore.ServerInteractive/Utilities/Server/Services/CoreService/UserServiceBase.cs +2 -2
@@ -23,6 +23,6 @@ public abstract class UserServiceBase : IUserServiceBase
23 23 /// <inheritdoc/>
24 24 public JsonSerializerOptions JsonSerializerOptions { get; set; } = new();
25 25
26 /// <inheritdoc/>
27 public UserServiceBase() => JsonSerializerOptions.Converters.Add(new JsonDateTimeConverter());
26 /// <inheritdoc cref="IUserServiceBase" />
27 protected UserServiceBase() => JsonSerializerOptions.Converters.Add(new JsonDateTimeConverter());
28 28 }
Modified XFEExtension.NetCore.ServerInteractive/Utilities/Server/Services/ServerService/ServerIpInitializer.cs +29 -29
@@ -1,6 +1,4 @@
1 1 using XFEExtension.NetCore.ServerInteractive.Implements.ServerService;
2 using XFEExtension.NetCore.ServerInteractive.Profiles;
3 using XFEExtension.NetCore.StringExtension;
4 2
5 3 namespace XFEExtension.NetCore.ServerInteractive.Utilities.Server.Services.ServerService;
6 4
@@ -10,32 +8,34 @@ namespace XFEExtension.NetCore.ServerInteractive.Utilities.Server.Services.Serve
10 8 [Obsolete("核心服务器现已不再使用单一IP,故IP初始化器不再提供", DiagnosticId = "XFW0002", UrlFormat = "https://docs.xfegzs.com/View/Errors%2FServerInteractive%2FXFW0002")]
11 9 public class ServerIPInitializer : ServerInitializerServiceBase
12 10 {
13 private static int s_nextDefaultPort = 3300;
14 11 /// <inheritdoc/>
15 public override void Initialize()
16 {
17 ServerBaseProfile.SaveProfile();
18 foreach (var serverCoreService in XFEServer.ServerCoreProcessService.ServerCoreServiceList)
19 {
20 ServerBaseProfile.ServerLastBindingAddressDictionary.TryAdd(serverCoreService.ServerCoreName, $"http://localhost:{s_nextDefaultPort++}/");
21 if (!ServerBaseProfile.ServerLastBindingAddressDictionary.TryGetValue(serverCoreService.ServerCoreName, out var ipAddress)) continue;
22 Console.WriteLine($"正在设置服务器:{serverCoreService.ServerCoreName}");
23 Console.WriteLine($"是否绑定IP:{ipAddress}?(Y/N)");
24 var key = Console.ReadKey();
25 Console.WriteLine(key.Key.ToString());
26 if (key.Key == ConsoleKey.N)
27 {
28 ipAddress = string.Empty;
29 while (ipAddress.IsNullOrWhiteSpace())
30 {
31 XFEConsole.XFEConsole.CurrentConsoleTextWriter?.OriginalTextWriter.Write("请输入绑定的IP:");
32 ipAddress = Console.ReadLine();
33 }
34 ServerBaseProfile.ServerLastBindingAddressDictionary[serverCoreService.ServerCoreName] = ipAddress;
35 }
36 serverCoreService.BindingIPAddressList = [];
37 Console.WriteLine($"服务器{serverCoreService.ServerCoreName}设置完成!IP为:{ipAddress}");
38 }
39 ServerBaseProfile.SaveProfile();
40 }
12 public override void Initialize() { }
13 //private static int s_nextDefaultPort = 3300;
14 ///// <inheritdoc/>
15 //public override void Initialize()
16 //{
17 // ServerBaseProfile.SaveProfile();
18 // foreach (var serverCoreService in XFEServer.ServerCoreProcessService.ServerCoreServiceList)
19 // {
20 // ServerBaseProfile.ServerLastBindingAddressDictionary.TryAdd(serverCoreService.ServerCoreName, $"http://localhost:{s_nextDefaultPort++}/");
21 // if (!ServerBaseProfile.ServerLastBindingAddressDictionary.TryGetValue(serverCoreService.ServerCoreName, out var ipAddress)) continue;
22 // Console.WriteLine($"正在设置服务器:{serverCoreService.ServerCoreName}");
23 // Console.WriteLine($"是否绑定IP:{ipAddress}?(Y/N)");
24 // var key = Console.ReadKey();
25 // Console.WriteLine(key.Key.ToString());
26 // if (key.Key == ConsoleKey.N)
27 // {
28 // ipAddress = string.Empty;
29 // while (ipAddress.IsNullOrWhiteSpace())
30 // {
31 // XFEConsole.XFEConsole.CurrentConsoleTextWriter?.OriginalTextWriter.Write("请输入绑定的IP:");
32 // ipAddress = Console.ReadLine();
33 // }
34 // ServerBaseProfile.ServerLastBindingAddressDictionary[serverCoreService.ServerCoreName] = ipAddress;
35 // }
36 // serverCoreService.BindingIPAddressList = [];
37 // Console.WriteLine($"服务器{serverCoreService.ServerCoreName}设置完成!IP为:{ipAddress}");
38 // }
39 // ServerBaseProfile.SaveProfile();
40 //}
41 41 }
Modified XFEExtension.NetCore.ServerInteractive/XFEExtension.NetCore.ServerInteractive.csproj +2 -2
@@ -5,7 +5,7 @@
5 5 <ImplicitUsings>enable</ImplicitUsings>
6 6 <Nullable>enable</Nullable>
7 7 <GenerateDocumentationFile>True</GenerateDocumentationFile>
8 <Version>2.5.0</Version>
8 <Version>2.5.1</Version>
9 9 <Title>XFEExtension.NetCore.ServerInteractive</Title>
10 10 <RepositoryUrl>https://github.com/XFEstudio/XFEExtension.NetCore.ServerInteractive</RepositoryUrl>
11 11 <AnalysisLevel>latest</AnalysisLevel>
@@ -21,7 +21,7 @@
21 21 <PackageReleaseNotes>
22 22 ## 调整
23 23
24 将绑定IP地址改为多IP绑定
24 优化结构框架
25 25
26 26 ## 新增
27 27