Esempio n. 1
0
        public static bool AllowNonWindowsFabricPortsTraffic(NonWindowsFabricEndpointSet nonWindowsFabricEndpointSet)
        {
            foreach (KeyValuePair <string, InputEndpointType> nonWindowsFabricPort in nonWindowsFabricEndpointSet.NonWindowsFabricPorts)
            {
                int port = int.Parse(nonWindowsFabricPort.Value.Port, CultureInfo.InvariantCulture);
                if (!AllowNonWindowsFabricPortsTraffic(nonWindowsFabricPort.Key, port))
                {
                    TextLogger.LogError("Failed to allow traffic to non Windows Fabric port. Endpoint name : {0}. Port : {1}.", nonWindowsFabricPort.Key, port);

                    return(false);
                }
            }

            foreach (KeyValuePair <string, FabricEndpointsTypeApplicationEndpoints> nonWindowsFabricPortRange in nonWindowsFabricEndpointSet.NonWindowsFabricPortRanges)
            {
                if (!AllowNonWindowsFabricPortsTraffic(nonWindowsFabricPortRange.Key, nonWindowsFabricPortRange.Value.StartPort, nonWindowsFabricPortRange.Value.EndPort))
                {
                    TextLogger.LogError(
                        "Failed to allow traffic to non Windows Fabric port range. Endpoint name : {0}. Start Port : {1}. End Port : {2}.",
                        nonWindowsFabricPortRange.Key,
                        nonWindowsFabricPortRange.Value.StartPort,
                        nonWindowsFabricPortRange.Value.EndPort);

                    return(false);
                }
            }

            return(true);
        }
Esempio n. 2
0
        public static bool AllowDynamicPortsTraffic(int dynamicStartPort, int dynamicEndPort)
        {
            if (!AllowDynamicPortsTraffic("tcp", dynamicStartPort, dynamicEndPort))
            {
                TextLogger.LogError("Failed to allow traffic to dynamic port range for tcp. Start port : {0}. End port : {1}.", dynamicStartPort, dynamicEndPort);

                return(false);
            }

            if (!AllowDynamicPortsTraffic("udp", dynamicStartPort, dynamicEndPort))
            {
                TextLogger.LogError("Failed to allow traffic to dynamic port range for udp. Start port : {0}. End port : {1}.", dynamicStartPort, dynamicEndPort);

                return(false);
            }

            return(true);
        }
Esempio n. 3
0
        public static bool ReduceDynamicPortRange(int dynamicStartPort, int dynamicEndPort)
        {
            int dynamicPortCount = dynamicEndPort - dynamicStartPort + 1;

            TextLogger.LogInfo("Reducing dynamic port range. Start port : {0}. Dynamic port count : {1}.", dynamicStartPort, dynamicPortCount);

            if (Socket.OSSupportsIPv4)
            {
                if (!ReduceDynamicPortRange(dynamicStartPort, dynamicPortCount, "ipv4", "tcp"))
                {
                    TextLogger.LogError("Failed to reduce dynamic port range for ipv4:tcp. Start port : {0}. Dynamic port count : {1}.", dynamicStartPort, dynamicPortCount);

                    return(false);
                }

                if (!ReduceDynamicPortRange(dynamicStartPort, dynamicPortCount, "ipv4", "udp"))
                {
                    TextLogger.LogError("Failed to reduce dynamic port range for ipv4:udp. Start port : {0}. Dynamic port count : {1}.", dynamicStartPort, dynamicPortCount);

                    return(false);
                }
            }

            if (Socket.OSSupportsIPv6)
            {
                if (!ReduceDynamicPortRange(dynamicStartPort, dynamicPortCount, "ipv6", "tcp"))
                {
                    TextLogger.LogError("Failed to reduce dynamic port range for ipv6:tcp. Start port : {0}. Dynamic port count : {1}.", dynamicStartPort, dynamicPortCount);

                    return(false);
                }

                if (!ReduceDynamicPortRange(dynamicStartPort, dynamicPortCount, "ipv6", "udp"))
                {
                    TextLogger.LogError("Failed to reduce dynamic port range for ipv6:udp. Start port : {0}. Dynamic port count : {1}.", dynamicStartPort, dynamicPortCount);

                    return(false);
                }
            }

            return(true);
        }