Пример #1
0
        void SetRules()
        {
            string remoteAddresses = RangeCalculator.GetRemoteAddresses(addresses);

            // If the firewall rules aren't set yet.
            if (!set)
            {
                FirewallRule.CreateInbound(remoteAddresses, true, false);
                FirewallRule.CreateOutbound(remoteAddresses, true, false);
                active = true;
                set    = true;
                UpdateActive();
                return;
            }

            // If they are set but not enabled.
            if (set && !active)
            {
                FirewallRule.CreateInbound(remoteAddresses, true, true);
                FirewallRule.CreateOutbound(remoteAddresses, true, true);
                active = true;
                UpdateActive();
                return;
            }

            // If they are active and set.
            if (active && set)
            {
                FirewallRule.CreateInbound(remoteAddresses, false, true);
                FirewallRule.CreateOutbound(remoteAddresses, false, true);
                UpdateNotActive();
                active = false;
            }
        }
Пример #2
0
        void SetRules()
        {
            string remoteAddresses = RangeCalculator.GetRemoteAddresses(addresses);

            // If the firewall rules aren't set yet.
            if (!getSelectedGame().Created)
            {
                if (FirewallRule.CreateInbound(remoteAddresses, this.getSelectedGame(), true, false) &&
                    FirewallRule.CreateOutbound(remoteAddresses, this.getSelectedGame(), true, false))
                {
                    getSelectedGame().Active  = true;
                    getSelectedGame().Created = true;
                    UpdateActive();
                }
                return;
            }

            // If they are set but not enabled.
            if (getSelectedGame().Created&& !getSelectedGame().Active)
            {
                if (FirewallRule.CreateInbound(remoteAddresses, this.getSelectedGame(), true, true) &&
                    FirewallRule.CreateOutbound(remoteAddresses, this.getSelectedGame(), true, true))
                {
                    getSelectedGame().Active = true;
                    UpdateActive();
                }
                return;
            }

            // If they are active and set.
            if (getSelectedGame().Created&& getSelectedGame().Active)
            {
                if (FirewallRule.CreateInbound(remoteAddresses, this.getSelectedGame(), false, true) &&
                    FirewallRule.CreateOutbound(remoteAddresses, this.getSelectedGame(), false, true))
                {
                    getSelectedGame().Active = false;
                    UpdateActive();
                }
                return;
            }
        }