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"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"os/signal"
|
|
||||||
"os/user"
|
"os/user"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"syscall"
|
|
||||||
|
|
||||||
hkexsh "blitter.com/go/hkexsh"
|
hkexsh "blitter.com/go/hkexsh"
|
||||||
isatty "github.com/mattn/go-isatty"
|
isatty "github.com/mattn/go-isatty"
|
||||||
|
@ -113,9 +111,6 @@ func main() {
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
// From this point on, conn is a secure encrypted channel
|
// 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
|
// Set stdin in raw mode if it's an interactive session
|
||||||
// TODO: send flag to server side indicating this
|
// TODO: send flag to server side indicating this
|
||||||
// affects shell command used
|
// affects shell command used
|
||||||
|
@ -223,26 +218,7 @@ func main() {
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if isInteractive {
|
if isInteractive {
|
||||||
// Handle pty resizes (notify server side)
|
handleTermResizes()
|
||||||
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.
|
|
||||||
|
|
||||||
// client writer (to server) goroutine
|
// client writer (to server) goroutine
|
||||||
wg.Add(1)
|
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