mirror of
https://shylinux.com/x/icebergs
synced 2025-04-27 01:48:27 +08:00
opt some
This commit is contained in:
parent
2eccc6c00a
commit
fba8c1251b
@ -73,6 +73,9 @@ func init() {
|
|||||||
OPEN: {Hand: func(m *ice.Message, arg ...string) {
|
OPEN: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
ctx.ProcessOpen(m, kit.Format("http://%s:%s", m.Option(tcp.HOST), m.Option(tcp.PORT)))
|
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())},
|
}, mdb.HashAction(mdb.SHORT, "host,port", mdb.FIELD, "time,hash,type,name,host,port", mdb.ACTION, OPEN), mdb.ClearHashOnExitAction())},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -186,7 +186,7 @@ func init() {
|
|||||||
m.Cmd("", ice.Maps{ice.MSG_FIELDS: ""}, func(values ice.Maps) {
|
m.Cmd("", ice.Maps{ice.MSG_FIELDS: ""}, func(values ice.Maps) {
|
||||||
switch values[mdb.TYPE] {
|
switch values[mdb.TYPE] {
|
||||||
case WORKER:
|
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:
|
case MASTER:
|
||||||
m.PushSearch(mdb.TEXT, m.Cmd(SPIDE, values[mdb.NAME], ice.Maps{ice.MSG_FIELDS: ""}).Append(CLIENT_ORIGIN), values)
|
m.PushSearch(mdb.TEXT, m.Cmd(SPIDE, values[mdb.NAME], ice.Maps{ice.MSG_FIELDS: ""}).Append(CLIENT_ORIGIN), values)
|
||||||
}
|
}
|
||||||
|
@ -66,6 +66,34 @@ func _ssh_config(m *ice.Message, h string) *ssh.ServerConfig {
|
|||||||
}
|
}
|
||||||
return config
|
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) {
|
func _ssh_accept(m *ice.Message, h string, c net.Conn) {
|
||||||
conn, chans, reqs, err := ssh.NewServerConn(c, _ssh_config(m, h))
|
conn, chans, reqs, err := ssh.NewServerConn(c, _ssh_config(m, h))
|
||||||
if m.Warn(err) {
|
if m.Warn(err) {
|
||||||
@ -158,8 +186,9 @@ func init() {
|
|||||||
m.Cmd("", ctx.LOAD, m.OptionSimple(AUTHKEY))
|
m.Cmd("", ctx.LOAD, m.OptionSimple(AUTHKEY))
|
||||||
}
|
}
|
||||||
m.Go(func() {
|
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.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{}}) })
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}},
|
}},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user