Inheritance: Aura.Shared.Network.DefaultClient
示例#1
0
文件: Security.cs 项目: tkiapril/aura
		public SecurityViolationEventArgs(ChannelClient offender, IncidentSeverityLevel level, string report, string stacktrace)
		{
			this.Client = offender;
			this.Level = level;
			this.Report = report;
			this.StackReport = stacktrace;
		}
示例#2
0
        public override void Execute(ChannelClient client, Creature sender, Creature target, IList<string> args)
        {
            if (args.Count < 2)
            {
                ShowHelp(target);
                return;
            }

            var e = (Parent as CommandNamespace).Resolve(args[1]);

            var cmd = e as Command;

            if (cmd != null && !cmd.HasAuth(target, true))
                e = null;

            if (e == null)
                Send.ServerMessage(sender, "Command or namespace '{0}' not found", args[1]);
            else
                ShowHelp(target, e.GetHelp());
        }
示例#3
0
        private bool Handle(ChannelClient client, Creature creature, string message)
        {
            if (message.Length < 2)
                return false;

            var isTargetedCommand = message.StartsWith(_conf.Prefix2);
            var isSelfCommand = !isTargetedCommand && message.StartsWith(_conf.Prefix.ToString());

            if (!isSelfCommand && !isTargetedCommand)
                return false;

            message = message.Substring(isTargetedCommand ? _conf.Prefix2.Length : _conf.Prefix.ToString().Length);

            var args = _tokenizer.Tokenize(message);
            if (args.Count < 1)
                return false;

            var cmd = GlobalNamespace.GetCommand(args[0]);
            if (cmd == null)
                return false;

            var sender = creature;
            var target = creature;

            if (isTargetedCommand)
            {
                // Get target player
                if (args.Count < 2 || (target = ChannelServer.Instance.World.GetPlayer(args[1])) == null)
                {
                    Send.ServerMessage(creature, Localization.Get("Target not found."));
                    return true;
                }

                // Remove target name from the args
                args.RemoveAt(1);
            }

            cmd.Execute(client, sender, target, args);

            return true;
        }
示例#4
0
文件: Command.cs 项目: Xcelled/aurora
 public abstract void Execute(ChannelClient client, Creature sender, Creature target, IList<string> args);
示例#5
0
 public override void Execute(ChannelClient client, Creature sender, Creature target, IList<string> args)
 {
     Send.ServerMessage(target, "Listing of '{0}':", _ns.FullyQualifiedName);
     Send.ServerMessage(target, "Namespaces: {0}", string.Join(", ", _ns.Namespaces.Where(n => !n.Hide).Select(n => n.Name)));
     Send.ServerMessage(target, "Commands: {0}", string.Join(", ", _ns.Commands.Where(n => !n.Hide && n.HasAuth(target, false)).Select(n => n.Name)));
 }
示例#6
0
 private void OnClientDisconnected(ChannelClient client)
 {
     if (client == this.LoginServer)
         this.ConnectToLogin(false);
 }
示例#7
0
 public override bool Process(ChannelClient client, Creature creature, string message)
 {
     if (!Handle(client, creature, message))
         return OriginalManager.Process(client, creature, message);
     return true;
 }
示例#8
0
 public override void Execute(ChannelClient client, Creature sender, Creature target, IList<string> args)
 {
     _other.Execute(client, sender, target, args);
 }
示例#9
0
文件: Security.cs 项目: tkiapril/aura
		/// <summary>
		/// Bans account, length depends on ban points and previous bans.
		/// </summary>
		/// <param name="client"></param>
		private static void Ban(ChannelClient client)
		{
			var autobanCount = ++client.Account.AutobanCount;

			TimeSpan banLength;

			switch (ChannelServer.Instance.Conf.Autoban.LengthIncrease)
			{
				case AutobanLengthIncrease.None:
					banLength = ChannelServer.Instance.Conf.Autoban.InitialBanTime;
					break;

				case AutobanLengthIncrease.Linear:
					banLength = TimeSpan.FromMinutes((long)(ChannelServer.Instance.Conf.Autoban.InitialBanTime.TotalMinutes * autobanCount));
					break;

				case AutobanLengthIncrease.Exponential:
					banLength = TimeSpan.FromMinutes(ChannelServer.Instance.Conf.Autoban.InitialBanTime.TotalMinutes * (long)Math.Pow(autobanCount, 2));
					break;

				default:
					Log.Warning("Unknown AutobanLengthIncrease: {0}", ChannelServer.Instance.Conf.Autoban.LengthIncrease);
					goto case AutobanLengthIncrease.Exponential;
			}

			Log.Info("Autobanning account '{0}'. Total times they've been autobanned: {1}. Length of this ban: {2}", client.Account.Id, autobanCount, banLength);

			client.Account.BanExpiration = DateTime.Now + banLength;
			client.Account.BanReason = "Automatic ban triggered.";

			// So their score doesn't decrease while they're banned.
			client.Account.LastAutobanReduction = client.Account.BanExpiration;

			if (ChannelServer.Instance.Conf.Autoban.ResetScoreOnBan)
				client.Account.AutobanScore = 0;
		}
示例#10
0
文件: Security.cs 项目: tkiapril/aura
		/// <summary>
		/// Logs incident, increases ban points, and bans account if appropriate.
		/// </summary>
		/// <param name="client"></param>
		/// <param name="level"></param>
		/// <param name="report"></param>
		/// <param name="stacktrace"></param>
		public static void Incident(ChannelClient client, IncidentSeverityLevel level, string report, string stacktrace = null)
		{
			if (client.Account == null)
				return;

			switch (level)
			{
				case IncidentSeverityLevel.Mild: client.Account.AutobanScore += ChannelServer.Instance.Conf.Autoban.MildAmount; break;
				case IncidentSeverityLevel.Moderate: client.Account.AutobanScore += ChannelServer.Instance.Conf.Autoban.ModerateAmount; break;
				case IncidentSeverityLevel.Severe: client.Account.AutobanScore += ChannelServer.Instance.Conf.Autoban.SevereAmount; break;
				default:
					Log.Warning("Autoban.Incident: Unknown severity level {0}", level);
					goto case IncidentSeverityLevel.Mild;
			}

			Log.Info("Account '{0}' total ban score: {1}", client.Account.Id, client.Account.AutobanScore);

			client.Account.LastAutobanReduction = DateTime.Now;

			if (client.Account.AutobanScore >= ChannelServer.Instance.Conf.Autoban.BanAt)
				Ban(client);
		}