Core/Network: Changed AsyncAcceptor to have a start method that returns false if it can't start the network.
Core/Logging: Cleaned up network logging.
This commit is contained in:
@@ -25,13 +25,13 @@ namespace Framework.Networking
|
|||||||
|
|
||||||
public class AsyncAcceptor
|
public class AsyncAcceptor
|
||||||
{
|
{
|
||||||
public AsyncAcceptor(string ip, int port)
|
public bool Start(string ip, int port)
|
||||||
{
|
{
|
||||||
var bindIP = IPAddress.None;
|
IPAddress bindIP;
|
||||||
if (!IPAddress.TryParse(ip, out bindIP))
|
if (!IPAddress.TryParse(ip, out bindIP))
|
||||||
{
|
{
|
||||||
Log.outError(LogFilter.Network, "Server can't be started: Invalid IP-Address ({0})", ip);
|
Log.outError(LogFilter.Network, "Server can't be started: Invalid IP-Address ({0})", ip);
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
@@ -42,7 +42,10 @@ namespace Framework.Networking
|
|||||||
catch (SocketException ex)
|
catch (SocketException ex)
|
||||||
{
|
{
|
||||||
Log.outException(ex);
|
Log.outException(ex);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async void AsyncAcceptSocket(SocketAcceptDelegate mgrHandler)
|
public async void AsyncAcceptSocket(SocketAcceptDelegate mgrHandler)
|
||||||
|
|||||||
@@ -27,7 +27,12 @@ namespace Framework.Networking
|
|||||||
{
|
{
|
||||||
Contract.Assert(threadCount > 0);
|
Contract.Assert(threadCount > 0);
|
||||||
|
|
||||||
Acceptor = new AsyncAcceptor(bindIp, port);
|
Acceptor = new AsyncAcceptor();
|
||||||
|
if (!Acceptor.Start(bindIp, port))
|
||||||
|
{
|
||||||
|
Log.outError(LogFilter.Network, "StartNetwork failed to Start AsyncAcceptor");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
_threadCount = threadCount;
|
_threadCount = threadCount;
|
||||||
_threads = new NetworkThread<TSocketType>[GetNetworkThreadCount()];
|
_threads = new NetworkThread<TSocketType>[GetNetworkThreadCount()];
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public class PacketLog
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Write(byte[] data, ClientOpcodes opcode, IPAddress address, uint port, ConnectionType connectionType)
|
public static void Write(byte[] data, uint opcode, IPAddress address, uint port, ConnectionType connectionType, bool isClientPacket)
|
||||||
{
|
{
|
||||||
if (!CanLog())
|
if (!CanLog())
|
||||||
return;
|
return;
|
||||||
@@ -58,7 +58,7 @@ public class PacketLog
|
|||||||
{
|
{
|
||||||
using (var writer = new BinaryWriter(File.Open(FullPath, FileMode.Append), Encoding.ASCII))
|
using (var writer = new BinaryWriter(File.Open(FullPath, FileMode.Append), Encoding.ASCII))
|
||||||
{
|
{
|
||||||
writer.Write("CMSG".ToCharArray());
|
writer.Write(isClientPacket ? 0x47534d43 : 0x47534d53);
|
||||||
writer.Write((uint)connectionType);
|
writer.Write((uint)connectionType);
|
||||||
writer.Write(Time.GetMSTime());
|
writer.Write(Time.GetMSTime());
|
||||||
|
|
||||||
@@ -72,36 +72,7 @@ public class PacketLog
|
|||||||
writer.Write(data.Length + 4);
|
writer.Write(data.Length + 4);
|
||||||
writer.Write(SocketIPBytes);
|
writer.Write(SocketIPBytes);
|
||||||
writer.Write(port);
|
writer.Write(port);
|
||||||
writer.Write((uint)opcode);
|
writer.Write(opcode);
|
||||||
writer.Write(data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void Write(byte[] data, ServerOpcodes opcode, IPAddress address, uint port, ConnectionType connectionType)
|
|
||||||
{
|
|
||||||
if (!CanLog())
|
|
||||||
return;
|
|
||||||
|
|
||||||
lock (syncObj)
|
|
||||||
{
|
|
||||||
using (var writer = new BinaryWriter(File.Open(FullPath, FileMode.Append), Encoding.ASCII))
|
|
||||||
{
|
|
||||||
writer.Write("SMSG".ToCharArray());
|
|
||||||
writer.Write((uint)connectionType);
|
|
||||||
writer.Write(Time.GetMSTime());
|
|
||||||
|
|
||||||
writer.Write(20);
|
|
||||||
byte[] SocketIPBytes = new byte[16];
|
|
||||||
if (address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
|
|
||||||
Buffer.BlockCopy(address.GetAddressBytes(), 0, SocketIPBytes, 0, 4);
|
|
||||||
else
|
|
||||||
Buffer.BlockCopy(address.GetAddressBytes(), 0, SocketIPBytes, 0, 16);
|
|
||||||
|
|
||||||
writer.Write(data.Length + 4);
|
|
||||||
writer.Write(SocketIPBytes);
|
|
||||||
writer.Write(port);
|
|
||||||
writer.Write((uint)opcode);
|
|
||||||
writer.Write(data);
|
writer.Write(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -161,6 +161,8 @@ namespace Game.Network
|
|||||||
|
|
||||||
var data = new byte[size];
|
var data = new byte[size];
|
||||||
Buffer.BlockCopy(GetReceiveBuffer(), 6, data, 0, size);
|
Buffer.BlockCopy(GetReceiveBuffer(), 6, data, 0, size);
|
||||||
|
|
||||||
|
PacketLog.Write(data, opcode, GetRemoteIpAddress(), GetRemotePort(), _connectType, true);
|
||||||
if (!ProcessPacket(new WorldPacket(data, opcode)))
|
if (!ProcessPacket(new WorldPacket(data, opcode)))
|
||||||
{
|
{
|
||||||
CloseSocket();
|
CloseSocket();
|
||||||
@@ -191,7 +193,6 @@ namespace Game.Network
|
|||||||
bool ProcessPacket(WorldPacket packet)
|
bool ProcessPacket(WorldPacket packet)
|
||||||
{
|
{
|
||||||
ClientOpcodes opcode = (ClientOpcodes)packet.GetOpcode();
|
ClientOpcodes opcode = (ClientOpcodes)packet.GetOpcode();
|
||||||
PacketLog.Write(packet.GetData(), opcode, GetRemoteIpAddress(), GetRemotePort(), _connectType);
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -272,14 +273,13 @@ namespace Game.Network
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
packet.LogPacket(_worldSession);
|
packet.LogPacket(_worldSession);
|
||||||
|
|
||||||
packet.WritePacketData();
|
packet.WritePacketData();
|
||||||
|
|
||||||
var data = packet.GetData();
|
var data = packet.GetData();
|
||||||
uint packetSize = (uint)data.Length;
|
|
||||||
ServerOpcodes opcode = packet.GetOpcode();
|
ServerOpcodes opcode = packet.GetOpcode();
|
||||||
PacketLog.Write(data, opcode, GetRemoteIpAddress(), GetRemotePort(), _connectType);
|
PacketLog.Write(data, (uint)opcode, GetRemoteIpAddress(), GetRemotePort(), _connectType, false);
|
||||||
|
|
||||||
|
uint packetSize = (uint)data.Length;
|
||||||
if (packetSize > 0x400 && worldCrypt.IsInitialized)
|
if (packetSize > 0x400 && worldCrypt.IsInitialized)
|
||||||
{
|
{
|
||||||
ByteBuffer buffer = new ByteBuffer();
|
ByteBuffer buffer = new ByteBuffer();
|
||||||
@@ -398,6 +398,7 @@ namespace Game.Network
|
|||||||
hmac.Process(_serverChallenge, 16);
|
hmac.Process(_serverChallenge, 16);
|
||||||
hmac.Finish(AuthCheckSeed, 16);
|
hmac.Finish(AuthCheckSeed, 16);
|
||||||
|
|
||||||
|
|
||||||
// Check that Key and account name are the same on client and server
|
// Check that Key and account name are the same on client and server
|
||||||
if (!hmac.Digest.Compare(authSession.Digest))
|
if (!hmac.Digest.Compare(authSession.Digest))
|
||||||
{
|
{
|
||||||
@@ -406,6 +407,7 @@ namespace Game.Network
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Sha256 keyData = new Sha256();
|
Sha256 keyData = new Sha256();
|
||||||
keyData.Finish(account.game.SessionKey, account.game.SessionKey.Length);
|
keyData.Finish(account.game.SessionKey, account.game.SessionKey.Length);
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,13 @@ namespace Game.Network
|
|||||||
if (!base.StartNetwork(bindIp, port, threadCount))
|
if (!base.StartNetwork(bindIp, port, threadCount))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
_instanceAcceptor = new AsyncAcceptor(bindIp, WorldConfig.GetIntValue(WorldCfg.PortInstance));
|
_instanceAcceptor = new AsyncAcceptor();
|
||||||
|
if (!_instanceAcceptor.Start(bindIp, WorldConfig.GetIntValue(WorldCfg.PortInstance)))
|
||||||
|
{
|
||||||
|
Log.outError(LogFilter.Network, "StartNetwork failed to start instance AsyncAcceptor");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
_instanceAcceptor.AsyncAcceptSocket(OnSocketOpen);
|
_instanceAcceptor.AsyncAcceptSocket(OnSocketOpen);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ PacketLogFile = "CypherCore.pkt"
|
|||||||
#
|
#
|
||||||
|
|
||||||
Appender.Console = 1,3,0
|
Appender.Console = 1,3,0
|
||||||
Appender.Server = 2,2,0
|
Appender.Server = 2,1,0
|
||||||
Appender.GM = 2,2,0,gm/gm_{0}.log
|
Appender.GM = 2,2,0,gm/gm_{0}.log
|
||||||
Appender.DBErrors = 2,4,0,DBErrors.log
|
Appender.DBErrors = 2,4,0,DBErrors.log
|
||||||
|
|
||||||
@@ -167,7 +167,7 @@ Logger.ServerLoading = 3,Console Server
|
|||||||
Logger.Commands = 3,Console GM
|
Logger.Commands = 3,Console GM
|
||||||
Logger.Sql = 3,Console DBErrors
|
Logger.Sql = 3,Console DBErrors
|
||||||
Logger.SqlUpdates = 3,Console Server
|
Logger.SqlUpdates = 3,Console Server
|
||||||
Logger.Network = 1,Console Server
|
Logger.Network = 3,Console Server
|
||||||
|
|
||||||
#Logger.Achievement=3,Console Server
|
#Logger.Achievement=3,Console Server
|
||||||
#Logger.AreaTrigger=3,Console Server
|
#Logger.AreaTrigger=3,Console Server
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,2 @@
|
|||||||
|
--
|
||||||
|
DELETE FROM `creature_addon` WHERE `guid` IN (255649,255653,255654,255655,255656,255660,255664,255773,255783,255975,255977,255979,255981,257450,257454,257471,257474,257481,257483,257486,257488,257498,257508,257509,257514,257535,257545,257549,257560,257567,257573,257575,257587,257601,257652,257655,257669,257711,257723,257724,257732,257751,257765,257794,257795,257806,257808,257820,257833,257840,257847,257873,257890,257896,257897,257899,257911,257912,257936,257939,257940,257944,257947,257963,257965,257979,257980,258398,258404,258405,258406,258412,258413,258414,258438,258473,258479,258483,258486,258489,258491,258496,258507,258528,258529,258531,258539,258541,258542,258557,258559,258561,258562,258564,258566,258571,258618,258648);
|
||||||
Reference in New Issue
Block a user