fork from 1.3
This commit is contained in:
32
FreeSR.Dispatch/Handlers/ComboGranterApiGetConfigHandler.cs
Normal file
32
FreeSR.Dispatch/Handlers/ComboGranterApiGetConfigHandler.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
namespace FreeSR.Dispatch.Handlers
|
||||
{
|
||||
using Ceen;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
internal class ComboGranterApiGetConfigHandler : IHttpModule
|
||||
{
|
||||
public async Task<bool> HandleAsync(IHttpContext context)
|
||||
{
|
||||
context.Response.StatusCode = HttpStatusCode.OK;
|
||||
context.Response.ContentType = "application/json";
|
||||
await context.Response.WriteAllJsonAsync(JsonConvert.SerializeObject(new
|
||||
{
|
||||
retcode = 0,
|
||||
message = "OK",
|
||||
data =
|
||||
new
|
||||
{
|
||||
protocol = true,
|
||||
qr_enabled = true,
|
||||
log_level = "INFO",
|
||||
announce_url = "https://sdk.hoyoverse.com/hkrpg/announcement/index.html?sdk_presentation_style=fullscreen\u0026sdk_screen_transparent=true\u0026auth_appid=announcement\u0026authkey_ver=1\u0026sign_type=2#/",
|
||||
push_alias_type = 0,
|
||||
disable_ysdk_guard = true,
|
||||
enable_announce_pic_popup = true
|
||||
}
|
||||
}));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
39
FreeSR.Dispatch/Handlers/ComboTokenRequestHandler.cs
Normal file
39
FreeSR.Dispatch/Handlers/ComboTokenRequestHandler.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
namespace FreeSR.Dispatch.Handlers
|
||||
{
|
||||
using Ceen;
|
||||
using FreeSR.Dispatch.Util;
|
||||
using FreeSR.Proto;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
internal class ComboTokenRequestHandler : IHttpModule
|
||||
{
|
||||
public async Task<bool> HandleAsync(IHttpContext context)
|
||||
{
|
||||
var data = await context.Request.Body.ReadAllAsStringAsync();
|
||||
var json = JObject.Parse(data);
|
||||
var clientData = JObject.Parse((string)json["data"]);
|
||||
|
||||
var dataObject = new JObject
|
||||
{
|
||||
{"combo_id", 1},
|
||||
{"open_id", clientData["uid"]},
|
||||
{"combo_token", clientData["token"]},
|
||||
{"data", new JObject {{"guest", false}}},
|
||||
{"heartbeat", false},
|
||||
{"account_type", 1},
|
||||
{"fatigue_remind", null}
|
||||
};
|
||||
|
||||
context.Response.StatusCode = HttpStatusCode.OK;
|
||||
context.Response.ContentType = "application/json";
|
||||
await context.Response.WriteAllJsonAsync(DispatchResponseBuilder.Create()
|
||||
.Retcode(Retcode.RETCODE_RET_SUCC)
|
||||
.Message("OK")
|
||||
.Object("data", dataObject)
|
||||
.Build());
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
34
FreeSR.Dispatch/Handlers/GetAgreementInfosHandler.cs
Normal file
34
FreeSR.Dispatch/Handlers/GetAgreementInfosHandler.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
namespace FreeSR.Dispatch.Handlers
|
||||
{
|
||||
using Ceen;
|
||||
using FreeSR.Dispatch.Util;
|
||||
using FreeSR.Proto;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
internal class GetAgreementInfosHandler : IHttpModule
|
||||
{
|
||||
public async Task<bool> HandleAsync(IHttpContext context)
|
||||
{
|
||||
context.Response.StatusCode = HttpStatusCode.OK;
|
||||
context.Response.ContentType = "application/json";
|
||||
await context.Response.WriteAllJsonAsync(DispatchResponseBuilder.Create()
|
||||
.Retcode(Retcode.RETCODE_RET_SUCC)
|
||||
.Message("OK")
|
||||
.Object("data", Data)
|
||||
.Build());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static JObject Data
|
||||
{
|
||||
get
|
||||
{
|
||||
return new JObject
|
||||
{
|
||||
{"marketing_agreements", new JArray()}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
22
FreeSR.Dispatch/Handlers/GetExperimentListHandler.cs
Normal file
22
FreeSR.Dispatch/Handlers/GetExperimentListHandler.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
namespace FreeSR.Dispatch.Handlers
|
||||
{
|
||||
using Ceen;
|
||||
using FreeSR.Dispatch.Util;
|
||||
using FreeSR.Proto;
|
||||
|
||||
internal class GetExperimentListHandler : IHttpModule
|
||||
{
|
||||
public async Task<bool> HandleAsync(IHttpContext context)
|
||||
{
|
||||
context.Response.StatusCode = HttpStatusCode.OK;
|
||||
context.Response.ContentType = "application/json";
|
||||
await context.Response.WriteAllJsonAsync(DispatchResponseBuilder.Create()
|
||||
.Retcode(Retcode.RETCODE_RET_SUCC)
|
||||
.Boolean("success", true)
|
||||
.String("message", "")
|
||||
.Build());
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
26
FreeSR.Dispatch/Handlers/HkrpgDataUploadHandler.cs
Normal file
26
FreeSR.Dispatch/Handlers/HkrpgDataUploadHandler.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
namespace FreeSR.Dispatch.Handlers
|
||||
{
|
||||
using Ceen;
|
||||
using FreeSR.Dispatch.Util;
|
||||
using NLog;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
internal class HkrpgDataUploadHandler : IHttpModule
|
||||
{
|
||||
private static readonly Logger s_log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public async Task<bool> HandleAsync(IHttpContext context)
|
||||
{
|
||||
string logs = await context.Request.Body.ReadAllAsStringAsync();
|
||||
s_log.Info(logs);
|
||||
|
||||
context.Response.StatusCode = HttpStatusCode.OK;
|
||||
context.Response.ContentType = "application/json";
|
||||
await context.Response.WriteAllJsonAsync(DispatchResponseBuilder.Create()
|
||||
.Code(0)
|
||||
.Build());
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
57
FreeSR.Dispatch/Handlers/LoginRequestHandler.cs
Normal file
57
FreeSR.Dispatch/Handlers/LoginRequestHandler.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
namespace FreeSR.Dispatch.Handlers
|
||||
{
|
||||
using Ceen;
|
||||
using FreeSR.Database;
|
||||
using FreeSR.Database.Account;
|
||||
using FreeSR.Database.Account.Model;
|
||||
using FreeSR.Dispatch.Util;
|
||||
using FreeSR.Proto;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
internal class LoginRequestHandler : IHttpModule
|
||||
{
|
||||
public async Task<bool> HandleAsync(IHttpContext context)
|
||||
{
|
||||
context.Response.StatusCode = HttpStatusCode.OK;
|
||||
context.Response.ContentType = "application/json";
|
||||
|
||||
string data = await context.Request.Body.ReadAllAsStringAsync();
|
||||
JObject loginJson = JObject.Parse(data);
|
||||
|
||||
AccountDatabase accountDatabase = DatabaseManager.Instance.Get<AccountDatabase>();
|
||||
|
||||
string accountName = (string)loginJson["account"];
|
||||
string password = (string)loginJson["password"];
|
||||
|
||||
AccountModel account = await accountDatabase.GetByName(accountName);
|
||||
if (account == null)
|
||||
{
|
||||
await context.Response.WriteAllJsonAsync(DispatchResponseBuilder.Create()
|
||||
.Retcode(Retcode.RETCODE_RET_FAIL)
|
||||
.Message("Account not found.")
|
||||
.Object("data", null)
|
||||
.Build());
|
||||
return true;
|
||||
}
|
||||
|
||||
// no password check, because client patch is closed-source for now.
|
||||
|
||||
await context.Response.WriteAllJsonAsync(DispatchResponseBuilder.Create()
|
||||
.Retcode(Retcode.RETCODE_RET_SUCC)
|
||||
.Message("OK")
|
||||
.Object("data", new JObject
|
||||
{
|
||||
{"account", account.ToLoginResponseData()},
|
||||
{"device_grant_required", false},
|
||||
{"safe_moblie_required", false},
|
||||
{"realperson_required", false},
|
||||
{"reactivate_required", false},
|
||||
{"realname_operation", "None"}
|
||||
, })
|
||||
.Build());
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
36
FreeSR.Dispatch/Handlers/QueryDispatchHandler.cs
Normal file
36
FreeSR.Dispatch/Handlers/QueryDispatchHandler.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
namespace FreeSR.Dispatch.Handlers
|
||||
{
|
||||
using Ceen;
|
||||
using FreeSR.Dispatch.Service.Manager;
|
||||
using FreeSR.Dispatch.Util;
|
||||
using FreeSR.Proto;
|
||||
using NLog;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
internal class QueryDispatchHandler : IHttpModule
|
||||
{
|
||||
private static readonly Logger s_log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public async Task<bool> HandleAsync(IHttpContext context)
|
||||
{
|
||||
var query = context.Request.QueryString;
|
||||
var version = query["version"];
|
||||
var timestamp = query["t"];
|
||||
var languageType = query["language_type"];
|
||||
var platformType = query["platform_type"];
|
||||
|
||||
s_log.Info($"query_dispatch: version: {version}, time: {timestamp}, language: {languageType}, platform: {platformType}");
|
||||
|
||||
context.Response.StatusCode = HttpStatusCode.OK;
|
||||
context.Response.ContentType = "text/plain";
|
||||
await context.Response.WriteAllAsync(Convert.ToBase64String(ProtobufUtil.Serialize(new DispatchRegionsData
|
||||
{
|
||||
Retcode = Retcode.RETCODE_RET_SUCC,
|
||||
TopSeverRegionName = RegionManager.GetTopServerRegionName(),
|
||||
RegionList = RegionManager.GetRegionList()
|
||||
})));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
34
FreeSR.Dispatch/Handlers/QueryGatewayHandler.cs
Normal file
34
FreeSR.Dispatch/Handlers/QueryGatewayHandler.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
namespace FreeSR.Dispatch.Handlers
|
||||
{
|
||||
using Ceen;
|
||||
using FreeSR.Dispatch.Util;
|
||||
using FreeSR.Proto;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
internal class QueryGatewayHandler : IHttpModule
|
||||
{
|
||||
public async Task<bool> HandleAsync(IHttpContext context)
|
||||
{
|
||||
context.Response.StatusCode = HttpStatusCode.OK;
|
||||
context.Response.ContentType = "text/plain";
|
||||
await context.Response.WriteAllAsync(Convert.ToBase64String(ProtobufUtil.Serialize(new Gateserver
|
||||
{
|
||||
Retcode = Retcode.RETCODE_RET_SUCC,
|
||||
Msg = "OK",
|
||||
Ip = "127.0.0.1",
|
||||
RegionName = "FreeSR",
|
||||
Port = 22301,
|
||||
Mljaogdhcki = true,
|
||||
LoginWhiteMsg = "Access verification failed. Please check if you have logged in to the correct account and server.",
|
||||
Jcdlppbocpe = true,
|
||||
Gifijbibiin = true,
|
||||
Ibplbfhmgkf = true,
|
||||
MbResVersion = "5335706",
|
||||
AssetBundleUrl = "https://autopatchos.starrails.com/asb/V1.3Live/output_5355192_0007722cfc",
|
||||
ExResourceUrl = "https://autopatchos.starrails.com/design_data/V1.3Live/output_5371504_9fdb2fe63e",
|
||||
})));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
37
FreeSR.Dispatch/Handlers/RiskyApiCheckHandler.cs
Normal file
37
FreeSR.Dispatch/Handlers/RiskyApiCheckHandler.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
namespace FreeSR.Dispatch.Handlers
|
||||
{
|
||||
using Ceen;
|
||||
using FreeSR.Dispatch.Util;
|
||||
using FreeSR.Proto;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
internal class RiskyApiCheckHandler : IHttpModule
|
||||
{
|
||||
public async Task<bool> HandleAsync(IHttpContext context)
|
||||
{
|
||||
context.Response.StatusCode = HttpStatusCode.OK;
|
||||
context.Response.ContentType = "application/json";
|
||||
await context.Response.WriteAllJsonAsync(DispatchResponseBuilder.Create()
|
||||
.Retcode(Retcode.RETCODE_RET_SUCC)
|
||||
.Message("OK")
|
||||
.Object("data", CaptchaData)
|
||||
.Build());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static JObject CaptchaData
|
||||
{
|
||||
get
|
||||
{
|
||||
return new JObject
|
||||
{
|
||||
{"id", ""},
|
||||
{"action", "ACTION_NONE"},
|
||||
{"geetest", null}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
32
FreeSR.Dispatch/Handlers/Sdk/CreateAccountHandler.cs
Normal file
32
FreeSR.Dispatch/Handlers/Sdk/CreateAccountHandler.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
namespace FreeSR.Dispatch.Handlers.Sdk
|
||||
{
|
||||
using Ceen;
|
||||
using FreeSR.Database;
|
||||
using FreeSR.Database.Account;
|
||||
|
||||
internal class CreateAccountHandler : IHttpModule
|
||||
{
|
||||
public async Task<bool> HandleAsync(IHttpContext context)
|
||||
{
|
||||
var query = context.Request.QueryString;
|
||||
|
||||
var name = query["user"];
|
||||
var password = query["pass"];
|
||||
|
||||
var database = DatabaseManager.Instance.Get<AccountDatabase>();
|
||||
var account = await database.Create(name, password);
|
||||
|
||||
context.Response.StatusCode = HttpStatusCode.OK;
|
||||
if (account == null)
|
||||
{
|
||||
await context.Response.WriteAllAsync("Sorry, this username is already taken.", "text/plain");
|
||||
}
|
||||
else
|
||||
{
|
||||
await context.Response.WriteAllAsync($"Successfully created account with name {account.Name}, uid: {account.Uid}", "text/plain");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
20
FreeSR.Dispatch/Handlers/SdkDataUploadHandler.cs
Normal file
20
FreeSR.Dispatch/Handlers/SdkDataUploadHandler.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
namespace FreeSR.Dispatch.Handlers
|
||||
{
|
||||
using Ceen;
|
||||
using FreeSR.Dispatch.Util;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
internal class SdkDataUploadHandler : IHttpModule
|
||||
{
|
||||
public async Task<bool> HandleAsync(IHttpContext context)
|
||||
{
|
||||
context.Response.StatusCode = HttpStatusCode.OK;
|
||||
context.Response.ContentType = "application/json";
|
||||
await context.Response.WriteAllJsonAsync(DispatchResponseBuilder.Create()
|
||||
.Code(0)
|
||||
.Build());
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
61
FreeSR.Dispatch/Handlers/TokenLoginRequestHandler.cs
Normal file
61
FreeSR.Dispatch/Handlers/TokenLoginRequestHandler.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
namespace FreeSR.Dispatch.Handlers
|
||||
{
|
||||
using Ceen;
|
||||
using FreeSR.Database;
|
||||
using FreeSR.Database.Account;
|
||||
using FreeSR.Database.Account.Model;
|
||||
using FreeSR.Dispatch.Util;
|
||||
using FreeSR.Proto;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
internal class TokenLoginRequestHandler : IHttpModule
|
||||
{
|
||||
public async Task<bool> HandleAsync(IHttpContext context)
|
||||
{
|
||||
var data = await context.Request.Body.ReadAllAsStringAsync();
|
||||
var json = JObject.Parse(data);
|
||||
|
||||
var uid = int.Parse((string)json["uid"]);
|
||||
var token = (string)json["token"];
|
||||
|
||||
AccountDatabase accountDatabase = DatabaseManager.Instance.Get<AccountDatabase>();
|
||||
AccountModel account = await accountDatabase.GetByUid(uid);
|
||||
if (account == null)
|
||||
{
|
||||
await context.Response.WriteAllJsonAsync(DispatchResponseBuilder.Create()
|
||||
.Retcode(Retcode.RETCODE_RET_FAIL)
|
||||
.Message("Account not found.")
|
||||
.Object("data", null)
|
||||
.Build());
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (account.Token != token)
|
||||
{
|
||||
await context.Response.WriteAllJsonAsync(DispatchResponseBuilder.Create()
|
||||
.Retcode(Retcode.RETCODE_RET_FAIL)
|
||||
.Message("Invalid user token.")
|
||||
.Object("data", null)
|
||||
.Build());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
await context.Response.WriteAllJsonAsync(DispatchResponseBuilder.Create()
|
||||
.Retcode(Retcode.RETCODE_RET_SUCC)
|
||||
.Message("OK")
|
||||
.Object("data", new JObject
|
||||
{
|
||||
{"account", account.ToLoginResponseData()},
|
||||
{"device_grant_required", false},
|
||||
{"safe_moblie_required", false},
|
||||
{"realperson_required", false},
|
||||
{"reactivate_required", false},
|
||||
{"realname_operation", "None"}
|
||||
})
|
||||
.Build());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user