Ejemplo n.º 1
0
		private ClientInformation(PacketIn packet)
		{
            try
            {
                ProtocolVersion = packet.ReadByte();
                var claimedRemainingLength = packet.ReadUInt16();
                if (packet.RemainingLength != claimedRemainingLength)
                {
                    Log.Warn(WCell_Core.Auth_Logon_with_invalid_length, claimedRemainingLength, packet.RemainingLength);
                }

                var clientInstallationType = packet.ReadFourCC();
                _clientInstallationType = ClientTypeUtility.Lookup(clientInstallationType);

                Version = new ClientVersion(packet.ReadBytes(5));
                Architecture = packet.ReadFourCC().TrimEnd('\0');
                OS = packet.ReadFourCC().TrimEnd('\0');

                var locale = packet.ReadFourCC();
                _locale = ClientLocaleUtility.Lookup(locale);

                TimeZone = BitConverter.ToUInt32(packet.ReadBytes(4), 0);
                IPAddress = new XmlIPAddress(packet.ReadBytes(4));

                Log.Info(WCell_Core.ClientInformationFourCCs, ProtocolVersion, ClientInstallationType, Version, Architecture, OS, Locale, TimeZone, IPAddress);
            }
            catch
            {
            }
		}
Ejemplo n.º 2
0
		private ClientInformation(PacketIn packet)
		{
			packet.SkipBytes(1);	// 0

			try
			{
				Version = new ClientVersion(packet.ReadBytes(5));
				Architecture = packet.ReadReversedString();
				OS = packet.ReadReversedString();

				var localeStr = packet.ReadReversedPascalString(4);
				if (!ClientLocales.Lookup(localeStr, out m_Locale))
				{
					m_Locale = WCellConstants.DefaultLocale;
				}

				TimeZone = BitConverter.ToUInt32(packet.ReadBytes(4), 0);
				IPAddress = new XmlIPAddress(packet.ReadBytes(4));
			}
			catch
			{
			}
		}
Ejemplo n.º 3
0
        /// <summary>
        /// Registers a realm server with the authentication server
        /// </summary>
        /// <param name="serverName">the name of the server</param>
        /// <param name="serverType">the type of the server</param>
        /// <param name="flags">the up/down status of the serer (green/red)</param>
        /// <param name="serverCategory">the timezone the server is in</param>
        /// <param name="serverStatus">the status of the server (locked or not)</param>
        public void RegisterRealmServer(string serverName, string addr, int port, int chrCount, int capacity, 
			RealmServerType serverType, RealmFlags flags, RealmCategory serverCategory, 
			RealmStatus serverStatus, ClientVersion clientVersion)
        {
        	var context = OperationContext.Current;
			if (context == null)
			{
				return;
			}

        	var channel = context.Channel;
			if (channel == null)
			{
				return;
			}

            var id = GetCurrentId();
            var realm = AuthenticationServer.GetRealmById(id);
            var ep = GetCurrentEndPoint();

            // find out whether this server is just re-registering (came back online)
            var isNew = realm == null;

            if (isNew)
            {
                realm = AuthenticationServer.GetRealmByName(serverName);
                if (isNew = (realm == null))
				{
					if (!AuthServerConfiguration.RealmIPs.Contains(ep.Address))
					{
						// Ignore unknown realms
						log.Warn("Unallowed Realm (\"{0}\") tried to register from: {1}", serverName, ep.Address);
						var chan = OperationContext.Current.Channel;
						if (chan != null)
						{
							try
							{
								chan.Close();
							}
							catch (Exception) {}
						}
						return;
					}
                    realm = new RealmEntry();
                }
                realm.ChannelId = id;
            }

            if (string.IsNullOrEmpty(addr))
            {
                // no host given
                addr = ep.Address;
            }

            realm.Name = serverName;
            realm.Address = addr;
            realm.Port = port;
            realm.Flags = flags;
            realm.Status = serverStatus;
            realm.ServerType = serverType;
            realm.Category = serverCategory;
            realm.CharCount = chrCount;
            realm.CharCapacity = capacity;
        	realm.ClientVersion = clientVersion;

        	realm.Channel = channel;
            realm.ChannelAddress = ep.Address;
            realm.ChannelPort = ep.Port;


            if (isNew)
            {
                // register after setting all infos
                lock (AuthenticationServer.Realms)
                {
                    realm.ChannelId = id;
                    AuthenticationServer.Realms.Add(id, realm);
                }
            }
			log.Info(Resources.RealmRegistered, realm); //realm.ChannelAddress);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Registers a realm server with the authentication server
        /// </summary>
        /// <param name="realmName">the name of the server</param>
        /// <param name="serverType">the type of the server</param>
        /// <param name="flags">the up/down status of the serer (green/red)</param>
        /// <param name="serverCategory">the timezone the server is in</param>
        /// <param name="serverStatus">the status of the server (locked or not)</param>
        public void RegisterRealmServer(string realmName, string addr, int port, int chrCount, int capacity, 
			RealmServerType serverType, RealmFlags flags, RealmCategory serverCategory, 
			RealmStatus serverStatus, ClientVersion clientVersion)
        {
        	var context = OperationContext.Current;
			if (context == null)
			{
				return;
			}

        	var channel = context.Channel;
			if (channel == null)
			{
				return;
			}

            var id = GetCurrentId();
            var realm = AuthenticationServer.GetRealmById(id);
            var ep = GetCurrentEndPoint();
            string epAddress = "";
            if(ep == null)
            {
            	epAddress = channel.RemoteAddress.Uri.Host;
            	log.Warn("IPC::RegisterRealmServer Endpoint is null, falling back to: {0}", channel.RemoteAddress.Uri.Host);
            }
            else
            {
            	epAddress = ep.Address;
            	log.Info("IPC::RegisterRealmServer Endpoint address is: {0}", ep.Address);
            }
			

            // find out whether this server is just re-registering (came back online)
            var isNew = realm == null;

            if (isNew)
            {
                realm = AuthenticationServer.GetRealmByName(realmName);
                if (realm == null)
				{
					if (!AuthServerConfiguration.RealmIPs.Contains(epAddress))
					{
						// Ignore unknown realms
						log.Warn("Unallowed Realm (\"{0}\") tried to register from: {1} (For more info, see the <RealmIPs> entry in your configuration)", 
							realmName, epAddress, AuthServerConfiguration.Instance.FilePath);
						var chan = OperationContext.Current.Channel;
						if (chan != null)
						{
							try
							{
								chan.Close();
							}
							catch (Exception) {}
						}
						return;
					}
					realm = new RealmEntry();
                }
				else
                {
                	lock (AuthenticationServer.Realms)
					{
						AuthenticationServer.RemoveRealmByName(realmName);
                	}
                }
            }

            if (string.IsNullOrEmpty(addr))
            {
                // no host given
                addr = epAddress;
            }

			realm.ChannelId = id;
            realm.Name = realmName;
            realm.Address = addr;
            realm.Port = port;
            realm.Flags = flags;
            realm.Status = serverStatus;
            realm.ServerType = serverType;
            realm.Category = serverCategory;
            realm.CharCount = chrCount;
            realm.CharCapacity = capacity;
        	realm.ClientVersion = clientVersion;

        	realm.Channel = channel;
            realm.ChannelAddress = epAddress;
            realm.ChannelPort = ep == null ? channel.RemoteAddress.Uri.Port : ep.Port;


            if (isNew)
            {
                // register after setting all infos
                lock (AuthenticationServer.Realms)
                {
                    AuthenticationServer.AddRealm(realm);
                }
            }
			log.Info(resources.RealmRegistered, realm); //realm.ChannelAddress);
        }
Ejemplo n.º 5
0
 /// <summary>Default constructor.</summary>
 /// <param name="majorVersion">the major part of this version</param>
 /// <param name="minorVersion">the minor part of this version</param>
 /// <param name="revision">the revision of this version</param>
 public ClientVersion(byte majorVersion, byte minorVersion, byte revision)
 {
     this = new ClientVersion(majorVersion, minorVersion, revision, ushort.MaxValue);
 }
Ejemplo n.º 6
0
 /// <summary>Default constructor</summary>
 /// <param name="build">the build of this version</param>
 public ClientVersion(ushort build)
 {
     this = new ClientVersion(byte.MaxValue, byte.MaxValue, byte.MaxValue, build);
 }
Ejemplo n.º 7
0
 public bool IsSupported(ClientVersion version)
 {
     return(Major == version.Major && Minor == version.Minor &&
            Revision == version.Revision);
 }
Ejemplo n.º 8
0
		private void FindVersionInfo()
		{
			long startOffset = FileString.IndexOf("=> Version %s (%s) %s");

			if (startOffset > 0)
			{
				BaseStream.Position = startOffset;
				this.ReadCString();

				while (PeekChar() == 0)
				{
					BaseStream.Position++;
				}
				var version = this.ReadCString();

				while (PeekChar() == 0)
				{
					BaseStream.Position++;
				}
				var build = this.ReadCString();

				try
				{
					m_version = new ClientVersion(version + "." + build);
				}
				catch
				{
					// something went wrong:
					FindVersionInfo2();
				}
				/*
				 * 6898....2.1.3...RELEASE_BUILD
				 * */
				//BaseStream.Position = startOffset - 16;

				//var build = this.ReadCString();
				//BaseStream.Position += 3;
				//m_version = new ClientVersion(this.ReadCString() + "." + build);
			}
			else
			{
				//throw new InvalidDataException("Could not locate version information");
				FindVersionInfo2();
			}
		}
Ejemplo n.º 9
0
		/// <summary>
		/// Things changed in 3.2.0
		/// </summary>
		private void FindVersionInfo2()
		{
			long startOffset = FileString.IndexOf("RELEASE_BUILD");

			if (startOffset > 0)
			{
				BaseStream.Position = startOffset;

				do
				{
					BaseStream.Position--;
				} while (PeekChar() == 0);

				while (PeekChar() != 0)
				{
					BaseStream.Position--;
				}

				BaseStream.Position++;
				var version = this.ReadCString();
				BaseStream.Position -= 2;

				while (PeekChar() != 0)
				{
					BaseStream.Position--;
				}

				do
				{
					BaseStream.Position--;
				} while (PeekChar() == 0);

				while (PeekChar() != 0)
				{
					BaseStream.Position--;
				}

				BaseStream.Position++;
				var build = this.ReadCString();

				m_version = new ClientVersion(version + "." + build);
				/*
				 * Aug 17 2009.10314....3.2.0..RELEASE_BUILD
				 * */
				//BaseStream.Position = startOffset - 16;

				//var build = this.ReadCString();
				//BaseStream.Position += 3;
				//m_version = new ClientVersion(this.ReadCString() + "." + build);
			}
			else
			{
				throw new InvalidDataException("Could not locate version information");
			}
		}
Ejemplo n.º 10
0
		public bool IsSupported(ClientVersion version)
		{
			return Major == version.Major && Minor == version.Minor && Revision == version.Revision;
		}
Ejemplo n.º 11
0
		/// <summary>
		/// Compares a version to this ersion
		/// </summary>
		/// <param name="value">the version to compare</param>
		/// <returns>-1 if the version is less than this, 0 is it is equal, and -1 if it is greater than this</returns>
		public int CompareTo(ClientVersion value)
		{
			if (Major != value.Major)
			{
				if (Major > value.Major)
				{
					return 1;
				}

				return -1;
			}

			if (Minor != value.Minor)
			{
				if (Minor > value.Minor)
				{
					return 1;
				}

				return -1;
			}

			if (Revision != value.Revision)
			{
				if (Revision > value.Revision)
				{
					return 1;
				}

				return -1;
			}

			if (Build == value.Build)
			{
				return 0;
			}

			if (Build > value.Build)
			{
				return 1;
			}

			return -1;
		}