diff --git a/ServerSelector/Views/MainView.axaml.cs b/ServerSelector/Views/MainView.axaml.cs
index 793b126..ba2171e 100644
--- a/ServerSelector/Views/MainView.axaml.cs
+++ b/ServerSelector/Views/MainView.axaml.cs
@@ -15,6 +15,12 @@ public partial class MainView : UserControl
private void Save_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
{
+ if (string.IsNullOrEmpty(txtGamePath.Text) || string.IsNullOrEmpty(txtLauncherPath.Text))
+ {
+ ShowWarningMsg("Game path / launcher path is empty", "Error");
+ return;
+ }
+
try
{
ServerSwitcher.SaveCfg(CmbServerSelection.SelectedIndex == 0, txtGamePath.Text, txtLauncherPath.Text);
diff --git a/nksrv/IntlServer/AutoLoginEndpoint.cs b/nksrv/IntlServer/AutoLoginEndpoint.cs
index 4b5ee18..196c88c 100644
--- a/nksrv/IntlServer/AutoLoginEndpoint.cs
+++ b/nksrv/IntlServer/AutoLoginEndpoint.cs
@@ -12,7 +12,7 @@ namespace nksrv.IntlServer
protected override async Task HandleAsync()
{
- WriteJsonString("{\"del_account_info\":\"{\\\"ret\\\":0,\\\"msg\\\":\\\"\\\",\\\"status\\\":0,\\\"created_at\\\":\\\"0\\\",\\\"target_destroy_at\\\":\\\"0\\\",\\\"destroyed_at\\\":\\\"0\\\",\\\"err_code\\\":0,\\\"seq\\\":\\\"" + Seq + "\\\"}\",\"del_account_status\":0,\"del_li_account_status\":0,\"extra_json\":{\"del_li_account_info\":\"{\\\"ret\\\":0,\\\"msg\\\":\\\"\\\",\\\"status\\\":0,\\\"created_at\\\":\\\"0\\\",\\\"target_destroy_at\\\":\\\"0\\\",\\\"destroyed_at\\\":\\\"0\\\",\\\"err_code\\\":0,\\\"seq\\\":\\\"" + Seq + "\\\"}\",\"get_status_msg\":\"success\",\"get_status_ret\":0,\"get_status_rsp\":{\"adult_age\":14,\"adult_age_map\":{},\"adult_check_status\":1,\"adult_check_status_expiration\":\"0\",\"adult_status_map\":{},\"certificate_type\":3,\"email\":\"\",\"eu_user_agree_status\":0,\"game_grade\":0,\"game_grade_map\":{},\"is_dma\":true,\"is_eea\":false,\"is_need_li_cert\":false,\"msg\":\"success\",\"need_parent_control\":0,\"need_realname_auth\":0,\"parent_certificate_status\":0,\"parent_certificate_status_expiration\":\"0\",\"parent_control_map\":{},\"qr_code_ret\":0,\"realname_auth_status\":0,\"region\":\"724\",\"ret\":0,\"ts\":\"" + DateTimeOffset.UtcNow.ToUnixTimeSeconds()
+ await WriteJsonStringAsync("{\"del_account_info\":\"{\\\"ret\\\":0,\\\"msg\\\":\\\"\\\",\\\"status\\\":0,\\\"created_at\\\":\\\"0\\\",\\\"target_destroy_at\\\":\\\"0\\\",\\\"destroyed_at\\\":\\\"0\\\",\\\"err_code\\\":0,\\\"seq\\\":\\\"" + Seq + "\\\"}\",\"del_account_status\":0,\"del_li_account_status\":0,\"extra_json\":{\"del_li_account_info\":\"{\\\"ret\\\":0,\\\"msg\\\":\\\"\\\",\\\"status\\\":0,\\\"created_at\\\":\\\"0\\\",\\\"target_destroy_at\\\":\\\"0\\\",\\\"destroyed_at\\\":\\\"0\\\",\\\"err_code\\\":0,\\\"seq\\\":\\\"" + Seq + "\\\"}\",\"get_status_msg\":\"success\",\"get_status_ret\":0,\"get_status_rsp\":{\"adult_age\":14,\"adult_age_map\":{},\"adult_check_status\":1,\"adult_check_status_expiration\":\"0\",\"adult_status_map\":{},\"certificate_type\":3,\"email\":\"\",\"eu_user_agree_status\":0,\"game_grade\":0,\"game_grade_map\":{},\"is_dma\":true,\"is_eea\":false,\"is_need_li_cert\":false,\"msg\":\"success\",\"need_parent_control\":0,\"need_realname_auth\":0,\"parent_certificate_status\":0,\"parent_certificate_status_expiration\":\"0\",\"parent_control_map\":{},\"qr_code_ret\":0,\"realname_auth_status\":0,\"region\":\"724\",\"ret\":0,\"ts\":\"" + DateTimeOffset.UtcNow.ToUnixTimeSeconds()
+ "\"},\"need_notify_msg\":\"success\",\"need_notify_ret\":0,\"need_notify_rsp\":{\"has_bind_li\":true,\"is_receive_email\":1,\"is_receive_email_in_night\":0,\"user_agreed_game_dma\":\"2\",\"user_agreed_game_pp\":\"1\",\"user_agreed_game_tos\":\"1\",\"user_agreed_li_dt\":\"\",\"user_agreed_li_pp\":\"1\",\"user_agreed_li_tos\":\"\"}},\"msg\":\"success\",\"ret\":0,\"seq\":\"" + Seq + "\"}");
}
}
diff --git a/nksrv/IntlServer/CodeStatusEndpoint.cs b/nksrv/IntlServer/CodeStatusEndpoint.cs
index 2c7b57b..8d2387f 100644
--- a/nksrv/IntlServer/CodeStatusEndpoint.cs
+++ b/nksrv/IntlServer/CodeStatusEndpoint.cs
@@ -15,11 +15,8 @@ namespace nksrv.IntlServer
protected override async Task HandleAsync()
{
-
// pretend that any code is valid
-
- WriteJsonString("{\"expire_time\":759,\"msg\":\"Success\",\"ret\":0,\"seq\":\""+Seq+"\"}");
-
+ await WriteJsonStringAsync("{\"expire_time\":759,\"msg\":\"Success\",\"ret\":0,\"seq\":\""+Seq+"\"}");
}
}
}
diff --git a/nksrv/IntlServer/GetNoticeContent.cs b/nksrv/IntlServer/GetNoticeContent.cs
index 8bbcd3d..76997da 100644
--- a/nksrv/IntlServer/GetNoticeContent.cs
+++ b/nksrv/IntlServer/GetNoticeContent.cs
@@ -13,7 +13,7 @@ namespace nksrv.IntlServer
protected override async Task HandleAsync()
{
- WriteJsonString("{\r\n \"msg\": \"success\",\r\n \"notice_list\": [\r\n {\r\n \"app_id\": \"3001001\",\r\n \"app_notice_id\": \"post-6rpvwgrdx1b\",\r\n \"area_list\": \"[\\\"81\\\",\\\"82\\\",\\\"83\\\",\\\"84\\\",\\\"85\\\"]\",\r\n \"content_list\": [\r\n {\r\n \"app_content_id\": \"post-9ilpu79xxzp\",\r\n \"content\": \"This isn't working\",\r\n \"extra_data\": \"{}\",\r\n \"id\": 48706,\r\n \"lang_type\": \"en\",\r\n \"picture_list\": [\r\n {\r\n \"extra_data\": \"{\\\"id\\\":\\\"TitleImage\\\"}\",\r\n \"hash\": \"44a99a61152b5b80a0466ff9f0cee2bc\",\r\n \"redirect_url\": \"\",\r\n \"url\": \"pnt-console-cdn.playernetwork.intlgame.com/prod/29080/notice/022681b1121a40259a575fbe587651b4.jpg\"\r\n }\r\n ],\r\n \"title\": \"New Character\",\r\n \"update_time\": 1717637493\r\n }\r\n ],\r\n \"end_time\": 1719431999,\r\n \"extra_data\": \"{\\\"NoticeType\\\":\\\"Event\\\",\\\"Order\\\":\\\"11\\\",\\\"extra_reserved\\\":\\\"{\\\\\\\"Author\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"Category\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"CreateType\\\\\\\":\\\\\\\"4\\\\\\\",\\\\\\\"IsOpenService\\\\\\\":\\\\\\\"0\\\\\\\",\\\\\\\"IsToping\\\\\\\":false,\\\\\\\"Keyword\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"Sort\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"TopEnd\\\\\\\":\\\\\\\"2000-01-01 00:00:01\\\\\\\",\\\\\\\"TopStart\\\\\\\":\\\\\\\"2000-01-01 00:00:01\\\\\\\"}\\\"}\",\r\n \"id\": 7560,\r\n \"picture_list\": [],\r\n \"start_time\": 1717617599,\r\n \"status\": 1,\r\n \"update_time\": 1717637494\r\n }\r\n ],\r\n \"ret\": 0,\r\n \"seq\": \"" + Seq + "\"\r\n}");
+ await WriteJsonStringAsync("{\r\n \"msg\": \"success\",\r\n \"notice_list\": [\r\n {\r\n \"app_id\": \"3001001\",\r\n \"app_notice_id\": \"post-6rpvwgrdx1b\",\r\n \"area_list\": \"[\\\"81\\\",\\\"82\\\",\\\"83\\\",\\\"84\\\",\\\"85\\\"]\",\r\n \"content_list\": [\r\n {\r\n \"app_content_id\": \"post-9ilpu79xxzp\",\r\n \"content\": \"This isn't working\",\r\n \"extra_data\": \"{}\",\r\n \"id\": 48706,\r\n \"lang_type\": \"en\",\r\n \"picture_list\": [\r\n {\r\n \"extra_data\": \"{\\\"id\\\":\\\"TitleImage\\\"}\",\r\n \"hash\": \"44a99a61152b5b80a0466ff9f0cee2bc\",\r\n \"redirect_url\": \"\",\r\n \"url\": \"pnt-console-cdn.playernetwork.intlgame.com/prod/29080/notice/022681b1121a40259a575fbe587651b4.jpg\"\r\n }\r\n ],\r\n \"title\": \"New Character\",\r\n \"update_time\": 1717637493\r\n }\r\n ],\r\n \"end_time\": 1719431999,\r\n \"extra_data\": \"{\\\"NoticeType\\\":\\\"Event\\\",\\\"Order\\\":\\\"11\\\",\\\"extra_reserved\\\":\\\"{\\\\\\\"Author\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"Category\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"CreateType\\\\\\\":\\\\\\\"4\\\\\\\",\\\\\\\"IsOpenService\\\\\\\":\\\\\\\"0\\\\\\\",\\\\\\\"IsToping\\\\\\\":false,\\\\\\\"Keyword\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"Sort\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"TopEnd\\\\\\\":\\\\\\\"2000-01-01 00:00:01\\\\\\\",\\\\\\\"TopStart\\\\\\\":\\\\\\\"2000-01-01 00:00:01\\\\\\\"}\\\"}\",\r\n \"id\": 7560,\r\n \"picture_list\": [],\r\n \"start_time\": 1717617599,\r\n \"status\": 1,\r\n \"update_time\": 1717637494\r\n }\r\n ],\r\n \"ret\": 0,\r\n \"seq\": \"" + Seq + "\"\r\n}");
}
}
}
diff --git a/nksrv/IntlServer/IntlAccountRedirect.cs b/nksrv/IntlServer/IntlAccountRedirect.cs
index e13c3c5..fb263a3 100644
--- a/nksrv/IntlServer/IntlAccountRedirect.cs
+++ b/nksrv/IntlServer/IntlAccountRedirect.cs
@@ -51,7 +51,7 @@ namespace nksrv.IntlServer
var result = await client.SendAsync(request);
var s = await result.Content.ReadAsStringAsync();
- WriteJsonString(s);
+ await WriteJsonStringAsync(s);
Console.WriteLine("li-sg redirect out: " + s);
}
}
diff --git a/nksrv/IntlServer/IntlAccountRegisterEndpoint.cs b/nksrv/IntlServer/IntlAccountRegisterEndpoint.cs
index d36ebb8..c1250ca 100644
--- a/nksrv/IntlServer/IntlAccountRegisterEndpoint.cs
+++ b/nksrv/IntlServer/IntlAccountRegisterEndpoint.cs
@@ -30,7 +30,7 @@ namespace nksrv.IntlServer
{
if (item.Username == ep.account)
{
- WriteJsonString("{\"msg\":\"send code failed; invalid account\",\"ret\":2112,\"seq\":\"" + seg + "\"}");
+ await WriteJsonStringAsync("{\"msg\":\"send code failed; invalid account\",\"ret\":2112,\"seq\":\"" + seg + "\"}");
return;
}
}
@@ -51,7 +51,7 @@ namespace nksrv.IntlServer
JsonDb.Instance.Users.Add(user);
var tok = IntlHandler.CreateLauncherTokenForUser(user);
- WriteJsonString("{\"expire\":" + tok.ExpirationTime + ",\"is_login\":false,\"msg\":\"Success\",\"register_time\":" + user.RegisterTime + ",\"ret\":0,\"seq\":\"" + seg + "\",\"token\":\"" + tok.Token + "\",\"uid\":\"" + user.ID + "\"}");
+ await WriteJsonStringAsync("{\"expire\":" + tok.ExpirationTime + ",\"is_login\":false,\"msg\":\"Success\",\"register_time\":" + user.RegisterTime + ",\"ret\":0,\"seq\":\"" + seg + "\",\"token\":\"" + tok.Token + "\",\"uid\":\"" + user.ID + "\"}");
}
else
{
@@ -61,17 +61,17 @@ namespace nksrv.IntlServer
public class RegisterEPReq
{
- public DeviceInfo device_info { get; set; }
- public string verify_code { get; set; }
- public string account { get; set; }
+ public DeviceInfo device_info { get; set; } = new();
+ public string verify_code { get; set; } = "";
+ public string account { get; set; } = "";
public int account_type { get; set; }
- public string phone_area_code { get; set; }
- public string password { get; set; }
- public string user_name { get; set; }
- public string birthday { get; set; }
- public string region { get; set; }
- public string user_lang_type { get; set; }
- public string extra_json { get; set; }
+ public string phone_area_code { get; set; } = "";
+ public string password { get; set; } = "";
+ public string user_name { get; set; } = "";
+ public string birthday { get; set; } = "";
+ public string region { get; set; } = "";
+ public string user_lang_type { get; set; } = "";
+ public string extra_json { get; set; } = "";
}
}
}
diff --git a/nksrv/IntlServer/IntlAwsNaRedirect.cs b/nksrv/IntlServer/IntlAwsNaRedirect.cs
deleted file mode 100644
index 2fe18f4..0000000
--- a/nksrv/IntlServer/IntlAwsNaRedirect.cs
+++ /dev/null
@@ -1,58 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Net.Http.Headers;
-using System.Net;
-using System.Text;
-using System.Threading.Tasks;
-using EmbedIO;
-using nksrv.Utils;
-
-namespace nksrv.IntlServer
-{
- ///
- /// redirector for /v2/ endpoint
- ///
- internal class IntlAwsNaRedirect : IntlMsgHandler
- {
- public override bool RequiresAuth => false;
-
- protected override async Task HandleAsync()
- {
- Console.WriteLine("AWS NA redirect in: " + Content);
- HttpClientHandler handler = new()
- {
- AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate,
- ServerCertificateCustomValidationCallback = (httpRequestMessage, cert, cetChain, policyErrors) => true,
- AllowAutoRedirect = true // from gameassembly dll
- };
-
- HttpClient client = new(new LoggingHttpHandler(handler));
- client.DefaultRequestHeaders
- .Accept
- .Add(new MediaTypeWithQualityHeaderValue("*/*"));//ACCEPT header
- client.DefaultRequestHeaders.AcceptEncoding.Add(new StringWithQualityHeaderValue("identity"));
- client.DefaultRequestHeaders.Connection.Add("Keep-Alive");
-
-
- // client.DefaultRequestHeaders.Remove("User-agent");
-
- HttpRequestMessage request = new(HttpMethod.Post, "https://50.18.221.30" + ctx.Request.RawUrl);
- request.Version = HttpVersion.Version11;
- request.Headers.TryAddWithoutValidation("Host", "aws-na.intlgame.com");
-
- var systemContent = new StringContent(Content);
- systemContent.Headers.Remove("Content-Type");
- systemContent.Headers.Add("Content-Type", "application/json;charset=UTF-8");
- systemContent.Headers.Add("Content-Length", ctx.Request.ContentLength64.ToString());
-
- request.Content = systemContent;// CONTENT-TYPE header
-
-
- var result = await client.SendAsync(request);
- var s = await result.Content.ReadAsStringAsync();
- Console.WriteLine("Redirect out: " + s);
- WriteJsonString(s);
- }
- }
-}
diff --git a/nksrv/IntlServer/IntlGetAccountInfo.cs b/nksrv/IntlServer/IntlGetAccountInfo.cs
index fc65bda..f4452b7 100644
--- a/nksrv/IntlServer/IntlGetAccountInfo.cs
+++ b/nksrv/IntlServer/IntlGetAccountInfo.cs
@@ -15,7 +15,7 @@ namespace nksrv.IntlServer
if (User == null || UsedToken == null)
throw new Exception("no user"); // should never happen
- WriteJsonString("{\"account_type\":1,\"birthday\":\"1970-01\",\"email\":\"" + User.Username + "\",\"expire\":" + UsedToken.ExpirationTime + ",\"is_receive_email\":1,\"is_receive_email_in_night\":0,\"is_receive_video\":-1,\"lang_type\":\"en\",\"msg\":\"Success\",\"nick_name\":\"\",\"phone\":\"\",\"phone_area_code\":\"\",\"privacy_policy\":\"1\",\"privacy_update_time\":1717783097,\"region\":\"724\",\"ret\":0,\"seq\":\"" + Seq + "\",\"terms_of_service\":\"\",\"terms_update_time\":0,\"uid\":\"" + User.ID + "\",\"user_agreed_dt\":\"\",\"user_agreed_pp\":\"1\",\"user_agreed_tos\":\"\",\"user_name\":\"" + User.PlayerName + "\",\"username_pass_verify\":0}");
+ await WriteJsonStringAsync("{\"account_type\":1,\"birthday\":\"1970-01\",\"email\":\"" + User.Username + "\",\"expire\":" + UsedToken.ExpirationTime + ",\"is_receive_email\":1,\"is_receive_email_in_night\":0,\"is_receive_video\":-1,\"lang_type\":\"en\",\"msg\":\"Success\",\"nick_name\":\"\",\"phone\":\"\",\"phone_area_code\":\"\",\"privacy_policy\":\"1\",\"privacy_update_time\":1717783097,\"region\":\"724\",\"ret\":0,\"seq\":\"" + Seq + "\",\"terms_of_service\":\"\",\"terms_update_time\":0,\"uid\":\"" + User.ID + "\",\"user_agreed_dt\":\"\",\"user_agreed_pp\":\"1\",\"user_agreed_tos\":\"\",\"user_name\":\"" + User.PlayerName + "\",\"username_pass_verify\":0}");
}
}
}
diff --git a/nksrv/IntlServer/IntlGetProfileBindInfo.cs b/nksrv/IntlServer/IntlGetProfileBindInfo.cs
index 6573804..69a1cd7 100644
--- a/nksrv/IntlServer/IntlGetProfileBindInfo.cs
+++ b/nksrv/IntlServer/IntlGetProfileBindInfo.cs
@@ -12,7 +12,7 @@ namespace nksrv.IntlServer
// TODO: last login time, but is it needed?
- WriteJsonString("{\"bind_list\":[{\"bind_ts\":1717783095,\"channel_info\":{\"birthday\":\"1970-01\",\"email\":\"" + User.Username + "\",\"is_receive_email\":1,\"lang_type\":\"en\",\"last_login_time\":171000000,\"nick_name\":\"\",\"phone\":\"\",\"phone_area_code\":\"\",\"region\":\"724\",\"register_account\":\"" + User.Username + "\",\"register_account_type\":1,\"register_time\":" + User.RegisterTime + ",\"seq\":\"" + Seq + "\",\"uid\":\"2752409592679849\",\"user_name\":\"" + User.PlayerName + "\",\"username_pass_verify\":0},\"channelid\":131,\"email\":\"" + User.Username + "\",\"history_scopes\":[],\"is_primary\":1,\"picture_url\":\"\",\"user_name\":\"" + User.PlayerName + "\"}],\"create_ts\":" + User.RegisterTime + ",\"last_login_ts\":171000000,\"msg\":\"success\",\"ret\":0,\"seq\":\"" + Seq + "\"}");
+ await WriteJsonStringAsync("{\"bind_list\":[{\"bind_ts\":1717783095,\"channel_info\":{\"birthday\":\"1970-01\",\"email\":\"" + User.Username + "\",\"is_receive_email\":1,\"lang_type\":\"en\",\"last_login_time\":171000000,\"nick_name\":\"\",\"phone\":\"\",\"phone_area_code\":\"\",\"region\":\"724\",\"register_account\":\"" + User.Username + "\",\"register_account_type\":1,\"register_time\":" + User.RegisterTime + ",\"seq\":\"" + Seq + "\",\"uid\":\"2752409592679849\",\"user_name\":\"" + User.PlayerName + "\",\"username_pass_verify\":0},\"channelid\":131,\"email\":\"" + User.Username + "\",\"history_scopes\":[],\"is_primary\":1,\"picture_url\":\"\",\"user_name\":\"" + User.PlayerName + "\"}],\"create_ts\":" + User.RegisterTime + ",\"last_login_ts\":171000000,\"msg\":\"success\",\"ret\":0,\"seq\":\"" + Seq + "\"}");
}
}
}
\ No newline at end of file
diff --git a/nksrv/IntlServer/IntlGetProfileInfo.cs b/nksrv/IntlServer/IntlGetProfileInfo.cs
index b307880..d39d976 100644
--- a/nksrv/IntlServer/IntlGetProfileInfo.cs
+++ b/nksrv/IntlServer/IntlGetProfileInfo.cs
@@ -15,7 +15,7 @@ namespace nksrv.IntlServer
if (User == null)
throw new Exception("no user"); // should never happen
- WriteJsonString("{\"bind_list\":[{\"channel_info\":{\"birthday\":\"1970-01\",\"email\":\""+User.Username+"\",\"is_receive_email\":1,\"lang_type\":\"en\",\"last_login_time\":1719075003,\"nick_name\":\"\",\"phone\":\"\",\"phone_area_code\":\"\",\"region\":\"724\",\"register_account\":\""+User.Username+"\",\"register_account_type\":1,\"register_time\":"+User.RegisterTime+",\"seq\":\"abc\",\"uid\":\""+User.ID+"\",\"user_name\":\""+User.PlayerName+"\",\"username_pass_verify\":0},\"channelid\":131,\"email\":\"" + User.Username + "\",\"picture_url\":\"\",\"user_name\":\""+User.PlayerName+"\"}],\"birthday\":\"1970-01\",\"email\":\"" + User.Username + "\",\"gender\":0,\"msg\":\"success\",\"picture_url\":\"\",\"ret\":0,\"seq\":\"" + Seq + "\",\"user_name\":\"" + User.PlayerName + "\"}");
+ await WriteJsonStringAsync("{\"bind_list\":[{\"channel_info\":{\"birthday\":\"1970-01\",\"email\":\""+User.Username+"\",\"is_receive_email\":1,\"lang_type\":\"en\",\"last_login_time\":1719075003,\"nick_name\":\"\",\"phone\":\"\",\"phone_area_code\":\"\",\"region\":\"724\",\"register_account\":\""+User.Username+"\",\"register_account_type\":1,\"register_time\":"+User.RegisterTime+",\"seq\":\"abc\",\"uid\":\""+User.ID+"\",\"user_name\":\""+User.PlayerName+"\",\"username_pass_verify\":0},\"channelid\":131,\"email\":\"" + User.Username + "\",\"picture_url\":\"\",\"user_name\":\""+User.PlayerName+"\"}],\"birthday\":\"1970-01\",\"email\":\"" + User.Username + "\",\"gender\":0,\"msg\":\"success\",\"picture_url\":\"\",\"ret\":0,\"seq\":\"" + Seq + "\",\"user_name\":\"" + User.PlayerName + "\"}");
}
}
}
diff --git a/nksrv/IntlServer/IntlHandler.cs b/nksrv/IntlServer/IntlHandler.cs
index a9f1847..307c753 100644
--- a/nksrv/IntlServer/IntlHandler.cs
+++ b/nksrv/IntlServer/IntlHandler.cs
@@ -22,7 +22,6 @@ namespace nksrv.IntlServer
{"/profile/query_account_info", new IntlQueryAccountInfo() }, // /account/register
{"/conf/get_conf", new IntlReturnJsonHandler(GetConfResp) }, // /v2/conf/get_conf
{"/minorcer/get_status", new IntlReturnJsonHandler(MinorcerResp) }, // /v2/minorcer/get_status
- {"/minorcer/set_all_status", new IntlMinocerSetStatus() }, // /v2/minorcer/set_all_status
{"/profile/set_protocol", new IntlReturnJsonHandler(SetProtocolResp) },
{"/profile/userinfo", new IntlGetProfileInfo() },
{"/getuserinfo", new IntlGetAccountInfo() },
@@ -40,16 +39,6 @@ namespace nksrv.IntlServer
public const string AquireConfigResp = "{\"ret\":23111202,\"msg\":\"no matched config error( [match logic]no match )\",\"rule_id\":\"\",\"resource_list\":\"\",\"sdk_enable\":0,\"sdk_debug_enable\":0,\"report_log_enable\":0,\"log_level\":0,\"inner_seq\":\"((SEGID))\",\"ab_test\":{\"id\":\"\",\"group\":\"\"},\"seq\":\"((SEGID))\"}";
public static async Task Handle(IHttpContext context)
{
-
- //if (context.Request.RawUrl.StartsWith("/v2/"))
- //{
- // await new IntlAwsNaRedirect().HandleAsync(context);
- //}
- //else if (context.Request.RawUrl.StartsWith("/account/"))
- //{
- // await new IntlAccountRedirect().HandleAsync(context);
- //}
- //return;
IntlMsgHandler? handler = null;
foreach (var item in Handlers)
{
@@ -62,7 +51,6 @@ namespace nksrv.IntlServer
if (handler == null)
{
context.Response.StatusCode = 404;
- // Logger.Error("Launcher Endpoint - Not Found: " + context.RequestedPath);
}
else
{
@@ -81,5 +69,4 @@ namespace nksrv.IntlServer
return token;
}
}
-
}
diff --git a/nksrv/IntlServer/IntlLogin1Endpoint.cs b/nksrv/IntlServer/IntlLogin1Endpoint.cs
index 43f4603..bdb77f5 100644
--- a/nksrv/IntlServer/IntlLogin1Endpoint.cs
+++ b/nksrv/IntlServer/IntlLogin1Endpoint.cs
@@ -27,7 +27,7 @@ namespace nksrv.IntlServer
var tok = IntlHandler.CreateLauncherTokenForUser(item);
item.LastLogin = DateTime.UtcNow;
JsonDb.Save();
- WriteJsonString("{\"expire\":" + tok.ExpirationTime + ",\"is_login\":true,\"msg\":\"Success\",\"register_time\":" + item.RegisterTime + ",\"ret\":0,\"seq\":\"" + Seq + "\",\"token\":\"" + tok.Token + "\",\"uid\":\"" + item.ID + "\"}");
+ await WriteJsonStringAsync("{\"expire\":" + tok.ExpirationTime + ",\"is_login\":true,\"msg\":\"Success\",\"register_time\":" + item.RegisterTime + ",\"ret\":0,\"seq\":\"" + Seq + "\",\"token\":\"" + tok.Token + "\",\"uid\":\"" + item.ID + "\"}");
return;
}
@@ -35,7 +35,7 @@ namespace nksrv.IntlServer
string? seg = ctx.GetRequestQueryData().Get("seq");
- WriteJsonString("{\"msg\":\"the account does not exists!\",\"ret\":2001,\"seq\":\"" + seg + "\"}");
+ await WriteJsonStringAsync("{\"msg\":\"the account does not exists!\",\"ret\":2001,\"seq\":\"" + seg + "\"}");
}
else
{
@@ -45,12 +45,12 @@ namespace nksrv.IntlServer
public class LoginEndpoint2Req
{
- public DeviceInfo device_info { get; set; }
- public string extra_json { get; set; }
- public string account { get; set; }
+ public DeviceInfo device_info { get; set; } = new();
+ public string extra_json { get; set; } = "";
+ public string account { get; set; } = "";
public int account_type { get; set; }
- public string password { get; set; }
- public string phone_area_code { get; set; }
+ public string password { get; set; } = "";
+ public string phone_area_code { get; set; } = "";
public int support_captcha { get; set; }
}
}
diff --git a/nksrv/IntlServer/IntlLogin2Endpoint.cs b/nksrv/IntlServer/IntlLogin2Endpoint.cs
index 8bb36d7..a7f8cdb 100644
--- a/nksrv/IntlServer/IntlLogin2Endpoint.cs
+++ b/nksrv/IntlServer/IntlLogin2Endpoint.cs
@@ -24,10 +24,8 @@ namespace nksrv.IntlServer
var user = JsonDb.Instance.Users.Find(x => x.ID == tok.UserID);
if (user != null)
{
-
// todo: they use another token here, but we will reuse the same one.
-
- WriteJsonString("{\"birthday\":\"1970-01\",\"channel_info\":{\"account\":\"" + user.Username + "\",\"account_plat_type\":131,\"account_token\":\"" + ep.channel_info.account_token + "\",\"account_type\":1,\"account_uid\":\"" + user.ID + "\",\"expire_ts\":1721667004,\"is_login\":true,\"lang_type\":\"en\",\"phone_area_code\":\"\",\"token\":\"" + ep.channel_info.account_token + "\"},\"del_account_info\":\"{\\\"ret\\\":0,\\\"msg\\\":\\\"\\\",\\\"status\\\":0,\\\"created_at\\\":\\\"0\\\",\\\"target_destroy_at\\\":\\\"0\\\",\\\"destroyed_at\\\":\\\"0\\\",\\\"err_code\\\":0,\\\"seq\\\":\\\"1719075066-0339089836-025921-1161847390\\\"}\",\"del_account_status\":0,\"del_li_account_status\":0,\"email\":\"" + user.Username + "\",\"extra_json\":{\"del_li_account_info\":\"{\\\"ret\\\":0,\\\"msg\\\":\\\"\\\",\\\"status\\\":0,\\\"created_at\\\":\\\"0\\\",\\\"target_destroy_at\\\":\\\"0\\\",\\\"destroyed_at\\\":\\\"0\\\",\\\"err_code\\\":0,\\\"seq\\\":\\\"1719075065-4128751114-032271-2064970828\\\"}\",\"get_status_rsp\":{\"adult_age\":14,\"adult_age_map\":{},\"adult_check_status\":1,\"adult_check_status_expiration\":\"0\",\"adult_status_map\":{},\"certificate_type\":3,\"email\":\"\",\"eu_user_agree_status\":0,\"game_grade\":0,\"game_grade_map\":{},\"is_dma\":true,\"is_eea\":false,\"is_need_li_cert\":false,\"msg\":\"success\",\"need_parent_control\":0,\"need_realname_auth\":0,\"parent_certificate_status\":0,\"parent_certificate_status_expiration\":\"0\",\"parent_control_map\":{},\"qr_code_ret\":0,\"realname_auth_status\":0,\"region\":\"724\",\"ret\":0,\"ts\":\"1719075065\"},\"need_notify_rsp\":{\"game_sacc_openid\":\"\",\"game_sacc_uid\":\"\",\"has_game_sacc_openid\":false,\"has_game_sacc_uid\":false,\"has_li_openid\":true,\"has_li_uid\":true,\"is_receive_email\":1,\"is_receive_email_in_night\":0,\"li_openid\":\"43599204002070510000\",\"li_uid\":\"2752409592679849\",\"need_notify\":false,\"user_agreed_game_dma\":\"2\",\"user_agreed_game_pp\":\"1\",\"user_agreed_game_tos\":\"1\",\"user_agreed_li_dt\":\"\",\"user_agreed_li_pp\":\"1\",\"user_agreed_li_tos\":\"\"}},\"first_login\":0,\"gender\":0,\"msg\":\"success\",\"need_name_auth\":false,\"openid\":\"43599204002070510000\",\"pf\":\"LevelInfinite_LevelInfinite-Windows-windows-Windows-LevelInfinite-09af79d65d6e4fdf2d2569f0d365739d-43599204002070510000\",\"pf_key\":\"abc\",\"picture_url\":\"\",\"reg_channel_dis\":\"Windows\",\"ret\":0,\"seq\":\"29080-2d28ea26-d71f-4822-9118-0156f1e2dba4-1719075060-99\",\"token\":\"" + tok.Token + "\",\"token_expire_time\":" + tok.ExpirationTime + ",\"uid\":\"" + user.ID + "\",\"user_name\":\"" + user.PlayerName + "\"}");
+ await WriteJsonStringAsync("{\"birthday\":\"1970-01\",\"channel_info\":{\"account\":\"" + user.Username + "\",\"account_plat_type\":131,\"account_token\":\"" + ep.channel_info.account_token + "\",\"account_type\":1,\"account_uid\":\"" + user.ID + "\",\"expire_ts\":1721667004,\"is_login\":true,\"lang_type\":\"en\",\"phone_area_code\":\"\",\"token\":\"" + ep.channel_info.account_token + "\"},\"del_account_info\":\"{\\\"ret\\\":0,\\\"msg\\\":\\\"\\\",\\\"status\\\":0,\\\"created_at\\\":\\\"0\\\",\\\"target_destroy_at\\\":\\\"0\\\",\\\"destroyed_at\\\":\\\"0\\\",\\\"err_code\\\":0,\\\"seq\\\":\\\"1719075066-0339089836-025921-1161847390\\\"}\",\"del_account_status\":0,\"del_li_account_status\":0,\"email\":\"" + user.Username + "\",\"extra_json\":{\"del_li_account_info\":\"{\\\"ret\\\":0,\\\"msg\\\":\\\"\\\",\\\"status\\\":0,\\\"created_at\\\":\\\"0\\\",\\\"target_destroy_at\\\":\\\"0\\\",\\\"destroyed_at\\\":\\\"0\\\",\\\"err_code\\\":0,\\\"seq\\\":\\\"1719075065-4128751114-032271-2064970828\\\"}\",\"get_status_rsp\":{\"adult_age\":14,\"adult_age_map\":{},\"adult_check_status\":1,\"adult_check_status_expiration\":\"0\",\"adult_status_map\":{},\"certificate_type\":3,\"email\":\"\",\"eu_user_agree_status\":0,\"game_grade\":0,\"game_grade_map\":{},\"is_dma\":true,\"is_eea\":false,\"is_need_li_cert\":false,\"msg\":\"success\",\"need_parent_control\":0,\"need_realname_auth\":0,\"parent_certificate_status\":0,\"parent_certificate_status_expiration\":\"0\",\"parent_control_map\":{},\"qr_code_ret\":0,\"realname_auth_status\":0,\"region\":\"724\",\"ret\":0,\"ts\":\"1719075065\"},\"need_notify_rsp\":{\"game_sacc_openid\":\"\",\"game_sacc_uid\":\"\",\"has_game_sacc_openid\":false,\"has_game_sacc_uid\":false,\"has_li_openid\":true,\"has_li_uid\":true,\"is_receive_email\":1,\"is_receive_email_in_night\":0,\"li_openid\":\"43599204002070510000\",\"li_uid\":\"2752409592679849\",\"need_notify\":false,\"user_agreed_game_dma\":\"2\",\"user_agreed_game_pp\":\"1\",\"user_agreed_game_tos\":\"1\",\"user_agreed_li_dt\":\"\",\"user_agreed_li_pp\":\"1\",\"user_agreed_li_tos\":\"\"}},\"first_login\":0,\"gender\":0,\"msg\":\"success\",\"need_name_auth\":false,\"openid\":\"43599204002070510000\",\"pf\":\"LevelInfinite_LevelInfinite-Windows-windows-Windows-LevelInfinite-09af79d65d6e4fdf2d2569f0d365739d-43599204002070510000\",\"pf_key\":\"abc\",\"picture_url\":\"\",\"reg_channel_dis\":\"Windows\",\"ret\":0,\"seq\":\"29080-2d28ea26-d71f-4822-9118-0156f1e2dba4-1719075060-99\",\"token\":\"" + tok.Token + "\",\"token_expire_time\":" + tok.ExpirationTime + ",\"uid\":\"" + user.ID + "\",\"user_name\":\"" + user.PlayerName + "\"}");
return;
}
@@ -43,50 +41,36 @@ namespace nksrv.IntlServer
}
}
- public class ChannelInfo
- {
- public string openid { get; set; }
- public string token { get; set; }
- public int account_type { get; set; }
- public string account { get; set; }
- public string phone_area_code { get; set; }
- public int account_plat_type { get; set; }
- public string lang_type { get; set; }
- public bool is_login { get; set; }
- public string account_uid { get; set; }
- public string account_token { get; set; }
- }
-
public class DeviceInfo
{
- public string guest_id { get; set; }
- public string lang_type { get; set; }
- public string root_info { get; set; }
- public string app_version { get; set; }
- public string screen_dpi { get; set; }
+ public string guest_id { get; set; } = "";
+ public string lang_type { get; set; } = "";
+ public string root_info { get; set; } = "";
+ public string app_version { get; set; } = "";
+ public string screen_dpi { get; set; } = "";
public int screen_height { get; set; }
public int screen_width { get; set; }
- public string device_brand { get; set; }
- public string device_model { get; set; }
+ public string device_brand { get; set; } = "";
+ public string device_model { get; set; } = "";
public int network_type { get; set; }
public int ram_total { get; set; }
public int rom_total { get; set; }
- public string cpu_name { get; set; }
- public string client_region { get; set; }
- public string vm_type { get; set; }
- public string xwid { get; set; }
- public string new_xwid { get; set; }
- public string xwid_flag { get; set; }
- public string cpu_arch { get; set; }
+ public string cpu_name { get; set; } = "";
+ public string client_region { get; set; } = "";
+ public string vm_type { get; set; } = "";
+ public string xwid { get; set; } = "";
+ public string new_xwid { get; set; } = "";
+ public string xwid_flag { get; set; } = "";
+ public string cpu_arch { get; set; } = "";
}
public class LoginEndpoint1Req
{
- public ChannelInfo channel_info { get; set; }
- public DeviceInfo device_info { get; set; }
- public string channel_dis { get; set; }
- public string login_extra_info { get; set; }
- public string lang_type { get; set; }
+ public ChannelInfo channel_info { get; set; } = new();
+ public DeviceInfo device_info { get; set; } = new();
+ public string channel_dis { get; set; } = "";
+ public string login_extra_info { get; set; } = "";
+ public string lang_type { get; set; } = "";
}
}
}
diff --git a/nksrv/IntlServer/IntlMinocerSetStatus.cs b/nksrv/IntlServer/IntlMinocerSetStatus.cs
deleted file mode 100644
index 10c3be7..0000000
--- a/nksrv/IntlServer/IntlMinocerSetStatus.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using EmbedIO;
-
-namespace nksrv.IntlServer
-{
- public class IntlMinocerSetStatus : IntlMsgHandler
- {
- public override bool RequiresAuth => true;
-
- protected override async Task HandleAsync()
- {
- var c = await ctx.GetRequestBodyAsStringAsync();
- throw new NotImplementedException();
- }
- }
-}
diff --git a/nksrv/IntlServer/IntlMsgHandler.cs b/nksrv/IntlServer/IntlMsgHandler.cs
index a05aeb4..a0fe619 100644
--- a/nksrv/IntlServer/IntlMsgHandler.cs
+++ b/nksrv/IntlServer/IntlMsgHandler.cs
@@ -42,6 +42,7 @@ namespace nksrv.IntlServer
if (string.IsNullOrEmpty(tokToCheck))
throw new Exception("missing auth token");
+
if (x != null)
{
foreach (var tok in JsonDb.Instance.LauncherAccessTokens)
@@ -59,13 +60,13 @@ namespace nksrv.IntlServer
if (User == null)
{
- WriteJsonString("{\"msg\":\"expired verify_code!\",\"ret\":2022,\"seq\":\"" + Seq + "\"}\r\n");
+ await WriteJsonStringAsync("{\"msg\":\"expired verify_code!\",\"ret\":2022,\"seq\":\"" + Seq + "\"}\r\n");
return;
}
}
else
{
- WriteJsonString("{\"msg\":\"expired verify_code!\",\"ret\":2022,\"seq\":\"" + Seq + "\"}\r\n");
+ await WriteJsonStringAsync("{\"msg\":\"expired verify_code!\",\"ret\":2022,\"seq\":\"" + Seq + "\"}\r\n");
return;
}
}
@@ -74,40 +75,40 @@ namespace nksrv.IntlServer
}
protected abstract Task HandleAsync();
- protected void WriteJsonString(string data)
+ protected async Task WriteJsonStringAsync(string data)
{
- // check if we are sending valid json
- JObject.Parse(data);
-
- var bt = Encoding.UTF8.GetBytes(data);
- ctx.Response.ContentEncoding = null;
- ctx.Response.ContentType = "application/json";
- ctx.Response.ContentLength64 = bt.Length;
- ctx.Response.OutputStream.Write(bt, 0, bt.Length);
- ctx.Response.OutputStream.Flush();
+ if (ctx != null)
+ {
+ var bt = Encoding.UTF8.GetBytes(data);
+ ctx.Response.ContentEncoding = null;
+ ctx.Response.ContentType = "application/json";
+ ctx.Response.ContentLength64 = bt.Length;
+ await ctx.Response.OutputStream.WriteAsync(bt, 0, bt.Length, ctx.CancellationToken);
+ await ctx.Response.OutputStream.FlushAsync();
+ }
}
public class ChannelInfo
{
- public string openid { get; set; }
- public string token { get; set; }
+ public string openid { get; set; } = "";
+ public string token { get; set; } = "";
public int account_type { get; set; }
- public string account { get; set; }
- public string phone_area_code { get; set; }
+ public string account { get; set; } = "";
+ public string phone_area_code { get; set; } = "";
public int account_plat_type { get; set; }
- public string lang_type { get; set; }
+ public string lang_type { get; set; } = "";
public bool is_login { get; set; }
- public string account_uid { get; set; }
- public string account_token { get; set; }
+ public string account_uid { get; set; } = "";
+ public string account_token { get; set; } = "";
}
public class AuthPkt
{
- public ChannelInfo channel_info { get; set; }
+ public ChannelInfo channel_info { get; set; } = new();
}
public class AuthPkt2
{
- public string token;
- public string openid;
- public string account_token;
+ public string token = "";
+ public string openid = "";
+ public string account_token = "";
}
}
}
diff --git a/nksrv/IntlServer/IntlQueryAccountInfo.cs b/nksrv/IntlServer/IntlQueryAccountInfo.cs
index b982cda..db2a6d3 100644
--- a/nksrv/IntlServer/IntlQueryAccountInfo.cs
+++ b/nksrv/IntlServer/IntlQueryAccountInfo.cs
@@ -15,8 +15,10 @@ namespace nksrv.IntlServer
protected override async Task HandleAsync()
{
+ if (User == null) throw new Exception("user cannot be null");
+
// doesnt seem to be important, send some data
- WriteJsonString("{\"game_sacc_openid\":\"\",\"game_sacc_uid\":\"\",\"has_game_sacc_openid\":false,\"has_game_sacc_uid\":false,\"has_li_openid\":false,\"has_li_uid\":true,\"is_receive_email\":-1,\"is_receive_email_in_night\":-1,\"li_openid\":\"\",\"li_uid\":\"" + User.ID + "\",\"msg\":\"success\",\"need_notify\":false,\"ret\":0,\"seq\":\"" + Seq + "\",\"user_agreed_game_dma\":\"\",\"user_agreed_game_pp\":\"\",\"user_agreed_game_tos\":\"\",\"user_agreed_li_dt\":\"\",\"user_agreed_li_pp\":\"\",\"user_agreed_li_tos\":\"\"}");
+ await WriteJsonStringAsync("{\"game_sacc_openid\":\"\",\"game_sacc_uid\":\"\",\"has_game_sacc_openid\":false,\"has_game_sacc_uid\":false,\"has_li_openid\":false,\"has_li_uid\":true,\"is_receive_email\":-1,\"is_receive_email_in_night\":-1,\"li_openid\":\"\",\"li_uid\":\"" + User.ID + "\",\"msg\":\"success\",\"need_notify\":false,\"ret\":0,\"seq\":\"" + Seq + "\",\"user_agreed_game_dma\":\"\",\"user_agreed_game_pp\":\"\",\"user_agreed_game_tos\":\"\",\"user_agreed_li_dt\":\"\",\"user_agreed_li_pp\":\"\",\"user_agreed_li_tos\":\"\"}");
}
}
}
diff --git a/nksrv/IntlServer/IntlReturnJsonHandler.cs b/nksrv/IntlServer/IntlReturnJsonHandler.cs
index aca7163..faca0bc 100644
--- a/nksrv/IntlServer/IntlReturnJsonHandler.cs
+++ b/nksrv/IntlServer/IntlReturnJsonHandler.cs
@@ -20,10 +20,10 @@ namespace nksrv.IntlServer
protected override async Task HandleAsync()
{
- var str= await ctx.GetRequestBodyAsStringAsync();
+ var str = await ctx.GetRequestBodyAsStringAsync();
string? seg = ctx.GetRequestQueryData().Get("seq");
- WriteJsonString(JsonToReturn.Replace("((SEGID))", seg));
+ await WriteJsonStringAsync(JsonToReturn.Replace("((SEGID))", seg));
}
}
}
diff --git a/nksrv/IntlServer/SendCodeEndpoint.cs b/nksrv/IntlServer/SendCodeEndpoint.cs
index b1c7171..ca1d650 100644
--- a/nksrv/IntlServer/SendCodeEndpoint.cs
+++ b/nksrv/IntlServer/SendCodeEndpoint.cs
@@ -30,13 +30,13 @@ namespace nksrv.IntlServer
{
if (item.Username == ep.account)
{
- WriteJsonString("{\"msg\":\"send code failed; invalid account\",\"ret\":2112,\"seq\":\"" + seg + "\"}");
+ await WriteJsonStringAsync("{\"msg\":\"send code failed; invalid account\",\"ret\":2112,\"seq\":\"" + seg + "\"}");
return;
}
}
// pretend that we sent the code
- WriteJsonString("{\"expire_time\":898,\"msg\":\"Success\",\"ret\":0,\"seq\":\"" + seg + "\"}");
+ await WriteJsonStringAsync("{\"expire_time\":898,\"msg\":\"Success\",\"ret\":0,\"seq\":\"" + seg + "\"}");
}
else
{
@@ -46,11 +46,11 @@ namespace nksrv.IntlServer
public class SendCodeRequest
{
- public DeviceInfo device_info { get; set; }
- public string extra_json { get; set; }
- public string account { get; set; }
+ public DeviceInfo device_info { get; set; } = new();
+ public string extra_json { get; set; } = "";
+ public string account { get; set; } = "";
public int account_type { get; set; }
- public string phone_area_code { get; set; }
+ public string phone_area_code { get; set; } = "";
public int code_type { get; set; }
public int support_captcha { get; set; }
}
diff --git a/nksrv/LobbyServer/LobbyHandler.cs b/nksrv/LobbyServer/LobbyHandler.cs
index fb09ca1..eebb678 100644
--- a/nksrv/LobbyServer/LobbyHandler.cs
+++ b/nksrv/LobbyServer/LobbyHandler.cs
@@ -38,9 +38,6 @@ namespace nksrv.LobbyServer
}
public static async Task DispatchSingle(IHttpContext ctx)
{
- //var x = new RedirectionHandler();
- //await x.HandleAsync(ctx);
- //return;
LobbyMsgHandler? handler = null;
foreach (var item in Handlers)
{
@@ -53,11 +50,9 @@ namespace nksrv.LobbyServer
if (handler == null)
{
ctx.Response.StatusCode = 404;
- //Logger.Error("HTTPS: No handler for /v1/" + ctx.RequestedPath);
}
else
{
- // todo move everClass1.csything to its own handler
handler.Reset();
await handler.HandleAsync(ctx);
return;
@@ -75,7 +70,6 @@ namespace nksrv.LobbyServer
var info = new GameClientInfo() { ClientPublicKey = publicKey.ToArray() };
-
var box = SodiumKeyExchange.CalculateServerSharedSecret(JsonDb.ServerPublicKey, JsonDb.ServerPrivateKey, publicKey.ToArray());
info.Keys = box;
@@ -157,19 +151,18 @@ namespace nksrv.LobbyServer
///
/// Client public key generated by game client
///
- public byte[] ClientPublicKey;
+ public byte[] ClientPublicKey = [];
///
/// Authentication token
///
- public string ClientAuthToken;
+ public string ClientAuthToken = "";
///
/// Rx/Tx key pair
///
- public SodiumKeyExchangeSharedSecretBox Keys;
+ public SodiumKeyExchangeSharedSecretBox Keys = new();
///
/// User ID of the user
///
public ulong UserId;
-
}
}
diff --git a/nksrv/LobbyServer/Msgs/Antibot/BattleReportData.cs b/nksrv/LobbyServer/Msgs/Antibot/BattleReportData.cs
index 5348259..3a8e808 100644
--- a/nksrv/LobbyServer/Msgs/Antibot/BattleReportData.cs
+++ b/nksrv/LobbyServer/Msgs/Antibot/BattleReportData.cs
@@ -12,12 +12,11 @@ namespace nksrv.LobbyServer.Msgs.Antibot
{
protected override async Task HandleAsync()
{
- var req = ReadData();
-
- // I don't really care about reimplementing the server side anticheat, so return
-
+ var req = await ReadData();
var response = new ResBattleReportData();
+ // this is responsible for server side anticheat
+
WriteData(response);
}
}
diff --git a/nksrv/LobbyServer/Msgs/Badge/DeleteBadge.cs b/nksrv/LobbyServer/Msgs/Badge/DeleteBadge.cs
index 600826a..b38850d 100644
--- a/nksrv/LobbyServer/Msgs/Badge/DeleteBadge.cs
+++ b/nksrv/LobbyServer/Msgs/Badge/DeleteBadge.cs
@@ -12,7 +12,7 @@ namespace nksrv.LobbyServer.Msgs.Badge
{
protected override async Task HandleAsync()
{
- var req = ReadData();
+ var req = await ReadData();
var response = new ResDeleteBadge();
diff --git a/nksrv/LobbyServer/Msgs/Gacha/CheckGachaDailyEvent.cs b/nksrv/LobbyServer/Msgs/Gacha/CheckGachaDailyEvent.cs
index ae6d920..86804a6 100644
--- a/nksrv/LobbyServer/Msgs/Gacha/CheckGachaDailyEvent.cs
+++ b/nksrv/LobbyServer/Msgs/Gacha/CheckGachaDailyEvent.cs
@@ -12,12 +12,12 @@ namespace nksrv.LobbyServer.Msgs.Gacha
{
protected override async Task HandleAsync()
{
- var req = ReadData();
+ var req = await ReadData();
var response = new ResCheckDailyFreeGacha();
// TODO implement
- response.FreeCount = 1000;
+ response.FreeCount = 0;
response.EventData = new NetEventData() { Id = 1 };
WriteData(response);
diff --git a/nksrv/LobbyServer/Msgs/Messenger/GetPickedMessage.cs b/nksrv/LobbyServer/Msgs/Messenger/GetPickedMessage.cs
index b391366..2b16ea4 100644
--- a/nksrv/LobbyServer/Msgs/Messenger/GetPickedMessage.cs
+++ b/nksrv/LobbyServer/Msgs/Messenger/GetPickedMessage.cs
@@ -12,7 +12,7 @@ namespace nksrv.LobbyServer.Msgs.Messenger
{
protected override async Task HandleAsync()
{
- var req = ReadData();
+ var req = await ReadData();
// TODO: get proper response
var response = new ResGetPickedMessageList();
diff --git a/nksrv/LobbyServer/Msgs/Messenger/GetRandomPick.cs b/nksrv/LobbyServer/Msgs/Messenger/GetRandomPick.cs
index 174883f..f6c65de 100644
--- a/nksrv/LobbyServer/Msgs/Messenger/GetRandomPick.cs
+++ b/nksrv/LobbyServer/Msgs/Messenger/GetRandomPick.cs
@@ -12,7 +12,7 @@ namespace nksrv.LobbyServer.Msgs.Messenger
{
protected override async Task HandleAsync()
{
- var req = ReadData();
+ var req = await ReadData();
// TODO: get proper response
var response = new ResForcePickTodayRandomMessage();
diff --git a/nksrv/LobbyServer/Msgs/Messenger/ProceedMsg.cs b/nksrv/LobbyServer/Msgs/Messenger/ProceedMsg.cs
index 9c3b6ab..9d854c6 100644
--- a/nksrv/LobbyServer/Msgs/Messenger/ProceedMsg.cs
+++ b/nksrv/LobbyServer/Msgs/Messenger/ProceedMsg.cs
@@ -7,7 +7,7 @@ namespace nksrv.LobbyServer.Msgs.Messenger
{
protected override async Task HandleAsync()
{
- var req = ReadData();
+ var req = await ReadData();
// TODO: save these things
var response = new ResProceedMessage();
diff --git a/nksrv/LobbyServer/Msgs/Mission/Rewards/GetDailyRewards.cs b/nksrv/LobbyServer/Msgs/Mission/Rewards/GetDailyRewards.cs
index ddf7dd1..94f67bd 100644
--- a/nksrv/LobbyServer/Msgs/Mission/Rewards/GetDailyRewards.cs
+++ b/nksrv/LobbyServer/Msgs/Mission/Rewards/GetDailyRewards.cs
@@ -12,7 +12,7 @@ namespace nksrv.LobbyServer.Msgs.Mission.Rewards
{
protected override async Task HandleAsync()
{
- var req = ReadData();
+ var req = await ReadData();
// TODO: implement
var response = new ResGetDailyRewardedData();
diff --git a/nksrv/LobbyServer/Msgs/Mission/Rewards/GetJukeboxRewards.cs b/nksrv/LobbyServer/Msgs/Mission/Rewards/GetJukeboxRewards.cs
index 34cd6c2..69a7a4d 100644
--- a/nksrv/LobbyServer/Msgs/Mission/Rewards/GetJukeboxRewards.cs
+++ b/nksrv/LobbyServer/Msgs/Mission/Rewards/GetJukeboxRewards.cs
@@ -7,7 +7,7 @@ namespace nksrv.LobbyServer.Msgs.Outpost
{
protected override async Task HandleAsync()
{
- var req = ReadData();
+ var req = await ReadData();
// TODO: save these things
var response = new ResGetJukeboxRewardedData();
diff --git a/nksrv/LobbyServer/Msgs/RedirectionHandler.cs b/nksrv/LobbyServer/Msgs/RedirectionHandler.cs
deleted file mode 100644
index 6b7af2e..0000000
--- a/nksrv/LobbyServer/Msgs/RedirectionHandler.cs
+++ /dev/null
@@ -1,69 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Net.Http.Headers;
-using System.Net;
-using System.Text;
-using System.Threading.Tasks;
-using EmbedIO;
-using nksrv.Utils;
-using Sodium;
-using System.IO.Compression;
-
-namespace nksrv.LobbyServer.Msgs
-{
- public class RedirectionHandler : LobbyMsgHandler
- {
- protected override async Task HandleAsync()
- {
- byte[] reqBody = ctx == null ? Contents : (await DecryptOrReturnContentAsync(ctx)).Contents;
-
- HttpClientHandler handler = new HttpClientHandler()
- {
- AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate,
- AllowAutoRedirect = true // from gameassembly dll
- };
-
- HttpClient client = new(new LoggingHttpHandler(handler));
- client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/octet-stream+protobuf"));
- client.BaseAddress = new Uri("https://global-lobby.nikke-kr.com");
- client.DefaultRequestVersion = HttpVersion.Version20;
- var systemContent = new ByteArrayContent(reqBody);
- systemContent.Headers.Remove("Content-Type");
- if (ctx.Request.ContentLength64 != 0)
- systemContent.Headers.Add("Content-Type", "application/octet-stream+protobuf");
- systemContent.Headers.Add("Content-Length", ctx.Request.ContentLength64.ToString());
-
- // request.Content = systemContent;// CONTENT-TYPE header
-
-
- var result = await client.PostAsync(ctx.Request.RawUrl, systemContent);
- var bt = await result.Content.ReadAsByteArrayAsync();
-
- ctx.Response.ContentEncoding = null;
- ctx.Response.ContentType = result.Content.Headers.GetValues("Content-Type").First();
- ctx.Response.ContentLength64 = bt.Length;
- ctx.Response.OutputStream.Write(bt, 0, bt.Length);
- ctx.Response.OutputStream.Flush();
- }
-
- public static async Task DecryptOrReturnContentAsync(IHttpContext ctx)
- {
- using MemoryStream buffer = new MemoryStream();
-
- var stream = ctx.Request.InputStream;
-
- var encoding = ctx.Request.Headers[HttpHeaderNames.ContentEncoding]?.Trim();
- Stream decryptedStream = encoding switch
- {
- CompressionMethodNames.Gzip => new GZipStream(stream, CompressionMode.Decompress),
- CompressionMethodNames.Deflate => new DeflateStream(stream, CompressionMode.Decompress),
- CompressionMethodNames.None or null => stream,
- "gzip,enc" => stream,
- _ => throw HttpException.BadRequest($"Unsupported content encoding \"{encoding}\""),
- };
- await stream.CopyToAsync(buffer, 81920, ctx.CancellationToken).ConfigureAwait(continueOnCapturedContext: false);
- return new PacketDecryptResponse() { Contents = buffer.ToArray() };
- }
- }
-}
diff --git a/nksrv/LobbyServer/Msgs/Stage/EnterStage.cs b/nksrv/LobbyServer/Msgs/Stage/EnterStage.cs
index aaad112..8aa78c3 100644
--- a/nksrv/LobbyServer/Msgs/Stage/EnterStage.cs
+++ b/nksrv/LobbyServer/Msgs/Stage/EnterStage.cs
@@ -12,7 +12,7 @@ namespace nksrv.LobbyServer.Msgs.Stage
{
protected override async Task HandleAsync()
{
- var req = ReadData();
+ var req = await ReadData();
var response = new ResEnterStage();
diff --git a/nksrv/StaticInfo/StageCompletionReward.cs b/nksrv/StaticInfo/StageCompletionReward.cs
deleted file mode 100644
index 989abe1..0000000
--- a/nksrv/StaticInfo/StageCompletionReward.cs
+++ /dev/null
@@ -1,55 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace nksrv.StaticInfo
-{
- public static class StageCompletionReward
- {
- //
- public static readonly Dictionary RewardData =
- new() {
- // Chapter 0
- { 6000001, new NetRewardData() { Currency = {
- new NetCurrencyData() { Type = (int)CurrencyType.Gold, Value = 500 },
- new NetCurrencyData() { Type = (int)CurrencyType.CharacterExp , Value = 600 }
- } }
- },
- { 6000002, new NetRewardData() { Currency = {
- new NetCurrencyData() { Type = (int)CurrencyType.Gold, Value = 500 },
- new NetCurrencyData() { Type = (int)CurrencyType.CharacterExp , Value = 600 }
- } }
- },
- { 6000003, new NetRewardData() { Currency = {
- new NetCurrencyData() { Type = (int)CurrencyType.Gold, Value = 500 },
- new NetCurrencyData() { Type = (int)CurrencyType.CharacterExp , Value = 600 }
- } }
- },
- // Chapter 1
- { 6001001, new NetRewardData() { Currency = {
- new NetCurrencyData() { Type = (int)CurrencyType.Gold, Value = 1000 },
- new NetCurrencyData() { Type = (int)CurrencyType.CharacterExp , Value = 1200 }
- } }
- },
- { 6001002, new NetRewardData() { Currency = {
- new NetCurrencyData() { Type = (int)CurrencyType.Gold, Value = 1000 },
- new NetCurrencyData() { Type = (int)CurrencyType.CharacterExp , Value = 1200 }
- } }
- },
- { 6001003, new NetRewardData() { Currency = {
- new NetCurrencyData() { Type = (int)CurrencyType.Gold, Value = 1000 },
- new NetCurrencyData() { Type = (int)CurrencyType.CharacterExp , Value = 1200 }
- } }
- },
- { 6001004, new NetRewardData() { Currency = {
- new NetCurrencyData() { Type = (int)CurrencyType.Gold, Value = 1000 },
- new NetCurrencyData() { Type = (int)CurrencyType.CharacterExp , Value = 1200 }
-
- // todo include the other items
- } }
- },
- };
- }
-}
diff --git a/nksrv/StaticInfo/StaticDataParser.cs b/nksrv/StaticInfo/StaticDataParser.cs
index 5353eb6..5f70fb6 100644
--- a/nksrv/StaticInfo/StaticDataParser.cs
+++ b/nksrv/StaticInfo/StaticDataParser.cs
@@ -175,12 +175,13 @@ namespace nksrv.StaticInfo
{
string targetFile = Program.GetCachePathForPath(StaticDataUrl.Replace("https://cloud.nikke-kr.com", ""));
var targetDir = Path.GetDirectoryName(targetFile);
+ if (targetDir == null) throw new Exception("directory name is null for path " + targetDir);
Directory.CreateDirectory(targetDir);
if (!File.Exists(targetFile))
{
- // TODO: Ip might change
+ // TODO: IP might change
var requestUri = new Uri("https://43.132.66.200/" + StaticDataUrl.Replace("https://cloud.nikke-kr.com", ""));
using var request = new HttpRequestMessage(HttpMethod.Get, requestUri);
request.Headers.TryAddWithoutValidation("host", "cloud.nikke-kr.com");
@@ -346,7 +347,7 @@ namespace nksrv.StaticInfo
throw new Exception("expected id field in reward data");
}
- string value = id.ToObject();
+ string? value = id.ToObject();
if (value == field)
{
var chapter = item["chapter"];