Exemple #1
0
 public static void SendAuthReconnectProof(IAuthClient client)
 {
     using (var packet = new AuthPacketOut(AuthServerOpCode.AUTH_RECONNECT_PROOF))
     {
         packet.Write((byte)0);                // error
         packet.Write((short)0);
     }
 }
		/// <summary>
		/// Sends an authentication challenge error to the client.
		/// </summary>
		/// <param name="client">the client</param>
		/// <param name="error">the authentication challenge error to send</param>
		public static void SendAuthChallengeErrorReply(IAuthClient client, AccountStatus error)
		{
			using (var packet = new AuthPacketOut(AuthServerOpCode.AUTH_LOGON_CHALLENGE))
			{
				packet.Write((byte)0x00);
				packet.Write((byte)error);

				client.Send(packet);
			}
		}
Exemple #3
0
        /// <summary>
        /// Sends an authentication challenge error to the client.
        /// </summary>
        /// <param name="client">the client</param>
        /// <param name="error">the authentication challenge error to send</param>
        public static void SendAuthChallengeErrorReply(IAuthClient client, AccountStatus error)
        {
            using (var packet = new AuthPacketOut(AuthServerOpCode.AUTH_LOGON_CHALLENGE))
            {
                packet.Write((byte)0x00);
                packet.Write((byte)error);

                client.Send(packet);
            }
        }
		/// <summary>
		/// Sends an authentication challenge success reply to the client.
		/// </summary>
		/// <param name="client">the client</param>
		public static void SendAuthChallengeSuccessReply(IAuthClient client)
		{
			using (var packet = new AuthPacketOut(AuthServerOpCode.AUTH_LOGON_CHALLENGE))
			{
				packet.Write((byte)AccountStatus.Success);
				// Grunt command
				packet.Write((byte)0x00);

				client.Authenticator.WriteServerChallenge(packet);

				//var rand = new BigInteger(new Random(Environment.TickCount), 128);
				//packet.WriteBigInt(rand, 16);
				Random rand = new Random(Environment.TickCount);
				byte[] randbytes = new byte[16];
				rand.NextBytes(randbytes);
				packet.Write(randbytes);

				const byte securityFlag = 0x0;
				packet.Write(securityFlag);

				// Require PIN input
				//if ((securityFlag & 0x1) == 0x1)
				//{
				//    packet.WriteInt(0);
				//    packet.Write(new byte[16]);
				//}

				// Matrix input
				//if ((securityFlag & 0x2) == 0x2)
				//{
				//    packet.Write((byte)0);
				//    packet.Write((byte)0);
				//    packet.Write((byte)0);
				//    packet.Write((byte)0);
				//    packet.Write(0UL);
				//}
				// Require Security Token input
				//if ((securityFlag & 0x4) == 0x4)
				//{
				//    packet.Write((byte)1);
				//}

				client.Send(packet);
			}
		}
        /// <summary>
        /// Sends an authentication challenge success reply to the client.
        /// </summary>
        /// <param name="client">the client</param>
        public static void SendAuthChallengeSuccessReply(IAuthClient client)
        {
            using (var packet = new AuthPacketOut(AuthServerOpCode.AUTH_LOGON_CHALLENGE))
            {
                packet.Write((byte)AccountStatus.Success);
                // Grunt command
                packet.Write((byte)0x00);

                client.Authenticator.WriteServerChallenge(packet);

                //var rand = new BigInteger(new Random(Environment.TickCount), 128);
                //packet.WriteBigInt(rand, 16);
                Random rand      = new Random(Environment.TickCount);
                byte[] randbytes = new byte[16];
                rand.NextBytes(randbytes);
                packet.Write(randbytes);

                const byte securityFlag = 0x0;
                packet.Write(securityFlag);

                // Require PIN input
                //if ((securityFlag & 0x1) == 0x1)
                //{
                //    packet.WriteInt(0);
                //    packet.Write(new byte[16]);
                //}

                // Matrix input
                //if ((securityFlag & 0x2) == 0x2)
                //{
                //    packet.Write((byte)0);
                //    packet.Write((byte)0);
                //    packet.Write((byte)0);
                //    packet.Write((byte)0);
                //    packet.Write(0UL);
                //}
                // Require Security Token input
                //if ((securityFlag & 0x4) == 0x4)
                //{
                //    packet.Write((byte)1);
                //}

                client.Send(packet);
            }
        }
Exemple #6
0
        /// <summary>
        /// Writes the realm information to the specified packet.
        /// </summary>
        /// <param name="packet">the packet to write the realm info to</param>
        public void WriteRealm(IAuthClient client, AuthPacketOut packet)
        {
            var status = Status;
            var flags  = Flags;
            var name   = Name;

            if (!ClientVersion.IsSupported(client.Info.Version))
            {
                // if client is not supported, flag realm as offline and append the required client version
                flags = RealmFlags.Offline;
                name += " [" + ClientVersion.BasicString + "]";
            }
            else if (Flags.HasFlag(RealmFlags.Offline) && Status == RealmStatus.Locked)
            {
                // let staff members join anyway
                if (client.Account.Role.IsStaff)
                {
                    status = RealmStatus.Open;
                    flags  = RealmFlags.None;
                }
            }


            var addr = NetworkUtil.GetMatchingLocalIP(client.ClientAddress) ?? (object)Address;

            packet.Write((byte)ServerType);
            packet.Write((byte)status);
            packet.Write((byte)flags);
            packet.WriteCString(name);

            packet.WriteCString(GetAddress(addr.ToString()));

            packet.WriteFloat(Population);
            packet.Write(Chars);             // TODO: Change to amount of Characters of the querying account on this Realm
            packet.Write((byte)Category);

            if (flags.HasFlag(RealmFlags.SpecifyBuild))
            {
                packet.Write(ClientVersion.Major);
                packet.Write(ClientVersion.Minor);
                packet.Write(ClientVersion.Revision);
                packet.Write(ClientVersion.Build);
            }

            packet.WriteByte(0x00);
        }
Exemple #7
0
        /// <summary>
        /// Sends an authentication proof success reply to the client.
        /// </summary>
        /// <param name="client">the client</param>
        public static void SendAuthProofSuccessReply(IAuthClient client)
        {
            using (var packet = new AuthPacketOut(AuthServerOpCode.AUTH_LOGON_PROOF))
            {
                packet.Write((byte)AccountStatus.Success);
                client.Authenticator.WriteServerProof(packet);

                packet.WriteInt(0);
                packet.WriteInt(0);
                packet.WriteShort(0);

                client.Send(packet);
            }
        }
Exemple #8
0
        /// <summary>
        /// Sends the realm list to the client.
        /// </summary>
        /// <param name="client">the Session the incoming packet belongs to</param>
        public static void SendRealmList(IAuthClient client)
        {
            if (client.Account == null)
            {
                AuthenticationHandler.OnLoginError(client, AccountStatus.Failure);
                return;
            }
            using (var packet = new AuthPacketOut(AuthServerOpCode.REALM_LIST))
            {
                packet.Position += 2;                                                   // Packet length
                packet.Write(0);                                                        // Unknown Value (0x0000)
                //var cpos = packet.Position;
                //packet.Position = cpos + 2;

                packet.Write((short)AuthenticationServer.RealmCount);

                //var count = 0;
                foreach (var realm in AuthenticationServer.Realms)
                {
                    // check for client version
                    //if (realm.ClientVersion.IsSupported(client.Info.Version))
                    realm.WriteRealm(client, packet);
                }

                //packet.Write((byte)0x15);
                packet.Write((byte)0x10);
                packet.Write((byte)0x00);

                //packet.Position = cpos;
                //packet.WriteShort(count);

                packet.Position = 1;
                packet.Write((short)packet.TotalLength - 3);

                client.Send(packet);
            }
        }
		public static void SendAuthReconnectProof(IAuthClient client)
		{
			using (var packet = new AuthPacketOut(AuthServerOpCode.AUTH_RECONNECT_PROOF))
			{
				packet.Write((byte)0);// error
				packet.Write((short)0);
                client.Send(packet);
			}
		}
		/// <summary>
		/// Sends an authentication proof success reply to the client.
		/// </summary>
		/// <param name="client">the client</param>
		public static void SendAuthProofSuccessReply(IAuthClient client)
		{
			using (var packet = new AuthPacketOut(AuthServerOpCode.AUTH_LOGON_PROOF))
			{
				packet.Write((byte)AccountStatus.Success);
				client.Authenticator.WriteServerProof(packet);

				packet.WriteInt(0);
				packet.WriteInt(0);
				packet.WriteShort(0);

				client.Send(packet);
			}
		}
Exemple #11
0
        /// <summary>
        /// Writes the realm information to the specified packet.
        /// </summary>
        /// <param name="packet">the packet to write the realm info to</param>
        public void WriteRealm(IAuthClient client, AuthPacketOut packet)
        {
			var status = Status;
			var flags = Flags;
			var name = Name;

			if (!ClientVersion.IsSupported(client.Info.Version))
			{
				// if client is not supported, flag realm as offline and append the required client version
				flags = RealmFlags.Offline;
				name += " [" + ClientVersion.BasicString + "]";
			}
            else if (Flags.HasFlag(RealmFlags.Offline) && Status == RealmStatus.Locked)
            {
				// let staff members join anyway
				if (client.Account.Role.IsStaff)
                {
                    status = RealmStatus.Open;
                	flags = RealmFlags.None;
                }
			}


			var addr = NetworkUtil.GetMatchingLocalIP(client.ClientAddress) ?? (object)Address;

			packet.Write((byte)ServerType);
            packet.Write((byte)status);
            packet.Write((byte)flags);
            packet.WriteCString(name);

			packet.WriteCString(GetAddress(addr.ToString()));

            packet.WriteFloat(Population);
			packet.Write(Chars); // TODO: Change to amount of Characters of the querying account on this Realm
			packet.Write((byte)Category);

			if (flags.HasFlag(RealmFlags.SpecifyBuild))
			{
				packet.Write(ClientVersion.Major);
				packet.Write(ClientVersion.Minor);
				packet.Write(ClientVersion.Revision);
				packet.Write(ClientVersion.Build);
			}

			packet.WriteByte(0x00);
        }
Exemple #12
0
        /// <summary>
        /// Sends the realm list to the client.
        /// </summary>
        /// <param name="client">the Session the incoming packet belongs to</param>
        public static void SendRealmList(IAuthClient client)
        {
			if (client.Account == null)
			{
				AuthenticationHandler.OnLoginError(client, AccountStatus.Failure);
				return;
			}
            using (var packet = new AuthPacketOut(AuthServerOpCode.REALM_LIST))
            {
            	packet.Position += 2;							// Packet length
                packet.Write(0);								// Unknown Value (0x0000)
            	//var cpos = packet.Position;
            	//packet.Position = cpos + 2;

            	packet.Write((short)AuthenticationServer.RealmCount);

            	//var count = 0;
                foreach (var realm in AuthenticationServer.Realms)
                {
                	// check for client version
                	//if (realm.ClientVersion.IsSupported(client.Info.Version))
                	realm.WriteRealm(client, packet);
                }

            	//packet.Write((byte)0x15);
                packet.Write((byte)0x10);
				packet.Write((byte)0x00);

				//packet.Position = cpos;
				//packet.WriteShort(count);

                packet.Position = 1;
                packet.Write((short)packet.TotalLength - 3);

                client.Send(packet);
            }
        }
Exemple #13
0
        /// <summary>
        /// Writes the realm information to the specified packet.
        /// </summary>
        /// <param name="packet">the packet to write the realm info to</param>
        public void WriteRealm(IAuthClient client, AuthPacketOut packet)
        {
			var status = Status;
			var flags = Flags;
			var name = Name;
			if (!ClientVersion.IsSupported(client.Info.Version))
			{
				flags = RealmFlags.Offline;
				name += " [" + ClientVersion.BasicString + "]";
			}
            else if (Flags.HasFlag(RealmFlags.Offline) && Status == RealmStatus.Locked)
            {
            	var acc = client.Account;
                var role = acc.Role;
                if (role.IsStaff)
                {
                    status = RealmStatus.Open;
                	flags = RealmFlags.None;
                }
			}

            // TODO: Change char-count to amount of Characters of the querying account on this Realm
			packet.Write((byte)ServerType);
            packet.Write((byte)status);
            packet.Write((byte)flags);
            packet.WriteCString(name);
            packet.WriteCString(AddressString);
            packet.Write(Population);
            packet.Write(Chars);
            packet.Write((byte)Category);
            packet.Write((byte)0x00); // realm separator?
        }