Exemplo n.º 1
0
        /// <summary>
        /// 重新配置Guard
        /// </summary>
        bool ReconfigreGuard(int userId)
        {
            if (_server.IsConnected)
            {
                AdminServer.TheInstance.GameServerManager.SendServerConfigFile(_server);
                string fileContentString = null;
                using (MemoryStream configStream = new MemoryStream())
                {
                    _server.LordConfig.WriteGuardConfig(configStream);
                    fileContentString = SystemConfig.Current.DefaultEncoding.GetString(configStream.ToArray()); //Encoding.ASCII.GetString(configStream.ToArray());
                }

                e2g_ConfigInfo configInfo = new e2g_ConfigInfo();
                configInfo.ConfigFileDataLength = (ushort)fileContentString.Length;
                configInfo.ConfigFileData       = fileContentString;

                byte[] configInfoBytes = configInfo.ToBytes();

                e2g_config configProtocol = new e2g_config();
                Array.Copy(configInfoBytes, configProtocol.ConfigInfo, configInfoBytes.Length);

                if (_server.SendMessage(configProtocol))
                {
                    _server.AppendMessage(StringDef.AttemptToConfigGuard, GameServer.MessageInfo.Type.Normal);
                    _server.Disconnect();
                    return(true);
                }
            }
            else
            {
                foreach (GameServer svr in AdminServer.TheInstance.GameServerManager.Servers)
                {
                    if (_server.IpAddress == svr.IpAddress)
                    {
                        svr.ConfigState = GameServer.ConfigGuardState.Configuring;
                    }
                }
                return(true);
            }
            return(false);
        }
Exemplo n.º 2
0
		void SendConfigPackage(GameServer server)
		{
			string fileContentString = null;
			using (MemoryStream configStream = new MemoryStream())
			{
				server.LordConfig.WriteGuardConfig(configStream);
                fileContentString = SystemConfig.Current.DefaultEncoding.GetString(configStream.ToArray()); //Encoding.ASCII.GetString(configStream.ToArray());
			}

			int x = s_random.Next(1000);
			int y = Util.CaculateY(x);

			string encryptFileContent = fileContentString;
			//string encryptFileContent = string.Empty;
			//util.DBEncrypt(fileContentString, ref encryptFileContent);

			string md5 = UtilDllWrap.MD5(y.ToString(), SystemConfig.Current.DefaultEncoding);

			e2g_ConfigInfo configInfo = new e2g_ConfigInfo();
			configInfo.X = x;
			configInfo.Y = md5;
			configInfo.ConfigFileDataLength = (ushort)encryptFileContent.Length;
			configInfo.ConfigFileData = encryptFileContent;
			//configProtocol.X = x;
			//configProtocol.Y = md5;
			//configProtocol.ConfigFileDataLength = (ushort)encryptFileContent.Length;
			//configProtocol.ConfigFileData = encryptFileContent;

			server.CommunicationKey = UtilDllWrap.CreateRandomKey(8);

            byte[] encryptedKey = server.CommunicationKey;//romandou UtilDllWrap.RSAEncrypt(server.CommunicationKey);
            byte[] encryptedConfigInfo = configInfo.ToBytes();//romandou UtilDllWrap.RC4Encrypt(configInfo.ToBytes(), server.CommunicationKey);

			e2g_config configProtocol = new e2g_config();
			Array.Copy(encryptedKey, configProtocol.Key.Data, encryptedKey.Length);
			Array.Copy(encryptedConfigInfo, configProtocol.ConfigInfo, encryptedConfigInfo.Length);

			IPEndPoint target = new IPEndPoint(IPAddress.Parse(server.IpAddress), SystemConfig.Current.ConfigGuardPort);
			if (AdminServer.TheInstance.ConnectionManager.SendTo(target, configProtocol.ToBytes()))
				server.AppendMessage(StringDef.AttemptToConfigGuard, GameServer.MessageInfo.Type.Normal);
		}
Exemplo n.º 3
0
		/// <summary>
		/// 重新配置Guard
		/// </summary>
		bool ReconfigreGuard(int userId)
		{
			if (_server.IsConnected)
			{

                AdminServer.TheInstance.GameServerManager.SendServerConfigFile(_server);
				string fileContentString = null;
				using (MemoryStream configStream = new MemoryStream())
				{
					_server.LordConfig.WriteGuardConfig(configStream);
                    fileContentString = SystemConfig.Current.DefaultEncoding.GetString(configStream.ToArray()); //Encoding.ASCII.GetString(configStream.ToArray());
				}

				e2g_ConfigInfo configInfo = new e2g_ConfigInfo();
				configInfo.ConfigFileDataLength = (ushort)fileContentString.Length;
				configInfo.ConfigFileData = fileContentString;

				byte[] configInfoBytes = configInfo.ToBytes();

				e2g_config configProtocol = new e2g_config();
				Array.Copy(configInfoBytes, configProtocol.ConfigInfo, configInfoBytes.Length);

				if (_server.SendMessage(configProtocol))
				{
					_server.AppendMessage(StringDef.AttemptToConfigGuard, GameServer.MessageInfo.Type.Normal);
                    _server.Disconnect();
					return true;
				}
			}
            else
            {
                foreach (GameServer svr in AdminServer.TheInstance.GameServerManager.Servers)
                {
                    if (_server.IpAddress == svr.IpAddress)
                    {
                        svr.ConfigState = GameServer.ConfigGuardState.Configuring;

                    }
                }
                return true;
            }
			return false;
		}