mirror of
https://github.com/EpinelPS/EpinelPS.git
synced 2025-12-12 23:14:34 +01:00
remove old code
This commit is contained in:
@@ -1,89 +0,0 @@
|
||||
using EmbedIO;
|
||||
using EmbedIO.Routing;
|
||||
using EmbedIO.WebApi;
|
||||
using EpinelPS.Database;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace EpinelPS
|
||||
{
|
||||
public class AdminApiController : WebApiController
|
||||
{
|
||||
public static Dictionary<string, User> AdminAuthTokens = new();
|
||||
private static MD5 md5 = MD5.Create();
|
||||
[Route(HttpVerbs.Any, "/login")]
|
||||
public async Task Login()
|
||||
{
|
||||
var c = await HttpContext.GetRequestFormDataAsync();
|
||||
var username = c["username"];
|
||||
var password = c["password"];
|
||||
|
||||
if (HttpContext.Request.HttpMethod != "POST")
|
||||
{
|
||||
await HttpContext.SendStringAsync(File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "/www/admin/index.html").Replace("<errormsg/>", ""), "text/html", Encoding.Unicode);
|
||||
return;
|
||||
}
|
||||
|
||||
User? user = null;
|
||||
bool nullusernames = false;
|
||||
if (username != null && password != null)
|
||||
{
|
||||
var passwordHash = Convert.ToHexString(md5.ComputeHash(Encoding.ASCII.GetBytes(password))).ToLower();
|
||||
foreach (var item in JsonDb.Instance.Users)
|
||||
{
|
||||
if (item.Username == username)
|
||||
{
|
||||
if (item.Password.ToLower() == passwordHash)
|
||||
{
|
||||
user = item;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nullusernames = true;
|
||||
}
|
||||
|
||||
if (user == null)
|
||||
{
|
||||
if (nullusernames == false)
|
||||
{
|
||||
await HttpContext.SendStringAsync((string)File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "/www/admin/index.html").Replace("<errormsg/>", "Incorrect username or password"), "text/html", Encoding.Unicode);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
await HttpContext.SendStringAsync((string)File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "/www/admin/index.html").Replace("<errormsg/>", "Please enter a username or password"), "text/html", Encoding.Unicode);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (user.IsAdmin)
|
||||
{
|
||||
Response.Headers.Add("Set-Cookie", "token=" + CreateAuthToken(user) + ";path=/");
|
||||
HttpContext.Redirect("/admin/", 301);
|
||||
}
|
||||
else
|
||||
{
|
||||
await HttpContext.SendStringAsync((string)File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "/www/admin/index.html").Replace("<errormsg/>", "User does not have admin panel access."), "text/html", Encoding.Unicode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static string CreateAuthToken(User user)
|
||||
{
|
||||
var tok = RandomString(128);
|
||||
AdminAuthTokens.Add(tok, user);
|
||||
return tok;
|
||||
}
|
||||
|
||||
public static string RandomString(int length)
|
||||
{
|
||||
const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
return new string(Enumerable.Repeat(chars, length)
|
||||
.Select(s => s[new Random().Next(s.Length)]).ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,6 @@
|
||||
using EpinelPS.Database;
|
||||
using EpinelPS.IntlServer;
|
||||
using EpinelPS.Utils;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Org.BouncyCastle.Ocsp;
|
||||
using Swan.Logging;
|
||||
using static EpinelPS.IntlServer.IntlAccountRegisterEndpoint;
|
||||
using static EpinelPS.IntlServer.IntlLogin1Endpoint;
|
||||
using static EpinelPS.IntlServer.IntlLogin2Endpoint;
|
||||
using static EpinelPS.IntlServer.IntlMsgHandler;
|
||||
using static EpinelPS.IntlServer.SendCodeEndpoint;
|
||||
|
||||
namespace EpinelPS.Controllers
|
||||
{
|
||||
@@ -27,7 +18,7 @@ namespace EpinelPS.Controllers
|
||||
{
|
||||
if (item.Username == req.account && item.Password == req.password)
|
||||
{
|
||||
var tok = IntlHandler.CreateLauncherTokenForUser(item);
|
||||
var tok = CreateLauncherTokenForUser(item);
|
||||
item.LastLogin = DateTime.UtcNow;
|
||||
JsonDb.Save();
|
||||
|
||||
@@ -96,9 +87,20 @@ namespace EpinelPS.Controllers
|
||||
|
||||
JsonDb.Instance.Users.Add(user);
|
||||
|
||||
var tok = IntlHandler.CreateLauncherTokenForUser(user);
|
||||
var tok = CreateLauncherTokenForUser(user);
|
||||
|
||||
return "{\"expire\":" + tok.ExpirationTime + ",\"is_login\":false,\"msg\":\"Success\",\"register_time\":" + user.RegisterTime + ",\"ret\":0,\"seq\":\"" + seq + "\",\"token\":\"" + tok.Token + "\",\"uid\":\"" + user.ID + "\"}";
|
||||
}
|
||||
public static AccessToken CreateLauncherTokenForUser(User user)
|
||||
{
|
||||
// TODO: implement access token expiration
|
||||
AccessToken token = new() { ExpirationTime = DateTimeOffset.UtcNow.AddYears(1).ToUnixTimeSeconds() };
|
||||
token.Token = Rng.RandomString(64);
|
||||
token.UserID = user.ID;
|
||||
JsonDb.Instance.LauncherAccessTokens.Add(token);
|
||||
JsonDb.Save();
|
||||
|
||||
return token;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
using EpinelPS.Database;
|
||||
using EpinelPS.Utils;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Org.BouncyCastle.Ocsp;
|
||||
using static EpinelPS.IntlServer.IntlLogin1Endpoint;
|
||||
using static EpinelPS.IntlServer.IntlLogin2Endpoint;
|
||||
using static EpinelPS.IntlServer.IntlMsgHandler;
|
||||
|
||||
namespace EpinelPS.Controllers
|
||||
{
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
using Newtonsoft.Json;
|
||||
using EpinelPS.LobbyServer;
|
||||
using EpinelPS.LobbyServer;
|
||||
using EpinelPS.StaticInfo;
|
||||
using EpinelPS.Utils;
|
||||
using Swan.Logging;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using static Google.Rpc.Context.AttributeContext.Types;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace EpinelPS.Database
|
||||
{
|
||||
@@ -301,7 +298,7 @@ namespace EpinelPS.Database
|
||||
{
|
||||
if (!File.Exists(AppDomain.CurrentDomain.BaseDirectory + "/db.json"))
|
||||
{
|
||||
"users: warning: configuration not found, writing default data".Warn();
|
||||
Console.WriteLine("users: warning: configuration not found, writing default data");
|
||||
Instance = new CoreInfo();
|
||||
Save();
|
||||
}
|
||||
@@ -369,7 +366,7 @@ namespace EpinelPS.Database
|
||||
Save();
|
||||
|
||||
ValidateDb();
|
||||
"Loaded db".Info();
|
||||
Console.WriteLine("Loaded db");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -386,7 +383,7 @@ namespace EpinelPS.Database
|
||||
{
|
||||
if (c.Level > 1000)
|
||||
{
|
||||
$"Warning: Character level for character {c.Tid} cannot be above 1000, setting to 1000".Warn();
|
||||
Console.WriteLine($"Warning: Character level for character {c.Tid} cannot be above 1000, setting to 1000");
|
||||
c.Level = 1000;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ASodium" Version="0.6.1" />
|
||||
<PackageReference Include="DnsClient" Version="1.8.0" />
|
||||
<PackageReference Include="EmbedIO" Version="3.5.2" />
|
||||
<PackageReference Include="Google.Api.CommonProtos" Version="2.15.0" />
|
||||
<PackageReference Include="Google.Protobuf.Tools" Version="3.27.3" />
|
||||
<PackageReference Include="Grpc.AspNetCore" Version="2.65.0" />
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
using ICSharpCode.SharpZipLib.Zip;
|
||||
using EpinelPS.Utils;
|
||||
using ICSharpCode.SharpZipLib.Zip;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using EpinelPS.Utils;
|
||||
using Swan.Logging;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
@@ -49,7 +47,7 @@ namespace EpinelPS.StaticInfo
|
||||
{
|
||||
await Load();
|
||||
|
||||
Logger.Info("Preparing");
|
||||
Console.WriteLine("Preparing");
|
||||
var stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
await Instance.Parse();
|
||||
@@ -303,7 +301,7 @@ namespace EpinelPS.StaticInfo
|
||||
if (obj != null)
|
||||
LevelData.Add(obj.level, obj);
|
||||
else
|
||||
Logger.Warn("failed to read character level table entry");
|
||||
Console.WriteLine("failed to read character level table entry");
|
||||
}
|
||||
|
||||
var tacticLessonTable = await LoadZip("TacticAcademyFunctionTable.json", progress);
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
namespace EpinelPS.IntlServer
|
||||
{
|
||||
internal class AutoLoginEndpoint : IntlMsgHandler
|
||||
{
|
||||
public override bool RequiresAuth => true;
|
||||
|
||||
protected override async Task HandleAsync()
|
||||
{
|
||||
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 + "\"}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
namespace EpinelPS.IntlServer
|
||||
{
|
||||
public class CodeStatusEndpoint : IntlMsgHandler
|
||||
{
|
||||
public override bool RequiresAuth => false;
|
||||
|
||||
protected override async Task HandleAsync()
|
||||
{
|
||||
// pretend that any code is valid
|
||||
await WriteJsonStringAsync("{\"expire_time\":759,\"msg\":\"Success\",\"ret\":0,\"seq\":\"" + Seq + "\"}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
namespace EpinelPS.IntlServer
|
||||
{
|
||||
public class GetNoticeContent : IntlMsgHandler
|
||||
{
|
||||
public override bool RequiresAuth => false;
|
||||
|
||||
protected override async Task HandleAsync()
|
||||
{
|
||||
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\": 1819431999,\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}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
using EpinelPS.Utils;
|
||||
using System.Net;
|
||||
using System.Net.Http.Headers;
|
||||
|
||||
namespace EpinelPS.IntlServer
|
||||
{
|
||||
/// <summary>
|
||||
/// redirect for /account endponts
|
||||
/// </summary>
|
||||
public class IntlAccountRedirect : IntlMsgHandler
|
||||
{
|
||||
public override bool RequiresAuth => false;
|
||||
|
||||
protected override async Task HandleAsync()
|
||||
{
|
||||
if (ctx == null) throw new Exception("ctx cannot be null");
|
||||
Console.WriteLine("li-sg 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 HttpRequestMessage(HttpMethod.Post, "https://49.51.129.135" + ctx.Request.RawUrl);
|
||||
request.Version = HttpVersion.Version11;
|
||||
request.Headers.TryAddWithoutValidation("Host", "li-sg.intlgame.com");
|
||||
|
||||
var systemContent = new StringContent(Content);
|
||||
systemContent.Headers.Remove("Content-Type");
|
||||
systemContent.Headers.Add("Content-Type", "application/json");
|
||||
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();
|
||||
await WriteJsonStringAsync(s);
|
||||
Console.WriteLine("li-sg redirect out: " + s);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
using EmbedIO;
|
||||
using Newtonsoft.Json;
|
||||
using EpinelPS.Database;
|
||||
using EpinelPS.Utils;
|
||||
using System.Net;
|
||||
using static EpinelPS.IntlServer.IntlLogin2Endpoint;
|
||||
|
||||
namespace EpinelPS.IntlServer
|
||||
{
|
||||
public class IntlAccountRegisterEndpoint : IntlMsgHandler
|
||||
{
|
||||
public override bool RequiresAuth => false;
|
||||
|
||||
protected override async Task HandleAsync()
|
||||
{
|
||||
RegisterEPReq? ep = JsonConvert.DeserializeObject<RegisterEPReq>(Content);
|
||||
if (ep != null)
|
||||
{
|
||||
// check if the account already exists
|
||||
foreach (var item in JsonDb.Instance.Users)
|
||||
{
|
||||
if (item.Username == ep.account)
|
||||
{
|
||||
await WriteJsonStringAsync("{\"msg\":\"send code failed; invalid account\",\"ret\":2112,\"seq\":\"" + Seq + "\"}");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var uid = (ulong)new Random().Next(1, int.MaxValue);
|
||||
|
||||
// Check if we havent generated a UID that exists
|
||||
foreach (var item in JsonDb.Instance.Users)
|
||||
{
|
||||
if (item.ID == uid)
|
||||
{
|
||||
uid -= (ulong)new Random().Next(1, 1221);
|
||||
}
|
||||
}
|
||||
|
||||
var user = new User() { ID = uid, Password = ep.password, RegisterTime = DateTimeOffset.UtcNow.ToUnixTimeSeconds(), Username = ep.account, PlayerName = "Player_" + Rng.RandomString(8) };
|
||||
|
||||
JsonDb.Instance.Users.Add(user);
|
||||
|
||||
var tok = IntlHandler.CreateLauncherTokenForUser(user);
|
||||
await WriteJsonStringAsync("{\"expire\":" + tok.ExpirationTime + ",\"is_login\":false,\"msg\":\"Success\",\"register_time\":" + user.RegisterTime + ",\"ret\":0,\"seq\":\"" + Seq + "\",\"token\":\"" + tok.Token + "\",\"uid\":\"" + user.ID + "\"}");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new HttpException(HttpStatusCode.BadRequest);
|
||||
}
|
||||
}
|
||||
|
||||
public class RegisterEPReq
|
||||
{
|
||||
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; } = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
namespace EpinelPS.IntlServer
|
||||
{
|
||||
internal class IntlGetAccountInfo : IntlMsgHandler
|
||||
{
|
||||
public override bool RequiresAuth => true;
|
||||
|
||||
protected override async Task HandleAsync()
|
||||
{
|
||||
if (User == null || UsedToken == null)
|
||||
throw new Exception("no user"); // should never happen
|
||||
|
||||
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}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
|
||||
namespace EpinelPS.IntlServer
|
||||
{
|
||||
internal class IntlGetProfileBindInfo : IntlMsgHandler
|
||||
{
|
||||
public override bool RequiresAuth => true;
|
||||
|
||||
protected override async Task HandleAsync()
|
||||
{
|
||||
if (User == null)
|
||||
throw new Exception("no user"); // should never happen
|
||||
|
||||
|
||||
// TODO: last login time, but is it needed?
|
||||
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 + "\"}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
namespace EpinelPS.IntlServer
|
||||
{
|
||||
public class IntlGetProfileInfo : IntlMsgHandler
|
||||
{
|
||||
public override bool RequiresAuth => true;
|
||||
|
||||
protected override async Task HandleAsync()
|
||||
{
|
||||
if (User == null)
|
||||
throw new Exception("no user"); // should never happen
|
||||
|
||||
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 + "\"}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
using EmbedIO;
|
||||
using EpinelPS.Database;
|
||||
using EpinelPS.Utils;
|
||||
|
||||
namespace EpinelPS.IntlServer
|
||||
{
|
||||
public static class IntlHandler
|
||||
{
|
||||
public static Dictionary<string, IntlMsgHandler> Handlers = new Dictionary<string, IntlMsgHandler>()
|
||||
{
|
||||
{"/login", new IntlLogin1Endpoint() }, // /account/login
|
||||
{"/auth/login", new IntlLogin2Endpoint() }, // /v2/auth/login
|
||||
{"/sendcode", new SendCodeEndpoint() }, // /account/sendcode
|
||||
{"/codestatus", new CodeStatusEndpoint() }, //
|
||||
{"/register", new IntlAccountRegisterEndpoint() }, // /account/register
|
||||
{"/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
|
||||
{"/profile/set_protocol", new IntlReturnJsonHandler(SetProtocolResp) },
|
||||
{"/profile/userinfo", new IntlGetProfileInfo() },
|
||||
{"/getuserinfo", new IntlGetAccountInfo() },
|
||||
{"/lbs/ipregion", new IntlReturnJsonHandler(IpRegionResp) },
|
||||
{"/profile/get_bind_info", new IntlGetProfileBindInfo() },
|
||||
{"/gnconfig/acquire_config", new IntlReturnJsonHandler(AquireConfigResp) },
|
||||
{"/auth/auto_login", new AutoLoginEndpoint() },
|
||||
{"/reward/send", new IntlReturnJsonHandler(SetProtocolResp) }, // /v2/reward/send
|
||||
{"/notice/get_notice_content", new GetNoticeContent() }, // /v2/notice/get_notice_content
|
||||
{"/fleet.repo.game.RepoSVC/GetVersion", new JuniperLauncherGetRepoVersion() }, // /api/v1/fleet.repo.game.RepoSVC/GetVersion
|
||||
{"/fleet.repo.game.RepoMgr/GetGameLauncher", new JuniperLauncherGetGameLauncher() }, // /api/v1/fleet.repo.game.RepoMgr/
|
||||
{"/fleet.repo.game.RepoSVC/GetRegion", new JuniperLauncherGetRegion() }, // /api/v1/fleet.repo.game.RepoMgr/ // GetGameLauncher
|
||||
{"/fleet.auth.game.AuthSvr/Login", new JupiterAuthLogin() } // /api/v1/fleet.auth.game.AuthSvr/Login
|
||||
};
|
||||
public const string GetConfResp = "{\"conf_version\":\"102\",\"msg\":\"\",\"ret\":1,\"seq\":\"((SEGID))\"}";
|
||||
public const string MinorcerResp = "{\"adult_age\":15,\"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\":\"300\",\"ret\":0,\"seq\":\"((SEGID))\",\"ts\":\"1719156511\"}";
|
||||
public const string SetProtocolResp = "{\"msg\":\"success\",\"ret\":0,\"seq\":\"((SEGID))\"}";
|
||||
public const string IpRegionResp = "{\"alpha2\":\"GR\",\"extra_json\":{\"certificate_type_map\":{}},\"msg\":\"success\",\"region\":\"300\",\"ret\":0,\"seq\":\"((SEGID))\",\"timestamp\":324234322}";
|
||||
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)
|
||||
{
|
||||
IntlMsgHandler? handler = null;
|
||||
foreach (var item in Handlers)
|
||||
{
|
||||
if (context.RequestedPath == item.Key)
|
||||
{
|
||||
handler = item.Value;
|
||||
}
|
||||
}
|
||||
|
||||
if (handler == null)
|
||||
{
|
||||
context.Response.StatusCode = 404;
|
||||
}
|
||||
else
|
||||
{
|
||||
handler.Reset();
|
||||
await handler.HandleAsync(context);
|
||||
}
|
||||
}
|
||||
|
||||
public static AccessToken CreateLauncherTokenForUser(User user)
|
||||
{
|
||||
// TODO: implement access token expiration
|
||||
AccessToken token = new() { ExpirationTime = DateTimeOffset.UtcNow.AddYears(1).ToUnixTimeSeconds() };
|
||||
token.Token = Rng.RandomString(64);
|
||||
token.UserID = user.ID;
|
||||
JsonDb.Instance.LauncherAccessTokens.Add(token);
|
||||
JsonDb.Save();
|
||||
|
||||
return token;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
using EmbedIO;
|
||||
using Newtonsoft.Json;
|
||||
using EpinelPS.Database;
|
||||
using System.Net;
|
||||
using static EpinelPS.IntlServer.IntlLogin2Endpoint;
|
||||
|
||||
namespace EpinelPS.IntlServer
|
||||
{
|
||||
public class IntlLogin1Endpoint : IntlMsgHandler
|
||||
{
|
||||
public override bool RequiresAuth => false;
|
||||
|
||||
protected override async Task HandleAsync()
|
||||
{
|
||||
LoginEndpoint2Req? ep = JsonConvert.DeserializeObject<LoginEndpoint2Req>(Content);
|
||||
if (ep != null)
|
||||
{
|
||||
foreach (var item in JsonDb.Instance.Users)
|
||||
{
|
||||
if (item.Username == ep.account && item.Password == ep.password)
|
||||
{
|
||||
var tok = IntlHandler.CreateLauncherTokenForUser(item);
|
||||
item.LastLogin = DateTime.UtcNow;
|
||||
JsonDb.Save();
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
await WriteJsonStringAsync("{\"msg\":\"the account does not exists!\",\"ret\":2001,\"seq\":\"" + Seq + "\"}");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new HttpException(HttpStatusCode.BadRequest);
|
||||
}
|
||||
}
|
||||
|
||||
public class LoginEndpoint2Req
|
||||
{
|
||||
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 int support_captcha { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
using EmbedIO;
|
||||
using Newtonsoft.Json;
|
||||
using EpinelPS.Database;
|
||||
using System.Net;
|
||||
|
||||
namespace EpinelPS.IntlServer
|
||||
{
|
||||
/// <summary>
|
||||
/// This handles the login endpoint.
|
||||
/// </summary>
|
||||
public class IntlLogin2Endpoint : IntlMsgHandler
|
||||
{
|
||||
public override bool RequiresAuth => false;
|
||||
|
||||
protected override async Task HandleAsync()
|
||||
{
|
||||
LoginEndpoint1Req? ep = JsonConvert.DeserializeObject<LoginEndpoint1Req>(Content);
|
||||
if (ep != null)
|
||||
{
|
||||
foreach (var tok in JsonDb.Instance.LauncherAccessTokens)
|
||||
{
|
||||
if (tok.Token == ep.channel_info.account_token)
|
||||
{
|
||||
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.
|
||||
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;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
throw new HttpException(HttpStatusCode.MultipleChoices);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new HttpException(HttpStatusCode.BadRequest);
|
||||
}
|
||||
}
|
||||
|
||||
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 int screen_height { get; set; }
|
||||
public int screen_width { 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 class LoginEndpoint1Req
|
||||
{
|
||||
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; } = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,129 +0,0 @@
|
||||
using EmbedIO;
|
||||
using Newtonsoft.Json;
|
||||
using EpinelPS.Database;
|
||||
using Swan.Logging;
|
||||
using System.Text;
|
||||
|
||||
namespace EpinelPS.IntlServer
|
||||
{
|
||||
public abstract class IntlMsgHandler
|
||||
{
|
||||
protected IHttpContext? ctx;
|
||||
protected string Content = "";
|
||||
protected User? User;
|
||||
protected string Seq = "";
|
||||
protected AccessToken? UsedToken;
|
||||
public abstract bool RequiresAuth { get; }
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
UsedToken = null;
|
||||
Seq = "";
|
||||
User = null;
|
||||
Content = "";
|
||||
ctx = null;
|
||||
}
|
||||
public async Task HandleAsync(IHttpContext ctx)
|
||||
{
|
||||
this.ctx = ctx;
|
||||
Content = await ctx.GetRequestBodyAsStringAsync();
|
||||
Seq = ctx.GetRequestQueryData().Get("seq") ?? "";
|
||||
if (RequiresAuth)
|
||||
{
|
||||
var x = JsonConvert.DeserializeObject<AuthPkt>(Content);
|
||||
string tokToCheck = "";
|
||||
if (x != null && x.channel_info != null && !string.IsNullOrEmpty(x.channel_info.account_token))
|
||||
{
|
||||
tokToCheck = x.channel_info.account_token;
|
||||
}
|
||||
else
|
||||
{
|
||||
var x2 = JsonConvert.DeserializeObject<AuthPkt2>(Content);
|
||||
if (x2 != null)
|
||||
{
|
||||
tokToCheck = x2.token;
|
||||
}
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(tokToCheck))
|
||||
throw new Exception("missing auth token");
|
||||
|
||||
if (x != null)
|
||||
{
|
||||
foreach (var tok in JsonDb.Instance.LauncherAccessTokens)
|
||||
{
|
||||
if (tok.Token == tokToCheck)
|
||||
{
|
||||
var user = JsonDb.Instance.Users.Find(x => x.ID == tok.UserID);
|
||||
if (user != null)
|
||||
{
|
||||
UsedToken = tok;
|
||||
User = user;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (User == null)
|
||||
{
|
||||
Logger.Warn("Unknown auth token");
|
||||
await WriteJsonStringAsync("{\"msg\":\"expired verify_code!\",\"ret\":2022,\"seq\":\"" + Seq + "\"}\r\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Warn("Failed to parse auth data");
|
||||
await WriteJsonStringAsync("{\"msg\":\"expired verify_code!\",\"ret\":2022,\"seq\":\"" + Seq + "\"}\r\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
await HandleAsync();
|
||||
}
|
||||
protected abstract Task HandleAsync();
|
||||
protected async Task WriteJsonStringAsync(string data, bool juniper = false)
|
||||
{
|
||||
if (ctx != null)
|
||||
{
|
||||
var bt = Encoding.UTF8.GetBytes(data);
|
||||
if (juniper)
|
||||
{
|
||||
ctx.Response.ContentEncoding = Encoding.UTF8;
|
||||
ctx.Response.ContentType = "application/json";
|
||||
}
|
||||
else
|
||||
{
|
||||
ctx.Response.ContentEncoding = null;
|
||||
ctx.Response.ContentType = "application/json";
|
||||
ctx.Response.ContentLength64 = bt.Length;
|
||||
}
|
||||
await ctx.Response.OutputStream.WriteAsync(bt, ctx.CancellationToken);
|
||||
await ctx.Response.OutputStream.FlushAsync();
|
||||
}
|
||||
}
|
||||
|
||||
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 AuthPkt
|
||||
{
|
||||
public ChannelInfo channel_info { get; set; } = new();
|
||||
}
|
||||
public class AuthPkt2
|
||||
{
|
||||
public string token { get; set; } = "";
|
||||
public string openid { get; set; } = "";
|
||||
public string account_token { get; set; } = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
namespace EpinelPS.IntlServer
|
||||
{
|
||||
internal class IntlQueryAccountInfo : IntlMsgHandler
|
||||
{
|
||||
public override bool RequiresAuth => true;
|
||||
|
||||
protected override async Task HandleAsync()
|
||||
{
|
||||
if (User == null) throw new Exception("user cannot be null");
|
||||
|
||||
// doesnt seem to be important, send some data
|
||||
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\":\"\"}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
namespace EpinelPS.IntlServer
|
||||
{
|
||||
public class IntlReturnJsonHandler : IntlMsgHandler
|
||||
{
|
||||
private string JsonToReturn;
|
||||
public override bool RequiresAuth => false;
|
||||
|
||||
public IntlReturnJsonHandler(string jsonToReturn)
|
||||
{
|
||||
JsonToReturn = jsonToReturn;
|
||||
}
|
||||
|
||||
protected override async Task HandleAsync()
|
||||
{
|
||||
await WriteJsonStringAsync(JsonToReturn.Replace("((SEGID))", Seq));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EpinelPS.IntlServer
|
||||
{
|
||||
internal class JuniperLauncherGetRegion : IntlMsgHandler
|
||||
{
|
||||
public override bool RequiresAuth => false;
|
||||
|
||||
protected override async Task HandleAsync()
|
||||
{
|
||||
await WriteJsonStringAsync(@"{
|
||||
""result"": {
|
||||
""error_code"": 0,
|
||||
""error_message"": ""success""
|
||||
},
|
||||
""region_info"": [
|
||||
{
|
||||
""game_id"": ""16601"",
|
||||
""region_id"": ""10001"",
|
||||
""region_name_en_us"": ""Global"",
|
||||
""region_name_i18n"": """",
|
||||
""region_description_en_us"": ""Nikke Global Version"",
|
||||
""region_description_i18n"": """",
|
||||
""bind_branches"": """",
|
||||
""meta_data"": """",
|
||||
""sequence"": 0,
|
||||
""status"": 2,
|
||||
""branch_info"": [
|
||||
{
|
||||
""game_id"": ""16601"",
|
||||
""branch_id"": ""1"",
|
||||
""branch_name"": ""Official_release"",
|
||||
""branch_type"": 0,
|
||||
""description"": ""正式发布环境 release包""
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EpinelPS.IntlServer
|
||||
{
|
||||
internal class JuniperLauncherGetRepoVersion : IntlMsgHandler
|
||||
{
|
||||
public override bool RequiresAuth => false;
|
||||
|
||||
protected override async Task HandleAsync()
|
||||
{
|
||||
await WriteJsonStringAsync(File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "gameversion.json")), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EpinelPS.IntlServer
|
||||
{
|
||||
internal class JupiterAuthLogin : IntlMsgHandler
|
||||
{
|
||||
public override bool RequiresAuth => false;
|
||||
|
||||
protected override async Task HandleAsync()
|
||||
{
|
||||
await WriteJsonStringAsync(@"{
|
||||
""result"": {
|
||||
""error_code"": 0,
|
||||
""error_message"": ""COMM_SUCC""
|
||||
},
|
||||
""channel"": 0,
|
||||
""game_id"": ""0"",
|
||||
""openid"": """",
|
||||
""uid"": """",
|
||||
""biz_ticket"": """",
|
||||
""expire_interval"": 0,
|
||||
""refresh_interval"": 0,
|
||||
""login_key"": """",
|
||||
""login_ticket"": """",
|
||||
""third_uid"": """"
|
||||
}", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EpinelPS.IntlServer
|
||||
{
|
||||
internal class JuniperLauncherGetGameLauncher : IntlMsgHandler
|
||||
{
|
||||
public override bool RequiresAuth => false;
|
||||
|
||||
protected override async Task HandleAsync()
|
||||
{
|
||||
await WriteJsonStringAsync(@"{
|
||||
""result"": {
|
||||
""error_code"": 0,
|
||||
""error_message"": ""COMM_SUCC""
|
||||
},
|
||||
""game_launcher_info"": [
|
||||
{
|
||||
""id"": 27,
|
||||
""execute_file"": ""NIKKE\\Game\\NIKKE.exe"",
|
||||
""param"": """",
|
||||
""description"": ""Nikke main process"",
|
||||
""os"": ""any"",
|
||||
""branch_id"": 0,
|
||||
""status"": 1,
|
||||
""param_type"": 1
|
||||
}
|
||||
]
|
||||
}", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
using EmbedIO;
|
||||
using Newtonsoft.Json;
|
||||
using EpinelPS.Database;
|
||||
using System.Net;
|
||||
using static EpinelPS.IntlServer.IntlLogin2Endpoint;
|
||||
|
||||
namespace EpinelPS.IntlServer
|
||||
{
|
||||
public class SendCodeEndpoint : IntlMsgHandler
|
||||
{
|
||||
public override bool RequiresAuth => false;
|
||||
|
||||
protected override async Task HandleAsync()
|
||||
{
|
||||
SendCodeRequest? ep = JsonConvert.DeserializeObject<SendCodeRequest>(Content);
|
||||
if (ep != null)
|
||||
{
|
||||
// check if the account already exists
|
||||
|
||||
foreach (var item in JsonDb.Instance.Users)
|
||||
{
|
||||
if (item.Username == ep.account)
|
||||
{
|
||||
await WriteJsonStringAsync("{\"msg\":\"send code failed; invalid account\",\"ret\":2112,\"seq\":\"" + Seq + "\"}");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// pretend that we sent the code
|
||||
await WriteJsonStringAsync("{\"expire_time\":898,\"msg\":\"Success\",\"ret\":0,\"seq\":\"" + Seq + "\"}");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new HttpException(HttpStatusCode.BadRequest);
|
||||
}
|
||||
}
|
||||
|
||||
public class SendCodeRequest
|
||||
{
|
||||
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 int code_type { get; set; }
|
||||
public int support_captcha { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,7 @@
|
||||
using ASodium;
|
||||
using EmbedIO;
|
||||
using Google.Protobuf;
|
||||
using EpinelPS.Database;
|
||||
using EpinelPS.Utils;
|
||||
using Swan.Logging;
|
||||
using Google.Protobuf;
|
||||
|
||||
namespace EpinelPS.LobbyServer
|
||||
{
|
||||
@@ -19,7 +17,7 @@ namespace EpinelPS.LobbyServer
|
||||
var attrib = (PacketPathAttribute?)Attribute.GetCustomAttribute(type, typeof(PacketPathAttribute));
|
||||
if (attrib == null)
|
||||
{
|
||||
Logger.Error("WARNING: Failed to get attribute for " + type.FullName);
|
||||
Console.WriteLine("WARNING: Failed to get attribute for " + type.FullName);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -31,7 +29,7 @@ namespace EpinelPS.LobbyServer
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Error($"WARNING: Type {type.FullName} has PacketPathAttribute but does not implement LobbyMsgHandler");
|
||||
Console.WriteLine($"WARNING: Type {type.FullName} has PacketPathAttribute but does not implement LobbyMsgHandler");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
using EmbedIO;
|
||||
using EpinelPS.Database;
|
||||
using EpinelPS.Utils;
|
||||
using Google.Protobuf;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using EpinelPS.Database;
|
||||
using EpinelPS.Utils;
|
||||
|
||||
namespace EpinelPS.LobbyServer.Msgs.Auth
|
||||
{
|
||||
@@ -22,7 +21,7 @@ namespace EpinelPS.LobbyServer.Msgs.Auth
|
||||
UserId = item.UserID;
|
||||
}
|
||||
}
|
||||
if (UserId == 0) throw new HttpException(403);
|
||||
if (UserId == 0) throw new BadHttpRequestException("unknown auth token", 403);
|
||||
|
||||
var user = GetUser();
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using EmbedIO;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using EpinelPS.Database;
|
||||
using EpinelPS.Database;
|
||||
using EpinelPS.Utils;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
|
||||
namespace EpinelPS.LobbyServer.Msgs.Auth
|
||||
{
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using EpinelPS.LobbyServer.Msgs.Stage;
|
||||
using EpinelPS.StaticInfo;
|
||||
using EpinelPS.Utils;
|
||||
using Swan.Logging;
|
||||
|
||||
namespace EpinelPS.LobbyServer.Msgs.Campaign
|
||||
{
|
||||
@@ -26,7 +25,7 @@ namespace EpinelPS.LobbyServer.Msgs.Campaign
|
||||
{
|
||||
if (item.PositionId == req.FieldObject.PositionId)
|
||||
{
|
||||
Logger.Warn("attempted to collect campaign field object twice!");
|
||||
Console.WriteLine("attempted to collect campaign field object twice!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using EpinelPS.Database;
|
||||
using EpinelPS.StaticInfo;
|
||||
using EpinelPS.Utils;
|
||||
using Swan.Logging;
|
||||
|
||||
namespace EpinelPS.LobbyServer.Msgs.Character
|
||||
{
|
||||
@@ -42,7 +41,7 @@ namespace EpinelPS.LobbyServer.Msgs.Character
|
||||
else
|
||||
{
|
||||
// TOOD: log this
|
||||
Logger.Error("ERROR: Not enough currency for upgrade");
|
||||
Console.WriteLine("ERROR: Not enough currency for upgrade");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,4 @@
|
||||
using EpinelPS.Utils;
|
||||
using Swan.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EpinelPS.LobbyServer.Msgs.Character
|
||||
{
|
||||
@@ -25,7 +19,7 @@ namespace EpinelPS.LobbyServer.Msgs.Character
|
||||
{
|
||||
if (item.CharacterSerialNumber != 0)
|
||||
{
|
||||
Logger.Warn("must remove character from synchrodevice first");
|
||||
Console.WriteLine("must remove character from synchrodevice first");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
using EpinelPS.Database;
|
||||
using EpinelPS.StaticInfo;
|
||||
using EpinelPS.Utils;
|
||||
using Swan.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EpinelPS.LobbyServer.Msgs.Character
|
||||
{
|
||||
@@ -26,12 +20,12 @@ namespace EpinelPS.LobbyServer.Msgs.Character
|
||||
{
|
||||
if (item.Level == 1)
|
||||
{
|
||||
Logger.Warn("Character level is already 1 - cannot reset");
|
||||
Console.WriteLine("Character level is already 1 - cannot reset");
|
||||
return;
|
||||
}
|
||||
if (item.Level == 200)
|
||||
{
|
||||
Logger.Warn("Character level is 200 - cannot reset");
|
||||
Console.WriteLine("Character level is 200 - cannot reset");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
using EpinelPS.Database;
|
||||
using EpinelPS.StaticInfo;
|
||||
using EpinelPS.Utils;
|
||||
using Swan.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EpinelPS.LobbyServer.Msgs.Character
|
||||
{
|
||||
@@ -42,7 +36,7 @@ namespace EpinelPS.LobbyServer.Msgs.Character
|
||||
else
|
||||
{
|
||||
// TOOD: log this
|
||||
Logger.Error("ERROR: Not enough currency for upgrade");
|
||||
Console.WriteLine("ERROR: Not enough currency for upgrade");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
using EpinelPS.Database;
|
||||
using EpinelPS.Utils;
|
||||
using Swan.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EpinelPS.LobbyServer.Msgs.Character
|
||||
{
|
||||
@@ -25,7 +19,7 @@ namespace EpinelPS.LobbyServer.Msgs.Character
|
||||
{
|
||||
if (item.CharacterSerialNumber == 0)
|
||||
{
|
||||
Logger.Warn("must add character from synchrodevice first");
|
||||
Console.WriteLine("must add character from synchrodevice first");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using EpinelPS.StaticInfo;
|
||||
using EpinelPS.Utils;
|
||||
using Swan.Logging;
|
||||
|
||||
namespace EpinelPS.LobbyServer.Msgs.Outpost
|
||||
{
|
||||
@@ -30,7 +29,7 @@ namespace EpinelPS.LobbyServer.Msgs.Outpost
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Error($"User {user.PlayerName} tried to clear lesson {req.LessonTid} without enough currency");
|
||||
Console.WriteLine($"User {user.PlayerName} tried to clear lesson {req.LessonTid} without enough currency");
|
||||
}
|
||||
await WriteDataAsync(response);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using EpinelPS.Utils;
|
||||
using Swan.Logging;
|
||||
|
||||
namespace EpinelPS.LobbyServer.Msgs.Shop
|
||||
{
|
||||
@@ -21,7 +20,7 @@ namespace EpinelPS.LobbyServer.Msgs.Shop
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Error("Error while handling GetProductList request. Have you replaced sodium library?" + ex);
|
||||
Console.WriteLine("Error while handling GetProductList request. Have you replaced sodium library?" + ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
using EpinelPS.Database;
|
||||
using EpinelPS.StaticInfo;
|
||||
using EpinelPS.Utils;
|
||||
using Swan.Logging;
|
||||
using System.Linq;
|
||||
|
||||
namespace EpinelPS.LobbyServer.Msgs.Stage
|
||||
{
|
||||
@@ -59,7 +57,7 @@ namespace EpinelPS.LobbyServer.Msgs.Stage
|
||||
if (rewardData != null)
|
||||
response.StageClearReward = RegisterRewardsForUser(user, rewardData);
|
||||
else
|
||||
Logger.Warn("rewardId is null for stage " + StageId);
|
||||
Console.WriteLine("rewardId is null for stage " + StageId);
|
||||
|
||||
|
||||
if (clearedStage.stage_category == "Normal" || clearedStage.stage_category == "Boss" || clearedStage.stage_category == "Hard")
|
||||
@@ -74,7 +72,7 @@ namespace EpinelPS.LobbyServer.Msgs.Stage
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Warn("Unknown chapter mod " + clearedStage.chapter_mod);
|
||||
Console.WriteLine("Unknown chapter mod " + clearedStage.chapter_mod);
|
||||
}
|
||||
}
|
||||
else if (clearedStage.stage_category == "Extra")
|
||||
@@ -83,7 +81,7 @@ namespace EpinelPS.LobbyServer.Msgs.Stage
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Warn("Unknown stage category " + clearedStage.stage_category);
|
||||
Console.WriteLine("Unknown stage category " + clearedStage.stage_category);
|
||||
}
|
||||
|
||||
if (clearedStage.stage_type != "Sub")
|
||||
@@ -130,7 +128,7 @@ namespace EpinelPS.LobbyServer.Msgs.Stage
|
||||
|
||||
if (newLevelExp == -1)
|
||||
{
|
||||
Logger.Warn("Unknown user level value for xp " + newXp);
|
||||
Console.WriteLine("Unknown user level value for xp " + newXp);
|
||||
}
|
||||
|
||||
|
||||
@@ -232,7 +230,7 @@ namespace EpinelPS.LobbyServer.Msgs.Stage
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Warn("TODO: Reward type " + item.reward_type);
|
||||
Console.WriteLine("TODO: Reward type " + item.reward_type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using EpinelPS.Utils;
|
||||
using Swan;
|
||||
|
||||
namespace EpinelPS.LobbyServer.Msgs.User
|
||||
{
|
||||
@@ -23,7 +22,7 @@ namespace EpinelPS.LobbyServer.Msgs.User
|
||||
|
||||
});
|
||||
|
||||
r.Mail[0].Items.Add(new NetMailRewardItem() { ExpiredAt = DateTime.UtcNow.AddYears(10).ToUnixEpochDate(), RewardId = 1, RewardType = (int)CurrencyType.ChargeCash, RewardValue = 100000 });
|
||||
r.Mail[0].Items.Add(new NetMailRewardItem() { ExpiredAt = DateTimeOffset.UtcNow.AddYears(10).ToUnixTimeSeconds(), RewardId = 1, RewardType = (int)CurrencyType.ChargeCash, RewardValue = 100000 });
|
||||
|
||||
await WriteDataAsync(r);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using EpinelPS.Utils;
|
||||
using Swan.Logging;
|
||||
|
||||
namespace EpinelPS.LobbyServer.Msgs.User
|
||||
{
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using EpinelPS.Utils;
|
||||
using Swan.Logging;
|
||||
|
||||
namespace EpinelPS.LobbyServer.Msgs.User
|
||||
{
|
||||
@@ -18,13 +17,13 @@ namespace EpinelPS.LobbyServer.Msgs.User
|
||||
|
||||
foreach (var item in req.ScenarioGroupIds)
|
||||
{
|
||||
Logger.Info("check scenario " + item);
|
||||
Console.WriteLine("check scenario " + item);
|
||||
foreach (var completed in user.CompletedScenarios)
|
||||
{
|
||||
// story thingy was completed
|
||||
if (completed == item)
|
||||
{
|
||||
Logger.Info(item + " is completed");
|
||||
Console.WriteLine(item + " is completed");
|
||||
response.ExistGroupIds.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,6 @@ using EpinelPS.LobbyServer.Msgs.Stage;
|
||||
using EpinelPS.StaticInfo;
|
||||
using EpinelPS.Utils;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Https;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Swan.Logging;
|
||||
using System.Net;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
@@ -19,17 +17,15 @@ namespace EpinelPS
|
||||
{
|
||||
try
|
||||
{
|
||||
Logger.UnregisterLogger<ConsoleLogger>();
|
||||
Logger.RegisterLogger(new GreatLogger());
|
||||
Logger.Info("Initializing database");
|
||||
Console.WriteLine("Initializing JsonDb");
|
||||
JsonDb.Save();
|
||||
|
||||
GameData.Instance.GetAllCostumes(); // force static data to be loaded
|
||||
|
||||
Logger.Info("Initialize handlers");
|
||||
Console.WriteLine("Initialize handlers");
|
||||
LobbyHandler.Init();
|
||||
|
||||
Logger.Info("Starting server");
|
||||
Console.WriteLine("Starting ASP.NET core on ports 80/443");
|
||||
new Thread(() =>
|
||||
{
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
@@ -160,9 +156,9 @@ namespace EpinelPS
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Error("Fatal error:");
|
||||
Logger.Error(ex.ToString());
|
||||
Logger.Error("Press any key to exit");
|
||||
Console.WriteLine("Fatal error:");
|
||||
Console.WriteLine(ex.ToString());
|
||||
Console.WriteLine("Press any key to exit");
|
||||
Console.ReadKey();
|
||||
}
|
||||
}
|
||||
@@ -419,18 +415,6 @@ namespace EpinelPS
|
||||
ctx.Response.ContentType = "multipart/mixed; boundary=\"f5d5cf4d-5627-422f-b3c6-532f1a0cbc0a\"";
|
||||
ctx.Response.Body.Write(responseBytes);
|
||||
}
|
||||
//private static async Task HandleDataEndpoint(IHttpContext ctx)
|
||||
//{
|
||||
// //this endpoint does not appear to be needed, it is used for telemetry
|
||||
// if (ctx.RequestedPath == "/v1/dsr/query")
|
||||
// {
|
||||
// await WriteJsonStringAsync(ctx, "{\"ret\":0,\"msg\":\"\",\"status\":0,\"created_at\":\"0\",\"target_destroy_at\":\"0\",\"destroyed_at\":\"0\",\"err_code\":0,\"seq\":\"1\"}");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// ctx.Response.StatusCode = 404;
|
||||
// }
|
||||
//}
|
||||
public static string GetCachePathForPath(string path)
|
||||
{
|
||||
return AppDomain.CurrentDomain.BaseDirectory + "cache/" + path;
|
||||
@@ -500,7 +484,7 @@ namespace EpinelPS
|
||||
url = url.Replace("/v1", "");
|
||||
|
||||
// find appropriate handler
|
||||
Logger.Info("BATCH: /v1" + url);
|
||||
Console.WriteLine("BATCH: /v1" + url);
|
||||
|
||||
foreach (var item in LobbyHandler.Handlers)
|
||||
{
|
||||
@@ -512,7 +496,7 @@ namespace EpinelPS
|
||||
return item.Value.ReturnBytes;
|
||||
}
|
||||
}
|
||||
Logger.Error("HANDLER NOT FOUND: " + url);
|
||||
Console.WriteLine("HANDLER NOT FOUND: " + url);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using DnsClient;
|
||||
using Swan.Logging;
|
||||
using System.Net;
|
||||
|
||||
namespace EpinelPS.Utils
|
||||
@@ -16,14 +15,14 @@ namespace EpinelPS.Utils
|
||||
var targetDir = Path.GetDirectoryName(targetFile);
|
||||
if (targetDir == null)
|
||||
{
|
||||
Logger.Error($"ERROR: Directory name cannot be null for request " + url + ", file path is " + targetFile);
|
||||
Console.WriteLine($"ERROR: Directory name cannot be null for request " + url + ", file path is " + targetFile);
|
||||
return null;
|
||||
}
|
||||
Directory.CreateDirectory(targetDir);
|
||||
|
||||
if (!File.Exists(targetFile))
|
||||
{
|
||||
Logger.Info("Download " + targetFile);
|
||||
Console.WriteLine("Download " + targetFile);
|
||||
|
||||
if (CloudIp == null)
|
||||
{
|
||||
@@ -46,7 +45,7 @@ namespace EpinelPS.Utils
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Error("Failed to download " + url + " with status code " + response.StatusCode);
|
||||
Console.WriteLine("Failed to download " + url + " with status code " + response.StatusCode);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Newtonsoft.Json;
|
||||
using Swan.Logging;
|
||||
|
||||
namespace EpinelPS.Utils
|
||||
{
|
||||
@@ -40,10 +39,10 @@ namespace EpinelPS.Utils
|
||||
{
|
||||
if (!File.Exists(AppDomain.CurrentDomain.BaseDirectory + "/gameconfig.json"))
|
||||
{
|
||||
Logger.Error("Gameconfig.json is not found, the game WILL NOT work!");
|
||||
Console.WriteLine("Gameconfig.json is not found, the game WILL NOT work!");
|
||||
_root = new GameConfigRoot();
|
||||
}
|
||||
Logger.Info("Loaded game config");
|
||||
Console.WriteLine("Loaded game config");
|
||||
|
||||
|
||||
_root = JsonConvert.DeserializeObject<GameConfigRoot>(File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "/gameconfig.json"));
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
using Swan.Logging;
|
||||
|
||||
namespace EpinelPS.Utils
|
||||
{
|
||||
public class GreatLogger : Swan.Logging.ILogger
|
||||
{
|
||||
public Swan.Logging.LogLevel LogLevel => Swan.Logging.LogLevel.Info;
|
||||
static readonly object lockObject = new();
|
||||
public void Log(LogMessageReceivedEventArgs logEvent)
|
||||
{
|
||||
var msg = logEvent.Message;
|
||||
|
||||
// strip out request id that embedio prints
|
||||
if (msg.StartsWith('['))
|
||||
{
|
||||
msg = msg[(msg.IndexOf("]") + 2)..];
|
||||
}
|
||||
|
||||
// ignore telemtry server errors
|
||||
if (msg.StartsWith("POST /v2/dr/"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var newFG = GetColorForMsg(logEvent);
|
||||
|
||||
lock (lockObject)
|
||||
{
|
||||
var oldFG = Console.ForegroundColor;
|
||||
Console.ForegroundColor = newFG;
|
||||
Console.WriteLine(msg);
|
||||
if (logEvent.Exception != null)
|
||||
Console.WriteLine(logEvent.Exception);
|
||||
Console.ForegroundColor = oldFG;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static ConsoleColor GetColorForMsg(LogMessageReceivedEventArgs logEvent)
|
||||
{
|
||||
if (logEvent.Message.Contains("404 Not Found"))
|
||||
return ConsoleColor.Red;
|
||||
else if (logEvent.Message.Contains("200 OK"))
|
||||
return ConsoleColor.DarkGreen;
|
||||
return logEvent.MessageType switch
|
||||
{
|
||||
Swan.Logging.LogLevel.None => ConsoleColor.White,
|
||||
Swan.Logging.LogLevel.Trace => ConsoleColor.Gray,
|
||||
Swan.Logging.LogLevel.Debug => ConsoleColor.Gray,
|
||||
Swan.Logging.LogLevel.Info => ConsoleColor.Gray,
|
||||
Swan.Logging.LogLevel.Warning => ConsoleColor.Yellow,
|
||||
Swan.Logging.LogLevel.Error => ConsoleColor.Red,
|
||||
Swan.Logging.LogLevel.Fatal => ConsoleColor.Red,
|
||||
_ => ConsoleColor.White,
|
||||
};
|
||||
}
|
||||
public void Dispose()
|
||||
{
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
92
EpinelPS/Utils/JsonPrototypes.cs
Normal file
92
EpinelPS/Utils/JsonPrototypes.cs
Normal file
@@ -0,0 +1,92 @@
|
||||
namespace EpinelPS
|
||||
{
|
||||
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 AuthPkt
|
||||
{
|
||||
public ChannelInfo channel_info { get; set; } = new();
|
||||
}
|
||||
public class AuthPkt2
|
||||
{
|
||||
public string token { get; set; } = "";
|
||||
public string openid { 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 int screen_height { get; set; }
|
||||
public int screen_width { 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 class LoginEndpoint1Req
|
||||
{
|
||||
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; } = "";
|
||||
}
|
||||
public class LoginEndpoint2Req
|
||||
{
|
||||
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 int support_captcha { get; set; }
|
||||
}
|
||||
|
||||
public class RegisterEPReq
|
||||
{
|
||||
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 class SendCodeRequest
|
||||
{
|
||||
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 int code_type { get; set; }
|
||||
public int support_captcha { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
using EpinelPS.Database;
|
||||
using EpinelPS.StaticInfo;
|
||||
using Swan.Logging;
|
||||
|
||||
namespace EpinelPS.Utils
|
||||
{
|
||||
@@ -87,7 +86,7 @@ namespace EpinelPS.Utils
|
||||
case "Module_D":
|
||||
return 3;
|
||||
default:
|
||||
Logger.Warn("Unknown item subtype: " + subType);
|
||||
Console.WriteLine("Unknown item subtype: " + subType);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@@ -126,7 +125,7 @@ namespace EpinelPS.Utils
|
||||
|
||||
foreach (var c in reward.Character)
|
||||
{
|
||||
Logger.Warn("MergeRewards - TODO Character");
|
||||
Console.WriteLine("MergeRewards - TODO Character");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using EmbedIO;
|
||||
using EpinelPS.LobbyServer;
|
||||
using EpinelPS.LobbyServer;
|
||||
using Sodium;
|
||||
using System.Buffers.Binary;
|
||||
using System.IO.Compression;
|
||||
@@ -22,13 +21,12 @@ namespace EpinelPS.Utils
|
||||
Stream decryptedStream;
|
||||
switch (encoding)
|
||||
{
|
||||
case CompressionMethodNames.Gzip:
|
||||
case "gzip":
|
||||
decryptedStream = new GZipStream(stream, CompressionMode.Decompress);
|
||||
break;
|
||||
case CompressionMethodNames.Deflate:
|
||||
case "deflate":
|
||||
decryptedStream = new DeflateStream(stream, CompressionMode.Decompress);
|
||||
break;
|
||||
case CompressionMethodNames.None:
|
||||
case null:
|
||||
case "":
|
||||
decryptedStream = stream;
|
||||
@@ -46,7 +44,7 @@ namespace EpinelPS.Utils
|
||||
|
||||
var bytes = encryptedBytes.ToArray();
|
||||
|
||||
var key = LobbyHandler.GetInfo(decryptionToken) ?? throw HttpException.BadRequest("Invalid decryption token");
|
||||
var key = LobbyHandler.GetInfo(decryptionToken) ?? throw new BadHttpRequestException("Invalid decryption token");
|
||||
var additionalData = GenerateAdditionalData(decryptionToken, false);
|
||||
|
||||
var x = SecretAeadXChaCha20Poly1305.Decrypt(bytes, nonce, key.Keys.ReadSharedSecret, [.. additionalData]);
|
||||
@@ -74,7 +72,7 @@ namespace EpinelPS.Utils
|
||||
|
||||
return new PacketDecryptResponse() { Contents = contents, UserId = key.UserId, UsedAuthToken = decryptionToken };
|
||||
default:
|
||||
throw HttpException.BadRequest($"Unsupported content encoding \"{encoding}\"");
|
||||
throw new Exception($"Unsupported content encoding \"{encoding}\"");
|
||||
}
|
||||
|
||||
|
||||
@@ -147,7 +145,7 @@ namespace EpinelPS.Utils
|
||||
|
||||
public static byte[] EncryptData(byte[] message, string authToken)
|
||||
{
|
||||
var key = LobbyHandler.GetInfo(authToken) ?? throw HttpException.BadRequest("Invalid decryption token");
|
||||
var key = LobbyHandler.GetInfo(authToken) ?? throw new BadHttpRequestException("Invalid decryption token");
|
||||
MemoryStream m = new();
|
||||
|
||||
m.WriteByte(89); // cbor ushort
|
||||
|
||||
Reference in New Issue
Block a user