Exemple #1
0
 private void OnHello(Client client, HelloPacket packet)
 {
     client.State           = _proxy.GetState(client, packet.Key);
     client.State.LastHello = packet;
     if (client.State.ConRealKey.Length != 0)
     {
         packet.Key = client.State.ConRealKey;
         client.State.ConRealKey = new byte[0];
     }
     client.Connect(packet);
     packet.Send = false;
 }
Exemple #2
0
 public Client(string hostname = "Client", bool localIP = false)
 {
     if (!localIP)
     {
         ClientInfo = new HelloPacket(hostname, Networking.getExternalIPE(), Port);
     }
     else if (localIP)
     {
         ClientInfo = new HelloPacket(hostname, Networking.getLocalIPE(), Port);
     }
     RaiseClientDisconnectedEvent += HandleClientDisconnectedEvent;
     RaiseClientWinEvent          += HandleClientWinEvent;
 }
Exemple #3
0
        static void Main(string[] args)
        {
            Packets.Load("Packets.json");

            Reconnect reconnect = new Reconnect()
            {
                Host    = "54.93.78.148",
                Port    = 2050,
                GameId  = -2,
                KeyTime = 0,
                Key     = new byte[0]
            };
            NetClient client = new NetClient(reconnect);

            client.Hook(PacketType.Failure, (p) =>
            {
                Console.WriteLine("Failure: " + ((FailurePacket)p).ErrorDescription);
            });
            client.Hook(PacketType.MapInfo, (p) =>
            {
                LoadPacket load = new LoadPacket()
                {
                    CharId      = 2,
                    IsFromArena = false
                };
                client.SendPacket(load);
            });
            client.Hook(PacketType.Update, (p) =>
            {
                client.SendPacket(new UpdateAckPacket());
            });
            client.Hook(PacketType.NewTick, (p) =>
            {
                Console.WriteLine("NEW_TICK, id: " + ((NewTickPacket)p).TickId);
            });
            HelloPacket hello = new HelloPacket()
            {
                BuildVersion = "X31.2.3",
                GameId       = reconnect.GameId,
                Guid         = RSA.Instance.Encrypt(""),
                Password     = RSA.Instance.Encrypt(""),
                Secret       = RSA.Instance.Encrypt(""),
                GameNet      = "rotmg",
                PlayPlatform = "rotmg"
            };

            client.SendPacket(hello);

            Console.ReadKey();
        }
Exemple #4
0
        private void OnHello(Client client, HelloPacket packet)
        {
            client.State = _proxy.GetState(client, packet.Key);
            if (client.State.ConRealKey.Length != 0)
            {
                packet.Key = client.State.ConRealKey;
                client.State.ConRealKey = new byte[0];
                Console.WriteLine($"[HELLO PACKET] Packet Key: {Encoding.ASCII.GetString(packet.Key)}\r\n" +
                                  $"               State  Key: {Encoding.ASCII.GetString(client.State.ConRealKey)}");
            }

            client.Connect(packet);
            packet.Send = false;
        }
Exemple #5
0
 /// <summary>
 /// This creates a Host which will host the game.
 /// The UDP Listener is the backbone of a host and is requisite for the entire process.
 /// </summary>
 public Host(string hostname = "Host", bool localIP = false)
 {
     // Set up the IP Address to send out with the UDP Packet
     if (!localIP)
     {
         HostInformation = new HelloPacket(hostname, Networking.getExternalIPE(), Port);
     }
     else if (localIP)
     {
         HostInformation = new HelloPacket(hostname, Networking.getLocalIPE(), Port);
     }
     // TODO: Figure out whether the Host should start listening when created or if it should be started after creation by a public method.
     RaiseClientJoinedEvent       += HandleClientJoinedEvent;
     RaiseClientDisconnectedEvent += HandleClientDisconnectedEvent;
 }
Exemple #6
0
        // This is the UDP listener which listens for the hello broadcast.
        // It will then start a tcp client to reply to the server.
        // TCP is required for the response to ensure connection.


        // This is the UDP listener which listens for the hello broadcast.
        private static void StartListener(HelloPacket serverInfo)
        {
            Console.WriteLine($"Creating UDP server listener {serverInfo.ToString()}");
            //IPEndPoint listenEP = new IPEndPoint(IPAddress.Parse(clientInfo.address), listenPort);
            //UdpClient listener = new UdpClient(listenEP);
            //IPEndPoint groupEP = new IPEndPoint(IPAddress.Any, listenPort);
            UdpClient server       = new UdpClient(listenPort);
            Message   responseData = Utilities.Serialize(serverInfo);

            try
            {
                while (true)
                {
                    Console.WriteLine("UDP Waiting for broadcast");
                    // The groupEP gets the IP address needed for the RSVP
                    // So I could just send the port as a string, but what if some other program is using this port?
                    // Then with that an object may be best.

                    IPEndPoint clientEP = new IPEndPoint(IPAddress.Any, 0);
                    Message    message  = new Message();
                    message.data = server.Receive(ref clientEP);

                    HelloPacket receivedData = Utilities.Deserialize(message) as HelloPacket;

                    Console.WriteLine($"Received broadcast from {clientEP} :");
                    Console.WriteLine($" RSVP address {receivedData.ToString()}");

                    // Add client to the hostList
                    Console.WriteLine("Adding {0} to hostList", receivedData.ToString());
                    hostList.Add(receivedData);

                    // Send the server data to the client
                    Console.WriteLine("UDP Server sending response");
                    server.Send(responseData.data, responseData.data.Length, clientEP);

                    // Start TCP client (separate function I guess).
                    // StartTCPClient(clientInfo, serverData);
                }
            }
            catch (SocketException e)
            {
                Console.WriteLine(e);
            }
            finally
            {
                server.Close();
            }
        }
Exemple #7
0
 private void OnHello(Client client, HelloPacket packet)
 {
     if (FailurePacket.ActualBuildVersion != null)
     {
         packet.BuildVersion = FailurePacket.ActualBuildVersion;
     }
     client.State           = _proxy.GetState(client, packet.Key);
     client.State.LastHello = packet;
     if (client.State.ConRealKey.Length != 0)
     {
         packet.Key = client.State.ConRealKey;
         client.State.ConRealKey = new byte[0];
     }
     client.Connect(packet);
     packet.Send = false;
 }
Exemple #8
0
        private void Connected()
        {
            Reset();
            HelloPacket hello = new HelloPacket
            {
                BuildVersion = BuildVersion,
                GameId       = Reconnect.GameId,
                Guid         = RSA.Instance.Encrypt(_account.Email),
                Password     = RSA.Instance.Encrypt(_account.Password),
                Secret       = RSA.Instance.Encrypt(""),
                Key          = Reconnect.Key,
                KeyTime      = Reconnect.KeyTime,
                GameNet      = "rotmg",
                PlayPlatform = "rotmg"
            };

            _net.SendPacket(hello);
        }
Exemple #9
0
        private static void Test()
        {
            Console.WriteLine("\n\nTesting the Program:");
            int udpClientNum = 2;
            // Start up the server thread.
            HelloPacket hello1     = new HelloPacket("server", "127.0.0.1", port);
            Thread      udpserver1 = new Thread(() => StartListener(hello1));

            udpserver1.Start();

            // Start up the UDP client threads
            Thread[] clientThreadList = new Thread[listenerMaxNumber];
            for (int x = 0; x < clientThreadList.Length; x++)
            {
                Console.WriteLine("Creating UDP Client {0}", x + 1);
                HelloPacket clientInfo = new HelloPacket($"client {x + 1}", $"127.0.0.{udpClientNum}", port);
                Console.WriteLine($"UDP Client Created: {clientInfo.ToString()}");
                clientThreadList[x] = new Thread(() => StartBroadcast(clientInfo));
                clientThreadList[x].IsBackground = true;
                clientThreadList[x].Start();
                Console.WriteLine("Creating TCP Client {0}", x + 1);
                clientThreadList[x] = new Thread(() => CallListenerTest(clientInfo));
                clientThreadList[x].IsBackground = true;
                clientThreadList[x].Start();
                udpClientNum++;
            }


            // Test the Client and Listener Threads

            Console.WriteLine("Press any key to start the taters...");
            Console.ReadKey();

            Thread[] taterThreadList = new Thread[taterMaxNumber];
            for (int x = 0; x < taterThreadList.Length; x++)
            {
                Console.WriteLine("Creating IP_Tato server {0}", x + 1);
                IP_Tato tater = new IP_Tato("Tater #" + x, 5);
                taterThreadList[x] = new Thread(() => ServerTest(tater));
                taterThreadList[x].Start();
            }
        }
        private void HelloPacketRecieved(Socket client, HelloPacket packet)
        {
            Console.WriteLine("Recieved HELLO packet from {0}", packet.Name);

            if (packet.Password == "Password")
            {
                InfoPacket info = new InfoPacket();
                info.ConnectedClients = Networking.ConnectedClients.Count;
                info.Message          = "Welcome " + packet.Name + "!";
                client.Send(info);
            }
            else
            {
                FailurePacket failure = new FailurePacket();
                failure.ErrorId      = 0;
                failure.ErrorMessage = "WRONG PASSWORD!";
                client.Send(failure);
                Networking.Kick(client);
            }
        }
Exemple #11
0
        // lastClient may not be needed, but this class will be expanded to include other routing protocols
        public static HelloPacket RouteTater(List <HelloPacket> hostList, HelloPacket lastClient)
        {
            // This method could include a using statement like what is used in Serialize

            // rolls is used to determine the effectiveness of the routing protocol
            // Not the best, because it is entirely dependant on the size of the host list
            int         rolls  = 0;
            Random      random = new Random();
            HelloPacket newTargetClient;
            //do
            //{
            int index = random.Next(hostList.ToArray().Length);

            newTargetClient = hostList[index];
            rolls++;
            //}
            // while (newTargetClient == lastClient);
            Console.WriteLine("New targetClient {0} chosen after {1} roll(s)", newTargetClient, rolls);
            return(newTargetClient);
        }
Exemple #12
0
        public static void Test()
        {
            // Start up the listener threads
            HelloPacket client    = new HelloPacket("server", "127.0.0.2", listenPort);
            Thread      listener1 = new Thread(() => StartListener(client));

            listener1.Start();

            // Start up the broadcast thread.
            HelloPacket hello      = new HelloPacket("client", "127.0.0.3", listenPort);
            Thread      broadcast1 = new Thread(() => StartBroadcast(hello));

            broadcast1.Start();

            HelloPacket hello2     = new HelloPacket("client", "127.0.0.4", listenPort);
            Thread      broadcast2 = new Thread(() => StartBroadcast(hello2));

            broadcast2.Start();
            //
        }
Exemple #13
0
        static void Main(string[] args)
        {
            Reconnect reconnect = new Reconnect()
            {
                Host    = "54.93.78.148",
                Port    = 2050,
                GameId  = -2,
                KeyTime = 0,
                Key     = new byte[0]
            };

            NetClient client = new NetClient();

            client.Hook(PacketType.FAILURE, (p) => { Log.Error("Failure: " + ((FailurePacket)p).ErrorDescription); });
            client.Hook(PacketType.MAPINFO, (p) =>
            {
                LoadPacket load = new LoadPacket()
                {
                    CharId      = 2,
                    IsFromArena = false
                };
                client.SendPacket(load);
            });
            client.Hook(PacketType.UPDATE, (p) => { client.SendPacket(new UpdateAckPacket()); });
            client.Hook(PacketType.NEWTICK, (p) => { Log.Debug("NEW_TICK, id: " + ((NewTickPacket)p).TickId); });
            HelloPacket hello = new HelloPacket()
            {
                BuildVersion = Constants.Game.Version,
                GameId       = reconnect.GameId,
                Guid         = RSA.Instance.Encrypt(""),
                Password     = RSA.Instance.Encrypt(""),
                Secret       = RSA.Instance.Encrypt(""),
                GameNet      = "rotmg",
                PlayPlatform = "rotmg"
            };

            client.Connect(reconnect);
            client.SendPacket(hello);
            Console.ReadKey();
        }
Exemple #14
0
        /*
         * public static void TestClientandListenerThreads()
         * {
         *  Console.WriteLine("\n\nTesting the Program:");
         *  // Test the Client and Listener Threads
         *
         *  // Create Threadstarts to the methods.
         *  // ThreadStart listenerref = new ThreadStart(CallListenerTest);
         *  Console.WriteLine("In Main: Creating the Listener threads");
         *
         *  Thread[] listenerThreadList = new Thread[listenerMaxNumber];
         *  for (int x = 0; x < listenerThreadList.Length; x++)
         *  {
         *      Console.WriteLine("Creating Listener {0}", x + 1);
         *      listenerThreadList[x] = new Thread(() => CallListenerTest()));
         *      listenerThreadList[x].IsBackground = true;
         *      listenerThreadList[x].Start();
         *  }
         *  Console.WriteLine("Press any key to continue...");
         *  Console.ReadKey();
         *
         *  Thread[] serverThreadList = new Thread[taterMaxNumber];
         *  for (int x = 0; x < serverThreadList.Length; x++)
         *  {
         *      Console.WriteLine("Creating IP_Tato server {0}", x + 1);
         *      IP_Tato tater = new IP_Tato("Tater #" + x, 5);
         *      serverThreadList[x] = new Thread(() => ServerTest(tater));
         *      serverThreadList[x].Start();
         *  }
         *
         *
         *
         *  // Create the listener thread.
         *  // Thread listenerThread = new Thread(listenerref);
         *  // This makes it so that the program never is stuck open waiting on the listener to shut down.
         *
         *
         *  // Keep going on the main thread.
         *
         *  Console.WriteLine("\n\nMain Thread has concluded.\n\n");
         *
         *  Console.ReadKey();
         * }
         */
        public static void TestUDPHello()
        {
            int udpClientNum = 2;
            // Start up the server thread.
            HelloPacket hello1     = new HelloPacket("server", "127.0.0.1", listenPort);
            Thread      udpserver1 = new Thread(() => StartListener(hello1));

            udpserver1.Start();

            // Start up the UDP client threads
            Thread[] listenerThreadList = new Thread[listenerMaxNumber];
            for (int x = 0; x < listenerThreadList.Length; x++)
            {
                Console.WriteLine("Creating UDP Client {0}", x + 1);
                HelloPacket clientInfo = new HelloPacket($"client {x+1}", $"127.0.0.{udpClientNum}", listenPort);
                Console.WriteLine($"UDP Client Created: {clientInfo.ToString()}");
                listenerThreadList[x] = new Thread(() => StartBroadcast(clientInfo));
                listenerThreadList[x].IsBackground = true;
                listenerThreadList[x].Start();
                udpClientNum++;
            }
        }
Exemple #15
0
        private void Application_Startup()
        {
            Console.WriteLine("Application Startup has been called.");
            // TODO: add in a config screen which will update the client information.
            // IP_Tato tater = new IP_Tato();
            // ProcessPotato(tater);

            HelloPacket clientInfo = new HelloPacket("client", Networking.getExternalIPE(), 13000);

            // Start the network discovery
            Console.WriteLine("Starting the UDP Broadcast at {0}", clientInfo.ToString());
            Thread UDPBroadcast = new Thread(() => StartBroadcast(clientInfo));

            UDPBroadcast.Start();

            // Start the network listener.
            Thread ListenerThread = new Thread(() => StartListener(clientInfo));

            ListenerThread.Start();
            // When the listener processes the correct request
            // Create and show the popup.
        }
Exemple #16
0
        private void SendCommandToClient(HelloPacket targetClient, string command)
        {
            UdpClient client  = new UdpClient();
            Message   request = new Message();

            request = Utilities.Serialize(command);

            IPEndPoint serverEP = new IPEndPoint(IPAddress.Any, 0);

            client.Send(request.data, request.data.Length, targetClient.EndPoint());

            Console.WriteLine($"Command {command} sent to the client: {targetClient.ToString()}");
            Message responseMessage = new Message(256);

            // s.Receive(responseMessage.data);

            responseMessage.data = client.Receive(ref serverEP);
            object responseData = Utilities.Deserialize(responseMessage);

            Console.WriteLine($"Received respone from {responseData.ToString()}");

            client.Close();
        }
Exemple #17
0
    // Token: 0x06000233 RID: 563 RVA: 0x000103AC File Offset: 0x0000E5AC
    private void Hello(HelloPacket hello)
    {
        this._serverConnection         = new TcpClient();
        this._serverConnection.NoDelay = true;
        string key = Client.ByteArrayToString(hello.Key);

        if (hello.Key.Length != 0 && this.Proxy.ClientDestinations.ContainsKey(key))
        {
            ReconnectPacket u9Kj4tAStSlt3Dcm6rdEl60w8MG = this.Proxy.ClientDestinations[key];
            hello.GameId  = u9Kj4tAStSlt3Dcm6rdEl60w8MG.GameId;
            hello.Key     = u9Kj4tAStSlt3Dcm6rdEl60w8MG.Key;
            hello.KeyTime = u9Kj4tAStSlt3Dcm6rdEl60w8MG.KeyTime;
            this._serverConnection.BeginConnect(u9Kj4tAStSlt3Dcm6rdEl60w8MG.Host, u9Kj4tAStSlt3Dcm6rdEl60w8MG.Port, new AsyncCallback(this.ServerConnected), hello);
            Console.WriteLine("Client: Restored reconnect info.");
        }
        else
        {
            string host = (!ServerParser._IOpSuG4guyYLeez9LywVYmMYQtG.ContainsKey(Settings.Default.CurrentServer)) ? ServerParser._IOpSuG4guyYLeez9LywVYmMYQtG.First <KeyValuePair <string, string> >().Value : ServerParser._IOpSuG4guyYLeez9LywVYmMYQtG[Settings.Default.CurrentServer];
            this._serverConnection.BeginConnect(host, 2050, new AsyncCallback(this.ServerConnected), hello);
            Console.WriteLine("Client: Used default connect info.");
        }
        hello.Send = false;
    }
Exemple #18
0
        private void JoinServer()
        {
            // Thread BroadcastResponseListener = new Thread(() => StartTCPListener(thisHost));
            // BroadcastResponseListener.Start();
            // Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
            // Console.WriteLine();

            UdpClient Client  = new UdpClient();
            Message   request = new Message();

            request = Utilities.Serialize(ClientInfo);

            IPEndPoint serverEP = new IPEndPoint(IPAddress.Any, 0);

            Client.EnableBroadcast = true;
            Client.Send(request.data, request.data.Length, new IPEndPoint(IPAddress.Broadcast, 13000));

            Console.WriteLine("Message sent to the broadcast address");
            Message responseMessage = new Message(256);

            // s.Receive(responseMessage.data);

            responseMessage.data = Client.Receive(ref serverEP);

            object responseData = Utilities.Deserialize(responseMessage);

            if (responseData is HelloPacket)
            {
                ServerInfo = responseData as HelloPacket;
                Thread UDPCommandListenerThread = new Thread(UDPCommandListener);
                UDPCommandListenerThread.Start();
            }
            Console.WriteLine($"Received respone from {responseData.ToString()}");

            Client.Close();
        }
Exemple #19
0
        public void ProcessPacket(ClientConnection client, BasePacket packet)
        {
            if (packet.header.isCompressed == 0x01)
            {
                BasePacket.DecompressPacket(ref packet);
            }

            List <SubPacket> subPackets = packet.GetSubpackets();

            foreach (SubPacket subpacket in subPackets)
            {
                //Initial Connect Packet, Create session
                if (subpacket.header.type == 0x01)
                {
                    HelloPacket hello = new HelloPacket(packet.data);

                    if (packet.header.connectionType == BasePacket.TYPE_ZONE)
                    {
                        mServer.AddSession(client, Session.Channel.ZONE, hello.sessionId);
                        Session session = mServer.GetSession(hello.sessionId);
                        session.routing1 = mServer.GetWorldManager().GetZoneServer(session.currentZoneId);
                        session.routing1.SendSessionStart(session, true);
                    }
                    else if (packet.header.connectionType == BasePacket.TYPE_CHAT)
                    {
                        mServer.AddSession(client, Session.Channel.CHAT, hello.sessionId);
                    }

                    client.QueuePacket(_0x7Packet.BuildPacket(0x0E016EE5));
                    client.QueuePacket(_0x2Packet.BuildPacket(hello.sessionId));
                }
                //Ping from World Server
                else if (subpacket.header.type == 0x07)
                {
                    SubPacket init = _0x8PingPacket.BuildPacket(client.owner.sessionId);
                    client.QueuePacket(BasePacket.CreatePacket(init, true, false));
                }
                //Zoning Related
                else if (subpacket.header.type == 0x08)
                {
                    //Response, client's current [actorID][time]
                    //BasePacket init = Login0x7ResponsePacket.BuildPacket(BitConverter.ToUInt32(packet.data, 0x10), Utils.UnixTimeStampUTC(), 0x07);
                    //client.QueuePacket(init);
                    packet.DebugPrintPacket();
                }
                //Game Message
                else if (subpacket.header.type == 0x03)
                {
                    //Send to the correct zone server
                    uint targetSession = subpacket.header.targetId;

                    InterceptProcess(mServer.GetSession(targetSession), subpacket);

                    if (mServer.GetSession(targetSession).routing1 != null)
                    {
                        mServer.GetSession(targetSession).routing1.SendPacket(subpacket);
                    }

                    if (mServer.GetSession(targetSession).routing2 != null)
                    {
                        mServer.GetSession(targetSession).routing2.SendPacket(subpacket);
                    }
                }
                //World Server Type
                else if (subpacket.header.type >= 0x1000)
                {
                    uint    targetSession = subpacket.header.targetId;
                    Session session       = mServer.GetSession(targetSession);

                    switch (subpacket.header.type)
                    {
                    //Session Begin Confirm
                    case 0x1000:
                        SessionBeginConfirmPacket beginConfirmPacket = new SessionBeginConfirmPacket(packet.data);

                        if (beginConfirmPacket.invalidPacket || beginConfirmPacket.errorCode == 0)
                        {
                            Program.Log.Error("Session {0} had a error beginning session.", beginConfirmPacket.sessionId);
                        }

                        break;

                    //Session End Confirm
                    case 0x1001:
                        SessionEndConfirmPacket endConfirmPacket = new SessionEndConfirmPacket(packet.data);

                        if (!endConfirmPacket.invalidPacket && endConfirmPacket.errorCode != 0)
                        {
                            //Check destination, if != 0, update route and start new session
                            if (endConfirmPacket.destinationZone != 0)
                            {
                                session.currentZoneId = endConfirmPacket.destinationZone;
                                session.routing1      = Server.GetServer().GetWorldManager().GetZoneServer(endConfirmPacket.destinationZone);
                                session.routing1.SendSessionStart(session);
                            }
                            else
                            {
                                mServer.RemoveSession(Session.Channel.ZONE, endConfirmPacket.sessionId);
                                mServer.RemoveSession(Session.Channel.CHAT, endConfirmPacket.sessionId);
                            }
                        }
                        else
                        {
                            Program.Log.Error("Session {0} had an error ending session.", endConfirmPacket.sessionId);
                        }

                        break;

                    //Zone Change Request
                    case 0x1002:
                        WorldRequestZoneChangePacket zoneChangePacket = new WorldRequestZoneChangePacket(packet.data);

                        if (!zoneChangePacket.invalidPacket)
                        {
                            mServer.GetWorldManager().DoZoneServerChange(session, zoneChangePacket.destinationZoneId, "", zoneChangePacket.destinationSpawnType, zoneChangePacket.destinationX, zoneChangePacket.destinationY, zoneChangePacket.destinationZ, zoneChangePacket.destinationRot);
                        }

                        break;
                    }
                }
                else
                {
                    packet.DebugPrintPacket();
                }
            }
        }
Exemple #20
0
        void ProcessHelloPacket(HelloPacket pkt)
        {
            Console.WriteLine("Accepting new client...");
            db0 = new Database();
            if ((account = db0.Verify(pkt.GUID, pkt.Password)) == null)
            {
                Console.WriteLine("Account not verified.");
                account = Database.CreateGuestAccount(pkt.GUID);

                //Database.SaveCharacter(account, Database.CreateCharacter(782, 1));
                //Database.Register(pkt.GUID, pkt.Password, true);

                if (account == null)
                {
                    Console.WriteLine("Account is null");
                    SendPacket(new svrPackets.FailurePacket()
                    {
                        Message = "Invalid account."
                    });

                    return;
                }
            }
            if (db0.isWhitelisted(db0.Verify(pkt.GUID, pkt.Password)) == false)
            {
                Console.WriteLine("Not whitelisted account trying to connect.");
                SendPacket(new svrPackets.FailurePacket()
                {
                    Message = "You are not whitelisted!"
                });
                //eventual account ban code (assuming you would punish someone for bypassing the webserver and trying to connect throught a proxy or whatever)
                return;
            }
            if (db0.isBanned(db0.Verify(pkt.GUID, pkt.Password)) == true)
            {
                Console.WriteLine("Banned account trying to connect.");
                SendPacket(new svrPackets.FailurePacket()
                {
                    Message = "Your account is banned!"
                });
                //eventual IP ban code (assuming you would punish someone for bypassing the webserver and trying to connect throught a proxy or whatever)
                return;
            }
            Console.WriteLine("Client trying to connect");
            if (!RealmManager.TryConnect(this))
            {
                if (CheckAccountInUse(account.AccountId) != false)
                {
                    Console.WriteLine("Account in use: " + account.AccountId);
                    account = null;
                    SendPacket(new svrPackets.FailurePacket()
                    {
                        Message = "Account in use! Retrying..."
                    });
                    Disconnect();
                    return;
                }
                account = null;
                SendPacket(new svrPackets.FailurePacket()
                {
                    Message = "Failed to connect."
                });
                Console.WriteLine("Failed to connect.");
            }
            else
            {
                Console.WriteLine("Client loading world");
                World world = RealmManager.GetWorld(pkt.GameId);
                if (world == null)
                {
                    SendPacket(new svrPackets.FailurePacket()
                    {
                        Message = "Invalid world."
                    });
                    Console.WriteLine("Invalid world");
                }
                else
                {
                    Console.WriteLine("Client joined world " + world.Id.ToString());
                    if (world.Id == -6) //Test World
                    {
                        (world as realm.worlds.Test).LoadJson(pkt.MapInfo);
                    }
                    else if (world.IsLimbo)
                    {
                        world = world.GetInstance(this);
                    }

                    var seed = (uint)((long)Environment.TickCount * pkt.GUID.GetHashCode()) % uint.MaxValue;
                    Random      = new wRandom(seed);
                    targetWorld = world.Id;
                    SendPacket(new MapInfoPacket()
                    {
                        Width         = world.Map.Width,
                        Height        = world.Map.Height,
                        Name          = world.Name,
                        Seed          = seed,
                        Background    = world.Background,
                        AllowTeleport = world.AllowTeleport,
                        ShowDisplays  = world.ShowDisplays,
                        ClientXML     = world.ClientXML,
                        ExtraXML      = world.ExtraXML
                    });
                    stage = ProtocalStage.Handshaked;
                    Console.WriteLine("End of client world packet");
                }
            }
        }
        private void ProcessHelloPacket(HelloPacket pkt)
        {
            db = new Database();
            //Console.Out.WriteLine(pkt.GUID + ": " + pkt.Password);
            if ((account = db.Verify(pkt.GUID, pkt.Password)) == null)
            {
                Console.WriteLine(@"Account not verified.");
                account = Database.CreateGuestAccount(pkt.GUID);

                if (account == null)
                {
                    Console.WriteLine(@"Account is null!");
                    SendPacket(new FailurePacket
                    {
                        Message = "Invalid account."
                    });
                    Disconnect();
                    db.Dispose();
                    return;
                }
            }
            if ((ip = db.CheckIp(skt.RemoteEndPoint.ToString().Split(':')[0])) == null)
            {
                Console.WriteLine(@"Error checking IP");
                SendPacket(new FailurePacket
                {
                    Message = "Error with IP."
                });
                Disconnect();
                db.Dispose();
                return;
            }
            Console.WriteLine(@"Client trying to connect!");
            ConnectedBuild = pkt.BuildVersion;
            if (!RealmManager.TryConnect(this))
            {
                if (CheckAccountInUse(account.AccountId) != false)
                {
                    Console.WriteLine(@"Account in use: " + account.AccountId + @" " + account.Name);
                    account = null;
                    SendPacket(new FailurePacket
                    {
                        Message = "Account in use! Retrying..."
                    });
                    Disconnect();
                    db.Dispose();
                    return;
                }
                account = null;
                SendPacket(new FailurePacket
                {
                    Message = "Failed to connect."
                });
                Disconnect();
                Console.WriteLine(@"Failed to connect.");
            }
            else
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine(@"Client loading world");
                Console.ForegroundColor = ConsoleColor.White;
                var world = RealmManager.GetWorld(pkt.GameId);
                if (world == null)
                {
                    SendPacket(new FailurePacket
                    {
                        Message = "Invalid world."
                    });
                    Disconnect();
                    Console.WriteLine(@"Invalid world");
                }
                Console.ForegroundColor = ConsoleColor.Yellow;
                try
                {
                    Console.WriteLine(@"Client joined world " + world.Id);
                }
                catch
                {
                    Console.WriteLine(@"Error! World is null");
                }
                Console.ForegroundColor = ConsoleColor.White;
                if (world.Id == -6) //Test World
                {
                    (world as Test).LoadJson(pkt.MapInfo);
                }

                else if (world.IsLimbo)
                {
                    world = world.GetInstance(this);
                }
                var seed = (uint)((long)Environment.TickCount * pkt.GUID.GetHashCode()) % uint.MaxValue;
                Random      = new wRandom(seed);
                targetWorld = world.Id;
                if (!ConnectedBuildStartsWith(clientVer))
                {
                    SendPacket(new TextPacket
                    {
                        BubbleTime = 1,
                        Stars      = -1,
                        Name       = "",
                        Text       = "Your client is outdated. Visit http://forum.zerorealms.com to get the latest one!"
                    });
                    Disconnect();

                    /*SendPacket(new TextBoxPacket
                     * {
                     *  Button1 = "Okay",
                     *  Message = "Your client is outdated, Click <font color=\"white\"><b><a href='http://forum.zerorealms.com'>Here</a></b></font> to get the latest one!",
                     *  Title = "Outdated Client!",
                     *  Type = "NewClient"
                     * });*/
                }
                SendPacket(new MapInfoPacket
                {
                    Width         = world.Map.Width,
                    Height        = world.Map.Height,
                    Name          = world.Name,
                    Seed          = seed,
                    Background    = world.Background,
                    AllowTeleport = world.AllowTeleport,
                    ShowDisplays  = world.ShowDisplays,
                    Music         = world.GetMusic(Random),
                    ClientXML     = world.ClientXML,
                    ExtraXML      = world.ExtraXML,

                    SendMusic = ConnectedBuildStartsWith(clientVer)
                });
                stage = ProtocalStage.Handshaked;
            }
        }
Exemple #22
0
        // This listener will basically function as the client for most intents and purposes.
        public static void CallListenerTest(HelloPacket clientInfo)
        {
            TcpListener listener = null;

            try
            {
                Console.WriteLine("IP is {0}", clientInfo.address);
                IPAddress localip = IPAddress.Parse((clientInfo.address));
                Console.WriteLine("Starting a tcplistener at {0} using port {1}", localip, clientInfo.port);
                listener = new TcpListener(localip, clientInfo.port);
                listener.Start();
                Console.WriteLine("Listener has started.");

                // Create Buffer
                byte[] buffer = new byte[buffersize];

                while (true)
                {
                    // Add an extra space to help distinguish between each server transaction.
                    Console.WriteLine();
                    Console.WriteLine("Client wating for a connection... ");

                    // Accept a pending connection
                    TcpClient client = listener.AcceptTcpClient();
                    Console.WriteLine("Connected!");

                    // Instantiate the stream
                    NetworkStream stream = client.GetStream();

                    // While there is data to be read
                    // TODO: Implement the ability to read more data with a smaller buffer.
                    while ((stream.Read(buffer, 0, buffer.Length)) != 0)
                    {
                        try
                        {
                            // Instantiate a Message object to hold the incoming object
                            Message incomingMessage = new Message();
                            // Assign the data which has been read to incomingMessage
                            incomingMessage.data = buffer;
                            // Deserialize the inbound data into an object which can be processed
                            //   By the function or workerthread.
                            IP_Tato receivedTato = Utilities.Deserialize(incomingMessage) as IP_Tato;
                            // Verify that the server received the correct data
                            Console.WriteLine("Client Received: " + receivedTato.ToString());

                            Console.WriteLine("Processing Request...");

                            // TODO: Create a worker thread to work with the potato.
                            //      This will be especially necessary when UI gets involved.
                            // For now it is just going to call a function
                            IP_Tato objectResponse = (IP_Tato)ProcessPotato(receivedTato);

                            if (objectResponse.Exploded)
                            {
                                // Exact the consequences of an exploded tater
                            }
                            else
                            {
                                Console.WriteLine($"You have received an IP_Tato from {receivedTato.LastClient}");
                                Console.WriteLine("Press any key to send the tater back!");
                                Console.ReadKey();
                            }

                            // Instantiate a Message to hold the response message
                            Message responseMessage = new Message();
                            responseMessage = Utilities.Serialize(objectResponse);

                            // Send back a response.
                            stream.Write(responseMessage.data, 0, responseMessage.data.Length);
                            // Verify that the data sent against the client receipt.
                            Console.WriteLine("Client Sent {0}", objectResponse.ToString());
                        }
                        catch (Exception ErrorProcessRequest)
                        {
                            Console.WriteLine("The request failed to be processed. Error details: " + ErrorProcessRequest);
                        }



                        // byte[] msg = System.Text.Encoding.ASCII.GetBytes("Server Received: " + data.ToString());
                    }
                    Console.WriteLine("---Listener Transaction Closed---");
                    stream.Close();
                    client.Close();
                }
            }
            catch (SocketException e)
            {
                Console.WriteLine("Server SocketException: {0}", e);
            }
            finally
            {
                listener.Stop();
            }
        }
Exemple #23
0
        int targetWorld = -1;         //-2 = nexus

        void ProcessHelloPacket(HelloPacket pkt)
        {
            if (isGuest)
            {
                Disconnect();
            }
            db = new Database();
            if ((account = db.Verify(pkt.GUID, pkt.Password)) == null)
            {
                Console.WriteLine("Account not verified.");
                account = Database.CreateGuestAccount(pkt.GUID);

                if (account == null)
                {
                    Console.WriteLine("Account is null!");
                    SendPacket(new svrPackets.FailurePacket()
                    {
                        Message = "Invalid account."
                    });
                    Disconnect();
                    return;
                }
            }
            Console.WriteLine("Client is connecting!");
            ConnectedBuild = pkt.BuildVersion;
            if (!RealmManager.TryConnect(this))
            {
                if (CheckAccountInUse(account.AccountId) != false)
                {
                    Console.WriteLine("Account in use: " + account.AccountId + " " + account.Name);
                    account = null;
                    SendPacket(new svrPackets.FailurePacket()
                    {
                        Message = "Account in use! Retrying..."
                    });
                    Disconnect();
                    return;
                }
                account = null;
                SendPacket(new svrPackets.FailurePacket()
                {
                    Message = "Failed to connect."
                });
                Disconnect();
                Console.WriteLine(skt.RemoteEndPoint + " to connect.");
                return;
            }
            else
            {
                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.WriteLine(skt.RemoteEndPoint + " loading world");
                World world = RealmManager.GetWorld(pkt.GameId);
                if (world == null)
                {
                    SendPacket(new svrPackets.FailurePacket()
                    {
                        Message = "Invalid world."
                    });
                    Disconnect();
                    Console.WriteLine("Invalid world");
                }
                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.WriteLine(skt.RemoteEndPoint + " joined world " + world.Id.ToString());
                if (world.Id == -5)                 //Test World
                {
                    (world as realm.worlds.Test).LoadJson(pkt.MapInfo);
                }
                else if (world.IsLimbo)
                {
                    world = world.GetInstance(this);
                }
                var seed = (uint)((long)Environment.TickCount * pkt.GUID.GetHashCode()) % uint.MaxValue;
                Random      = new wRandom(seed);
                targetWorld = world.Id;
                SendPacket(new MapInfoPacket()
                {
                    Width         = world.Map.Width,
                    Height        = world.Map.Height,
                    Name          = world.Name,
                    Seed          = seed,
                    Background    = world.Background,
                    AllowTeleport = world.AllowTeleport,
                    ShowDisplays  = world.ShowDisplays,
                    //Music = world.GetMusic(Random),
                    ClientXML = world.ClientXML,
                    ExtraXML  = world.ExtraXML
                });
                //TODO: Fix this
                if (hasRead)
                {
                    return;
                }
                else
                {
                    SendPacket(new TextBoxPacket
                    {
                        Button1 = "I understand!",
                        Message = "This server is not meant to be played! It is a playground for exploits. Any exploits such as duping, godmode, and anything in between is allowed. Be warned that players may be able to steal your items. :) \n Add zeroehdev on skype to discuss any exploits. \n Your actions, ip, and id are being logged and time stamped.",
                        Title   = "Watch Out!",
                        Type    = "Test"
                    });
                    Console.WriteLine("[" + DateTime.Now + "]" + Account.AccountId + " has connected!");
                    var dir = @"logs";
                    if (!System.IO.Directory.Exists(dir))
                    {
                        System.IO.Directory.CreateDirectory(dir);
                    }
                    using (System.IO.StreamWriter writer = new System.IO.StreamWriter(@"logs\IDConnectedLog.txt", true))
                    {
                        writer.WriteLine("[" + DateTime.Now + "]" + Account.AccountId + " has connected!");
                    }
                    hasRead = !hasRead;
                }
                //DDoS client and server 101:
                //while (hasRead == false)
                //{
                //	//hasRead ^= hasRead;
                //	SendPacket(new TextBoxPacket
                //	{
                //		Button1 = "I understand!",
                //		Message =
                //			"This server is not meant to be played, but rather to be exploited. Any exploits such as duping, godmode, and anything else is allowed. Be warned that players may be able to steal your items. :) \n Add zeroehdev on skype to discuss any exploits. \n Your actions, ip, username, and id are being logged and time stamped.",
                //		Title = "Watch Out!",
                //		Type = "Test"
                //	});
                //	//hasRead ^= hasRead;
                //}
                //hasRead = true;
                stage = ProtocalStage.Handshaked;
            }
        }
Exemple #24
0
 public Join()
 {
     clientInfo = new HelloPacket("client", Networking.getExternalIPE(), 13000);
     InitializeComponent();
 }
Exemple #25
0
    // Token: 0x06000232 RID: 562 RVA: 0x0000FDC0 File Offset: 0x0000DFC0
    private void HandlePacket(Packet packet)
    {
        UpdatePacket updatePacket = packet as UpdatePacket;

        if (updatePacket != null)
        {
            this._objectTracker.Update(updatePacket);
            this.SafeWalk.Update(updatePacket);
            this._autoNexus.Update(updatePacket);
            this._fameHelper.Update(updatePacket);
            this._accuracyFarm.Update(updatePacket);
            this._antiLag.Update(updatePacket);
            this._autoLoot.Update(updatePacket);
            this._mapHack.Update(updatePacket);
            this._o3Helper.Update(updatePacket);
            this._showLHPot.Update(updatePacket);
            return;
        }
        NewTickPacket newTickPacket = packet as NewTickPacket;

        if (newTickPacket != null)
        {
            this._objectTracker.NewTick(newTickPacket);
            this._antiDebuffs.NewTick(newTickPacket);
            this._autoNexus.NewTick(newTickPacket);
            this._antiDdos.NewTick();
            this._fameHelper.NewTick(newTickPacket);
            this._accuracyFarm.NewTick(newTickPacket);
            this._antiLag.NewTick(newTickPacket);
            this._o3Helper.NewTick(newTickPacket);
            this._autoNexus2.NewTick(newTickPacket);
            return;
        }
        MovePacket movePacket = packet as MovePacket;

        if (movePacket != null)
        {
            this.PreviousTime = movePacket._Nx46RcGIU0H1BCGWaJXjN1ieopt;
            this._objectTracker.move(movePacket);
            this._antiDebuffs.Move(movePacket);
            this._autoLoot.Move(movePacket);
            this.AntiAfk.move(movePacket);
            this._autoNexus.move(movePacket);
            this._autoNexus2.move(movePacket);
            return;
        }
        MapInfoPacket mapInfoPacket = packet as MapInfoPacket;

        if (mapInfoPacket != null)
        {
            Console.WriteLine("Client: Map is " + mapInfoPacket.Name);
            this._objectTracker.MapInfo(mapInfoPacket);
            this._autoNexus2.MapInfo(mapInfoPacket);
            this.SafeWalk.MapInfo(mapInfoPacket);
            this._autoNexus.MapInfo(mapInfoPacket);
            this._autoLoot.MapInfo(mapInfoPacket);
            this._fameHelper.MapInfo();
            _accuracyFarm.MapInfo();
            this._antiLag.MapInfo(mapInfoPacket);
            this._mapHack.MapInfo(mapInfoPacket);
            this._o3Helper.MapInfo(mapInfoPacket);
            this._showLHPot.MapInfo(mapInfoPacket);
            return;
        }
        PlayerTextPacket playerTextPacket = packet as PlayerTextPacket;

        if (playerTextPacket != null)
        {
            this._teleportTools.text(playerTextPacket);
            this._ipJoin.text(playerTextPacket);
            this._fameHelper._QrK9KtR4xguWgEYrBE9xnEwwcqd(playerTextPacket);
            this._antiLag.PlayerText(playerTextPacket);
            this._mapHack.text(playerTextPacket);
            this._autoNexus._QrK9KtR4xguWgEYrBE9xnEwwcqd(playerTextPacket);
            return;
        }
        _5Qyhf9ImNgkDzh4BmaDRKP646iH createSuccessPacket = packet as _5Qyhf9ImNgkDzh4BmaDRKP646iH;

        if (createSuccessPacket != null)
        {
            this.PlayerId = createSuccessPacket.ObjectId;
            this._objectTracker._1lYB9SyYVs1zUAIHgLGbUs7pmeb();
            this._bazaarTimer.CreateSuccess();
            this._autoNexus2._1lYB9SyYVs1zUAIHgLGbUs7pmeb();
            return;
        }
        FailurePacket failurePacket = packet as FailurePacket;

        if (failurePacket != null)
        {
            Console.WriteLine(string.Format("Client: Got failure {0}, {1} ({2})", failurePacket.ErrorId, failurePacket.ErrorMessage, failurePacket.ErrorPlace));
            return;
        }
        ReconnectPacket reconnectPacket = packet as ReconnectPacket;

        if (reconnectPacket != null)
        {
            this.Reconnect(reconnectPacket);
            return;
        }
        HelloPacket helloPacket = packet as HelloPacket;

        if (helloPacket != null)
        {
            this.Hello(helloPacket);
            return;
        }
        PlayerHitPacket playerHitPacket = packet as PlayerHitPacket;

        if (playerHitPacket != null)
        {
            this._autoNexus.PlayerHit(playerHitPacket);
            this._antiDebuffs.PlayerHit(playerHitPacket);
            return;
        }
        AoEPacket pqhqze9k9pObME2LmlIcbfEeSYS = packet as AoEPacket;

        if (pqhqze9k9pObME2LmlIcbfEeSYS != null)
        {
            this._autoNexus._M1PxW31jx87SGG4gvOYAwe86vjg(pqhqze9k9pObME2LmlIcbfEeSYS);
            this._antiDebuffs.AoE(pqhqze9k9pObME2LmlIcbfEeSYS);
            return;
        }
        AoEAckPacket x7UwVkbcYG7VnZWu4HCA8hCeQtS = packet as AoEAckPacket;

        if (x7UwVkbcYG7VnZWu4HCA8hCeQtS != null)
        {
            this._autoNexus._iKqf12lpU2ifSlxUxUegqEC5CVe(x7UwVkbcYG7VnZWu4HCA8hCeQtS);
            return;
        }
        GroundDamagePacket hllcDvAIxPBOvJZP4BFTFQUoryN = packet as GroundDamagePacket;

        if (hllcDvAIxPBOvJZP4BFTFQUoryN != null)
        {
            this._autoNexus._524YRDmz9HCOj575eu5oeD5ruJb(hllcDvAIxPBOvJZP4BFTFQUoryN);
            return;
        }
        _6lHFncsY9352Wg3pNnnFZ49g5xA 6lHFncsY9352Wg3pNnnFZ49g5xA = packet as QuestObjIdPacket;
        if (6lHFncsY9352Wg3pNnnFZ49g5xA != null)
        {
            this._teleportTools._FMTVFcTfzNRteqoB3XiUkaNps7l(6lHFncsY9352Wg3pNnnFZ49g5xA);
            return;
        }
        ShowEffectPacket showEffectPacket = packet as ShowEffectPacket;

        if (showEffectPacket != null)
        {
            this._antiLag.ShowEffect(showEffectPacket);
            this._autoNexus._1nwhQXngJ6rNjd7Ufx1bWeF0vhM(showEffectPacket);
            this._o3Helper._1nwhQXngJ6rNjd7Ufx1bWeF0vhM(showEffectPacket);
            return;
        }
        _4wU9AwmH67XtmNygsXuDz9DUXYm 4wU9AwmH67XtmNygsXuDz9DUXYm = packet as _4wU9AwmH67XtmNygsXuDz9DUXYm;
        if (4wU9AwmH67XtmNygsXuDz9DUXYm != null)
        {
            this._antiLag._Q1PiJQ99KBCJeLcZ0HOk3AUAjIP(4wU9AwmH67XtmNygsXuDz9DUXYm);
            return;
        }
        PlayerShootPacket fbqBESNaaIBpK5dNK9X5lWOOll = packet as PlayerShootPacket;

        if (fbqBESNaaIBpK5dNK9X5lWOOll != null)
        {
            this._autoNexus2.PlayerShoot(fbqBESNaaIBpK5dNK9X5lWOOll);
            return;
        }
        TextPacket cbwOjnzusZzuPkHfx7wuwePHqrf = packet as TextPacket;

        if (cbwOjnzusZzuPkHfx7wuwePHqrf != null)
        {
            this._antiSpam._IDtpCgDjmC1AQOcZCJSFNAYjlbH(cbwOjnzusZzuPkHfx7wuwePHqrf);
            this._antiLag.Text(cbwOjnzusZzuPkHfx7wuwePHqrf);
            this._o3Helper._IDtpCgDjmC1AQOcZCJSFNAYjlbH(cbwOjnzusZzuPkHfx7wuwePHqrf);
            return;
        }
        UseItemPacket lylWoxWrca2h31SiYiDb8gyQP0o = packet as UseItemPacket;

        if (lylWoxWrca2h31SiYiDb8gyQP0o != null)
        {
            this._autoNexus2.UseItem(lylWoxWrca2h31SiYiDb8gyQP0o);
            this._fameHelper.UseItem(lylWoxWrca2h31SiYiDb8gyQP0o);
            return;
        }
        EnemyShootPacket cbwrHXLbrCktla3qkqXNmNymbvH = packet as EnemyShootPacket;

        if (cbwrHXLbrCktla3qkqXNmNymbvH != null)
        {
            this._objectTracker._Qz49aY7UXgmnBNNMA6Q6IEQtadk(cbwrHXLbrCktla3qkqXNmNymbvH);
            return;
        }
        InvSwapPacket maJp2qic3r54gk5Eg1eeMowxvXh = packet as InvSwapPacket;

        if (maJp2qic3r54gk5Eg1eeMowxvXh != null)
        {
            this._autoLoot.InvSwap(maJp2qic3r54gk5Eg1eeMowxvXh);
            this._autoNexus._ZHfjECn2B9JJHnVF67eBaO57JUp(maJp2qic3r54gk5Eg1eeMowxvXh);
            return;
        }
        EscapePacket m74ADSrj0VfuNwRBO916gAw0Nu = packet as EscapePacket;

        if (m74ADSrj0VfuNwRBO916gAw0Nu != null)
        {
            this.Escape(m74ADSrj0VfuNwRBO916gAw0Nu);
            return;
        }
        InvitedToGuildPacket tJHGMoVf7DhHyQm8a6SCuL1cSWl = packet as InvitedToGuildPacket;

        if (tJHGMoVf7DhHyQm8a6SCuL1cSWl != null)
        {
            this._antiDdos.Invite(tJHGMoVf7DhHyQm8a6SCuL1cSWl);
            return;
        }
        TeleportPacket rvckmor8bw91EVaRfdwc25aHYbc = packet as TeleportPacket;

        if (rvckmor8bw91EVaRfdwc25aHYbc != null)
        {
            this._fameHelper.Teleport(rvckmor8bw91EVaRfdwc25aHYbc);
            this._accuracyFarm.Teleport(rvckmor8bw91EVaRfdwc25aHYbc);
            return;
        }
        _6UIiGxMChbVinHsvx5uqg8WrMRc 6UIiGxMChbVinHsvx5uqg8WrMRc = packet as InvResultPacket;
        if (6UIiGxMChbVinHsvx5uqg8WrMRc != null)
        {
            this._autoLoot._yOjSn1WKSXsXVziJpL1eH5gSoWg(6UIiGxMChbVinHsvx5uqg8WrMRc);
            return;
        }
        NotificationPacket zIBPB6zZVww7yGWtjJqRMmACh1q = packet as NotificationPacket;

        if (zIBPB6zZVww7yGWtjJqRMmACh1q != null)
        {
            this._autoNexus._4GSfC8bADOwIwOXLYze8EOUBQxJ(zIBPB6zZVww7yGWtjJqRMmACh1q);
            return;
        }
        AccountListPacket k4pBHmoGRyaE6dWf1FIvL0dcuzKA = packet as AccountListPacket;

        if (k4pBHmoGRyaE6dWf1FIvL0dcuzKA != null)
        {
            this._antiLag.AccountList(k4pBHmoGRyaE6dWf1FIvL0dcuzKA);
            return;
        }
        EditAccountListPacket co7ACSeK1WWaCGAPAqLaov37Wqdb = packet as EditAccountListPacket;

        if (co7ACSeK1WWaCGAPAqLaov37Wqdb != null)
        {
            this._antiLag.EditAccountList(co7ACSeK1WWaCGAPAqLaov37Wqdb);
            return;
        }
        _7k8aOfI7MhNrVnHioUXbsPAxkbm 7k8aOfI7MhNrVnHioUXbsPAxkbm = packet as EnemyHitPacket;
        if (7k8aOfI7MhNrVnHioUXbsPAxkbm != null)
        {
            this._o3Helper._9BgsXisaUbFFlj5HLRd76sERUUX(7k8aOfI7MhNrVnHioUXbsPAxkbm);
            return;
        }
        DeathPacket wOmvsGmaE1PheZ2fPjD9V16UEseb = packet as DeathPacket;

        if (wOmvsGmaE1PheZ2fPjD9V16UEseb != null)
        {
            this._autoNexus._qQsqaOxgCR9yg9ky7erATaKrgCC(wOmvsGmaE1PheZ2fPjD9V16UEseb);
            return;
        }
    }
Exemple #26
0
        void ProcessHelloPacket(HelloPacket pkt)
        {
            if (isGuest)
            {
                Disconnect();
            }
            db = new Database();
            if ((account = db.Verify(pkt.GUID, pkt.Password)) == null)
            {
                Console.WriteLine("Account not verified.");
                account = Database.CreateGuestAccount(pkt.GUID);

                if (account == null)
                {
                    Console.WriteLine("Account is null!");
                    SendPacket(new svrPackets.FailurePacket()
                    {
                        Message = "Invalid account."
                    });
                    Disconnect();
                    return;
                }
            }
            Console.WriteLine("Client trying to connect!");
            ConnectedBuild = pkt.BuildVersion;
            if (!RealmManager.TryConnect(this))
            {
                if (CheckAccountInUse(account.AccountId) != false)
                {
                    Console.WriteLine("Account in use: " + account.AccountId + " " + account.Name);
                    account = null;
                    SendPacket(new svrPackets.FailurePacket()
                    {
                        Message = "Account in use! Retrying..."
                    });
                    Disconnect();
                    return;
                }
                account = null;
                SendPacket(new svrPackets.FailurePacket()
                {
                    Message = "Failed to connect."
                });
                Disconnect();
                Console.WriteLine("Failed to connect.");
                return;
            }
            else
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("Client loading world");
                Console.ForegroundColor = ConsoleColor.White;
                World world = RealmManager.GetWorld(pkt.GameId);
                if (world == null)
                {
                    SendPacket(new svrPackets.FailurePacket()
                    {
                        Message = "Invalid world."
                    });
                    Disconnect();
                    Console.WriteLine("Invalid world");
                }
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("Client joined world " + world.Id.ToString());
                Console.ForegroundColor = ConsoleColor.White;
                if (world.Id == -6) //Test World
                {
                    (world as realm.worlds.Test).LoadJson(pkt.MapInfo);
                }

                else if (world.IsLimbo)
                {
                    world = world.GetInstance(this);
                }
                var seed = (uint)((long)Environment.TickCount * pkt.GUID.GetHashCode()) % uint.MaxValue;
                Random      = new wRandom(seed);
                targetWorld = world.Id;
                SendPacket(new MapInfoPacket()
                {
                    Width         = world.Map.Width,
                    Height        = world.Map.Height,
                    Name          = world.Name,
                    Seed          = seed,
                    Background    = world.Background,
                    AllowTeleport = world.AllowTeleport,
                    ShowDisplays  = world.ShowDisplays,
                    ClientXML     = world.ClientXML,
                    ExtraXML      = world.ExtraXML
                });
                stage = ProtocalStage.Handshaked;
                if (!Connected)
                {
                    Connected = true;
                }
            }
        }
Exemple #27
0
        /// <summary>
        /// This will be the way that clients are added to the current group.
        /// Games can be hosted as open or closed. (closed will keep new players from joining)
        /// Closed will be the default.
        ///
        /// Returns a reference to the Listener
        /// </summary>
        private void ClientDiscover()
        {
            // UDP listener logic
            Console.WriteLine($"Creating UDP server listener {HostInformation.ToString()}");

            Message responseData = Utilities.Serialize(HostInformation);

            try
            {
                // Stop listening when the game starts (in closed mode).
                while (!ClosedGame)
                {
                    Console.WriteLine("UDP Waiting for broadcast");

                    IPEndPoint clientEP = new IPEndPoint(IPAddress.Any, 0);
                    Message    message  = new Message();
                    message.data = server.Receive(ref clientEP);
                    if (!ClosedGame)
                    {
                        object receivedData = Utilities.Deserialize(message);
                        if (receivedData is HelloPacket)
                        {
                            // Add new client to Lists
                            HelloPacket newClient = receivedData as HelloPacket;
                            this.OnRaiseClientJoinedEvent(newClient);
                        }
                        if (receivedData is string)
                        {
                            switch (receivedData as string)
                            {
                            case "RESPONSE:Disconnect":
                                OnRaiseClientDisconnectedEvent(HostList.Find(HelloPacket => HelloPacket.EndPoint() == clientEP));
                                break;
                            }
                        }

                        Console.WriteLine($"Received broadcast from {clientEP} :");
                        Console.WriteLine($" RSVP address {receivedData.ToString()}");



                        // Add the client EndPoint to the ClientList
                        Console.WriteLine($"{clientEP} added to the clientlist");
                        ClientList.Add(clientEP);


                        // Send the server data to the client
                        Console.WriteLine("UDP Server sending response");
                        server.Send(responseData.data, responseData.data.Length, clientEP);
                    }
                }
            }
            catch (SocketException e)
            {
                Console.WriteLine(e);
            }
            catch (ThreadAbortException e)
            {
                Console.WriteLine("Thread Aborted: {0}", e);
                Console.WriteLine("Disposing of UDP server");
            }
            finally
            {
                server.Close();
            }
        }
Exemple #28
0
 /// <summary>
 /// Connects the client to the server in the resulting state lookup from the HelloPacket portal keye.
 /// </summary>
 /// <param name="state">Packet containing the portal key to be used for the lookuo</param>
 public void Connect(HelloPacket state)
 {
     _serverConnection         = new TcpClient();
     _serverConnection.NoDelay = true;
     _serverConnection.BeginConnect(State.ConTargetAddress, State.ConTargetPort, ServerConnected, state);
 }
Exemple #29
0
 private void OnHelloPacket(Client client, HelloPacket packet)
 {
     this.m_currentGameId = packet.GameId;
     this.m_chests        = new Dictionary <int, int[]>();
 }
Exemple #30
0
 private void HandleClientJoinedEvent(object sender, HelloPacket client)
 {
     Console.WriteLine($"Adding {client.ToString()} to HostList.");
     HostList.Add(client);
 }