improve logging, various qol fixes

This commit is contained in:
Mikhail
2024-08-31 12:39:47 -04:00
parent f199ca63e0
commit a68a201c13
10 changed files with 210 additions and 9 deletions

View File

@@ -1,6 +1,7 @@
using EpinelPS.Database;
using EpinelPS.Utils;
using Microsoft.AspNetCore.Mvc;
using Org.BouncyCastle.Ocsp;
namespace EpinelPS.Controllers
{
@@ -44,8 +45,12 @@ namespace EpinelPS.Controllers
[HttpPost]
[Route("auth/auto_login")]
public string AutoLogin(string seq)
public string AutoLogin(string seq, [FromBody] AuthPkt2 req)
{
User? user;
if ((user = NetUtils.GetUser(req.token).Item1) == null) return BadAuthToken;
return "{\"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 + "\"}";
}
@@ -118,12 +123,24 @@ namespace EpinelPS.Controllers
[HttpPost]
[Route("profile/get_bind_info")]
public string GetProfileBindInfo(string seq, [FromBody] AuthPkt req)
public string GetProfileBindInfo(string seq, [FromBody] AuthPkt2 req)
{
User? user;
if ((user = NetUtils.GetUser(req.channel_info.token).Item1) == null) return BadAuthToken;
if ((user = NetUtils.GetUser(req.token).Item1) == null) return BadAuthToken;
return "{\"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 + "\"}";
}
[HttpPost]
[Route("auth/refresh_sacc_token")]
public string RefreshAuthToken(string seq, [FromBody] AuthPkt2 req)
{
// TODO redo auth token system
AccessToken? user;
if ((user = NetUtils.GetUser(req.token).Item2) == null) return BadAuthToken;
user.ExpirationTime = DateTimeOffset.UtcNow.AddYears(1).ToUnixTimeSeconds();
return "{\"msg\":\"success\",\"ret\":0,\"seq\":\"" + seq + "\"}";
}
}
}

View File

@@ -1,5 +1,6 @@
using EpinelPS.LobbyServer;
using Microsoft.AspNetCore.Mvc;
using System.Diagnostics;
namespace EpinelPS.Controllers
{
@@ -12,7 +13,16 @@ namespace EpinelPS.Controllers
[Consumes("application/octet-stream+protobuf")]
public async Task CatchAll(string all)
{
Stopwatch st = Stopwatch.StartNew();
await LobbyHandler.DispatchSingle(HttpContext);
st.Stop();
var fg = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.DarkGreen;
Console.WriteLine("POST " + HttpContext.Request.Path.Value + " completed in " + st.Elapsed);
Console.ForegroundColor = fg;
}
}
}