Example #1
0
        public override void remove(string host, string type, byte[] key)
        {
            bool sync = false;

            lock (pool)
            {
                for (int i = 0; i < pool.Count; i++)
                {
                    HostKey hk = pool[i];
                    if (host == null ||
                        (hk.isMatched(host) &&
                         (type == null || (hk.getType().Equals(type) &&
                                           (key == null || Util.array_equals(key, hk.key))))))
                    {
                        string hosts = hk.getHost();
                        if (hosts.Equals(host) ||
                            ((hk is HashedHostKey) &&
                             ((HashedHostKey)hk).isHashed()))
                        {
                            pool.Remove(hk);
                        }
                        else
                        {
                            hk.host = deleteSubString(hosts, host);
                        }
                        sync = true;
                    }
                }
            }
            if (sync)
            {
                try { Sync(); }
                catch /*(Exception e)*/ { };
            }
        }
Example #2
0
 public override HostKey[] getHostKey(string host, string type)
 {
     lock (pool)
     {
         int count = 0;
         for (int i = 0; i < pool.Count; i++)
         {
             HostKey hk = pool[i];
             if (hk.type == HostKey.UNKNOWN)
             {
                 continue;
             }
             if (host == null ||
                 (hk.isMatched(host) &&
                  (type == null || hk.getType().Equals(type))))
             {
                 count++;
             }
         }
         if (count == 0)
         {
             return(null);
         }
         HostKey[] foo = new HostKey[count];
         int       j   = 0;
         for (int i = 0; i < pool.Count; i++)
         {
             HostKey hk = pool[i];
             if (hk.type == HostKey.UNKNOWN)
             {
                 continue;
             }
             if (host == null ||
                 (hk.isMatched(host) &&
                  (type == null || hk.getType().Equals(type))))
             {
                 foo[j++] = hk;
             }
         }
         return(foo);
     }
 }