From 6eadb1e6852be6c6fbcced1f020eeeb56be43574 Mon Sep 17 00:00:00 2001 From: shylinux Date: Thu, 10 Dec 2020 19:30:51 +0800 Subject: [PATCH] add _ssh_tick --- base/ssh/connect.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/base/ssh/connect.go b/base/ssh/connect.go index e1949a4e..1cde18dd 100644 --- a/base/ssh/connect.go +++ b/base/ssh/connect.go @@ -20,6 +20,17 @@ import ( "strings" ) +func _ssh_tick(m *ice.Message, pw io.Writer) { + if m.Option("tick") == "" { + return + } + m.Go(func() { + for { + m.Sleep(m.Option("tick")) + pw.Write([]byte("\n")) + } + }) +} func _ssh_password(m *ice.Message, file string) { if f, e := os.Open(file); e == nil { defer f.Close() @@ -159,7 +170,7 @@ func init() { }) }}, - "open": {Name: "open authfile= username=shy password= verfiy= host=shylinux.com port=22 private=.ssh/id_rsa", Help: "终端", Hand: func(m *ice.Message, arg ...string) { + "open": {Name: "open authfile= username=shy password= verfiy= host=shylinux.com port=22 private=.ssh/id_rsa tick=", Help: "终端", Hand: func(m *ice.Message, arg ...string) { var client *ssh.Client w, h, _ := terminal.GetSize(int(os.Stdin.Fd())) @@ -219,6 +230,7 @@ func init() { session := _ssh_session(m, client, w, h, pr, os.Stdout, os.Stderr) _ssh_init(m, pw) + _ssh_tick(m, pw) session.Wait() })