mirror of
https://git.muiegratis.online/suikoakari/Campofinale
synced 2025-12-12 17:44:37 +01:00
FakeClientTester
This commit is contained in:
@@ -19,6 +19,10 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Protobuf Include="*.proto" ProtoRoot="." GrpcServices="None" />
|
<Protobuf Include="*.proto" ProtoRoot="." GrpcServices="None" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Remove="Campofinale.cs" />
|
||||||
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Remove="AbilityActionCreateGadget.proto" />
|
<None Remove="AbilityActionCreateGadget.proto" />
|
||||||
<None Remove="AbilityActionSummon.proto" />
|
<None Remove="AbilityActionSummon.proto" />
|
||||||
@@ -897,5 +901,8 @@
|
|||||||
<None Remove="WorktopOptionNotify.proto" />
|
<None Remove="WorktopOptionNotify.proto" />
|
||||||
<None Remove="WorldPlayerReviveReq.proto" />
|
<None Remove="WorldPlayerReviveReq.proto" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="Campofinale.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
6678
Campofinale.Protocol/Campofinale.proto
Normal file
6678
Campofinale.Protocol/Campofinale.proto
Normal file
File diff suppressed because it is too large
Load Diff
@@ -165,6 +165,7 @@ namespace Campofinale.Network
|
|||||||
PutUInt16(data, (ushort)body.Length, 1);
|
PutUInt16(data, (ushort)body.Length, 1);
|
||||||
PutByteArray(data, head.ToByteArray(), 3);
|
PutByteArray(data, head.ToByteArray(), 3);
|
||||||
PutByteArray(data, body, 3 + head.ToByteArray().Length);
|
PutByteArray(data, body, 3 + head.ToByteArray().Length);
|
||||||
|
if(Server.config!=null)
|
||||||
if (Server.config.logOptions.packets && !Server.scMessageToHide.Contains((ScMsgId)msgId))
|
if (Server.config.logOptions.packets && !Server.scMessageToHide.Contains((ScMsgId)msgId))
|
||||||
Logger.Print($"Sending Packet: {((ScMsgId)msgId).ToString().Pastel(Color.LightBlue)} Id: {msgId} with {data.Length} Bytes");
|
Logger.Print($"Sending Packet: {((ScMsgId)msgId).ToString().Pastel(Color.LightBlue)} Id: {msgId} with {data.Length} Bytes");
|
||||||
|
|
||||||
@@ -193,5 +194,27 @@ namespace Campofinale.Network
|
|||||||
seqNext = csHead_.UpSeqid;
|
seqNext = csHead_.UpSeqid;
|
||||||
return new Packet() { csHead = csHead_, finishedBody = BodyBytes,cmdId=csHead_.Msgid };
|
return new Packet() { csHead = csHead_, finishedBody = BodyBytes,cmdId=csHead_.Msgid };
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Read the byteArray as a valid packet
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="byteArray"></param>
|
||||||
|
/// <returns>The decoded packet</returns>
|
||||||
|
public static Packet Read(byte[] byteArray)
|
||||||
|
{
|
||||||
|
byte headLength = GetByte(byteArray, 0);
|
||||||
|
ushort bodyLength = GetUInt16(byteArray, 1);
|
||||||
|
|
||||||
|
byte[] csHeadBytes = new byte[headLength];
|
||||||
|
byte[] BodyBytes = new byte[bodyLength];
|
||||||
|
Array.Copy(byteArray, 3, csHeadBytes, 0, headLength);
|
||||||
|
Array.Copy(byteArray, 3 + headLength, BodyBytes, 0, bodyLength);
|
||||||
|
CSHead csHead_ = CSHead.Parser.ParseFrom(csHeadBytes);
|
||||||
|
/*if (Server.config.logOptions.packets && !Server.csMessageToHide.Contains((CsMsgId)csHead_.Msgid))
|
||||||
|
{
|
||||||
|
Logger.Print(csHead_.ToString());
|
||||||
|
}*/
|
||||||
|
seqNext = csHead_.UpSeqid;
|
||||||
|
return new Packet() { csHead = csHead_, finishedBody = BodyBytes, cmdId = csHead_.Msgid };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,80 @@
|
|||||||
using Campofinale;
|
using Campofinale;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using System.Net.Sockets;
|
||||||
|
using System.Net;
|
||||||
|
using Campofinale.Network;
|
||||||
|
using Campofinale.Protocol;
|
||||||
|
using Google.Protobuf;
|
||||||
|
using Pastel;
|
||||||
|
using System.Drawing;
|
||||||
|
|
||||||
class Program
|
class Program
|
||||||
{
|
{
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
StartServer(args);
|
StartServer(args);
|
||||||
|
//FakeClientTester();
|
||||||
}
|
}
|
||||||
|
public static byte[] ConcatenateByteArrays(byte[] array1, byte[] array2)
|
||||||
|
{
|
||||||
|
return array1.Concat(array2).ToArray();
|
||||||
|
}
|
||||||
|
private static void FakeClientTester()
|
||||||
|
{
|
||||||
|
string serverIp = "beyond-ric.gryphline.com";
|
||||||
|
int serverPort = 30000;
|
||||||
|
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||||
|
|
||||||
|
IPAddress[] addresses = Dns.GetHostAddresses(serverIp);
|
||||||
|
|
||||||
|
IPAddress ipAddress = addresses[0];
|
||||||
|
|
||||||
|
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()));
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
byte[] buffer = new byte[3];
|
||||||
|
int length = socket.Receive(buffer);
|
||||||
|
if (length == 3)
|
||||||
|
{
|
||||||
|
Packet packet = null;
|
||||||
|
byte headLength = Packet.GetByte(buffer, 0);
|
||||||
|
ushort bodyLength = Packet.GetUInt16(buffer, 1);
|
||||||
|
byte[] moreData = new byte[bodyLength + headLength];
|
||||||
|
while (socket.Available < moreData.Length)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
int mLength = socket.Receive(moreData);
|
||||||
|
if (mLength == moreData.Length)
|
||||||
|
{
|
||||||
|
buffer = ConcatenateByteArrays(buffer, moreData);
|
||||||
|
packet = Packet.Read(buffer);
|
||||||
|
|
||||||
|
switch ((ScMsgId)packet.cmdId)
|
||||||
|
{
|
||||||
|
case ScMsgId.ScLogin:
|
||||||
|
ScLogin p1 = ScLogin.Parser.ParseFrom(packet.finishedBody);
|
||||||
|
Console.WriteLine(JsonConvert.SerializeObject(p1));
|
||||||
|
break;
|
||||||
|
case ScMsgId.ScNtfErrorCode:
|
||||||
|
ScNtfErrorCode p2 = ScNtfErrorCode.Parser.ParseFrom(packet.finishedBody);
|
||||||
|
Console.WriteLine(JsonConvert.SerializeObject(p2));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
string base64 = Convert.ToBase64String(packet.finishedBody);
|
||||||
|
Console.WriteLine($"{(ScMsgId)packet.cmdId}: {base64}");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
private static void StartServer(string[] args)
|
private static void StartServer(string[] args)
|
||||||
{
|
{
|
||||||
Console.Title = "Initializing...";
|
Console.Title = "Initializing...";
|
||||||
|
|||||||
Reference in New Issue
Block a user