diff --git a/base/ssh/connect.go b/base/ssh/connect.go index 31b45322..66d648d1 100644 --- a/base/ssh/connect.go +++ b/base/ssh/connect.go @@ -125,6 +125,13 @@ func init() { w, h, e := terminal.GetSize(fd) m.Assert(e) + fd1 := int(os.Stdout.Fd()) + oldState1, err := terminal.MakeRaw(fd1) + if err != nil { + panic(err) + } + defer terminal.Restore(fd1, oldState1) + session.Stdin = os.Stdin session.Stdout = os.Stdout session.Stderr = os.Stderr diff --git a/base/ssh/service.go b/base/ssh/service.go index 27030005..26788d0a 100644 --- a/base/ssh/service.go +++ b/base/ssh/service.go @@ -170,7 +170,9 @@ func init() { } m.Option(tcp.LISTEN_CB, func(c net.Conn) { m.Go(func() { _ssh_accept(m, kit.Hashs(m.Option(tcp.PORT)), c) }) }) - m.Go(func() { m.Cmdy(tcp.SERVER, tcp.LISTEN, kit.MDB_NAME, SSH, tcp.PORT, m.Option(tcp.PORT)) }) + m.Go(func() { + m.Cmdy(tcp.SERVER, tcp.LISTEN, kit.MDB_TYPE, SSH, kit.MDB_NAME, tcp.PORT, tcp.PORT, m.Option(tcp.PORT)) + }) }}, mdb.INSERT: {Name: "insert text:textarea", Help: "添加", Hand: func(m *ice.Message, arg ...string) { diff --git a/base/tcp/client.go b/base/tcp/client.go index 5ba6d00d..d3d57f1d 100644 --- a/base/tcp/client.go +++ b/base/tcp/client.go @@ -23,13 +23,13 @@ type Conn struct { func (c *Conn) Read(b []byte) (int, error) { n, e := c.Conn.Read(b) c.s.nr += n - c.m.Conf(CLIENT, kit.Keys(kit.MDB_HASH, c.h, kit.MDB_META, "nread"), c.s.nr) + // c.m.Conf(CLIENT, kit.Keys(kit.MDB_HASH, c.h, kit.MDB_META, "nread"), c.s.nr) return n, e } func (c *Conn) Write(b []byte) (int, error) { n, e := c.Conn.Write(b) c.s.nw += n - c.m.Conf(CLIENT, kit.Keys(kit.MDB_HASH, c.h, kit.MDB_META, "nwrite"), c.s.nw) + // c.m.Conf(CLIENT, kit.Keys(kit.MDB_HASH, c.h, kit.MDB_META, "nwrite"), c.s.nw) return n, e } func (c *Conn) Close() error { diff --git a/go.mod b/go.mod index 9eafe8f1..b138b205 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/gorilla/websocket v1.4.2 github.com/kr/pty v1.1.1 github.com/nareix/joy4 v0.0.0-20200507095837-05a4ffbb5369 - github.com/shylinux/toolkits v0.1.8 + github.com/shylinux/toolkits v0.1.9 github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e github.com/tuotoo/qrcode v0.0.0-20190222102259-ac9c44189bf2 golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550 diff --git a/init.go b/init.go index eecd886a..21872b0a 100644 --- a/init.go +++ b/init.go @@ -1,6 +1,8 @@ package ice import ( + "encoding/json" + kit "github.com/shylinux/toolkits" "os" @@ -139,6 +141,16 @@ var Pulse = &Message{ } var wait = make(chan bool, 1) +func Init(file string) { + if f, e := os.Open(file); e == nil { + defer f.Close() + + var data interface{} + json.NewDecoder(f).Decode(&data) + + kit.Fetch(data, func(key string, value string) { Pulse.Option(key, value) }) + } +} func Run(arg ...string) string { if len(arg) == 0 { arg = os.Args[1:] @@ -164,13 +176,14 @@ func Run(arg ...string) string { os.Exit(frame.code) default: - _log_disable = false + _log_disable = os.Getenv("ctx_debug") != "true" if Pulse.Cmdy(arg); Pulse.Result() == "" { Pulse.Table() } if strings.TrimSpace(Pulse.Result()) == "" { Pulse.Set(MSG_RESULT).Cmdy("cli.system", arg) } + Pulse.Sleep("10ms") } return Pulse.Result() diff --git a/misc.go b/misc.go index 68864ac5..4127ac6f 100644 --- a/misc.go +++ b/misc.go @@ -54,14 +54,6 @@ func (m *Message) Space(arg interface{}) []string { return []string{"web.space", kit.Format(arg)} } -var count = int32(0) - -func (m *Message) AddCmd(cmd *Command) string { - name := fmt.Sprintf("_cb_%d", atomic.AddInt32(&count, 1)) - m.target.Commands[name] = cmd - return kit.Keys(m.target.Cap(CTX_FOLLOW), name) -} - func (m *Message) PushRender(key, view, name string, arg ...string) *Message { if m.Option(MSG_USERUA) == "" { return m @@ -110,4 +102,12 @@ func (m *Message) PushPlugin(key string, arg ...string) *Message { return m } +var count = int32(0) + +func (m *Message) AddCmd(cmd *Command) string { + name := fmt.Sprintf("_cb_%d", atomic.AddInt32(&count, 1)) + m.target.Commands[name] = cmd + return kit.Keys(m.target.Cap(CTX_FOLLOW), name) +} + var BinPack = map[string][]byte{}