private void AuthRequestPacketHandler(SchumixPacket pck, NetworkStream stream, string hst, int bck)
        {
            // opcode is already read, DO _NOT_ READ AGAIN
            string guid = pck.Read <string>();
            string hash = pck.Read <string>();

            if (hash != sUtilities.Md5(ServerConfigs.Password))
            {
                if (_HostList.ContainsKey(hst + SchumixBase.Colon + bck))
                {
                    _HostList.Remove(hst + SchumixBase.Colon + bck);
                }

                Log.Warning("AuthHandler", sLConsole.GetString("Auth unsuccessful! Guid of client: {0}"), guid);
                Log.Debug("Security", sLConsole.GetString("Hash was: {0}"), hash);
                Log.Notice("AuthHandler", sLConsole.GetString("Back port is: {0}"), bck);
                var packet = new SchumixPacket();
                packet.Write <int>((int)Opcode.SMSG_AUTH_DENIED);
                packet.Write <int>((int)0);
                SendPacketBack(packet, stream, hst, bck);
            }
            else
            {
                Log.Success("AuthHandler", sLConsole.GetString("Auth successful. Guid of client: {0}"), guid);
                Log.Debug("Security", sLConsole.GetString("Hash was: {0}"), hash);
                Log.Notice("AuthHandler", sLConsole.GetString("Back port is: {0}"), bck);
                var packet = new SchumixPacket();
                packet.Write <int>((int)Opcode.SMSG_AUTH_APPROVED);
                packet.Write <int>((int)1);
                SendPacketBack(packet, stream, hst, bck);
            }
        }
        public void HandlePacket(SchumixPacket packet, TcpClient client, NetworkStream stream)
        {
            var hst = client.Client.RemoteEndPoint.ToString().Split(SchumixBase.Colon)[0];
            int bck = client.Client.RemoteEndPoint.ToString().Split(SchumixBase.Colon)[1].ToInt32();

            int packetid = 0;

            try
            {
                packetid = packet.Read <int>();
            }
            catch (Exception)
            {
                var packet2 = new SchumixPacket();
                packet2.Write <int>((int)Opcode.SCMSG_PACKET_NULL);
                packet2.Write <string>(sLConsole.GetString("Wrong packetid, aborting connection!"));
                SendPacketBack(packet2, stream, hst, bck);
                Log.Warning("HandlePacket", sLConsole.GetString("Wrong packetid, aborting connection!"));
                return;
            }

            Log.Debug("HandlePacket", sLConsole.GetString("Got packet with ID: {0} from: {1}"), packetid, client.Client.RemoteEndPoint);

            if (!_AuthList.ContainsKey(hst + SchumixBase.Colon + bck))
            {
                if (packetid != (int)Opcode.CMSG_REQUEST_AUTH)
                {
                    var packet2 = new SchumixPacket();
                    packet2.Write <int>((int)Opcode.SMSG_AUTH_DENIED);
                    packet2.Write <int>((int)0);
                    SendPacketBack(packet2, stream, hst, bck);
                    return;
                }
                else
                {
                    _AuthList.Add(hst + SchumixBase.Colon + bck, true);
                }
            }

            if (!_HostList.ContainsKey(hst + SchumixBase.Colon + bck))
            {
                _HostList.Add(hst + SchumixBase.Colon + bck, stream);
            }

            if (PacketMethodMap.ContainsKey((Opcode)packetid))
            {
                PacketMethodMap[(Opcode)packetid].Method.Invoke(packet, stream, hst, bck);
                return;
            }
            else
            {
                Log.Notice("HandlePacket", sLConsole.GetString("Received unhandled packetid: {0}"), packetid);
            }
        }
        private void CloseHandler(SchumixPacket pck, NetworkStream stream, string hst, int bck)
        {
            if (_HostList.ContainsKey(hst + SchumixBase.Colon + bck))
            {
                _HostList.Remove(hst + SchumixBase.Colon + bck);
            }

            if (_AuthList.ContainsKey(hst + SchumixBase.Colon + bck))
            {
                _AuthList.Remove(hst + SchumixBase.Colon + bck);
            }

            string guid      = pck.Read <string>();
            string file      = pck.Read <string>();
            string dir       = pck.Read <string>();
            string ce        = pck.Read <string>();
            string locale    = pck.Read <string>();
            string reconnect = pck.Read <string>();
            string identify  = pck.Read <string>();

            Log.Warning("CloseHandler", sLConsole.GetString("Connection closed! Guid of client: {0}"), guid);

            if (hst != "127.0.0.1")
            {
                return;
            }

            if (!reconnect.ToBoolean())
            {
                return;
            }

            Log.Notice("CloseHandler", sLConsole.GetString("Restart in progress..."));

            if (sSchumix._processlist.ContainsKey(identify))
            {
                sSchumix.Start(file, dir, ce, locale, sUtilities.GetRandomString());
            }

            sSchumix._processlist.Remove(identify);
        }
Esempio n. 4
0
 /// <summary>
 /// The SCS Random number handler. (SMSG_SEND_SCS_RANDOM)
 /// </summary>
 /// <param name='pck'>
 /// Packet.
 /// </param>
 /// <param name='hst'>
 /// Host.
 /// </param>
 public void ScsRandHandler(SchumixPacket pck, string hst)
 {
     // read random value.
     var rand = pck.Read<int>();
     Log.Notice("Random", sLConsole.GetString("SCS sent random: {0}"), rand);
 }
Esempio n. 5
0
        /// <summary>
        /// Handles the packet.
        /// </summary>
        /// <param name='packet'>
        /// Packet.
        /// </param>
        /// <param name='client'>
        /// Client.
        /// </param>
        public void HandlePacket(SchumixPacket packet, TcpClient client)
        {
            var hst = client.Client.RemoteEndPoint.ToString().Split(SchumixBase.Colon)[0];
            int packetid = 0;

            try
            {
                packetid = packet.Read<int>();
            }
            catch(Exception)
            {
                var packet2 = new SchumixPacket();
                packet2.Write<int>((int)Opcode.SCMSG_PACKET_NULL);
                packet2.Write<string>(sLConsole.GetString("Wrong packetid, aborting connection!"));
                ClientSocket.SendPacketToSCS(packet);
                Log.Warning("ClientPacketHandler", sLConsole.GetString("Wrong packetid, aborting connection!"));
                return;
            }

            Log.Debug("ClientPacketHandler", sLConsole.GetString("Got packet with ID: {0} from: {1}"), packetid, client.Client.RemoteEndPoint);

            if(PacketMethodMap.ContainsKey((Opcode)packetid))
            {
                PacketMethodMap[(Opcode)packetid].Method.Invoke(packet, hst);
                return;
            }
            else
                Log.Notice("ClientPacketHandler", sLConsole.GetString("Received unhandled packetid: {0}"), packetid);
        }
Esempio n. 6
0
        public void HandlePacket(SchumixPacket packet, TcpClient client, NetworkStream stream)
        {
            var hst = client.Client.RemoteEndPoint.ToString().Split(SchumixBase.Colon)[0];
            int bck = client.Client.RemoteEndPoint.ToString().Split(SchumixBase.Colon)[1].ToInt32();

            int packetid = 0;

            try
            {
                packetid = packet.Read<int>();
            }
            catch(Exception)
            {
                var packet2 = new SchumixPacket();
                packet2.Write<int>((int)Opcode.SCMSG_PACKET_NULL);
                packet2.Write<string>(sLConsole.GetString("Wrong packetid, aborting connection!"));
                SendPacketBack(packet2, stream, hst, bck);
                Log.Warning("HandlePacket", sLConsole.GetString("Wrong packetid, aborting connection!"));
                return;
            }

            Log.Debug("HandlePacket", sLConsole.GetString("Got packet with ID: {0} from: {1}"), packetid, client.Client.RemoteEndPoint);

            if(!_AuthList.ContainsKey(hst + SchumixBase.Colon + bck))
            {
                if(packetid != (int)Opcode.CMSG_REQUEST_AUTH)
                {
                    var packet2 = new SchumixPacket();
                    packet2.Write<int>((int)Opcode.SMSG_AUTH_DENIED);
                    packet2.Write<int>((int)0);
                    SendPacketBack(packet2, stream, hst, bck);
                    return;
                }
                else
                    _AuthList.Add(hst + SchumixBase.Colon + bck, true);
            }

            if(!_HostList.ContainsKey(hst + SchumixBase.Colon + bck))
                _HostList.Add(hst + SchumixBase.Colon + bck, stream);

            if(PacketMethodMap.ContainsKey((Opcode)packetid))
            {
                PacketMethodMap[(Opcode)packetid].Method.Invoke(packet, stream, hst, bck);
                return;
            }
            else
                Log.Notice("HandlePacket", sLConsole.GetString("Received unhandled packetid: {0}"), packetid);
        }
Esempio n. 7
0
        private void CloseHandler(SchumixPacket pck, NetworkStream stream, string hst, int bck)
        {
            if(_HostList.ContainsKey(hst + SchumixBase.Colon + bck))
                _HostList.Remove(hst + SchumixBase.Colon + bck);

            if(_AuthList.ContainsKey(hst + SchumixBase.Colon + bck))
                _AuthList.Remove(hst + SchumixBase.Colon + bck);

            string guid = pck.Read<string>();
            string file = pck.Read<string>();
            string dir = pck.Read<string>();
            string ce = pck.Read<string>();
            string locale = pck.Read<string>();
            string reconnect = pck.Read<string>();
            string identify = pck.Read<string>();
            Log.Warning("CloseHandler", sLConsole.GetString("Connection closed! Guid of client: {0}"), guid);

            if(hst != "127.0.0.1")
                return;

            if(!reconnect.ToBoolean())
                return;

            Log.Notice("CloseHandler", sLConsole.GetString("Restart in progress..."));

            if(sSchumix._processlist.ContainsKey(identify))
                sSchumix.Start(file, dir, ce, locale, sUtilities.GetRandomString());

            sSchumix._processlist.Remove(identify);
        }
Esempio n. 8
0
        private void AuthRequestPacketHandler(SchumixPacket pck, NetworkStream stream, string hst, int bck)
        {
            // opcode is already read, DO _NOT_ READ AGAIN
            string guid = pck.Read<string>();
            string hash = pck.Read<string>();

            if(hash != sUtilities.Md5(ServerConfigs.Password))
            {
                if(_HostList.ContainsKey(hst + SchumixBase.Colon + bck))
                    _HostList.Remove(hst + SchumixBase.Colon + bck);

                Log.Warning("AuthHandler", sLConsole.GetString("Auth unsuccessful! Guid of client: {0}"), guid);
                Log.Debug("Security", sLConsole.GetString("Hash was: {0}"), hash);
                Log.Notice("AuthHandler", sLConsole.GetString("Back port is: {0}"), bck);
                var packet = new SchumixPacket();
                packet.Write<int>((int)Opcode.SMSG_AUTH_DENIED);
                packet.Write<int>((int)0);
                SendPacketBack(packet, stream, hst, bck);
            }
            else
            {
                Log.Success("AuthHandler", sLConsole.GetString("Auth successful. Guid of client: {0}"), guid);
                Log.Debug("Security", sLConsole.GetString("Hash was: {0}"), hash);
                Log.Notice("AuthHandler", sLConsole.GetString("Back port is: {0}"), bck);
                var packet = new SchumixPacket();
                packet.Write<int>((int)Opcode.SMSG_AUTH_APPROVED);
                packet.Write<int>((int)1);
                SendPacketBack(packet, stream, hst, bck);
            }
        }