From 8075e819ada914c81ac0ab1c7ea46d68b27876b0 Mon Sep 17 00:00:00 2001 From: Kevin Burke Date: Tue, 18 Apr 2017 10:57:51 -0700 Subject: [PATCH] tweak interface --- config.go | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/config.go b/config.go index d7cbf5b..251065a 100644 --- a/config.go +++ b/config.go @@ -10,31 +10,24 @@ import ( "strings" ) -func User(hostname string) string { - return "" +type UserSettings struct { + systemConfig *Config + userConfig *Config + username string } -type ConfigFinder struct { - IgnoreSystemConfig bool - IgnoreUserConfig bool -} - -func (c *ConfigFinder) User(hostname string) string { - return "" -} - -var DefaultFinder = &ConfigFinder{IgnoreSystemConfig: false, IgnoreUserConfig: false} - func parseFile(filename string) (*Config, error) { f, err := os.Open(filename) if err != nil { return nil, err } defer f.Close() - return LoadReader(f) + return Decode(f) } -func LoadReader(r io.Reader) (c *Config, err error) { +// Decode reads r into a Config, or returns an error if r could not be parsed as +// an SSH config file. +func Decode(r io.Reader) (c *Config, err error) { defer func() { if r := recover(); r != nil { if _, ok := r.(runtime.Error); ok {