private TCPScanTaskInfo CreateTaskInfo(int nPort, EndPoint endPoint, int nProbes, int nTimeout, int nRetry, int nTotalTimeout, bool bUseNullProbes)
        {
            TCPScanTaskInfo ti = null;

            lock (m_obj_sync) {
                ti = m_que_task.Dequeue();
            }
            ti.Retry      = nRetry;
            ti.RunedRetry = 0;
            ti.Port       = nPort;
            ti.EndPoint   = endPoint;
            ti.IsStarted  = false;
            //ti.Socket = this.GetNextSocket(nTimeout);
            ti.CanConnect   = false;
            ti.Timeout      = nTimeout;
            ti.TotalTimeout = nTotalTimeout;
            ti.CurrentProbe = null;
            if (nProbes < 0)
            {
                ti.SendProbes = m_configer.GetProbesQueue(ProbeType.Tcp, nPort, 0);
            }
            else if (nProbes > 0)
            {
                ti.SendProbes = m_configer.GetProbesQueue(ProbeType.Tcp, nPort, nProbes);
            }
            else
            {
                ti.SendProbes = null;
            }
            if (!bUseNullProbes && ti.SendProbes != null && ti.SendProbes.Count != 0)
            {
                ti.CurrentProbe = ti.SendProbes.Dequeue();
            }
            return(ti);
        }
Ejemplo n.º 2
0
        private UDPScanTaskInfo CreateTaskInfo(int nPort, EndPoint endPoint, int nProbes, int nTimeout, int nRetry, int nTotalTimeout)
        {
            UDPScanTaskInfo ti = null;

            lock (m_obj_sync) {
                ti = m_que_task.Dequeue();
            }
            ti.Retry        = nRetry;
            ti.RunedRetry   = 0;
            ti.Port         = nPort;
            ti.EndPoint     = endPoint;
            ti.IsStarted    = false;
            ti.Timeout      = nTimeout;
            ti.TotalTimeout = nTotalTimeout;
            Queue <ProbeInfo> pi = null;

            if (nProbes < 0)
            {
                pi = m_configer.GetProbesQueue(ProbeType.Udp, nPort, 0);
            }
            else
            {
                pi = m_configer.GetProbesQueue(ProbeType.Udp, nPort, nProbes);
            }
            if (pi.Count == 0)
            {
                throw new InvalidOperationException("Can not match the probes whith port [" + nPort + "]");
            }
            ti.SendDatas.Clear();
            ti.SendDatasQueue.Clear();
            foreach (var v in pi)
            {
                ti.SendDatas.Add(v.Data);
                ti.SendDatasQueue.Enqueue(v.Data);
            }
            return(ti);
        }