public PortScannerInputParser(string input)
 {
     ParseIPAddress("127.0.0.1");
     PortType = EPortType.TCP;
     data     = !string.IsNullOrEmpty(input) ? Regex.Replace(input, @"\s+", "").Split(';') : null;
     Parse();
 }
Example #2
0
        /// <summary>
        ///     Returns the next available port for specified use.
        ///     Starts from a predefined value for enum
        /// </summary>
        /// <returns>An available TPC Port</returns>
        public static int GetNewPort(EPortType type)
        {
            var ipGlobalProperties = IPGlobalProperties.GetIPGlobalProperties();
            var tcpConnInfoArray   = ipGlobalProperties.GetActiveTcpConnections();

            while (true)
            {
                // Get port from tool
                var port = PortTypeUtils.GetPortNumber(type);
                // Check if our desired port is in use
                if (tcpConnInfoArray.All(t => t.LocalEndPoint.Port != port))
                {
                    // This port is good
                    return(port);
                }
            }
        }
Example #3
0
 public PortScannerPortInfo GetPortInfo(int port, EPortType type = EPortType.TCP)
 {
     if (portInfo != null)
     {
         if (portInfo.ContainsKey(port))
         {
             var portInfoList = portInfo[port];
             if (portInfoList.Length >= 1 && type == EPortType.TCP)
             {
                 return(portInfoList[0]);
             }
             else if (portInfoList.Length == 2 && type == EPortType.UDP)
             {
                 return(portInfoList[1]);
             }
         }
     }
     return(null);
 }
        /*
         * 80
         * 80-1024
         * 80;192.168.100.10
         * 80-1024;192.168.100.10
         * 80;192.168.100.10;TCP
         * 80-1024;192.168.100.10;UDP
         * 80;192.168.100.10;TCP;10
         * 80-1024;192.168.100.10;UDP;100
         */
        void Parse()
        {
            if (data == null)
            {
                return;
            }

            if (data.Length >= 1)
            {
                ParsePorts(data[0]);
            }
            if (data.Length >= 2)
            {
                ParseIPAddress(data[1]);
            }
            if (data.Length >= 3)
            {
                PortType = data[2].ToLower().Equals("tcp") ? EPortType.TCP : EPortType.UDP;
            }
            if (data.Length >= 4)
            {
                ParseTimeoutTreshold(data[3]);
            }
        }
Example #5
0
        public static int GetPortNumber(EPortType type)
        {
            int port;

            if (Ports.TryGetValue(type, out port))
            {
                Ports[type]++;
                return(port);
            }


            switch (type)
            {
            case EPortType.MultichainD:
                port = 7211;
                break;

            case EPortType.ClientMultichainD:
                port = 8211;
                break;

            case EPortType.Rpc:
                port = 24533;
                break;

            case EPortType.ClientRpc:
                port = 25533;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            Ports[type] = port + 1;
            return(port);
        }
Example #6
0
 public SetPortBehaviour(EPortType selectedPortType)
 {
     _SelectedPortType = selectedPortType;
 }
 public SetPortCornerBehaviour(SeaHex seaHex, EPortType portType)
 {
     _PortType = portType;
     _SelectedHex = seaHex;
 }
 private void PortButtonMouseDown(object sender, RoutedEventArgs e)
 {
     Button button = (Button)sender;
     switch (((Button)sender).Name)
     {
         case "btnTimberPort": _SelectedPortType = EPortType.Timber; break;
         case "btnWheatPort": _SelectedPortType = EPortType.Wheat; break;
         case "btnOrePort": _SelectedPortType = EPortType.Ore; break;
         case "btnClayPort": _SelectedPortType = EPortType.Clay; break;
         case "btnSheepPort": _SelectedPortType = EPortType.Sheep; break;
         case "btnNoPort": _SelectedPortType = EPortType.None; break;
         case "btn31Port": _SelectedPortType = EPortType.ThreeToOne; break;
         case "btnRandomPort": _SelectedPortType = EPortType.Random; break;
     }
     this.mapEditorViewPort.InteractionBehaviour = new SetPortBehaviour(_SelectedPortType);
 }