From 5e8f90b2e9e311b4ba48507cca55fc89a2cd368c Mon Sep 17 00:00:00 2001 From: rfi Date: Mon, 19 Feb 2024 11:31:35 +0700 Subject: [PATCH] incomplete sdk server + inferred server address --- BLHX.Server.Common/Utils/Config.cs | 2 +- BLHX.Server.Game/Connection.cs | 1 - BLHX.Server.SDK/BLHX.Server.SDK.csproj | 15 +++++ .../Controllers/AccountController.cs | 12 ++++ .../Controllers/ConfigController.cs | 22 +++++++ .../Properties/launchSettings.json | 41 ++++++++++++ BLHX.Server.SDK/SDKServer.cs | 66 +++++++++++++++++++ BLHX.Server.SDK/appsettings.Development.json | 8 +++ BLHX.Server.SDK/appsettings.json | 9 +++ BLHX.Server.sln | 12 +++- BLHX.Server/BLHX.Server.csproj | 1 + BLHX.Server/Program.cs | 10 ++- 12 files changed, 193 insertions(+), 6 deletions(-) create mode 100644 BLHX.Server.SDK/BLHX.Server.SDK.csproj create mode 100644 BLHX.Server.SDK/Controllers/AccountController.cs create mode 100644 BLHX.Server.SDK/Controllers/ConfigController.cs create mode 100644 BLHX.Server.SDK/Properties/launchSettings.json create mode 100644 BLHX.Server.SDK/SDKServer.cs create mode 100644 BLHX.Server.SDK/appsettings.Development.json create mode 100644 BLHX.Server.SDK/appsettings.json diff --git a/BLHX.Server.Common/Utils/Config.cs b/BLHX.Server.Common/Utils/Config.cs index 7098fe3..5f9bde1 100644 --- a/BLHX.Server.Common/Utils/Config.cs +++ b/BLHX.Server.Common/Utils/Config.cs @@ -2,7 +2,7 @@ public class Config : Singleton { - public string Address { get; set; } = "192.168.1.4"; + public string Address { get; set; } = "127.0.0.1"; public uint Port { get; set; } = 20000; public static void Load() diff --git a/BLHX.Server.Game/Connection.cs b/BLHX.Server.Game/Connection.cs index 631ae33..8f878d0 100644 --- a/BLHX.Server.Game/Connection.cs +++ b/BLHX.Server.Game/Connection.cs @@ -18,7 +18,6 @@ namespace BLHX.Server.Game readonly CancellationTokenSource cts = new(); readonly Task loopTask; ushort packetIdx = 0; - public static JsonSerializerOptions jsonSerializerOptions = new() { IncludeFields = true }; private ushort NextPacketIdx => packetIdx++; public IPEndPoint EndPoint => (IPEndPoint)tcpClient.Client.RemoteEndPoint!; diff --git a/BLHX.Server.SDK/BLHX.Server.SDK.csproj b/BLHX.Server.SDK/BLHX.Server.SDK.csproj new file mode 100644 index 0000000..c4a121b --- /dev/null +++ b/BLHX.Server.SDK/BLHX.Server.SDK.csproj @@ -0,0 +1,15 @@ + + + + net8.0 + enable + enable + Library + true + + + + + + + diff --git a/BLHX.Server.SDK/Controllers/AccountController.cs b/BLHX.Server.SDK/Controllers/AccountController.cs new file mode 100644 index 0000000..05b9a55 --- /dev/null +++ b/BLHX.Server.SDK/Controllers/AccountController.cs @@ -0,0 +1,12 @@ +using BLHX.Server.Sdk; + +namespace BLHX.Server.SDK.Controllers +{ + public class AccountController : IRegisterable + { + public static void Register(WebApplication app) + { + + } + } +} diff --git a/BLHX.Server.SDK/Controllers/ConfigController.cs b/BLHX.Server.SDK/Controllers/ConfigController.cs new file mode 100644 index 0000000..f1c36f8 --- /dev/null +++ b/BLHX.Server.SDK/Controllers/ConfigController.cs @@ -0,0 +1,22 @@ +using BLHX.Server.Sdk; + +namespace BLHX.Server.SDK.Controllers +{ + public class ConfigController : IRegisterable + { + public static void Register(WebApplication app) + { + app.MapPost("app/getCode", (HttpContext ctx) => + { + ctx.Response.ContentType = "application/json"; + ctx.Response.WriteAsync(@"{""result"":0,""data"":[{""codestr"":""-1"",""codemessage"":""Unknown Error""},{""codestr"":""0"",""codemessage"":""Success""},{""codestr"":""100100"",""codemessage"":""Device ID is banned""},{""codestr"":""100110"",""codemessage"":""Verification failed""},{""codestr"":""100111"",""codemessage"":""Account creation failed""},{""codestr"":""100112"",""codemessage"":""Account creation success; Account binding failed""},{""codestr"":""100113"",""codemessage"":""Account binding success; Verification failed""},{""codestr"":""100114"",""codemessage"":""IP is restricted during login creation""},{""codestr"":""100115"",""codemessage"":""Device ID is banned during login creation""},{""codestr"":""100116"",""codemessage"":""UID is banned during login creation""},{""codestr"":""100117"",""codemessage"":""Missing parameters""},{""codestr"":""100120"",""codemessage"":""Login failed, IP is restricted""},{""codestr"":""100130"",""codemessage"":""Login failed, UID is banned""},{""codestr"":""100140"",""codemessage"":""Access Token verification failed""},{""codestr"":""100150"",""codemessage"":""UID does not match with Transcode""},{""codestr"":""100160"",""codemessage"":""User birthday has already been added""},{""codestr"":""100170"",""codemessage"":""Invalid birthday format""},{""codestr"":""100180"",""codemessage"":""The third party account is not bound with any game account""},{""codestr"":""100190"",""codemessage"":""Failed to verify the third party parameter""},{""codestr"":""100200"",""codemessage"":""The third party account is already bound with another UID""},{""codestr"":""100210"",""codemessage"":""The third party account does not match with the one bound to this account""},{""codestr"":""100211"",""codemessage"":""Platform binding error""},{""codestr"":""100212"",""codemessage"":""Platform unbinding error""},{""codestr"":""100213"",""codemessage"":""Unable to unbind the account""},{""codestr"":""100220"",""codemessage"":""Authorization canceled""},{""codestr"":""100221"",""codemessage"":""Authorization failed""},{""codestr"":""100222"",""codemessage"":""Authorization failed""},{""codestr"":""100223"",""codemessage"":""Authorization failed""},{""codestr"":""100224"",""codemessage"":""Unable to use Google service""},{""codestr"":""100225"",""codemessage"":""Google authorization was canceled by user""},{""codestr"":""100226"",""codemessage"":""Unable to login during another login request""},{""codestr"":""100227"",""codemessage"":""Failed to login with the current account""},{""codestr"":""100228"",""codemessage"":""The account has been deleted. Log in failed.""},{""codestr"":""100229"",""codemessage"":""Account deletion cannot be performed repeatedly""},{""codestr"":""100231"",""codemessage"":""Failed to restore, the account was deleted completely""},{""codestr"":""100232"",""codemessage"":""Unable to restore, no deletion history of the account""},{""codestr"":""100233"",""codemessage"":""The account has been in the cooling-off period for account deletion now.""},{""codestr"":""100234"",""codemessage"":""The account is not authorized to login""},{""codestr"":""100230"",""codemessage"":""Initialization failed""},{""codestr"":""100240"",""codemessage"":""Apple authorization information does not match""},{""codestr"":""100241"",""codemessage"":""User cancelled Apple authorization request""},{""codestr"":""100242"",""codemessage"":""Apple authorization request failed""},{""codestr"":""100243"",""codemessage"":""Invalid response from Apple authorization request""},{""codestr"":""100244"",""codemessage"":""Failed to process Apple authorization request""},{""codestr"":""100245"",""codemessage"":""Apple authorization request failed for unknown reason""},{""codestr"":""100246"",""codemessage"":""System version does not support Apple authorization""},{""codestr"":""100300"",""codemessage"":""Invalid email address format""},{""codestr"":""100301"",""codemessage"":""Email addresses do not match""},{""codestr"":""100302"",""codemessage"":""Verification code request is too frequent""},{""codestr"":""100303"",""codemessage"":""Verification failed""},{""codestr"":""100304"",""codemessage"":""Verification failed too many times""},{""codestr"":""100305"",""codemessage"":""The account is banned""},{""codestr"":""100306"",""codemessage"":""Verification code cannot be empty""},{""codestr"":""100404"",""codemessage"":""Network error""},{""codestr"":""200100"",""codemessage"":""User birthday is required""},{""codestr"":""200110"",""codemessage"":""Monthly purchase limit exceeded""},{""codestr"":""200120"",""codemessage"":""Order creation failed: Item is not configured in SDK management platform""},{""codestr"":""200130"",""codemessage"":""Payment method does not exist""},{""codestr"":""200140"",""codemessage"":""serverTag does not exist""},{""codestr"":""200150"",""codemessage"":""Payment receipt verification failed""},{""codestr"":""200160"",""codemessage"":""Invalid purchase request""},{""codestr"":""200170"",""codemessage"":""Purchase request failed on game server""},{""codestr"":""200180"",""codemessage"":""It takes a long time for searching the purchase result""},{""codestr"":""200190"",""codemessage"":""Order ID does not exist""},{""codestr"":""200200"",""codemessage"":""Order status tracking timed out""},{""codestr"":""200210"",""codemessage"":""productid does not exist on payment backend""},{""codestr"":""200220"",""codemessage"":""Payment backend response - payment failed""},{""codestr"":""200230"",""codemessage"":""Payment backend response - payment canceled""},{""codestr"":""200240"",""codemessage"":""Current API version does not support the request""},{""codestr"":""200250"",""codemessage"":""Invalid parameters provided to API""},{""codestr"":""200260"",""codemessage"":""Fatal error during API operation""},{""codestr"":""200270"",""codemessage"":""The request is not supported by the Play store on current device""},{""codestr"":""200280"",""codemessage"":""Item has already been purchased, not consumed yet""},{""codestr"":""200290"",""codemessage"":""Item has already been purchased, failed to consume""},{""codestr"":""200300"",""codemessage"":""Unable to purchase the requested item""},{""codestr"":""200310"",""codemessage"":""Unable to connect to Google Play service""},{""codestr"":""200320"",""codemessage"":""Request reached maximum timeout before receiving any response from Google Play""},{""codestr"":""200330"",""codemessage"":""Network connection is turned off""},{""codestr"":""200340"",""codemessage"":""Payment canceled by user""},{""codestr"":""200350"",""codemessage"":""Order creation failed: Item doesn't exist at store""},{""codestr"":""200360"",""codemessage"":""Connection to play services failed""},{""codestr"":""300100"",""codemessage"":""System sharing failed""},{""codestr"":""200390"",""codemessage"":""Payment backend response - payment failed""},{""codestr"":""100205"",""codemessage"":""Unbind failed. Your game account hasn't been linked to a Google Play Games account.""},{""codestr"":""100214"",""codemessage"":""The game account now is linked to a Google Play Games account. If you unlink it from other accounts (except the Google Play Games account), it will also unlink from the Google Play Games account automatically.""},{""codestr"":""100206"",""codemessage"":""The non-guest account has been linked to a Google Play Games account automatically. You can log on another device with the Google Play Games account.""},{""codestr"":""100201"",""codemessage"":""The Google Play Games account has been linked to another game account. Confirm to unlink it from the old game account and re-link to the current one?""},{""codestr"":""100202"",""codemessage"":""The game account has been linked to another Google Play Games account. Confirm to unlink it from the old Google Play Games account and re-link to the current one?""},{""codestr"":""100203"",""codemessage"":""The current game account and Google Play Games account have each been linked to other accounts. Confirm to unlink the both from the old accounts and re-link them together?""},{""codestr"":""100204"",""codemessage"":""The guest account can't be linked to a Google Play Games account so you can't log on another device with the guest account. If you want to link the guest account to a Google Play Games account, please link it to a Yostar account/third-party account first.""},{""codestr"":""100803"",""codemessage"":""Callback URL exceeds its maximum characters""},{""codestr"":""200232"",""codemessage"":""Apple Pay is not available on this device""},{""codestr"":""200141"",""codemessage"":""Order creation failed: Purchase currency is not supported""},{""codestr"":""100215"",""codemessage"":""Unable to bound Twitter account in current App""},{""codestr"":""100216"",""codemessage"":""Unable to switch Twitter account in current App""},{""codestr"":""100217"",""codemessage"":""Unable to register Twitter account in current App""},{""codestr"":""100218"",""codemessage"":""Unable to login with Twitter account in current App""},{""codestr"":""100600"",""codemessage"":""Interface parameter error. Invoke failed""}]}"); + }); + + app.MapPost("app/getSettings", (HttpContext ctx) => + { + ctx.Response.ContentType = "application/json"; + ctx.Response.WriteAsync(@"{""settings"":{""APP_ANDROIDKEY"":""MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAk04kub4MdcLXmqSYOJxZ4aGWNxaPCjp2J2TjKAjmrwh1I7LtSPeutbYE6Zjgx9MYG3F7MpZncCUNoZ2gaKZSqhw39ITJ+3LJdXBtr8Y4IKbTi/XoCycHawUr6a+860SznPvIZZqaTUUzDp2YDZSgAQb01ZcTyQI/U+nLggJ9bOZq2Lddosyoymdv81d0xih3nxQ6eL6qFLHz+5nMp6Uos82VYqWpB88Gb4Ri0oclCLDlyiiRshuut7GFAjHl+kgf5GovoZReJqz86yq8eU45FtfziWiArX2h5TjUE9rYZjofGgsn2M83CWmpeEP/Ky9ZyjW+e1EKa1LXmvM3MdWIswIDAQAB"",""ADJUST_ENABLED"":1,""ADJUST_ISDEBUG"":0,""ADJUST_APPID"":""9ldfqpo1zx1c"",""ADJUST_CHARGEEVENTTOKEN"":""wpf4hu"",""app_gl"":""en"",""app_debug"":0,""app_fire"":1,""UserDestroyDays"":15,""DETECTION_ADDRESS"":{""AUTO"":{""DNS"":[""https://www.blhxusstatic.yo-star.com"",""https://www.blhxusstatic.yo-star.com""],""HTTP"":[""https://www.blhxusstatic.yo-star.com"",""https://www.blhxusstatic.yo-star.com""],""MTR"":[""https://www.blhxusstatic.yo-star.com"",""https://www.blhxusstatic.yo-star.com""]},""ENABLE"":1},""LOG_ENABLE"":1,""AIHELP_MODE"":1,""ADJUST_EVENTTOKENS"":{""2d_retention"":""kuhv8j"",""7d_retention"":""dhtuhc"",""account_create"":""binqg9"",""completed_registration"":""9og2k7"",""purchase"":""wopxnk"",""purchase_click"":""v3vmv8"",""purchase_click_diamond"":""bmrzqo"",""purchase_click_giftbag"":""xt7jbc"",""purchase_click_monthlycard"":""b3z5at"",""purchase_first"":""mqg9kg"",""role_create"":""2j5npu"",""role_levelup"":""h3ohkb"",""role_login"":""ax1v0t"",""role_logout"":""cmyuyx"",""tutorial_complete"":""d5ydk2"",""tutorial_complete_1"":""b3vh0x"",""tutorial_complete_2"":""fa1z6r"",""tutorial_complete_3"":""2gdwsh"",""tutorial_complete_4"":""pmg7ny"",""user_charge"":""wpf4hu"",""user_charge_first"":""u912no"",""ysdk_err"":""dmpp3y"",""behavior_verification_failed"":""q6psau"",""behavior_check"":""wgjks1""},""TWITTER_CLIENT_ID"":""NHBIOGhYVG1hZlhHMVIySjZHVXI6MTpjaQ"",""GOOGLE_CLIENT_ID"":""150452741869-sojo18oh2am6u573v5achpi78kau4s52.apps.googleusercontent.com"",""TWITTER_KEY"":""e7wRygYH7SUa2hQ8srVXzeUKm"",""TWITTER_SECRET"":""JCeb2Su9frkBqoBNCMH6gkcrLPol2o5VBe97baSCKEnl8oyhDi"",""FACEBOOK_APPID"":""962529950581548"",""FACEBOOK_CLIENTTOKEN"":""8e18135edd631fa22769c0cdad16bbba"",""APP_BIRTHSET_ENABLED"":0,""REMOTE_CONFIG"":[{""config_key"":""will_pay_android_en"",""event_name"":""prediction_payer""},{""config_key"":""will_payclick_android_en"",""event_name"":""prediction_payclicker""}]}}"); + }); + } + } +} diff --git a/BLHX.Server.SDK/Properties/launchSettings.json b/BLHX.Server.SDK/Properties/launchSettings.json new file mode 100644 index 0000000..b721068 --- /dev/null +++ b/BLHX.Server.SDK/Properties/launchSettings.json @@ -0,0 +1,41 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:55758", + "sslPort": 44326 + } + }, + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "weatherforecast", + "applicationUrl": "http://localhost:5048", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "weatherforecast", + "applicationUrl": "https://localhost:7187;http://localhost:5048", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "weatherforecast", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/BLHX.Server.SDK/SDKServer.cs b/BLHX.Server.SDK/SDKServer.cs new file mode 100644 index 0000000..256de82 --- /dev/null +++ b/BLHX.Server.SDK/SDKServer.cs @@ -0,0 +1,66 @@ +using BLHX.Server.Common.Utils; +using System.Reflection; + +namespace BLHX.Server.Sdk +{ + public class SDKServer + { + static readonly Logger c = new(nameof(SDKServer), ConsoleColor.Green); + static Task? runTask = null; + + public static void Main(string[] args) + { + var builder = WebApplication.CreateBuilder(args); + // Disables default logger + builder.Logging.ClearProviders(); + + var app = builder.Build(); + app.Urls.Add("http://*:80"); + app.Urls.Add("https://*:443"); + + app.UseMiddleware(); + + foreach (Type controller in Assembly.GetExecutingAssembly().GetTypes().Where(p => typeof(IRegisterable).IsAssignableFrom(p) && !p.IsInterface)) + { + controller.GetMethod(nameof(IRegisterable.Register))!.Invoke(null, new object[] { app }); +#if DEBUG + c.Log($"Registered HTTP controller '{controller.Name}'"); +#endif + } + + runTask = app.RunAsync(); + c.Log($"{nameof(SDKServer)} started in port {string.Join(", ", app.Urls.Select(x => x.Split(':').Last()))}!"); + } + + private class RequestLoggingMiddleware(RequestDelegate next) + { + private readonly RequestDelegate _next = next; + private static readonly string[] SurpressedRoutes = []; + + public async Task Invoke(HttpContext context) + { + try + { + await _next(context); + } + catch (Exception ex) + { +#if DEBUG + c.Error($"{ex} Request below:"); +#else + c.Error($"{ex.Message} Request below:"); +#endif + } + finally + { + c.Log($"{context.Response.StatusCode} {context.Request.Method.ToUpper()} {context.Request.Path + context.Request.QueryString}"); + } + } + } + } + + public interface IRegisterable + { + public abstract static void Register(WebApplication app); + } +} diff --git a/BLHX.Server.SDK/appsettings.Development.json b/BLHX.Server.SDK/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/BLHX.Server.SDK/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/BLHX.Server.SDK/appsettings.json b/BLHX.Server.SDK/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/BLHX.Server.SDK/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/BLHX.Server.sln b/BLHX.Server.sln index bd867ba..bebc0b3 100644 --- a/BLHX.Server.sln +++ b/BLHX.Server.sln @@ -3,11 +3,13 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.8.34309.116 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BLHX.Server", "BLHX.Server\BLHX.Server.csproj", "{C67D2B44-EFF0-4325-9C90-9D8BA4799E02}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BLHX.Server", "BLHX.Server\BLHX.Server.csproj", "{C67D2B44-EFF0-4325-9C90-9D8BA4799E02}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BLHX.Server.Game", "BLHX.Server.Game\BLHX.Server.Game.csproj", "{33059688-36C1-43D1-BEE6-3A5C5C7DA4E6}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BLHX.Server.Game", "BLHX.Server.Game\BLHX.Server.Game.csproj", "{33059688-36C1-43D1-BEE6-3A5C5C7DA4E6}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BLHX.Server.Common", "BLHX.Server.Common\BLHX.Server.Common.csproj", "{BA896C61-5025-4CBB-B56C-18A59D3D0D7D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BLHX.Server.Common", "BLHX.Server.Common\BLHX.Server.Common.csproj", "{BA896C61-5025-4CBB-B56C-18A59D3D0D7D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BLHX.Server.SDK", "BLHX.Server.SDK\BLHX.Server.SDK.csproj", "{DBEE7F5B-FA2F-43BE-9B80-7E3D9A6267F2}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -27,6 +29,10 @@ Global {BA896C61-5025-4CBB-B56C-18A59D3D0D7D}.Debug|Any CPU.Build.0 = Debug|Any CPU {BA896C61-5025-4CBB-B56C-18A59D3D0D7D}.Release|Any CPU.ActiveCfg = Release|Any CPU {BA896C61-5025-4CBB-B56C-18A59D3D0D7D}.Release|Any CPU.Build.0 = Release|Any CPU + {DBEE7F5B-FA2F-43BE-9B80-7E3D9A6267F2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DBEE7F5B-FA2F-43BE-9B80-7E3D9A6267F2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DBEE7F5B-FA2F-43BE-9B80-7E3D9A6267F2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DBEE7F5B-FA2F-43BE-9B80-7E3D9A6267F2}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/BLHX.Server/BLHX.Server.csproj b/BLHX.Server/BLHX.Server.csproj index 85fb59f..6600e2a 100644 --- a/BLHX.Server/BLHX.Server.csproj +++ b/BLHX.Server/BLHX.Server.csproj @@ -10,6 +10,7 @@ + diff --git a/BLHX.Server/Program.cs b/BLHX.Server/Program.cs index 8989236..12a7f19 100644 --- a/BLHX.Server/Program.cs +++ b/BLHX.Server/Program.cs @@ -1,17 +1,25 @@ using BLHX.Server.Common.Utils; using BLHX.Server.Game; +using BLHX.Server.Sdk; +using System.Net.NetworkInformation; namespace BLHX.Server; internal class Program { - static void Main() + static void Main(string[] args) { Logger.c.Log("Starting..."); Config.Load(); + if (Config.Instance.Address == "127.0.0.1") + { + Config.Instance.Address = NetworkInterface.GetAllNetworkInterfaces().Where(i => i.NetworkInterfaceType != NetworkInterfaceType.Loopback && i.OperationalStatus == OperationalStatus.Up).First().GetIPProperties().UnicastAddresses.Where(a => a.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork).First().Address.ToString(); + Config.Save(); + } Task.Run(GameServer.Start); + SDKServer.Main(args); Task.Run(InputSystem.Start).Wait(); } }