mirror of https://gogs.blitter.com/RLabs/xs
Experiment - moved sigwinch goroutine out of main client
This commit is contained in:
parent
8f087e9ca1
commit
89dd225910
|
@ -15,12 +15,10 @@ import (
|
|||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
"os/signal"
|
||||
"os/user"
|
||||
"runtime"
|
||||
"strings"
|
||||
"sync"
|
||||
"syscall"
|
||||
|
||||
hkexsh "blitter.com/go/hkexsh"
|
||||
isatty "github.com/mattn/go-isatty"
|
||||
|
@ -113,9 +111,6 @@ func main() {
|
|||
defer conn.Close()
|
||||
// From this point on, conn is a secure encrypted channel
|
||||
|
||||
rows := 0
|
||||
cols := 0
|
||||
|
||||
// Set stdin in raw mode if it's an interactive session
|
||||
// TODO: send flag to server side indicating this
|
||||
// affects shell command used
|
||||
|
@ -223,26 +218,7 @@ func main() {
|
|||
}()
|
||||
|
||||
if isInteractive {
|
||||
// Handle pty resizes (notify server side)
|
||||
ch := make(chan os.Signal, 1)
|
||||
signal.Notify(ch, syscall.SIGWINCH)
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
|
||||
for range ch {
|
||||
// Query client's term size so we can communicate it to server
|
||||
// pty after interactive session starts
|
||||
rows, cols, err = getTermSize()
|
||||
log.Printf("[rows %v cols %v]\n", rows, cols)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
termSzPacket := fmt.Sprintf("%d %d", rows, cols)
|
||||
conn.WritePacket([]byte(termSzPacket), hkexsh.CSOTermSize)
|
||||
}
|
||||
}()
|
||||
ch <- syscall.SIGWINCH // Initial resize.
|
||||
handleTermResizes()
|
||||
|
||||
// client writer (to server) goroutine
|
||||
wg.Add(1)
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
// +build linux
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
hkexsh "blitter.com/go/hkexsh"
|
||||
)
|
||||
|
||||
// Handle pty resizes (notify server side)
|
||||
func handleTermResizes() {
|
||||
rows := 0
|
||||
cols := 0
|
||||
|
||||
ch := make(chan os.Signal, 1)
|
||||
signal.Notify(ch, syscall.SIGWINCH)
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
|
||||
for range ch {
|
||||
// Query client's term size so we can communicate it to server
|
||||
// pty after interactive session starts
|
||||
rows, cols, err = getTermSize()
|
||||
log.Printf("[rows %v cols %v]\n", rows, cols)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
termSzPacket := fmt.Sprintf("%d %d", rows, cols)
|
||||
conn.WritePacket([]byte(termSzPacket), hkexsh.CSOTermSize)
|
||||
}
|
||||
}()
|
||||
ch <- syscall.SIGWINCH // Initial resize.
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
// +build windows
|
||||
package main
|
||||
|
||||
// Handle pty resizes (notify server side)
|
||||
func handleTermResizes() {
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue