From efa01ee0e10ebf0a5ea8c82ed0bc297c861d7379 Mon Sep 17 00:00:00 2001 From: Russ Magee Date: Thu, 21 Nov 2024 22:19:47 -0800 Subject: [PATCH] Fix for Issue #40: file copies are aborted --- xs/xs.go | 8 ++++---- xsd/xsd.go | 16 ++++------------ 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/xs/xs.go b/xs/xs.go index 6fcff2c..9269411 100755 --- a/xs/xs.go +++ b/xs/xs.go @@ -1078,10 +1078,6 @@ func main() { //nolint: funlen, gocyclo fmt.Fprintln(os.Stderr, rejectUserMsg()) rec.SetStatus(GeneralProtocolErr) } else { - // === Set up connection keepalive to server - conn.StartupKeepAlive() // goroutine, returns immediately - defer conn.ShutdownKeepAlive() - // === Set up chaffing to server conn.SetupChaff(chaffFreqMin, chaffFreqMax, chaffBytesMax) // enable client->server chaffing if chaffEnabled { @@ -1112,6 +1108,10 @@ func main() { //nolint: funlen, gocyclo // === Session entry (shellMode or copyMode) if shellMode { + // === Set up connection keepalive to server + conn.StartupKeepAlive() // goroutine, returns immediately + defer conn.ShutdownKeepAlive() + // === (shell) launch tunnels launchTuns(&conn /*remoteHost,*/, tunSpecStr) doShellMode(isInteractive, &conn, oldState, rec) diff --git a/xsd/xsd.go b/xsd/xsd.go index 62f9a39..dda8ac8 100755 --- a/xsd/xsd.go +++ b/xsd/xsd.go @@ -121,10 +121,6 @@ func runClientToServerCopyAs(who, ttype string, conn *xsnet.Conn, fpath string, c.Stdout = os.Stdout c.Stderr = os.Stderr - // === Set up connection keepalive to client - conn.StartupKeepAlive() // goroutine, returns immediately - defer conn.ShutdownKeepAlive() - if chaffing { conn.StartupChaff() } @@ -221,10 +217,6 @@ func runServerToClientCopyAs(who, ttype string, conn *xsnet.Conn, srcPath string c.Stderr = stdErrBuffer //c.Stderr = nil - // === Set up connection keepalive to client - conn.StartupKeepAlive() // goroutine, returns immediately - defer conn.ShutdownKeepAlive() - if chaffing { conn.StartupChaff() } @@ -380,11 +372,11 @@ func runShellAs(who, hname, ttype, cmd string, interactive bool, //nolint:funlen if chaffing { conn.StartupChaff() + // #gv:s/label=\"runShellAs\$4\"/label=\"deferChaffShutdown\"/ + defer func() { + conn.ShutdownChaff() + }() } - // #gv:s/label=\"runShellAs\$4\"/label=\"deferChaffShutdown\"/ - defer func() { - conn.ShutdownChaff() - }() // ..and the pty to stdout. // This may take some time exceeding that of the