forked from x/ContextOS
vps add ssh.close
This commit is contained in:
parent
66008f3a8a
commit
0c675bcbaf
@ -391,6 +391,7 @@ func (nfs *NFS) Spawn(m *ctx.Message, c *ctx.Context, arg ...string) ctx.Server
|
|||||||
"nline": &ctx.Cache{Name: "缓存命令行数", Value: "0", Help: "缓存命令行数"},
|
"nline": &ctx.Cache{Name: "缓存命令行数", Value: "0", Help: "缓存命令行数"},
|
||||||
"return": &ctx.Cache{Name: "缓存命令行数", Value: "0", Help: "缓存命令行数"},
|
"return": &ctx.Cache{Name: "缓存命令行数", Value: "0", Help: "缓存命令行数"},
|
||||||
|
|
||||||
|
"nbytes": &ctx.Cache{Name: "消息发送字节", Value: "0", Help: "消息发送字节"},
|
||||||
"nsend": &ctx.Cache{Name: "消息发送数量", Value: "0", Help: "消息发送数量"},
|
"nsend": &ctx.Cache{Name: "消息发送数量", Value: "0", Help: "消息发送数量"},
|
||||||
"nrecv": &ctx.Cache{Name: "消息接收数量", Value: "0", Help: "消息接收数量"},
|
"nrecv": &ctx.Cache{Name: "消息接收数量", Value: "0", Help: "消息接收数量"},
|
||||||
"target": &ctx.Cache{Name: "消息接收模块", Value: "ssh", Help: "消息接收模块"},
|
"target": &ctx.Cache{Name: "消息接收模块", Value: "ssh", Help: "消息接收模块"},
|
||||||
@ -450,13 +451,16 @@ func (nfs *NFS) Start(m *ctx.Message, arg ...string) bool { // {{{
|
|||||||
|
|
||||||
for {
|
for {
|
||||||
line, e := nfs.Reader.ReadString('\n')
|
line, e := nfs.Reader.ReadString('\n')
|
||||||
m.Assert(e)
|
|
||||||
|
|
||||||
if msg == nil {
|
if msg == nil {
|
||||||
msg = m.Sesss("ssh")
|
msg = m.Sesss("ssh")
|
||||||
m.Cap("target", msg.Target().Name)
|
m.Cap("target", msg.Target().Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if e == io.EOF {
|
||||||
|
msg.Cmd("close")
|
||||||
|
}
|
||||||
|
m.Assert(e)
|
||||||
|
|
||||||
if line = strings.TrimSpace(line); len(line) > 0 {
|
if line = strings.TrimSpace(line); len(line) > 0 {
|
||||||
ls := strings.SplitN(line, ":", 2)
|
ls := strings.SplitN(line, ":", 2)
|
||||||
ls[0] = strings.TrimSpace(ls[0])
|
ls[0] = strings.TrimSpace(ls[0])
|
||||||
@ -640,6 +644,7 @@ func (nfs *NFS) Close(m *ctx.Message, arg ...string) bool { // {{{
|
|||||||
nfs.in = nil
|
nfs.in = nil
|
||||||
}
|
}
|
||||||
case m.Source():
|
case m.Source():
|
||||||
|
m.Source().Close(m.Spawn(m.Source()))
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -750,10 +755,14 @@ var Index = &ctx.Context{Name: "nfs", Help: "存储中心",
|
|||||||
m.Option("time", info.ModTime())
|
m.Option("time", info.ModTime())
|
||||||
m.Option("mode", info.Mode())
|
m.Option("mode", info.Mode())
|
||||||
|
|
||||||
fmt.Fprintf(nfs.Writer, "detail: recv\n")
|
n, e := fmt.Fprintf(nfs.Writer, "detail: recv\n")
|
||||||
|
m.Capi("nbytes", n)
|
||||||
|
m.Assert(e)
|
||||||
}
|
}
|
||||||
for _, v := range arg {
|
for _, v := range arg {
|
||||||
fmt.Fprintf(nfs.Writer, "detail: %v\n", v)
|
n, e := fmt.Fprintf(nfs.Writer, "detail: %v\n", v)
|
||||||
|
m.Capi("nbytes", n)
|
||||||
|
m.Assert(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, k := range m.Meta["option"] {
|
for _, k := range m.Meta["option"] {
|
||||||
@ -761,14 +770,18 @@ var Index = &ctx.Context{Name: "nfs", Help: "存储中心",
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
for _, v := range m.Meta[k] {
|
for _, v := range m.Meta[k] {
|
||||||
fmt.Fprintf(nfs.Writer, "%s: %s\n", k, v)
|
n, e := fmt.Fprintf(nfs.Writer, "%s: %s\n", k, v)
|
||||||
|
m.Capi("nbytes", n)
|
||||||
|
m.Assert(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m.Log("info", nil, "%d send", m.Optioni("nsend"))
|
m.Log("info", nil, "%d send", m.Optioni("nsend"))
|
||||||
m.Log("info", nil, "detail: %v", m.Meta["detail"])
|
m.Log("info", nil, "detail: %v", m.Meta["detail"])
|
||||||
m.Log("info", nil, "option: %v", m.Meta["option"])
|
m.Log("info", nil, "option: %v", m.Meta["option"])
|
||||||
|
|
||||||
fmt.Fprintf(nfs.Writer, "\n")
|
n, e := fmt.Fprintf(nfs.Writer, "\n")
|
||||||
|
m.Capi("nbytes", n)
|
||||||
|
m.Assert(e)
|
||||||
nfs.Writer.Flush()
|
nfs.Writer.Flush()
|
||||||
|
|
||||||
if len(arg) > 1 && arg[0] == "file" {
|
if len(arg) > 1 && arg[0] == "file" {
|
||||||
|
@ -90,6 +90,9 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
|||||||
"domain.json": &ctx.Config{Name: "domain.json", Value: "var/domain.json", Help: "主机数量"},
|
"domain.json": &ctx.Config{Name: "domain.json", Value: "var/domain.json", Help: "主机数量"},
|
||||||
"domain.png": &ctx.Config{Name: "domain.png", Value: "var/domain.png", Help: "主机数量"},
|
"domain.png": &ctx.Config{Name: "domain.png", Value: "var/domain.png", Help: "主机数量"},
|
||||||
|
|
||||||
|
"mdb": &ctx.Config{Name: "mdb", Value: "mdb.chat", Help: "主机数量"},
|
||||||
|
"uid": &ctx.Config{Name: "uid", Value: "", Help: "主机数量"},
|
||||||
|
|
||||||
"type": &ctx.Config{Name: "type", Value: "terminal", Help: "主机数量"},
|
"type": &ctx.Config{Name: "type", Value: "terminal", Help: "主机数量"},
|
||||||
"kind": &ctx.Config{Name: "kind", Value: "terminal", Help: "主机数量"},
|
"kind": &ctx.Config{Name: "kind", Value: "terminal", Help: "主机数量"},
|
||||||
"name": &ctx.Config{Name: "name", Value: "vps", Help: "主机数量"},
|
"name": &ctx.Config{Name: "name", Value: "vps", Help: "主机数量"},
|
||||||
@ -202,6 +205,13 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
|||||||
})
|
})
|
||||||
m.Conf("domains", domain)
|
m.Conf("domains", domain)
|
||||||
|
|
||||||
|
mdb := m.Find(m.Conf("mdb"), true)
|
||||||
|
if mdb != nil {
|
||||||
|
domain := m.Cap("domain") + "." + m.Conf("domains")
|
||||||
|
mdb.Cmd("exec", "delete from goodship where value=?", domain)
|
||||||
|
mdb.Cmd("exec", "insert into goodship(uid, share, level, type, value, kind, name) value(?, 'root', 'root', 'terminal', ?, 'terminal', ?)", m.Conf("uid"), domain, domain)
|
||||||
|
}
|
||||||
|
|
||||||
m.Echo(m.Cap("domain"))
|
m.Echo(m.Cap("domain"))
|
||||||
m.Echo(".")
|
m.Echo(".")
|
||||||
m.Echo(m.Conf("domains"))
|
m.Echo(m.Conf("domains"))
|
||||||
@ -218,6 +228,9 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
|||||||
}
|
}
|
||||||
// }}}
|
// }}}
|
||||||
}},
|
}},
|
||||||
|
"close": &ctx.Command{Name: "close", Help: "连接断开", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
||||||
|
m.Target().Close(m)
|
||||||
|
}},
|
||||||
"save": &ctx.Command{Name: "save", Help: "远程执行", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
"save": &ctx.Command{Name: "save", Help: "远程执行", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
||||||
json := m.Sesss("nfs") // {{{
|
json := m.Sesss("nfs") // {{{
|
||||||
json.Put("option", "data", map[string]string{"domain": m.Cap("domain")})
|
json.Put("option", "data", map[string]string{"domain": m.Cap("domain")})
|
||||||
|
@ -437,7 +437,7 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
|||||||
part, e := writer.CreateFormFile(m.Option("file"), filepath.Base(m.Meta["file"][1]))
|
part, e := writer.CreateFormFile(m.Option("file"), filepath.Base(m.Meta["file"][1]))
|
||||||
m.Assert(e)
|
m.Assert(e)
|
||||||
|
|
||||||
n, e := io.Copy(part, file)
|
io.Copy(part, file)
|
||||||
for i := 0; i < len(arg)-1; i += 2 {
|
for i := 0; i < len(arg)-1; i += 2 {
|
||||||
writer.WriteField(arg[0], arg[1])
|
writer.WriteField(arg[0], arg[1])
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user