Bump version to 1.0.18

This commit is contained in:
2026-07-09 12:43:13 -04:00
parent f92b03c0ce
commit 73cad44769
4 changed files with 38 additions and 14 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
BINARY=syncserver BINARY=syncserver
VERSION?=1.0.17 VERSION?=1.0.18
GO?=go GO?=go
LDFLAGS=-s -w -X main.version=$(VERSION) -X main.commit=$(shell git rev-parse --short HEAD 2>/dev/null || echo unknown) 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 BUILD_FLAGS=CGO_ENABLED=0
+1 -1
View File
@@ -20,7 +20,7 @@ import (
"github.com/syncserver/internal/syncengine" "github.com/syncserver/internal/syncengine"
) )
var version = "1.0.17" var version = "1.0.18"
func main() { func main() {
cfgPath := flag.String("config", "", "Path to config.yaml") cfgPath := flag.String("config", "", "Path to config.yaml")
+6
View File
@@ -261,11 +261,17 @@ func (e *Engine) Run(ctx context.Context, jobID int64, pairID int64) error {
var result *RsyncResult var result *RsyncResult
if isRemoteToRemote(srcMachine, dstMachine) { 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{ result, err = runner.RunRemote(jobCtx, cfg, RemoteMachine{
Host: srcMachine.Host, Host: srcMachine.Host,
Port: srcMachine.Port, Port: srcMachine.Port,
SSHUser: srcMachine.SSHUser, SSHUser: srcMachine.SSHUser,
PrivKey: privKey, PrivKey: privKey,
DestPrivKey: destPrivKey,
}, onLine) }, onLine)
} else { } else {
result, err = runner.Run(jobCtx, cfg, onLine) result, err = runner.Run(jobCtx, cfg, onLine)
+21 -3
View File
@@ -2,6 +2,7 @@ package syncengine
import ( import (
"context" "context"
"encoding/base64"
"fmt" "fmt"
"io" "io"
"os/exec" "os/exec"
@@ -184,22 +185,39 @@ type RemoteMachine struct {
Port int Port int
SSHUser string SSHUser string
PrivKey string PrivKey string
DestPrivKey string
} }
func (r *RsyncRunner) RunRemote(ctx context.Context, pair *SyncPairConfig, remote RemoteMachine, onLine func(stream string, line string)) (*RsyncResult, error) { 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{ sshArgs := []string{
"ssh", "ssh",
"-i", remote.PrivKey, "-i", remote.PrivKey,
"-o", "StrictHostKeyChecking=accept-new", "-o", "StrictHostKeyChecking=accept-new",
"-o", "UserKnownHostsFile=" + strings.TrimRight(r.sshDir, "/") + "/known_hosts", "-o", "UserKnownHostsFile=" + strings.TrimRight(r.sshDir, "/") + "/known_hosts",
"-tt",
"-p", fmt.Sprintf("%d", remote.Port), "-p", fmt.Sprintf("%d", remote.Port),
fmt.Sprintf("%s@%s", remote.SSHUser, remote.Host), 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...) sshArgs = append(sshArgs, args...)
}
cmd := exec.CommandContext(ctx, "ssh", sshArgs...) cmd := exec.CommandContext(ctx, "ssh", sshArgs...)