diff --git a/base/web/broad.go b/base/web/broad.go index d9c8526e..201498eb 100644 --- a/base/web/broad.go +++ b/base/web/broad.go @@ -73,6 +73,9 @@ func init() { OPEN: {Hand: func(m *ice.Message, arg ...string) { ctx.ProcessOpen(m, kit.Format("http://%s:%s", m.Option(tcp.HOST), m.Option(tcp.PORT))) }}, + "send": {Hand: func(m *ice.Message, arg ...string) { + _broad_send(m, "", "", "255.255.255.255", "9020", arg...) + }}, }, mdb.HashAction(mdb.SHORT, "host,port", mdb.FIELD, "time,hash,type,name,host,port", mdb.ACTION, OPEN), mdb.ClearHashOnExitAction())}, }) } diff --git a/base/web/space.go b/base/web/space.go index 52ad8f8a..c4e85ab2 100644 --- a/base/web/space.go +++ b/base/web/space.go @@ -186,7 +186,7 @@ func init() { m.Cmd("", ice.Maps{ice.MSG_FIELDS: ""}, func(values ice.Maps) { switch values[mdb.TYPE] { case WORKER: - m.PushSearch(mdb.TEXT, kit.Format(MergePod(m, values[mdb.NAME])), values) + m.PushSearch(mdb.TEXT, kit.Format(tcp.PublishLocalhost(m, MergePod(m, values[mdb.NAME]))), values) case MASTER: m.PushSearch(mdb.TEXT, m.Cmd(SPIDE, values[mdb.NAME], ice.Maps{ice.MSG_FIELDS: ""}).Append(CLIENT_ORIGIN), values) } diff --git a/misc/ssh/service.go b/misc/ssh/service.go index 7776f36b..ee70a6da 100644 --- a/misc/ssh/service.go +++ b/misc/ssh/service.go @@ -66,6 +66,34 @@ func _ssh_config(m *ice.Message, h string) *ssh.ServerConfig { } return config } + +type Buf struct { + buf []byte +} +type Conn struct { + net.Conn + *Buf +} + +func (s Conn) Read(b []byte) (n int, err error) { + if len(s.buf) == 0 { + return s.Conn.Read(b) + } + if len(s.buf) < len(b) { + copy(b, s.buf) + s.buf = s.buf[:0] + return len(s.buf), nil + } + copy(b, s.buf) + s.buf = s.buf[len(b):] + return len(b), nil +} +func (s Conn) Peek(b []byte) (n int, err error) { + n, err = s.Conn.Read(b) + s.buf = append(s.buf, b...) + return n, err +} + func _ssh_accept(m *ice.Message, h string, c net.Conn) { conn, chans, reqs, err := ssh.NewServerConn(c, _ssh_config(m, h)) if m.Warn(err) { @@ -158,8 +186,9 @@ func init() { m.Cmd("", ctx.LOAD, m.OptionSimple(AUTHKEY)) } m.Go(func() { + m.Cmd(web.BROAD, "send", mdb.TYPE, "sshd", mdb.NAME, ice.Info.NodeName, tcp.HOST, m.Cmd(tcp.HOST).Append(aaa.IP), tcp.PORT, m.Option(tcp.PORT)) m.Cmd(tcp.SERVER, tcp.LISTEN, mdb.TYPE, SSH, mdb.NAME, m.Option(tcp.PORT), m.OptionSimple(tcp.PORT), func(c net.Conn) { - m.Go(func() { _ssh_accept(m, kit.Hashs(m.Option(tcp.PORT)), c) }) + m.Go(func() { _ssh_accept(m, kit.Hashs(m.Option(tcp.PORT)), Conn{Conn: c, Buf: &Buf{}}) }) }) }) }},