converge/pkg/iowrappers/sync.go
Erik Brakkee 75ac9a46f3 * fixes for windows
* detect kill ssh session
* include sftp session in the count of ssh sessions
* log session type in the agent
2024-07-23 19:26:59 +02:00

32 lines
532 B
Go

package iowrappers
import (
"io"
"log"
)
func SynchronizeStreams(stream1, stream2 io.ReadWriter) {
waitChannel := make(chan bool)
go func() {
defer func() {
waitChannel <- true
}()
_, err := io.Copy(stream1, stream2)
if err != nil {
log.Printf("sync streams error(1) %v\n", err)
}
}()
go func() {
defer func() {
waitChannel <- true
}()
_, err := io.Copy(stream2, stream1)
log.Printf("sync streams error(2) %v\n", err)
}()
<-waitChannel
log.Println("SynchronizeStreams: Connection closed")
}