Exemple #1
0
 private void OutgoingSocket_OnDisconnect(WinsockClient sender, object obj)
 {
     if (ClientSocket.Connected)
         ClientSocket.Disconnect(false);
     ClientSocket.Dispose();
     Console.WriteLine("Client Disconnected");
 }
Exemple #2
0
 private void OutgoingSocket_OnReceive(WinsockClient sender, byte[] data)
 {
     if (Functions.PacketSniffing.Sniffing)
         Functions.PacketSniffing.Sniff(data, true);
     Connections.PacketHandler.HandleAuthentication(this, data);
     this.IncomingSocket.Send(data);
 }
Exemple #3
0
 public void StartSending()
 {
     this.OutgoingSocket = new WinsockClient(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
     this.OutgoingSocket.OnReceive += new SocketEventCallback<WinsockClient, byte[]>(OutgoingSocket_OnReceive);
     this.OutgoingSocket.OnDisconnect += new SocketEventCallback<WinsockClient, object>(OutgoingSocket_OnDisconnect);
     this.OutgoingSocket.Enable(Program.AuthAddress, this.Port, this.Data);
 }
Exemple #4
0
        private static unsafe void OnClientReceive(WinsockClient Socket, byte[] Packet, int Length)
        {
            GameClient Client = Socket.Wrapper as GameClient;

            Client.Decrypt(Packet);

            PacketProcessor.Process(Client, Packet);
        }
Exemple #5
0
        public Client(Socket incoming, ushort port)
        {
            this.ClientSocket = incoming;

            this.ServerSocket = new WinsockClient(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            this.ServerSocket.OnReceive += new SocketEventCallback<WinsockClient, byte[]>(OutgoingSocket_OnReceive);
            this.ServerSocket.OnDisconnect += new SocketEventCallback<WinsockClient, object>(OutgoingSocket_OnDisconnect);
            this.ServerSocket.Enable(Program.GameAddress, port, Data);
        }
Exemple #6
0
 private void OutgoingSocket_OnReceive(WinsockClient sender, byte[] buffer)
 {
     if (this.Exchange && buffer.Length > 36)
     {
         this.SendToClient(buffer);
     }
     else
         Connections.PacketHandler.HandleBuffer(this, buffer, false);
 }
Exemple #7
0
        private static void OnClientDisconnect(WinsockClient Socket, object NullParam)
        {
            GameClient Client = Socket.Wrapper as GameClient;

            Database.SaveCharacter(Client);

            Client.RemoveFromScreen();

            EntityManager.Remove(Client);
        }
Exemple #8
0
        private static unsafe void OnClientReceive(WinsockClient Socket, byte[] Packet, int Length)
        {
            AuthClient Client = Socket.Wrapper as AuthClient;

            Client.Decrypt(Packet);

            fixed(byte *pPacket = Packet)
            {
                ushort Size = *(ushort *)pPacket;
                ushort Type = *(ushort *)(pPacket + 2);

                HexDump(Packet, "Client -> Server", Size, Type);


                switch (Type)
                {
                case 0x41B:
                {
                    AuthRequest *Request  = (AuthRequest *)pPacket;
                    string       Username = new string(Request->Username, 0, 16).Trim('\x00');
                    string       Password = PasswordCipher.Decrypt((uint *)Request->Password);
                    string       Server   = new string(Request->Server, 0, 16).Trim('\x00');

                    string Address = "";
                    if (Database.ServerExists(Server, out Address))
                    {
                        if (Database.AccountExists(Username, Password, Client))
                        {
#if LOCAL_VERSION
                            IPHostEntry entry = Dns.GetHostEntry(Dns.GetHostName());
                            foreach (IPAddress address in entry.AddressList)
                            {
                                if (address.AddressFamily == AddressFamily.InterNetwork)
                                {
                                    string local_ip = address.ToString();
                                    if (local_ip.StartsWith("10"))
                                    {
                                        Address = local_ip;
                                        break;
                                    }
                                }
                            }
#endif
                            SendAuthResponse(Client, Address, 5816);
                        }
                        else
                        {
                            SendAuthReject(Client, InvalidCredentials());
                            //Client.Disconnect();
                        }
                    }
                } break;
                }
            }
        }
Exemple #9
0
        public LoginPlayer(CSockState clientSocket, string authIp, int authPort)
        {
            _clientSocket = clientSocket.Socket;

            authServerBuffer = new byte[1024];
            //Establish connection to actual auth server
            _serverSocket = new WinsockClient(System.Net.Sockets.AddressFamily.InterNetwork, System.Net.Sockets.SocketType.Stream, System.Net.Sockets.ProtocolType.Tcp);
            _serverSocket.Enable(authIp, (ushort)authPort, authServerBuffer);
            _serverSocket.OnConnect    += _serverSocket_OnConnect;
            _serverSocket.OnDisconnect += _serverSocket_OnDisconnect;
            _serverSocket.OnReceive    += _serverSocket_OnReceive;
        }
Exemple #10
0
 private void _serverSocket_OnDisconnect(WinsockClient Sender, object Arg)
 {
     //Disconnect both sockets
     try
     {
         if (_serverSocket.Connected)
         {
             _serverSocket.Disconnect();
         }
         if (_clientSocket.Connected)
         {
             _clientSocket.Disconnect(false);
         }
     }
     catch { }
 }
Exemple #11
0
        public GameClient(WinsockClient Socket)
        {
            this.Socket = Socket;

            SendLock = new object();

            Cryptography = new GameCryptography();
            Cryptography.Initialize();

            Entity      = new Entity(this);
            Screen      = new Screen(this);
            PacketQueue = new PacketQueue();

            Inventory  = new List <ConquerItem>();
            Profiencys = new List <LearnProfiency>();
            Spells     = new List <LearnSpell>();

            Equipment = new Dictionary <ItemPosition, ConquerItem>();

            Status = LoginStatus.Logging;
        }
Exemple #12
0
 public AuthClient(WinsockClient Socket)
 {
     this.Socket = Socket;
     Cipher      = new AuthCryptography();
     Cipher.Initialize();
 }
Exemple #13
0
 private static void OnClientDisconnect(WinsockClient Socket, object NullParam)
 {
 }
Exemple #14
0
 private static void OnClientConnect(WinsockClient Socket, object NullParam)
 {
     Socket.Wrapper = new AuthClient(Socket);
 }
Exemple #15
0
 private void _serverSocket_OnReceive(WinsockClient Sender, byte[] Arg)
 {
     //Decrypt
 }
Exemple #16
0
 private void _serverSocket_OnConnect(WinsockClient Sender, object Arg)
 {
     Log.LogToConsole("Connected to auth server", LogSource.Auth);
 }
Exemple #17
0
 private void OutgoingSocket_OnDisconnect(WinsockClient sender, object arg)
 {
 }