Exemple #1
0
        public static void HandlePacketLoginRequest(Client client, LoginRequestPacket packet)
        {
            if (!client.CheckUsername(packet.Username))
            {
                client.Kick("Inconsistent username");
            }
            else if (packet.ProtocolOrEntityId < ProtocolVersion)
            {
                client.Kick("Outdated client");
            }
            else
            {
                if (client.Server.UseOfficalAuthentication)
                {
                    try
                    {
                        string authenticated = Http.GetHttpResponse(new Uri(String.Format("http://www.minecraft.net/game/checkserver.jsp?user={0}&serverId={1}", packet.Username, client.Server.ServerHash)));
                        if (authenticated != "YES")
                        {
                            client.Kick("Authentication failed");
                            return;
                        }
                    }
                    catch (Exception exc)
                    {
                        client.Kick("Error while authenticating...");
                        client.Logger.Log(exc);
                        return;
                    }
                }

                Task.Factory.StartNew(client.SendLoginSequence);
            }
        }
Exemple #2
0
        public static void HandlePacketHandshake(Client client, HandshakePacket packet)
        {
            client.Username = packet.Username;
            if (!client.CheckUsername(packet.Username))
            {
                client.Kick("Inconsistent username");
            }
            if (packet.ProtocolVersion < ProtocolVersion)
            {
                client.Kick("Outdated client");
            }
            else
            {
                client.Host = packet.ServerHost + ":" + packet.ServerPort;

                if (client.Server.EncryptionEnabled)
                {
                    client.SendEncryptionRequest();
                }
                else if (IsAuthenticated(client))
                {
                    Task.Factory.StartNew(client.SendLoginSequence);
                }
            }
        }
Exemple #3
0
        public static void HandlePacketLoginRequest(Client client, LoginRequestPacket packet)
        {
            if (!client.CheckUsername(packet.Username))
                client.Kick("Inconsistent username");
            else if (packet.ProtocolOrEntityId < ProtocolVersion)
                client.Kick("Outdated client");
            else
            {
                if (client.Server.UseOfficalAuthentication)
                {
                    try
                    {
                        string authenticated = Http.GetHttpResponse(new Uri(String.Format("http://www.minecraft.net/game/checkserver.jsp?user={0}&serverId={1}", packet.Username, client.Server.ServerHash)));
                        if (authenticated != "YES")
                        {
                            client.Kick("Authentication failed");
                            return;
                        }
                    }
                    catch (Exception exc)
                    {
                        client.Kick("Error while authenticating...");
                        client.Logger.Log(exc);
                        return;
                    }
                }

                Task.Factory.StartNew(client.SendLoginSequence);
            }
        }
Exemple #4
0
        public static void HandlePacketHandshake(Client client, HandshakePacket packet)
        {
            client.Username = packet.Username;
            if (!client.CheckUsername(packet.Username))
                client.Kick("Inconsistent username");
            if (packet.ProtocolVersion < ProtocolVersion)
                client.Kick("Outdated client");
            else
            {
                client.Host = packet.ServerHost + ":" + packet.ServerPort;

                if (client.Server.EncryptionEnabled)
                    client.SendEncryptionRequest();
                else if (IsAuthenticated(client))
                    Task.Factory.StartNew(client.SendLoginSequence);

            }
        }