X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=rpc%2Fdial.go;h=c098714cc0759388dd32e0d723819c4b4c598665;hb=fd97e8019e2ab166d9475ed59782c86247d8430b;hp=909ec7e1aaf7e70193af9e05d29cbbdd07769f79;hpb=7fd48d68ef5a77fa9df8ad0251722ed35800e0f8;p=safcm%2Fsafcm.git diff --git a/rpc/dial.go b/rpc/dial.go index 909ec7e..c098714 100644 --- a/rpc/dial.go +++ b/rpc/dial.go @@ -24,22 +24,35 @@ import ( "encoding/hex" "fmt" "io" + "io/fs" "os/exec" "strconv" "strings" "ruderich.org/simon/safcm" - "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 + + RemoteHelpers fs.FS +} + +func (c *Conn) DialSSH(cfg SSHConfig) error { if c.events == nil { return fmt.Errorf("cannot reuse Conn") } - remote := host - if user != "" { - remote = user + "@" + host + if cfg.RemoteHelpers == nil { + return fmt.Errorf("SSHConfig.RemoteHelpers not set") + } + c.remoteHelpers = cfg.RemoteHelpers + + remote := cfg.Host + if cfg.User != "" { + remote = cfg.User + "@" + cfg.Host } c.debugf("DialSSH: connecting to %q", remote) @@ -50,8 +63,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...), @@ -177,7 +190,6 @@ f() { tmp="$(mktemp "$x.XXXXXX")" # Report filename for upload echo "$tmp" - # Wait for upload to complete read unused @@ -203,9 +215,9 @@ f return err } - // Get embedded helper binary - helper, err := remote.Helpers.ReadFile( - fmt.Sprintf("helpers/%s-%s", goos, goarch)) + // Get remote helper binary + helper, err := fs.ReadFile(c.remoteHelpers, + fmt.Sprintf("%s-%s", goos, goarch)) if err != nil { return fmt.Errorf("remote not built for GOOS/GOARCH %s/%s", goos, goarch)