Bump version to 1.0.18
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
BINARY=syncserver
|
||||
VERSION?=1.0.17
|
||||
VERSION?=1.0.18
|
||||
GO?=go
|
||||
LDFLAGS=-s -w -X main.version=$(VERSION) -X main.commit=$(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
|
||||
BUILD_FLAGS=CGO_ENABLED=0
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ import (
|
||||
"github.com/syncserver/internal/syncengine"
|
||||
)
|
||||
|
||||
var version = "1.0.17"
|
||||
var version = "1.0.18"
|
||||
|
||||
func main() {
|
||||
cfgPath := flag.String("config", "", "Path to config.yaml")
|
||||
|
||||
@@ -261,11 +261,17 @@ func (e *Engine) Run(ctx context.Context, jobID int64, pairID int64) error {
|
||||
|
||||
var result *RsyncResult
|
||||
if isRemoteToRemote(srcMachine, dstMachine) {
|
||||
destPrivKey, err := e.resolveSSHKey(dstMachine)
|
||||
if err != nil {
|
||||
slog.Warn("failed to resolve destination SSH key, using server key", "error", err)
|
||||
destPrivKey = filepath.Join(e.cfg.SSHDir(), "id_ed25519")
|
||||
}
|
||||
result, err = runner.RunRemote(jobCtx, cfg, RemoteMachine{
|
||||
Host: srcMachine.Host,
|
||||
Port: srcMachine.Port,
|
||||
SSHUser: srcMachine.SSHUser,
|
||||
PrivKey: privKey,
|
||||
DestPrivKey: destPrivKey,
|
||||
}, onLine)
|
||||
} else {
|
||||
result, err = runner.Run(jobCtx, cfg, onLine)
|
||||
|
||||
@@ -2,6 +2,7 @@ package syncengine
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"io"
|
||||
"os/exec"
|
||||
@@ -184,22 +185,39 @@ type RemoteMachine struct {
|
||||
Port int
|
||||
SSHUser string
|
||||
PrivKey string
|
||||
DestPrivKey string
|
||||
}
|
||||
|
||||
func (r *RsyncRunner) RunRemote(ctx context.Context, pair *SyncPairConfig, remote RemoteMachine, onLine func(stream string, line string)) (*RsyncResult, error) {
|
||||
args := r.buildRemoteArgs(pair)
|
||||
args := r.buildArgs(pair)
|
||||
|
||||
var remoteCmd string
|
||||
if remote.DestPrivKey != "" {
|
||||
encodedKey := base64.StdEncoding.EncodeToString([]byte(remote.DestPrivKey))
|
||||
innerSSH := fmt.Sprintf(`ssh -i /tmp/syncserver-dest-key -o StrictHostKeyChecking=accept-new -o UserKnownHostsFile=/dev/null`)
|
||||
rsyncPart := fmt.Sprintf("rsync %s -e %q %s %s",
|
||||
strings.Join(args, " "), innerSSH, pair.Source, pair.Dest)
|
||||
remoteCmd = fmt.Sprintf(
|
||||
`echo '%s' | base64 -d > /tmp/syncserver-dest-key && chmod 600 /tmp/syncserver-dest-key && %s; STATUS=$?; rm -f /tmp/syncserver-dest-key; exit $STATUS`,
|
||||
encodedKey, rsyncPart)
|
||||
} else {
|
||||
remoteCmd = "rsync " + strings.Join(args, " ")
|
||||
}
|
||||
|
||||
sshArgs := []string{
|
||||
"ssh",
|
||||
"-i", remote.PrivKey,
|
||||
"-o", "StrictHostKeyChecking=accept-new",
|
||||
"-o", "UserKnownHostsFile=" + strings.TrimRight(r.sshDir, "/") + "/known_hosts",
|
||||
"-tt",
|
||||
"-p", fmt.Sprintf("%d", remote.Port),
|
||||
fmt.Sprintf("%s@%s", remote.SSHUser, remote.Host),
|
||||
"rsync",
|
||||
}
|
||||
if remote.DestPrivKey != "" {
|
||||
sshArgs = append(sshArgs, "bash", "-c", remoteCmd)
|
||||
} else {
|
||||
sshArgs = append(sshArgs, "rsync")
|
||||
sshArgs = append(sshArgs, args...)
|
||||
}
|
||||
|
||||
cmd := exec.CommandContext(ctx, "ssh", sshArgs...)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user