Fix regression that broke quick exit from ssh kitten
This commit is contained in:
parent
ac2ec44a7f
commit
bd5fcb00e0
3 changed files with 9 additions and 6 deletions
|
|
@ -524,16 +524,20 @@ func get_remote_command(cd *connection_data) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var debugprintln = tty.DebugPrintln
|
||||||
|
var _ = debugprintln
|
||||||
|
|
||||||
func drain_potential_tty_garbage(term *tty.Term) {
|
func drain_potential_tty_garbage(term *tty.Term) {
|
||||||
err := term.ApplyOperations(tty.TCSANOW, tty.SetNoEcho)
|
err := term.ApplyOperations(tty.TCSANOW, tty.SetRaw)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
canary, err := secrets.TokenBase64()
|
canary, err := secrets.TokenHex()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
dcs, err := tui.DCSToKitty("echo", canary+"\n\r")
|
dcs, err := tui.DCSToKitty("echo", canary)
|
||||||
|
q := utils.UnsafeStringToBytes(canary)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -541,7 +545,6 @@ func drain_potential_tty_garbage(term *tty.Term) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
q := utils.UnsafeStringToBytes(canary)
|
|
||||||
data := make([]byte, 0)
|
data := make([]byte, 0)
|
||||||
give_up_at := time.Now().Add(2 * time.Second)
|
give_up_at := time.Now().Add(2 * time.Second)
|
||||||
buf := make([]byte, 0, 8192)
|
buf := make([]byte, 0, 8192)
|
||||||
|
|
@ -553,7 +556,7 @@ func drain_potential_tty_garbage(term *tty.Term) {
|
||||||
}
|
}
|
||||||
n, err := term.ReadWithTimeout(buf, timeout)
|
n, err := term.ReadWithTimeout(buf, timeout)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
break
|
||||||
}
|
}
|
||||||
data = append(data, buf[:n]...)
|
data = append(data, buf[:n]...)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1194,6 +1194,7 @@ def handle_remote_cmd(self, cmd: str) -> None:
|
||||||
def handle_remote_echo(self, msg: str) -> None:
|
def handle_remote_echo(self, msg: str) -> None:
|
||||||
from base64 import standard_b64decode
|
from base64 import standard_b64decode
|
||||||
data = standard_b64decode(msg)
|
data = standard_b64decode(msg)
|
||||||
|
data = re.sub(rb'[^a-zA-Z0-9]', b'', data)
|
||||||
self.write_to_child(data)
|
self.write_to_child(data)
|
||||||
|
|
||||||
def handle_remote_ssh(self, msg: str) -> None:
|
def handle_remote_ssh(self, msg: str) -> None:
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,6 @@ fi
|
||||||
|
|
||||||
dcs_to_kitty() { printf "\033P@kitty-$1|%s\033\134" "$(printf "%s" "$2" | base64_encode)" > /dev/tty; }
|
dcs_to_kitty() { printf "\033P@kitty-$1|%s\033\134" "$(printf "%s" "$2" | base64_encode)" > /dev/tty; }
|
||||||
debug() { dcs_to_kitty "print" "debug: $1"; }
|
debug() { dcs_to_kitty "print" "debug: $1"; }
|
||||||
echo_via_kitty() { dcs_to_kitty "echo" "$1"; }
|
|
||||||
|
|
||||||
# If $HOME is configured set it here
|
# If $HOME is configured set it here
|
||||||
EXPORT_HOME_CMD
|
EXPORT_HOME_CMD
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue