]> ruderich.org/simon Gitweb - safcm/safcm.git/blobdiff - rpc/dial.go
rpc: use SSHConfig struct as argument to DialSSH()
[safcm/safcm.git] / rpc / dial.go
index caa34b098fe933ca9fba22d7f0ea35aadb05d33a..c0c6cd4088b2859d758aa0d06cf64405a2b70a16 100644 (file)
@@ -32,14 +32,20 @@ import (
        "ruderich.org/simon/safcm/remote"
 )
 
-func (c *Conn) DialSSH(user, host, sshConfig string) error {
+type SSHConfig struct {
+       Host      string
+       User      string // optional
+       SshConfig string // optional
+}
+
+func (c *Conn) DialSSH(cfg SSHConfig) error {
        if c.events == nil {
                return fmt.Errorf("cannot reuse Conn")
        }
 
-       remote := host
-       if user != "" {
-               remote = user + "@" + host
+       remote := cfg.Host
+       if cfg.User != "" {
+               remote = cfg.User + "@" + cfg.Host
        }
        c.debugf("DialSSH: connecting to %q", remote)
 
@@ -50,8 +56,8 @@ func (c *Conn) DialSSH(user, host, sshConfig string) error {
        }
 
        c.sshRemote = remote
-       if sshConfig != "" {
-               c.sshOpts = []string{"-F", sshConfig}
+       if cfg.SshConfig != "" {
+               c.sshOpts = []string{"-F", cfg.SshConfig}
        }
        c.cmd = exec.Command("ssh",
                append(append([]string{}, c.sshOpts...),