예제 #1
0
 public ULogRule(FireWallChains chain, string networkInterface, Protocols protocol, ICMPTypes?icmpType, IPAddress source, IPAddress sourceNetworkMask,
                 FirewallPort sourcePort, IPAddress destination, IPAddress destinationNetworkMask, FirewallPort destinationPort,
                 ConnectionStateTypes[] connectionStates, string note, byte logGroup, string prefix, uint bytesToCopy, ushort queueSize) :
     base(chain, networkInterface, protocol, icmpType, source, sourceNetworkMask, sourcePort, destination, destinationNetworkMask, destinationPort, connectionStates, note)
 {
     _logGroup    = logGroup;
     _prefix      = prefix;
     _bytesToCopy = bytesToCopy;
     _queueSize   = queueSize;
     if (_prefix != null)
     {
         if (_prefix.Length > 32)
         {
             throw new Exception("Unable to create ULog rule with a message prefix greater than 32 characters.");
         }
     }
     if (_logGroup < 1 || _logGroup > 32)
     {
         throw new Exception("Unable to create ULog rule with a log group not from 1-32.");
     }
     if (_queueSize < 1)
     {
         throw new Exception("Unable to create a ULog rule with a queue size less than 1.");
     }
 }
예제 #2
0
 public RejectRule(FireWallChains chain, string networkInterface, Protocols protocol, ICMPTypes? icmpType, IPAddress source, IPAddress sourceNetworkMask,
     FirewallPort sourcePort, IPAddress destination, IPAddress destinationNetworkMask, FirewallPort destinationPort,
     ConnectionStateTypes[] connectionStates,string note,RejectOptions rejectWith) :
     base(chain,networkInterface, protocol, icmpType, source, sourceNetworkMask, sourcePort, destination, destinationNetworkMask, destinationPort, connectionStates,note) 
 {
     _rejectWith = rejectWith;
 }
예제 #3
0
 public RejectRule(FireWallChains chain, string networkInterface, Protocols protocol, ICMPTypes?icmpType, IPAddress source, IPAddress sourceNetworkMask,
                   FirewallPort sourcePort, IPAddress destination, IPAddress destinationNetworkMask, FirewallPort destinationPort,
                   ConnectionStateTypes[] connectionStates, string note, RejectOptions rejectWith) :
     base(chain, networkInterface, protocol, icmpType, source, sourceNetworkMask, sourcePort, destination, destinationNetworkMask, destinationPort, connectionStates, note)
 {
     _rejectWith = rejectWith;
 }
        public void TestConstructor_AddsDisabledPorts()
        {
            var portToDisable = new PortModel(new PortInfo("port", 32), new Instance())
            {
                IsEnabled = false
            };
            var objectUnderTest = new PortChanges(new[] { portToDisable });

            FirewallPort firewallPortToDisable = objectUnderTest.PortsToDisable.Single();

            Assert.AreEqual(portToDisable.PortInfo.Port, firewallPortToDisable.Port);
            Assert.AreEqual(portToDisable.GetPortInfoTag(), firewallPortToDisable.Name);
        }
        public void TestOkCommand_ResultHasPortToEnable()
        {
            var objectUnderTest = new PortManagerViewModel(_mockedCloseAction, new Instance());

            PortModel portToEnable = objectUnderTest.Ports[0];

            portToEnable.IsEnabled = true;
            objectUnderTest.OkCommand.Execute(null);

            FirewallPort firewallPortToEnable = objectUnderTest.Result.PortsToEnable.Single();

            Assert.AreEqual(portToEnable.PortInfo.Port, firewallPortToEnable.Port);
            Assert.AreEqual(portToEnable.GetPortInfoTag(), firewallPortToEnable.Name);
        }
        public void TestOkCommand_ResultHasPortToDisable()
        {
            PortInfo     enabledPort     = PortManagerViewModel.s_supportedPorts[0];
            const string instanceName    = "instance-name";
            Instance     instance        = PortTestHelpers.GetInstanceWithEnabledPort(enabledPort, instanceName);
            var          objectUnderTest = new PortManagerViewModel(_mockedCloseAction, instance);

            objectUnderTest.Ports.Single(p => p.IsEnabled).IsEnabled = false;
            objectUnderTest.OkCommand.Execute(null);

            FirewallPort portToDisable = objectUnderTest.Result.PortsToDisable.Single();

            Assert.AreEqual(enabledPort.Port, portToDisable.Port);
            Assert.AreEqual(enabledPort.GetTag(instanceName), portToDisable.Name);
        }
예제 #7
0
 public LogRule(FireWallChains chain, string networkInterface, Protocols protocol, ICMPTypes? icmpType, IPAddress source, IPAddress sourceNetworkMask,
     FirewallPort sourcePort, IPAddress destination, IPAddress destinationNetworkMask, FirewallPort destinationPort,
     ConnectionStateTypes[] connectionStates,string note,LogLevels level,string logPrefix,bool logTcpOptions,bool logTcpSequence,bool logIPOptions) :
     base(chain,networkInterface, protocol, icmpType, source, sourceNetworkMask, sourcePort, destination, destinationNetworkMask, destinationPort, connectionStates,note) 
 {
     _logLevel = level;
     _logPrefix = logPrefix;
     _logTcpOptions = logTcpOptions;
     _logTcpSequence = logTcpSequence;
     _logIPOptions = logIPOptions;
     if (_logPrefix != null)
     {
         if (_logPrefix.Length > 29)
             throw new Exception("The log prefix " + _logPrefix + " is too long, it cannot exceed 29 characters.");
     }
 }
        public PortChanges(IEnumerable <PortModel> changedPorts)
        {
            PortsToEnable  = new List <FirewallPort>();
            PortsToDisable = new List <FirewallPort>();

            foreach (PortModel entry in changedPorts ?? Enumerable.Empty <PortModel>())
            {
                var firewallPort = new FirewallPort(entry.GetPortInfoTag(), entry.PortInfo.Port);
                if (entry.IsEnabled)
                {
                    PortsToEnable.Add(firewallPort);
                }
                else
                {
                    PortsToDisable.Add(firewallPort);
                }
            }
        }
예제 #9
0
 public LogRule(FireWallChains chain, string networkInterface, Protocols protocol, ICMPTypes?icmpType, IPAddress source, IPAddress sourceNetworkMask,
                FirewallPort sourcePort, IPAddress destination, IPAddress destinationNetworkMask, FirewallPort destinationPort,
                ConnectionStateTypes[] connectionStates, string note, LogLevels level, string logPrefix, bool logTcpOptions, bool logTcpSequence, bool logIPOptions) :
     base(chain, networkInterface, protocol, icmpType, source, sourceNetworkMask, sourcePort, destination, destinationNetworkMask, destinationPort, connectionStates, note)
 {
     _logLevel       = level;
     _logPrefix      = logPrefix;
     _logTcpOptions  = logTcpOptions;
     _logTcpSequence = logTcpSequence;
     _logIPOptions   = logIPOptions;
     if (_logPrefix != null)
     {
         if (_logPrefix.Length > 29)
         {
             throw new Exception("The log prefix " + _logPrefix + " is too long, it cannot exceed 29 characters.");
         }
     }
 }
예제 #10
0
 public ULogRule(FireWallChains chain, string networkInterface, Protocols protocol, ICMPTypes? icmpType, IPAddress source, IPAddress sourceNetworkMask,
     FirewallPort sourcePort, IPAddress destination, IPAddress destinationNetworkMask, FirewallPort destinationPort,
     ConnectionStateTypes[] connectionStates,string note,byte logGroup,string prefix,uint bytesToCopy,ushort queueSize) :
     base(chain,networkInterface, protocol, icmpType, source, sourceNetworkMask, sourcePort, destination, destinationNetworkMask, destinationPort, connectionStates,note) 
 {
     _logGroup = logGroup;
     _prefix = prefix;
     _bytesToCopy = bytesToCopy;
     _queueSize = queueSize;
     if (_prefix != null)
     {
         if (_prefix.Length > 32)
             throw new Exception("Unable to create ULog rule with a message prefix greater than 32 characters.");
     }
     if (_logGroup < 1 || _logGroup > 32)
         throw new Exception("Unable to create ULog rule with a log group not from 1-32.");
     if (_queueSize < 1)
         throw new Exception("Unable to create a ULog rule with a queue size less than 1.");
 }
예제 #11
0
        private void OnOkCommand()
        {
            var portsToEnable  = new List <FirewallPort>();
            var portsToDisable = new List <FirewallPort>();

            foreach (var entry in Ports.Where(x => x.Changed))
            {
                var firewallPort = new FirewallPort(entry.PortInfo.GetTag(_instance), entry.PortInfo.Port);
                if (entry.IsEnabled)
                {
                    portsToEnable.Add(firewallPort);
                }
                else
                {
                    portsToDisable.Add(firewallPort);
                }
            }

            Result = new PortChanges(portsToEnable: portsToEnable, portsToDisable: portsToDisable);

            _owner.Close();
        }
예제 #12
0
 public PortRedirectRule(FireWallChains chain, string networkInterface, Protocols protocol, IPAddress source, FirewallPort sourcePort, FirewallPort destinationPort,
                         ConnectionStateTypes[] connectionStates, string note, int toPort) :
     base(chain, networkInterface, protocol, null, source, null, sourcePort, null, null, destinationPort, connectionStates, note)
 {
     this._toPort = toPort;
 }
 public PortRedirectRule(FireWallChains chain, string networkInterface, Protocols protocol, IPAddress source, FirewallPort sourcePort, FirewallPort destinationPort,
     ConnectionStateTypes[] connectionStates,string note, int toPort) :
     base(chain, networkInterface, protocol, null, source, null, sourcePort, null, null, destinationPort, connectionStates,note)
 {
     this._toPort = toPort;
 }