Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cached KnownHosts implementation - continued... #744

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Commits on Feb 24, 2020

  1. Add cached KnownHosts implementation

    This adds a new class Net::SSH::KnownHosts::Cached which loads the
    known_hosts files once, builds an index, and uses that when searching
    for keys for a given host. An instance of this object can be passed
    using the `known_hosts` option in order to avoid loading known_hosts
    multiple times when making multiple connections to either the same host
    or several hosts.
    
    This behavior is implemented in a new class because it differs from the
    existing implementation in the case where the content of the known_hosts
    file changes outside the current process. With the standard
    implementation, those changes will always be picked up the next time a
    connection is made, whereas the Cached implementation won't
    automatically incorporated changes made out-of-band.
    nicklewis authored and donoghuc committed Feb 24, 2020
    Configuration menu
    Copy the full SHA
    09e833d View commit details
    Browse the repository at this point in the history

Commits on Mar 1, 2020

  1. Rebuild cache when known_hosts file has changed

    When the cache is built, store the file modification times. Only re-build the cache when the mtime does not exist or has changed since last read. Similarly with the add method, only rebuild the cache when the write is the only change since the last read.
    donoghuc committed Mar 1, 2020
    Configuration menu
    Copy the full SHA
    df7c87a View commit details
    Browse the repository at this point in the history

Commits on Mar 2, 2020

  1. [FOR DISCUSSION] sha256 has of known_hosts instead of mtime

    Instead of tracking mtime to determine if known_hosts need to be re-parsed, track file sha256 checksums. This avoids cases where mtimes are close enough together that a change goes un-noticed (discovered writing tests). Also based on feedback also invalidate cache if known_hosts file is deleted OOB.
    donoghuc committed Mar 2, 2020
    Configuration menu
    Copy the full SHA
    8ae4097 View commit details
    Browse the repository at this point in the history

Commits on Mar 8, 2020

  1. (Squash me) Improvements based on perf testing

    This commit ensures file paths are expanded given the defaults contain `~`. It also handles the case where *no* known host files are readable by intializsing caches to empty hashes in the init method.
    donoghuc committed Mar 8, 2020
    Configuration menu
    Copy the full SHA
    1f5124e View commit details
    Browse the repository at this point in the history