mirror of
https://git.muiegratis.online/suikoakari/Campofinale
synced 2025-12-13 10:04:34 +01:00
some changes
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
using Campofinale.Game;
|
using Campofinale.Game;
|
||||||
using HttpServerLite;
|
using HttpServerLite;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace Campofinale.Http
|
namespace Campofinale.Http
|
||||||
{
|
{
|
||||||
@@ -63,11 +64,46 @@ namespace Campofinale.Http
|
|||||||
|
|
||||||
await ctx.Response.SendAsync(resp);
|
await ctx.Response.SendAsync(resp);
|
||||||
}
|
}
|
||||||
|
public class U8ProductInfo
|
||||||
|
{
|
||||||
|
public string app_id;
|
||||||
|
public string channel_id;
|
||||||
|
public int world_id;
|
||||||
|
public int store_id;
|
||||||
|
public string product_id;
|
||||||
|
public string desc;
|
||||||
|
public string name;
|
||||||
|
public int type;
|
||||||
|
public long price;
|
||||||
|
public string extra_data;
|
||||||
|
public string appstore_id;
|
||||||
|
public string channel_product_id;
|
||||||
|
}
|
||||||
|
public class U8ProductListData
|
||||||
|
{
|
||||||
|
public List<U8ProductInfo> productList = new();
|
||||||
|
}
|
||||||
[StaticRoute(HttpServerLite.HttpMethod.POST, "/u8/pay/getAllProductList")]
|
[StaticRoute(HttpServerLite.HttpMethod.POST, "/u8/pay/getAllProductList")]
|
||||||
public static async Task getAllProductList(HttpContext ctx)
|
public static async Task getAllProductList(HttpContext ctx)
|
||||||
{
|
{
|
||||||
string resp = "{\"productList\":[]}";
|
string resp = "{\"productList\":[]}";
|
||||||
|
U8ProductListData rsp = new();
|
||||||
|
rsp.productList.Add(new U8ProductInfo()
|
||||||
|
{
|
||||||
|
appstore_id="0",
|
||||||
|
app_id="1",
|
||||||
|
channel_id="1",
|
||||||
|
channel_product_id="1",
|
||||||
|
desc="Test",
|
||||||
|
name="Test",
|
||||||
|
price=10,
|
||||||
|
type=0,
|
||||||
|
product_id="1",
|
||||||
|
store_id=1,
|
||||||
|
world_id=0,
|
||||||
|
|
||||||
|
});
|
||||||
|
resp = JsonConvert.SerializeObject(rsp);
|
||||||
ctx.Response.StatusCode = 200;
|
ctx.Response.StatusCode = 200;
|
||||||
ctx.Response.ContentLength = resp.Length;
|
ctx.Response.ContentLength = resp.Length;
|
||||||
ctx.Response.ContentType = "application/json";
|
ctx.Response.ContentType = "application/json";
|
||||||
@@ -164,7 +200,6 @@ namespace Campofinale.Http
|
|||||||
}
|
}
|
||||||
|
|
||||||
ctx.Response.StatusCode = 200;
|
ctx.Response.StatusCode = 200;
|
||||||
//ctx.Response.ContentLength = resp.Length;
|
|
||||||
ctx.Response.ContentType = "application/json";
|
ctx.Response.ContentType = "application/json";
|
||||||
|
|
||||||
await ctx.Response.SendAsync(resp);
|
await ctx.Response.SendAsync(resp);
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
using Campofinale.Database;
|
using Campofinale.Database;
|
||||||
using HttpServerLite;
|
using HttpServerLite;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.Json;
|
||||||
using static Campofinale.Game.Gacha.GachaManager;
|
using static Campofinale.Game.Gacha.GachaManager;
|
||||||
using static Campofinale.Http.Dispatch;
|
using static Campofinale.Http.Dispatch;
|
||||||
|
|
||||||
@@ -20,7 +24,18 @@ namespace Campofinale.Http
|
|||||||
await ctx.Response.SendAsync(resp);
|
await ctx.Response.SendAsync(resp);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
[StaticRoute(HttpServerLite.HttpMethod.GET, "/user/pay/v1/query_app_order")]
|
||||||
|
public static async Task query_app_order(HttpContext ctx)
|
||||||
|
{
|
||||||
|
string requestBody = ctx.Request.DataAsString;
|
||||||
|
Console.WriteLine(requestBody);
|
||||||
|
string resp = "{\"data\":{\"paidApp\":true,\"hasMinorOrder\":false},\"msg\":\"OK\",\"status\":0,\"type\":\"A\"}";
|
||||||
|
ctx.Response.StatusCode = 200;
|
||||||
|
ctx.Response.ContentType = "application/json";
|
||||||
|
|
||||||
|
await ctx.Response.SendAsync(resp);
|
||||||
|
|
||||||
|
}
|
||||||
[StaticRoute(HttpServerLite.HttpMethod.POST, "/user/auth/v1/token_by_phone_password")]
|
[StaticRoute(HttpServerLite.HttpMethod.POST, "/user/auth/v1/token_by_phone_password")]
|
||||||
public static async Task token_login_phone_cn(HttpContext ctx)
|
public static async Task token_login_phone_cn(HttpContext ctx)
|
||||||
{
|
{
|
||||||
@@ -100,21 +115,69 @@ namespace Campofinale.Http
|
|||||||
await ctx.Response.SendAsync(resp);
|
await ctx.Response.SendAsync(resp);
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct GrantData
|
public class GrantReqData
|
||||||
{
|
{
|
||||||
public string token;
|
public string token;
|
||||||
|
public string encodeNonce;
|
||||||
|
public string appCode;
|
||||||
}
|
}
|
||||||
[StaticRoute(HttpServerLite.HttpMethod.POST, "/user/oauth2/v2/grant")]
|
public class GrantRsp
|
||||||
public static async Task account_ugrant(HttpContext ctx)
|
{
|
||||||
|
public Data data;
|
||||||
|
public string msg;
|
||||||
|
public int status;
|
||||||
|
public string type;
|
||||||
|
|
||||||
|
public class Data
|
||||||
|
{
|
||||||
|
public string token;
|
||||||
|
public string code;
|
||||||
|
public string hgId;
|
||||||
|
public string uid;
|
||||||
|
public string encodeSign;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*[StaticRoute(HttpServerLite.HttpMethod.POST, "/user/oauth2/v2/grant")]
|
||||||
|
public static async Task account_ugrant_old(HttpContext ctx)
|
||||||
{
|
{
|
||||||
string requestBody = ctx.Request.DataAsString;
|
string requestBody = ctx.Request.DataAsString;
|
||||||
|
|
||||||
GrantData grant = Newtonsoft.Json.JsonConvert.DeserializeObject<GrantData>(requestBody);
|
GrantReqData grant = Newtonsoft.Json.JsonConvert.DeserializeObject<GrantReqData>(requestBody);
|
||||||
Account account = DatabaseManager.db.GetAccountByToken(grant.token);
|
Account account = DatabaseManager.db.GetAccountByToken(grant.token);
|
||||||
string resp = "{\"msg\": \"Error\", \"status\": 2, \"type\": \"A\"}";
|
string resp = "{\"msg\": \"Error\", \"status\": 2, \"type\": \"A\"}";
|
||||||
if (account != null)
|
if (account != null)
|
||||||
{
|
{
|
||||||
resp = "{\"data\": { \"uid\": \"" + account.id + "\", \"code\": \"" + DatabaseManager.db.GrantCode(account) + "\" }, \"msg\": \"OK\", \"status\": 0, \"type\": \"A\"}";
|
resp = "{\"data\": { \"uid\": \"" + account.id + "\", \"code\": \"" + DatabaseManager.db.GrantCode(account) + "\" }, \"msg\": \"OK\", \"status\": 0, \"type\": \"A\"}";
|
||||||
|
if(grant.appCode== "2289f1dd2b923c53")
|
||||||
|
{
|
||||||
|
var url = "https://as.hypergryph.com/user/oauth2/v2/grant";
|
||||||
|
|
||||||
|
var b = new
|
||||||
|
{
|
||||||
|
appCode = "2289f1dd2b923c53",
|
||||||
|
encodeNonce = grant.encodeNonce,
|
||||||
|
token = "/kKCPAzTCkGOKft+X7sE7T0W",
|
||||||
|
type = 1
|
||||||
|
};
|
||||||
|
|
||||||
|
var json = JsonSerializer.Serialize(b);
|
||||||
|
|
||||||
|
var handler = new HttpClientHandler
|
||||||
|
{
|
||||||
|
UseProxy = false,
|
||||||
|
};
|
||||||
|
|
||||||
|
using var client = new HttpClient(handler);
|
||||||
|
var content = new StringContent(json, Encoding.UTF8, "application/json");
|
||||||
|
|
||||||
|
var response = await client.PostAsync(url, content);
|
||||||
|
var responseString = await response.Content.ReadAsStringAsync();
|
||||||
|
Logger.Print(responseString);
|
||||||
|
GrantRspOff rsp = JsonSerializer.Deserialize<GrantRspOff>(responseString);
|
||||||
|
resp = "{ \"data\": { \"token\": \"" + DatabaseManager.db.GrantCode(account) + "\", \"hgId\": \"" + account.id + "\", \"encodeSign\": \""+ rsp.data.encodeSign + "\" }, \"msg\": \"OK\", \"status\": 0, \"type\": \"A\"}";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.Response.StatusCode = 200;
|
ctx.Response.StatusCode = 200;
|
||||||
@@ -122,26 +185,70 @@ namespace Campofinale.Http
|
|||||||
ctx.Response.ContentType = "application/json";
|
ctx.Response.ContentType = "application/json";
|
||||||
|
|
||||||
await ctx.Response.SendAsync(resp);
|
await ctx.Response.SendAsync(resp);
|
||||||
|
}*/
|
||||||
|
[StaticRoute(HttpServerLite.HttpMethod.POST, "/user/oauth2/v2/grant")]
|
||||||
|
public static async Task account_ugrant(HttpContext ctx)
|
||||||
|
{
|
||||||
|
string requestBody = ctx.Request.DataAsString;
|
||||||
|
|
||||||
|
GrantReqData grant = Newtonsoft.Json.JsonConvert.DeserializeObject<GrantReqData>(requestBody);
|
||||||
|
GrantRsp rsp = new GrantRsp();
|
||||||
|
Account account = DatabaseManager.db.GetAccountByToken(grant.token);
|
||||||
|
rsp.type = "A";
|
||||||
|
if (account != null)
|
||||||
|
{
|
||||||
|
rsp.msg = "OK";
|
||||||
|
string grantedToken = DatabaseManager.db.GrantCode(account);
|
||||||
|
rsp.data = new()
|
||||||
|
{
|
||||||
|
hgId = account.id,
|
||||||
|
uid = account.id,
|
||||||
|
token = grantedToken,
|
||||||
|
code = grantedToken
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rsp.status = 2;
|
||||||
|
rsp.msg = "Error";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.Response.StatusCode = 200;
|
||||||
|
ctx.Response.ContentType = "application/json";
|
||||||
|
await ctx.Response.SendAsync(JsonConvert.SerializeObject(rsp));
|
||||||
}
|
}
|
||||||
[StaticRoute(HttpServerLite.HttpMethod.POST, "/u8/user/auth/v2/grant")]
|
[StaticRoute(HttpServerLite.HttpMethod.POST, "/u8/user/auth/v2/grant")]
|
||||||
public static async Task account_grant(HttpContext ctx)
|
public static async Task account_grant(HttpContext ctx)
|
||||||
{
|
{
|
||||||
string requestBody = ctx.Request.DataAsString;
|
string requestBody = ctx.Request.DataAsString;
|
||||||
|
|
||||||
GrantData grant = Newtonsoft.Json.JsonConvert.DeserializeObject<GrantData>(requestBody);
|
GrantReqData grant = Newtonsoft.Json.JsonConvert.DeserializeObject<GrantReqData>(requestBody);
|
||||||
|
GrantRsp rsp = new GrantRsp();
|
||||||
Account account = DatabaseManager.db.GetAccountByTokenGrant(grant.token);
|
Account account = DatabaseManager.db.GetAccountByTokenGrant(grant.token);
|
||||||
string resp = "{\"msg\": \"Error\", \"status\": 2, \"type\": \"A\"}";
|
rsp.type = "A";
|
||||||
if (account != null)
|
if (account != null)
|
||||||
{
|
{
|
||||||
|
rsp.msg = "OK";
|
||||||
resp = "{\"data\": { \"token\": \"" + account.token + "\", \"uid\": \"" + account.id + "\", \"code\": \"" + account.grantToken + "\" }, \"msg\": \"OK\", \"status\": 0, \"type\": \"A\"}";
|
rsp.data = new()
|
||||||
|
{
|
||||||
|
hgId = account.id,
|
||||||
|
uid = account.id,
|
||||||
|
token = account.token,
|
||||||
|
code = account.grantToken,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rsp.status = 2;
|
||||||
|
rsp.msg = "Error";
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.Response.StatusCode = 200;
|
ctx.Response.StatusCode = 200;
|
||||||
|
|
||||||
ctx.Response.ContentType = "application/json";
|
ctx.Response.ContentType = "application/json";
|
||||||
|
|
||||||
await ctx.Response.SendAsync(resp);
|
await ctx.Response.SendAsync(JsonConvert.SerializeObject(rsp));
|
||||||
}
|
}
|
||||||
|
|
||||||
public class TokenChannelData
|
public class TokenChannelData
|
||||||
@@ -233,10 +340,8 @@ namespace Campofinale.Http
|
|||||||
{
|
{
|
||||||
transactions.transactionList = new();
|
transactions.transactionList = new();
|
||||||
}
|
}
|
||||||
string resp = Newtonsoft.Json.JsonConvert.SerializeObject(transactions);
|
|
||||||
|
|
||||||
ctx.Response.StatusCode = 200;
|
ctx.Response.StatusCode = 200;
|
||||||
await ctx.Response.SendAsync(resp);
|
await ctx.Response.SendAsync(JsonConvert.SerializeObject(transactions));
|
||||||
}
|
}
|
||||||
[StaticRoute(HttpServerLite.HttpMethod.GET, "/gachahistory")]
|
[StaticRoute(HttpServerLite.HttpMethod.GET, "/gachahistory")]
|
||||||
public static async Task gachahistory(HttpContext ctx)
|
public static async Task gachahistory(HttpContext ctx)
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class Program
|
|||||||
{
|
{
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
StartServer(args);
|
StartServer(args);
|
||||||
//FakeClientTester();
|
//FakeClientTester();
|
||||||
}
|
}
|
||||||
public static byte[] ConcatenateByteArrays(byte[] array1, byte[] array2)
|
public static byte[] ConcatenateByteArrays(byte[] array1, byte[] array2)
|
||||||
@@ -22,7 +22,7 @@ class Program
|
|||||||
private static void FakeClientTester()
|
private static void FakeClientTester()
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
string serverIp = "beyond-tyo.gryphline.com";
|
string serverIp = "beyond-cn.hypergryph.com";
|
||||||
int serverPort = 30000;
|
int serverPort = 30000;
|
||||||
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||||
|
|
||||||
@@ -33,7 +33,6 @@ class Program
|
|||||||
socket.Connect(new IPEndPoint(ipAddress, serverPort));
|
socket.Connect(new IPEndPoint(ipAddress, serverPort));
|
||||||
|
|
||||||
socket.Send(Packet.EncodePacket((int)CsMsgId.CsLogin,new CsLogin() { ClientVersion="0.5.5",Uid= "", Token= "", Env=EnvType.Prod,PlatformId=ClientPlatformType.Windows,Area=AreaType.Oversea,ClientResVersion="", LoginToken= "" }.ToByteArray()));
|
socket.Send(Packet.EncodePacket((int)CsMsgId.CsLogin,new CsLogin() { ClientVersion="0.5.5",Uid= "", Token= "", Env=EnvType.Prod,PlatformId=ClientPlatformType.Windows,Area=AreaType.Oversea,ClientResVersion="", LoginToken= "" }.ToByteArray()));
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
byte[] buffer = new byte[3];
|
byte[] buffer = new byte[3];
|
||||||
@@ -44,6 +43,7 @@ class Program
|
|||||||
byte headLength = Packet.GetByte(buffer, 0);
|
byte headLength = Packet.GetByte(buffer, 0);
|
||||||
ushort bodyLength = Packet.GetUInt16(buffer, 1);
|
ushort bodyLength = Packet.GetUInt16(buffer, 1);
|
||||||
byte[] moreData = new byte[bodyLength + headLength];
|
byte[] moreData = new byte[bodyLength + headLength];
|
||||||
|
|
||||||
while (socket.Available < moreData.Length)
|
while (socket.Available < moreData.Length)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user