public override HostKey[] GetHostKey(string host, string type) { lock (pool) { int count = 0; for (int i = 0; i < pool.Count; i++) { HostKey hk = (HostKey)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_1 = 0; i_1 < pool.Count; i_1++) { HostKey hk = (HostKey)pool[i_1]; if (hk.type == HostKey.UNKNOWN) { continue; } if (host == null || (hk.IsMatched(host) && (type == null || hk.GetType().Equals(type )))) { foo[j++] = hk; } } return(foo); } }
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 = (HostKey)(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 KnownHosts.HashedHostKey) && ((KnownHosts.HashedHostKey )hk).IsHashed())) { pool.RemoveElement(hk); } else { hk.host = DeleteSubString(hosts, host); } sync = true; } } } if (sync) { try { Sync(); } catch (Exception) { } } }