Ejemplo n.º 1
0
        /// <summary>
        /// InitObject: Initializes the VShieldEdgeConfig object.
        /// </summary>
        /// <returns>VShieldEdgeConfig</returns>
        private VShieldEdgeConfig InitObject()
        {
            VShieldEdgeConfig vsec   = new VShieldEdgeConfig();
            FirewallConfig    fwconf = new FirewallConfig();
            FirewallRule      fwrule = new FirewallRule();
            PortInfo          dpi    = new PortInfo();
            PortInfo          spi    = new PortInfo();
            IpInfo            dip    = new IpInfo();
            IpInfo            sip    = new IpInfo();

            try
            {
                fwrule.destinationIpAddress = dip;
                fwrule.destinationPort      = dpi;
                fwrule.ruleId          = 0;
                fwrule.sourceIpAddress = sip;
                fwrule.sourcePort      = spi;

                if (_FirewallRules.FirewallConfig.Count > 0)
                {
                    _FirewallRules.FirewallConfig.Add(fwrule);
                    return(_FirewallRules);
                }
                else
                {
                    fwconf.Add(fwrule);
                    vsec.FirewallConfig = fwconf;
                    return(vsec);
                }
            }
            catch (Exception e) { WriteObject("C-Sharp Exception: " + e); return(null); }
        }
Ejemplo n.º 2
0
        private VShieldEdgeConfig InitObject()
        {
            VShieldEdgeConfig vsec      = new VShieldEdgeConfig();
            NATConfig         natConfig = new NATConfig();
            NATRule           natRule   = new NATRule();
            PortInfo          ipi       = new PortInfo();
            PortInfo          epi       = new PortInfo();
            IpInfo            iip       = new IpInfo();
            IpInfo            eip       = new IpInfo();

            try
            {
                natRule.externalIpAddress = eip;
                natRule.externalPort      = epi;
                natRule.internalIpAddress = iip;
                natRule.internalPort      = ipi;

                if (_NatRules.NATConfig.Count > 0)
                {
                    _NatRules.NATConfig.Add(natRule);
                    return(_NatRules);
                }
                else
                {
                    natConfig.Add(natRule);
                    vsec.NATConfig = natConfig;
                    return(vsec);
                }
            }
            catch (Exception e) { WriteObject("C-Sharp Exception: " + e); return(null); }
        }