Exemplo n.º 1
0
        public override bool OnFlood(IClient client, IFloodRule rule, IPacket packet)
        {
            bool ret = true;

            lock (Scripts) {
                foreach (var s in Scripts)
                {
                    try {
                        User user = (User)s.Room.Users.Items.Find((x) => ((User)x).Client == client);
                        if (user == null)
                        {
                            continue;
                        }

                        var floodRule = rule as Objects.FloodRule ?? new Objects.FloodRule(s, rule);

                        if (!s.Engine.CallGlobalFunction <bool>("onFlood", user, floodRule, new Packet(s, packet)))
                        {
                            ret = false;
                        }
                    }
                    catch (JavaScriptException jex) {
                        OnError(jex);
                    }
                    finally { s.ResetCounters(); }
                }
            }
            return(ret);
        }
Exemplo n.º 2
0
        public FloodRule(JScript script, IFloodRule rule)
            : base(script.Engine)
        {
            this.id    = rule.Id;
            this.count = rule.Count;
            this.reset = rule.ResetTimeout;

            this.PopulateFunctions();
        }
Exemplo n.º 3
0
        public bool Equals(IFloodRule other)
        {
            if (other == null)
            {
                return(false);
            }

            return(this.Id == (AresId)other.Id &&
                   this.Name == other.Name);
        }
Exemplo n.º 4
0
        public bool OnFlood(IClient client, IFloodRule rule, IPacket packet)
        {
            bool ret = true;

            foreach (var plugin in this)
            {
                try {
                    if (plugin.Enabled && !plugin.Plugin.OnFlood(client, rule, packet))
                    {
                        ret = false;
                    }
                }
                catch (Exception ex) {
                    OnError(plugin, nameof(OnFlood), ex);
                }
            }

            return(ret);
        }
Exemplo n.º 5
0
 public FloodRule(Script script, IFloodRule rule)
     : base(script.Engine, ((ClrFunction)script.Engine.Global["FloodRule"]).InstancePrototype)
 {
     this.rule = rule;
     this.PopulateFunctions();
 }
Exemplo n.º 6
0
 internal FloodRule(Script script, ObjectInstance proto, string name, int id, double count, double timeout)
     : base(script.Engine, proto)
 {
     this.rule = new Zorbo.Ares.FloodRule(name, (AresId)id, count, timeout);
     this.PopulateFunctions();
 }
Exemplo n.º 7
0
 internal FloodRule(Script script, string name, int id, double count, double timeout)
     : base(script.Engine, ((ClrFunction)script.Engine.Global["FloodRule"]).InstancePrototype)
 {
     this.rule = new Zorbo.Ares.FloodRule(name, (AresId)id, count, timeout);
     this.PopulateFunctions();
 }
Exemplo n.º 8
0
 /// <summary>
 /// Occurs when a user floods the server with packets, returning false will prevent Zorbo from handling the packet.
 /// It's up to the Plugin to determine any extra action taken when a flood rule is broken.
 /// </summary>
 /// <param name="client">The client that triggered the flood rule.</param>
 /// <param name="rule">The flood rule that was violated.</param>
 /// <param name="packet">The packet that was sent that triggered the flood rule.</param>
 /// <returns></returns>
 public virtual bool OnFlood(IClient client, IFloodRule rule, IPacket packet)
 {
     return(true);
 }