예제 #1
0
파일: Links.cs 프로젝트: biuken/eAnt
        private string m_ExtractSourcesInfo(string elink)
        {
            Regex regex =
                new Regex(@"\/\|sources(?<sources>.*)\|(?<rest>.*)",
                          RegexOptions.IgnoreCase
                          | RegexOptions.Multiline
                          | RegexOptions.IgnorePatternWhitespace
                          | RegexOptions.Compiled
                          );
            Match m = regex.Match(elink);

            if (m.Success)
            {
                string    sources     = m.Result("${sources}");
                ArrayList sourcesList = new ArrayList();
                while (sources.Length > 0)
                {
                    regex = new Regex(@",(?<ip>[0-9.]+\.[0-9.]+\.[0-9.]+\.[0-9.]+):(?<port>[0-9]+)(?<sources>.*)",
                                      RegexOptions.IgnoreCase
                                      | RegexOptions.Multiline
                                      | RegexOptions.IgnorePatternWhitespace
                                      | RegexOptions.Compiled
                                      );
                    m = regex.Match(sources);
                    if (m.Success)
                    {
                        stDatosFuente sourcefound = new stDatosFuente();
                        IPAddress     ip          = System.Net.IPAddress.Parse(m.Result("${ip}"));
                        sourcefound.IP   = BitConverter.ToUInt32(ip.GetAddressBytes(), 0);
                        sourcefound.Port = Convert.ToUInt16(m.Result("${port}"));
                        sourcesList.Add(sourcefound);
                        sources = m.Result("${sources}");
                    }
                    else
                    {
                        break;
                    }
                }
                if (sourcesList.Count > 0)
                {
                    m_clients = new stDatosFuente[sourcesList.Count];
                    int i = 0;
                    foreach (stDatosFuente src in sourcesList)
                    {
                        m_clients[i] = src;
                        i++;
                    }
                }
                return(sources);
            }
            else
            {
                return("");
            }
        }
예제 #2
0
파일: Search.cs 프로젝트: biuken/eAnt
        public void AddSourcesToFile()
        {
            if ((Sources == null) || (Sources.Count == 0))
            {
                return;
            }
            CElement element = CKernel.FilesList[CKernel.StringToHash(this.Hash)];
            int      i;

            if ((element != null) && (element.File.FileStatus == Protocol.FileState.Ready))
            {
                stDatosFuente[] sourcesList = new stDatosFuente[Sources.Count];
                i = 0;
                foreach (uint ip in Sources.Keys)
                {
                    sourcesList[i].IP   = ip;
                    sourcesList[i].Port = (ushort)Sources[ip];
                    i++;
                }
                CKernel.ClientsList.AddClientsToFile(sourcesList, CKernel.StringToHash(this.Hash));
            }
        }