aboutsummaryrefslogtreecommitdiff
path: root/tofu
diff options
context:
space:
mode:
authorAdnan Maolood <[email protected]>2021-01-14 17:09:31 -0500
committerAdnan Maolood <[email protected]>2021-01-14 17:09:31 -0500
commit3fd55c5ceede90b3d57bc1bde41bba5e5325e345 (patch)
tree373438e6d49f6eecf5ae26596c1035d086bb7fa2 /tofu
parenttofu: Add NewHostsFile function (diff)
downloadgo-gemini-3fd55c5ceede90b3d57bc1bde41bba5e5325e345.tar.xz
go-gemini-3fd55c5ceede90b3d57bc1bde41bba5e5325e345.zip
tofu: Add KnownHosts.Load function
Diffstat (limited to 'tofu')
-rw-r--r--tofu/tofu.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/tofu/tofu.go b/tofu/tofu.go
index 9954734..0fd7d26 100644
--- a/tofu/tofu.go
+++ b/tofu/tofu.go
@@ -67,6 +67,17 @@ func (k *KnownHosts) WriteTo(w io.Writer) (int64, error) {
return int64(written), bw.Flush()
}
+// Load loads the known hosts entries from the provided path.
+func (k *KnownHosts) Load(path string) error {
+ f, err := os.Open(path)
+ if err != nil {
+ return err
+ }
+ defer f.Close()
+
+ return k.Parse(f)
+}
+
// Parse parses the provided io.Reader and adds the parsed hosts to the list.
// Invalid entries are ignored.
//