forked from x/icebergs
add some
This commit is contained in:
parent
da31659105
commit
2c9cd04a41
@ -262,7 +262,6 @@ func init() {
|
||||
})
|
||||
}
|
||||
func NodeInfo(m *ice.Message, arg ...string) {
|
||||
m.Info("what %v %v", arg, m.FormatStack(1, 100))
|
||||
mdb.Conf(m, RUNTIME, kit.Keys(NODE, mdb.TIME), m.Time())
|
||||
ice.Info.NodeName = mdb.Conf(m, RUNTIME, kit.Keys(NODE, mdb.NAME), kit.Select(ice.Info.NodeName, arg, 0))
|
||||
ice.Info.NodeType = mdb.Conf(m, RUNTIME, kit.Keys(NODE, mdb.TYPE), kit.Select(ice.Info.NodeType, arg, 1))
|
||||
|
@ -96,9 +96,7 @@ func _dream_list_icon(m *ice.Message) {
|
||||
})
|
||||
}
|
||||
func _dream_list_more(m *ice.Message, simple bool) *ice.Message {
|
||||
// list := m.CmdMap(SPIDE, CLIENT_NAME)
|
||||
m.Cmds(SPACE).Table(func(value ice.Maps) {
|
||||
// value[mdb.ICONS] = nfs.USR_ICONS_VOLCANOS
|
||||
value[nfs.REPOS] = "https://" + value[nfs.MODULE]
|
||||
value[aaa.ACCESS] = kit.Select("", value[aaa.USERROLE], value[aaa.USERROLE] != aaa.VOID)
|
||||
value[mdb.STATUS] = cli.START
|
||||
@ -223,6 +221,9 @@ const (
|
||||
|
||||
DREAM_TABLES = "dream.tables"
|
||||
DREAM_ACTION = "dream.action"
|
||||
|
||||
OPS_DREAM_CREATE = "ops.dream.create"
|
||||
OPS_DREAM_REMOVE = "ops.dream.remove"
|
||||
)
|
||||
const DREAM = "dream"
|
||||
|
||||
@ -307,6 +308,7 @@ func init() {
|
||||
if mdb.HashCreate(m); ice.Info.Important == true {
|
||||
_dream_start(m, m.Option(mdb.NAME))
|
||||
StreamPushRefreshConfirm(m, m.Trans("refresh for new space ", "刷新列表查看新空间 ")+m.Option(mdb.NAME))
|
||||
SpaceEvent(m, OPS_DREAM_CREATE, m.Option(mdb.NAME), m.OptionSimple(mdb.NAME, nfs.REPOS, nfs.BINARY)...)
|
||||
}
|
||||
}},
|
||||
mdb.REMOVE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
@ -534,7 +536,10 @@ func DreamTablesAction(arg ...string) ice.Actions {
|
||||
}
|
||||
}
|
||||
func DreamAction() ice.Actions {
|
||||
return gdb.EventsAction(DREAM_INPUTS, DREAM_CREATE, DREAM_REMOVE, DREAM_TRASH, DREAM_OPEN, DREAM_CLOSE, SPACE_LOGIN, SERVE_START)
|
||||
return gdb.EventsAction(
|
||||
DREAM_INPUTS, DREAM_CREATE, DREAM_REMOVE, DREAM_TRASH, DREAM_OPEN, DREAM_CLOSE, SPACE_LOGIN, SERVE_START,
|
||||
OPS_DREAM_CREATE, OPS_DREAM_REMOVE,
|
||||
)
|
||||
}
|
||||
func DreamWhiteHandle(m *ice.Message, arg ...string) {
|
||||
aaa.White(m, kit.Keys(DREAM, ctx.ACTION, m.ShortKey()))
|
||||
|
@ -104,16 +104,10 @@ func _space_fork(m *ice.Message) {
|
||||
defer gdb.EventDeferEvent(m, SPACE_OPEN, args)(SPACE_CLOSE, args)
|
||||
m.Go(func() {
|
||||
m.Cmd(SPACE, name, cli.PWD, name, kit.Dict(
|
||||
mdb.ICONS, mdb.Config(m, mdb.ICONS),
|
||||
mdb.TIME, ice.Info.Make.Time, nfs.MODULE, ice.Info.Make.Module, nfs.VERSION, ice.Info.Make.Versions(),
|
||||
mdb.ICONS, ice.Info.NodeIcon, mdb.TIME, ice.Info.Make.Time, nfs.MODULE, ice.Info.Make.Module, nfs.VERSION, ice.Info.Make.Versions(),
|
||||
AGENT, "Go-http-client", cli.SYSTEM, runtime.GOOS,
|
||||
))
|
||||
m.Cmd(SPACE).Table(func(value ice.Maps) {
|
||||
if kit.IsIn(value[mdb.TYPE], WORKER) && value[mdb.NAME] != name {
|
||||
m.Cmd(SPACE, value[mdb.NAME], gdb.EVENT, gdb.HAPPEN, gdb.EVENT, OPS_SERVER_OPEN, args, kit.Dict(ice.MSG_USERROLE, aaa.TECH))
|
||||
}
|
||||
})
|
||||
m.Cmd(gdb.EVENT, gdb.HAPPEN, gdb.EVENT, OPS_SERVER_OPEN, args, kit.Dict(ice.MSG_USERROLE, aaa.TECH))
|
||||
SpaceEvent(m, OPS_SERVER_OPEN, name, args...)
|
||||
})
|
||||
}
|
||||
_space_handle(m, safe, name, c)
|
||||
@ -482,3 +476,11 @@ func PodCmd(m *ice.Message, key string, arg ...string) bool {
|
||||
func SpaceName(name string) string {
|
||||
return kit.ReplaceAll(name, nfs.DF, "_", nfs.PS, "_", nfs.PT, "_", "[", "_", "]", "_")
|
||||
}
|
||||
func SpaceEvent(m *ice.Message, event, skip string, arg ...string) {
|
||||
m.Cmds(SPACE).Table(func(value ice.Maps) {
|
||||
if kit.IsIn(value[mdb.TYPE], WORKER) && value[mdb.NAME] != skip {
|
||||
m.Cmd(SPACE, value[mdb.NAME], gdb.EVENT, gdb.HAPPEN, gdb.EVENT, event, arg, kit.Dict(ice.MSG_USERROLE, aaa.TECH))
|
||||
}
|
||||
})
|
||||
m.Cmd(gdb.EVENT, gdb.HAPPEN, gdb.EVENT, event, arg, kit.Dict(ice.MSG_USERROLE, aaa.TECH))
|
||||
}
|
||||
|
@ -54,6 +54,9 @@ func init() {
|
||||
MessageInsertPlug(m, web.DREAM, "", "", web.DREAM, m.Option(mdb.NAME))
|
||||
}
|
||||
}},
|
||||
web.OPS_DREAM_CREATE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd("", mdb.CREATE, mdb.TYPE, aaa.TECH, web.TARGET, kit.Keys(kit.Select("", ice.OPS, m.IsWorker()), m.Option(mdb.NAME)))
|
||||
}},
|
||||
web.DREAM_REMOVE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
MessageInsertPlug(m, web.DREAM, "", "", web.DREAM, m.Option(mdb.NAME))
|
||||
}},
|
||||
|
@ -145,7 +145,7 @@ Volcanos(chat.ONFIGURE, {
|
||||
sub.Conf("_plugin_action", [{view: "item.button.localCreate.icons.state", _init: function(target) {
|
||||
can.page.Append(can, target, [{icon: icon.localCreate, title: "localCreate", onclick: function(event) {
|
||||
can.core.Next(sub._msg.IsDetail()? [sub._msg.TableDetail()]: sub._msg.Table(), function(value, next, index, list) { can.user.toastProcess(can, "create "+index+"/"+list.length, sub.ConfIndex())
|
||||
can.runAction(can.request(event, sub.Option(), value), ctx.RUN, ["", sub.ConfIndex(), mdb.CREATE], function() { next() })
|
||||
can.runAction(can.request({}, sub.Option(), value), ctx.RUN, ["", sub.ConfIndex(), mdb.CREATE], function() { next() })
|
||||
}, function() {
|
||||
can.user.toastSuccess(can, mdb.CREATE)
|
||||
can.onappend._float(can, sub.ConfIndex(), [])
|
||||
|
2
exec.go
2
exec.go
@ -163,7 +163,7 @@ func (m *Message) _command(arg ...Any) *Message {
|
||||
}
|
||||
}
|
||||
}
|
||||
if count := kit.Int(m.Option(MSG_COUNT, kit.Format(kit.Int(m.Option(MSG_COUNT))+1))); m.Warn(count > 3000, ErrTooDeepCount) {
|
||||
if count := kit.Int(m.Option(MSG_COUNT, kit.Format(kit.Int(m.Option(MSG_COUNT))+1))); m.Warn(count > 300, ErrTooDeepCount) {
|
||||
panic(count)
|
||||
}
|
||||
list := kit.Simple(args...)
|
||||
|
@ -119,7 +119,8 @@ func _ssh_conn(m *ice.Message, cb func(*ssh.Client), arg ...string) (err error)
|
||||
}
|
||||
return
|
||||
}))
|
||||
m.Cmd(tcp.CLIENT, tcp.DIAL, mdb.TYPE, SSH, mdb.NAME, m.Option(tcp.HOST), m.OptionSimple(tcp.HOST, tcp.PORT, aaa.USERNAME), arg, func(c net.Conn) {
|
||||
m.OptionDefault(tcp.PORT, tcp.PORT_22, aaa.USERNAME, aaa.ROOT)
|
||||
m.Cmd("tcp.client", tcp.DIAL, mdb.TYPE, SSH, mdb.NAME, m.Option(tcp.HOST), m.OptionSimple(tcp.HOST, tcp.PORT, aaa.USERNAME), arg, func(c net.Conn) {
|
||||
conn, chans, reqs, _err := ssh.NewClientConn(c, m.Option(tcp.HOST)+nfs.DF+m.Option(tcp.PORT), &ssh.ClientConfig{
|
||||
User: m.Option(aaa.USERNAME), Auth: methods, BannerCallback: func(message string) error { return nil },
|
||||
HostKeyCallback: func(hostname string, remote net.Addr, key ssh.PublicKey) error { return nil },
|
||||
@ -161,7 +162,7 @@ const CONNECT = "connect"
|
||||
func init() {
|
||||
psh.Index.MergeCommands(ice.Commands{
|
||||
CONNECT: {Help: "连接", Actions: ice.MergeActions(ice.Actions{
|
||||
tcp.OPEN: {Name: "open authfile username=shy host=shylinux.com port=22 cmds init private=.ssh/id_rsa password verfiy", Help: "终端", Hand: func(m *ice.Message, arg ...string) {
|
||||
tcp.OPEN: {Name: "open authfile username host=shylinux.com port=22 cmds init private=.ssh/id_rsa password verfiy", Help: "终端", Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.Option(ctx.CMDS) == "" {
|
||||
defer nfs.OptionLoad(m, m.Option(AUTHFILE)).Echo("exit %s@%s:%s\n", m.Option(aaa.USERNAME), m.Option(tcp.HOST), m.Option(tcp.PORT))
|
||||
_ssh_open(m.SetResult(), arg...)
|
||||
|
@ -64,7 +64,7 @@ type relay struct {
|
||||
short string `data:"machine"`
|
||||
tools string `data:"ssh.trans,ssh.auth,aaa.cert"`
|
||||
field string `data:"time,icons,machine,username,host,port,portal,dream,module,version,commitTime,compileTime,bootTime,go,git,package,shell,kernel,arch,vcpu,ncpu,mhz,mem,disk,network,listen,socket,proc,vendor"`
|
||||
create string `name:"create host* port=22 username machine icons"`
|
||||
create string `name:"create host* port=22 username=root machine icons"`
|
||||
upgrade string `name:"upgrade machine"`
|
||||
stats string `name:"stats machine" help:"采集" icon:"bi bi-card-list"`
|
||||
publish string `name:"publish" help:"发布" icon:"bi bi-send-check"`
|
||||
@ -167,7 +167,6 @@ func (s relay) Publish(m *ice.Message, arg ...string) {
|
||||
if m.Option(ice.INIT, ""); m.Option(web.PORTAL) != "" {
|
||||
m.Option(ice.INIT, kit.Format("cd %s", path.Base(m.DreamPath(m.Option(web.DREAM)))))
|
||||
}
|
||||
m.Debug("what %v", m.Option(web.PORTAL))
|
||||
m.Cmd(nfs.SAVE, kit.HomePath(".ssh/"+m.Option(MACHINE)+".json"), kit.Formats(kit.Dict(m.OptionSimple("username,host,port,init")))+ice.NL)
|
||||
kit.If(!m.Exists(path.Join(ice.USR_PUBLISH, RELAY)), func() { s.Compile(m) })
|
||||
os.Symlink(RELAY, ice.USR_PUBLISH+m.Option(MACHINE))
|
||||
@ -339,10 +338,6 @@ func (s relay) iframe(m *ice.Message, cmd string, arg ...string) {
|
||||
}
|
||||
func (s relay) shell(m *ice.Message, init string, arg ...string) {
|
||||
m.ProcessXterm(kit.Keys(m.Option(MACHINE), m.ActionKey()), s.CmdArgs(m, init), arg...)
|
||||
return
|
||||
m.ProcessXterm(kit.Keys(m.Option(MACHINE), m.ActionKey()), []string{kit.JoinWord(
|
||||
RELAY, tcp.HOST, m.Option(tcp.HOST), aaa.USERNAME, m.Option(aaa.USERNAME),
|
||||
), mdb.TEXT, strings.ReplaceAll(init, lex.NL, "; ")}, arg...)
|
||||
}
|
||||
func (s relay) foreachScript(m *ice.Message, script string, arg ...string) {
|
||||
m.Option(ice.MSG_TITLE, kit.Keys(m.Option(ice.MSG_USERPOD), m.CommandKey(), m.ActionKey()))
|
||||
@ -384,8 +379,9 @@ func (s relay) param(m *ice.Message, arg ...string) string {
|
||||
}
|
||||
func (s relay) CmdArgs(m *ice.Message, init string, arg ...string) string {
|
||||
kit.If(m.Option(web.PORTAL), func() { init = kit.Format("%q", "cd "+path.Base(m.DreamPath(m.Option(web.DREAM)))) })
|
||||
return kit.JoinWord(kit.Simple(strings.TrimPrefix(os.Args[0], kit.Path("")+nfs.PS), "ssh.connect", tcp.OPEN,
|
||||
ssh.AUTHFILE, "", m.OptionSimple(aaa.USERNAME, tcp.HOST, tcp.PORT), ice.INIT, init,
|
||||
return kit.JoinWord(kit.Simple(
|
||||
strings.TrimPrefix(os.Args[0], kit.Path("")+nfs.PS),
|
||||
"ssh.connect", tcp.OPEN, ssh.AUTHFILE, "", m.OptionSimple(aaa.USERNAME, tcp.HOST, tcp.PORT), ice.INIT, init,
|
||||
)...)
|
||||
}
|
||||
|
||||
@ -395,7 +391,7 @@ type Relay struct {
|
||||
}
|
||||
|
||||
func (s Relay) Cmds(m *ice.Message, host string, cmds string) *ice.Message {
|
||||
return m.Cmd("ssh.connect", tcp.OPEN, ssh.AUTHFILE, "", aaa.USERNAME, aaa.ROOT, tcp.HOST, host, ctx.CMDS, cmds)
|
||||
return m.Cmd(cli.SYSTEM, os.Args[0], "ssh.connect", tcp.OPEN, ssh.AUTHFILE, "", aaa.USERNAME, aaa.ROOT, tcp.HOST, host, tcp.PORT, tcp.PORT_22, ctx.CMDS, cmds)
|
||||
}
|
||||
func (s Relay) CmdsWait(m *ice.Message, host string, cmds string, res string) bool {
|
||||
for i := 0; i < 10; i++ {
|
||||
|
Loading…
x
Reference in New Issue
Block a user