mirror of
https://shylinux.com/x/icebergs
synced 2025-04-28 18:22:02 +08:00
add some
This commit is contained in:
parent
437a01a4c9
commit
644e80d040
@ -26,6 +26,7 @@ const (
|
|||||||
RESPONSE = "response"
|
RESPONSE = "response"
|
||||||
CONTENT = "content"
|
CONTENT = "content"
|
||||||
TITLE = "title"
|
TITLE = "title"
|
||||||
|
STYLE = "style"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Render(m *ice.Message, cmd string, args ...ice.Any) bool {
|
func Render(m *ice.Message, cmd string, args ...ice.Any) bool {
|
||||||
@ -74,8 +75,8 @@ func Render(m *ice.Message, cmd string, args ...ice.Any) bool {
|
|||||||
default:
|
default:
|
||||||
kit.If(cmd != "" && cmd != ice.RENDER_RAW, func() { m.Echo(kit.Format(cmd, args...)) })
|
kit.If(cmd != "" && cmd != ice.RENDER_RAW, func() { m.Echo(kit.Format(cmd, args...)) })
|
||||||
RenderType(m.W, nfs.JSON, "")
|
RenderType(m.W, nfs.JSON, "")
|
||||||
m.FormatsMeta(m.W, ice.MSG_USERIP, ice.MSG_USERUA, ice.MSG_METHOD,
|
m.FormatsMeta(m.W,
|
||||||
ice.MSG_USERWEB, ice.MSG_REFERER, ice.MSG_DAEMON, ice.MSG_USERPOD,
|
ice.MSG_USERIP, ice.MSG_USERUA, ice.MSG_METHOD, ice.MSG_REFERER, ice.MSG_DAEMON,
|
||||||
ice.MSG_LANGUAGE, ice.MSG_THEME, ice.MSG_BG, ice.MSG_FG,
|
ice.MSG_LANGUAGE, ice.MSG_THEME, ice.MSG_BG, ice.MSG_FG,
|
||||||
ice.MSG_RIVER, ice.MSG_STORM, ice.MSG_INDEX, ice.MSG_FIELDS,
|
ice.MSG_RIVER, ice.MSG_STORM, ice.MSG_INDEX, ice.MSG_FIELDS,
|
||||||
ice.MSG_SOURCE, ice.MSG_TARGET,
|
ice.MSG_SOURCE, ice.MSG_TARGET,
|
||||||
|
@ -140,6 +140,10 @@ func _space_handle(m *ice.Message, safe bool, name string, c *websocket.Conn) {
|
|||||||
m.WarnNotFound(!mdb.HashSelectDetail(m, next, func(value ice.Map) {
|
m.WarnNotFound(!mdb.HashSelectDetail(m, next, func(value ice.Map) {
|
||||||
switch c := value[mdb.TARGET].(type) {
|
switch c := value[mdb.TARGET].(type) {
|
||||||
case (*websocket.Conn): // 转发报文
|
case (*websocket.Conn): // 转发报文
|
||||||
|
kit.If(value[mdb.TYPE] == MASTER, func() {
|
||||||
|
msg.Option(ice.MSG_USERWEB, value[mdb.TEXT])
|
||||||
|
msg.Option(ice.MSG_USERPOD, kit.Keys(target[1:]))
|
||||||
|
})
|
||||||
_space_echo(msg, source, target, c)
|
_space_echo(msg, source, target, c)
|
||||||
case ice.Handler: // 接收响应
|
case ice.Handler: // 接收响应
|
||||||
msg.Go(func() { c(msg) })
|
msg.Go(func() { c(msg) })
|
||||||
@ -185,7 +189,8 @@ func _space_exec(m *ice.Message, name string, source, target []string, c *websoc
|
|||||||
kit.If(m.Optionv(ice.MSG_ARGS) != nil, func() { m.Options(ice.MSG_ARGS, kit.Simple(m.Optionv(ice.MSG_ARGS))) })
|
kit.If(m.Optionv(ice.MSG_ARGS) != nil, func() { m.Options(ice.MSG_ARGS, kit.Simple(m.Optionv(ice.MSG_ARGS))) })
|
||||||
}
|
}
|
||||||
defer m.Cost(kit.Format("%v->%v %v %v", source, target, m.Detailv(), m.FormatSize()))
|
defer m.Cost(kit.Format("%v->%v %v %v", source, target, m.Detailv(), m.FormatSize()))
|
||||||
_space_echo(m.Set(ice.MSG_OPTS).Options(m.OptionSimple(ice.LOG_DEBUG, ice.LOG_TRACEID)), []string{}, kit.Reverse(kit.Simple(source)), c)
|
_space_echo(m.Set(ice.MSG_OPTS).Options(m.OptionSimple(ice.MSG_USERWEB, ice.MSG_USERPOD, ice.LOG_DEBUG, ice.LOG_DISABLE, ice.LOG_TRACEID)), []string{}, kit.Reverse(kit.Simple(source)), c)
|
||||||
|
m.Option(ice.MSG_HANDLE, ice.TRUE)
|
||||||
}
|
}
|
||||||
func _space_echo(m *ice.Message, source, target []string, c *websocket.Conn) {
|
func _space_echo(m *ice.Message, source, target []string, c *websocket.Conn) {
|
||||||
defer func() { m.WarnNotValid(recover()) }()
|
defer func() { m.WarnNotValid(recover()) }()
|
||||||
|
1
conf.go
1
conf.go
@ -193,6 +193,7 @@ const ( // MSG
|
|||||||
MSG_UPLOAD = "_upload"
|
MSG_UPLOAD = "_upload"
|
||||||
MSG_SOURCE = "_source"
|
MSG_SOURCE = "_source"
|
||||||
MSG_TARGET = "_target"
|
MSG_TARGET = "_target"
|
||||||
|
MSG_HANDLE = "_handle"
|
||||||
MSG_ACTION = "_action"
|
MSG_ACTION = "_action"
|
||||||
MSG_STATUS = "_status"
|
MSG_STATUS = "_status"
|
||||||
|
|
||||||
|
@ -45,7 +45,8 @@ func init() {
|
|||||||
Notify(m, "usr/icons/Infomation.png", cli.RUNTIME, "系统启动成功", ctx.INDEX, cli.RUNTIME)
|
Notify(m, "usr/icons/Infomation.png", cli.RUNTIME, "系统启动成功", ctx.INDEX, cli.RUNTIME)
|
||||||
}},
|
}},
|
||||||
DESKTOP: {Help: "桌面", Role: aaa.VOID, Actions: ice.MergeActions(ice.Actions{
|
DESKTOP: {Help: "桌面", Role: aaa.VOID, Actions: ice.MergeActions(ice.Actions{
|
||||||
web.DREAM_ACTION: {Hand: func(m *ice.Message, arg ...string) { web.DreamProcessIframe(m, arg...) }},
|
// web.DREAM_ACTION: {Hand: func(m *ice.Message, arg ...string) { web.DreamProcessIframe(m, arg...) }},
|
||||||
|
// web.DREAM_ACTION: {Hand: func(m *ice.Message, arg ...string) { web.DreamProcess(m, "", arg, arg...) }},
|
||||||
}, web.DreamTablesAction(), PodCmdAction(), CmdHashAction(), mdb.ExportHashAction())},
|
}, web.DreamTablesAction(), PodCmdAction(), CmdHashAction(), mdb.ExportHashAction())},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -19,18 +19,14 @@ type matrix struct {
|
|||||||
list string `name:"list refresh" help:"矩阵"`
|
list string `name:"list refresh" help:"矩阵"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s matrix) List(m *ice.Message, arg ...string) *ice.Message {
|
func (s matrix) List(m *ice.Message, arg ...string) {
|
||||||
m.Cmdy(SSH_RELAY, web.DREAM)
|
m.Cmdy(SSH_RELAY, web.DREAM).Table(func(value ice.Maps) {
|
||||||
m.Table(func(value ice.Maps) {
|
|
||||||
if value[MACHINE] == tcp.LOCALHOST {
|
if value[MACHINE] == tcp.LOCALHOST {
|
||||||
m.PushButton(s.Portal, s.Word, s.Status, s.Vimer, s.Compile, s.Runtime, s.Xterm, s.Admin, s.Desktop, s.Open)
|
m.PushButton(s.Portal, s.Word, s.Status, s.Vimer, s.Compile, s.Runtime, s.Xterm, s.Desktop, s.Admin, s.Open)
|
||||||
} else {
|
} else {
|
||||||
m.PushButton(s.Portal, s.Admin, s.Desktop, s.Xterm, s.Runtime, s.Vimer, s.Open)
|
m.PushButton(s.Portal, s.Xterm, s.Vimer, s.Runtime, s.Desktop, s.Admin, s.Open)
|
||||||
}
|
}
|
||||||
})
|
}).Action(html.FILTER).Display("").Sort("type,status,space,machine", []string{web.SERVER, web.WORKER, ""}, []string{cli.START, cli.STOP, ""}, "str_r", "str")
|
||||||
m.Action(html.FILTER).Display("")
|
|
||||||
m.Sort("type,status,space,machine", []string{web.SERVER, web.WORKER, ""}, []string{cli.START, cli.STOP, ""}, "str_r", "str")
|
|
||||||
return m
|
|
||||||
}
|
}
|
||||||
func (s matrix) Portal(m *ice.Message, arg ...string) { s.iframe(m, arg...) }
|
func (s matrix) Portal(m *ice.Message, arg ...string) { s.iframe(m, arg...) }
|
||||||
func (s matrix) Word(m *ice.Message, arg ...string) { s.plug(m, arg...) }
|
func (s matrix) Word(m *ice.Message, arg ...string) { s.plug(m, arg...) }
|
||||||
@ -38,48 +34,39 @@ func (s matrix) Status(m *ice.Message, arg ...string) { s.plug(m, arg...) }
|
|||||||
func (s matrix) Vimer(m *ice.Message, arg ...string) { s.plug(m, arg...) }
|
func (s matrix) Vimer(m *ice.Message, arg ...string) { s.plug(m, arg...) }
|
||||||
func (s matrix) Compile(m *ice.Message, arg ...string) { s.plug(m, arg...) }
|
func (s matrix) Compile(m *ice.Message, arg ...string) { s.plug(m, arg...) }
|
||||||
func (s matrix) Runtime(m *ice.Message, arg ...string) { s.plug(m, arg...) }
|
func (s matrix) Runtime(m *ice.Message, arg ...string) { s.plug(m, arg...) }
|
||||||
func (s matrix) Xterm(m *ice.Message, arg ...string) {
|
func (s matrix) Xterm(m *ice.Message, arg ...string) { s.xterm(m, arg...) }
|
||||||
m.ProcessXterm(func() []string {
|
func (s matrix) Desktop(m *ice.Message, arg ...string) { s.plug(m, arg...) }
|
||||||
if m.Option(MACHINE) == tcp.LOCALHOST {
|
|
||||||
p := kit.Select(ice.CONTEXTS)
|
|
||||||
kit.If(m.Option(web.SPACE) != ice.CONTEXTS, func() { p = path.Join(p, nfs.USR_LOCAL_WORK+m.Option(web.SPACE)) })
|
|
||||||
return []string{cli.Shell(m.Message), "", kit.Format("cd ~/%s", p)}
|
|
||||||
}
|
|
||||||
msg := m.Cmd(SSH_RELAY, m.Option(MACHINE))
|
|
||||||
p := kit.Select(ice.CONTEXTS, msg.Append(web.DREAM))
|
|
||||||
kit.If(m.Option(web.SPACE) != ice.CONTEXTS, func() { p = path.Join(p, nfs.USR_LOCAL_WORK+m.Option(web.SPACE)) })
|
|
||||||
return []string{m.Option(MACHINE), "", kit.Format("cd ~/%s", p)}
|
|
||||||
}, arg...)
|
|
||||||
kit.If(!kit.HasPrefixList(arg, ice.RUN), func() {
|
|
||||||
m.Push(ctx.STYLE, html.FLOAT)
|
|
||||||
m.Push(web.TITLE, s.title(m))
|
|
||||||
})
|
|
||||||
}
|
|
||||||
func (s matrix) Admin(m *ice.Message, arg ...string) { s.open(m, arg...) }
|
func (s matrix) Admin(m *ice.Message, arg ...string) { s.open(m, arg...) }
|
||||||
func (s matrix) Desktop(m *ice.Message, arg ...string) { s.open(m, arg...) }
|
|
||||||
func (s matrix) Open(m *ice.Message, arg ...string) { s.open(m, arg...) }
|
func (s matrix) Open(m *ice.Message, arg ...string) { s.open(m, arg...) }
|
||||||
|
|
||||||
func init() { ice.Cmd("ssh.matrix", matrix{}) }
|
func init() { ice.Cmd("ssh.matrix", matrix{}) }
|
||||||
|
|
||||||
func (s matrix) title(m *ice.Message) string {
|
func (s matrix) plug(m *ice.Message, arg ...string) {
|
||||||
return kit.Select("contexts", kit.Keys(kit.Select("", m.Option(MACHINE), m.Option(MACHINE) != tcp.LOCALHOST),
|
if !kit.HasPrefixList(arg, ctx.RUN) {
|
||||||
|
defer m.Push(web.TITLE, s.title(m))
|
||||||
|
}
|
||||||
|
m.ProcessPodCmd(kit.Keys(
|
||||||
|
kit.Select("", ice.OPS, ice.Info.NodeType == web.WORKER),
|
||||||
|
kit.Select("", m.Option(MACHINE), m.Option(MACHINE) != tcp.LOCALHOST),
|
||||||
kit.Select("", m.Option(web.SPACE), m.Option(web.SPACE) != ice.CONTEXTS),
|
kit.Select("", m.Option(web.SPACE), m.Option(web.SPACE) != ice.CONTEXTS),
|
||||||
kit.Select("", m.ActionKey(), m.ActionKey() != web.OPEN),
|
), m.ActionKey(), arg, arg...)
|
||||||
))
|
}
|
||||||
|
func (s matrix) xterm(m *ice.Message, arg ...string) {
|
||||||
|
m.ProcessXterm(func() []string {
|
||||||
|
cmd, dir := cli.SH, ice.CONTEXTS
|
||||||
|
if m.Option(MACHINE) == tcp.LOCALHOST {
|
||||||
|
cmd = cli.Shell(m.Message)
|
||||||
|
} else {
|
||||||
|
cmd, dir = m.Option(MACHINE), kit.Select(dir, m.Cmd(SSH_RELAY, m.Option(MACHINE)).Append(web.DREAM))
|
||||||
|
}
|
||||||
|
kit.If(m.Option(web.SPACE) != ice.CONTEXTS, func() { dir = path.Join(dir, nfs.USR_LOCAL_WORK+m.Option(web.SPACE)) })
|
||||||
|
return []string{cmd, "", kit.Format("cd ~/%s", dir)}
|
||||||
|
}, arg...)
|
||||||
|
kit.If(!kit.HasPrefixList(arg, ctx.RUN), func() { m.Push(web.STYLE, html.FLOAT).Push(web.TITLE, s.title(m)) })
|
||||||
}
|
}
|
||||||
func (s matrix) iframe(m *ice.Message, arg ...string) {
|
func (s matrix) iframe(m *ice.Message, arg ...string) {
|
||||||
m.ProcessIframe(s.title(m), s.link(m), arg...)
|
m.ProcessIframe(s.title(m), s.link(m), arg...)
|
||||||
}
|
}
|
||||||
func (s matrix) plug(m *ice.Message, arg ...string) {
|
|
||||||
if kit.HasPrefixList(arg, ctx.RUN) || m.Option(MACHINE) == tcp.LOCALHOST {
|
|
||||||
m.ProcessFloat(m.ActionKey(), arg, arg...)
|
|
||||||
if !kit.HasPrefixList(arg, ctx.RUN) {
|
|
||||||
m.Push(web.TITLE, s.title(m))
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
m.ProcessOpen(s.link(m))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
func (s matrix) open(m *ice.Message, arg ...string) {
|
func (s matrix) open(m *ice.Message, arg ...string) {
|
||||||
if kit.HasPrefixList(arg, ctx.RUN) || m.Option(MACHINE) == tcp.LOCALHOST {
|
if kit.HasPrefixList(arg, ctx.RUN) || m.Option(MACHINE) == tcp.LOCALHOST {
|
||||||
m.ProcessIframe(s.title(m), s.link(m), arg...)
|
m.ProcessIframe(s.title(m), s.link(m), arg...)
|
||||||
@ -88,16 +75,15 @@ func (s matrix) open(m *ice.Message, arg ...string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
func (s matrix) link(m *ice.Message, arg ...string) (res string) {
|
func (s matrix) link(m *ice.Message, arg ...string) (res string) {
|
||||||
if m.Option(MACHINE) == tcp.LOCALHOST {
|
kit.If(m.Option(MACHINE) != tcp.LOCALHOST, func() { res = m.Cmd(SSH_RELAY, m.Option(MACHINE)).Append(mdb.LINK) })
|
||||||
res = m.UserHost()
|
kit.If(m.Option(web.SPACE) != ice.CONTEXTS, func() { res += web.S(m.Option(web.SPACE)) })
|
||||||
} else {
|
kit.If(m.ActionKey() != web.OPEN, func() { res += web.C(m.ActionKey()) })
|
||||||
res = m.Cmd(SSH_RELAY, m.Option(MACHINE)).Append(mdb.LINK)
|
return kit.Select(nfs.PS, res)
|
||||||
}
|
}
|
||||||
if m.Option(web.SPACE) != ice.CONTEXTS {
|
func (s matrix) title(m *ice.Message) string {
|
||||||
res += web.S(m.Option(web.SPACE))
|
return kit.Select(ice.CONTEXTS, kit.Keys(
|
||||||
}
|
kit.Select("", m.Option(MACHINE), m.Option(MACHINE) != tcp.LOCALHOST),
|
||||||
if m.ActionKey() != web.OPEN {
|
kit.Select("", m.Option(web.SPACE), m.Option(web.SPACE) != ice.CONTEXTS),
|
||||||
res += web.C(m.ActionKey())
|
kit.Select("", m.ActionKey(), m.ActionKey() != web.OPEN),
|
||||||
}
|
))
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
@ -164,6 +164,7 @@ func (s relay) Dream(m *ice.Message) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
fields := "time,machine,host,space,type,status,module,version,commitTime,compileTime,bootTime,link,icons"
|
fields := "time,machine,host,space,type,status,module,version,commitTime,compileTime,bootTime,link,icons"
|
||||||
s.foreach(m, func(msg *ice.Message, cmd []string) {
|
s.foreach(m, func(msg *ice.Message, cmd []string) {
|
||||||
m.Push("", kit.Dict(msg.OptionSimple(fields), mdb.TYPE, web.SERVER, mdb.STATUS, web.ONLINE, web.SPACE, ice.CONTEXTS, web.LINK, web.HostPort(m.Message, msg.Option(tcp.HOST), msg.Option(web.PORTAL))), kit.Split(fields))
|
m.Push("", kit.Dict(msg.OptionSimple(fields), mdb.TYPE, web.SERVER, mdb.STATUS, web.ONLINE, web.SPACE, ice.CONTEXTS, web.LINK, web.HostPort(m.Message, msg.Option(tcp.HOST), msg.Option(web.PORTAL))), kit.Split(fields))
|
||||||
@ -179,33 +180,29 @@ func (s relay) Dream(m *ice.Message) {
|
|||||||
}).Cut(fields))
|
}).Cut(fields))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
m.Options(ice.MSG_PROCESS, "")
|
|
||||||
if m.Action(s.Dream, "filter:text"); tcp.IsLocalHost(m.Message, m.Option(ice.MSG_USERIP)) {
|
m.Push(MACHINE, tcp.LOCALHOST).Push(tcp.HOST, tcp.PublishLocalhost(m.Message, tcp.LOCALHOST))
|
||||||
if _msg := m.Cmd(cli.SYSTEM, ice.BIN_ICE_BIN, web.ADMIN, cli.RUNTIME); len(_msg.Result()) > 0 {
|
m.Push("", kit.Dict(cli.ParseMake(m.AdminCmd(cli.RUNTIME).Result()), ice.SPACE, ice.CONTEXTS), kit.Split("time,space,module,version,commitTime,compileTime,bootTime"))
|
||||||
m.Push(MACHINE, tcp.LOCALHOST).Push(tcp.HOST, tcp.PublishLocalhost(m.Message, tcp.LOCALHOST))
|
m.Push(mdb.TYPE, web.SERVER).Push(mdb.STATUS, web.ONLINE).Push(web.LINK, web.UserHost(m.Message))
|
||||||
m.Push("", kit.Dict(cli.ParseMake(_msg.Result()), ice.SPACE, ice.CONTEXTS), kit.Split("time,space,module,version,commitTime,compileTime,bootTime"))
|
m.Push(mdb.ICONS, ice.SRC_MAIN_ICO)
|
||||||
m.Push(mdb.TYPE, web.SERVER).Push(mdb.STATUS, web.ONLINE).Push(web.LINK, web.UserHost(m.Message))
|
_msg := m.AdminCmd(web.ROUTE)
|
||||||
m.Push(mdb.ICONS, ice.SRC_MAIN_ICO)
|
m.Message.Copy(_msg.Table(func(value ice.Maps) {
|
||||||
}
|
_msg.Push(MACHINE, tcp.LOCALHOST).Push(tcp.HOST, tcp.PublishLocalhost(m.Message, tcp.LOCALHOST))
|
||||||
if _msg := m.Spawn().SplitIndex(m.Cmdx(cli.SYSTEM, kit.Split(s.admin(m, web.ROUTE)))); _msg.Length() > 0 {
|
_msg.Push(web.LINK, web.UserHost(m.Message)+web.S(value[web.SPACE]))
|
||||||
m.Message.Copy(_msg.Table(func(value ice.Maps) {
|
}).Cut(fields))
|
||||||
_msg.Push(MACHINE, tcp.LOCALHOST).Push(tcp.HOST, tcp.PublishLocalhost(m.Message, tcp.LOCALHOST))
|
|
||||||
_msg.Push(web.LINK, web.UserHost(m.Message)+web.S(value[web.SPACE]))
|
|
||||||
}).Cut(fields))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
m.RewriteAppend(func(value, key string, index int) string {
|
m.RewriteAppend(func(value, key string, index int) string {
|
||||||
if key == mdb.ICONS {
|
if key == mdb.ICONS {
|
||||||
if value == "" {
|
if value == "" {
|
||||||
value = kit.MergeURL2(m.Appendv(web.LINK)[index], "/require/"+nfs.USR_ICONS_ICEBERGS)
|
value = kit.MergeURL2(m.Appendv(web.LINK)[index], nfs.REQUIRE+nfs.USR_ICONS_ICEBERGS)
|
||||||
} else if strings.HasPrefix(value, nfs.REQUIRE) && m.Appendv(MACHINE)[index] != tcp.LOCALHOST {
|
} else if strings.HasPrefix(value, nfs.REQUIRE) && m.Appendv(MACHINE)[index] != tcp.LOCALHOST {
|
||||||
value = kit.MergeURL2(m.Appendv(web.LINK)[index], value)
|
value = kit.MergeURL2(m.Appendv(web.LINK)[index], value)
|
||||||
} else if kit.HasPrefix(value, nfs.USR, nfs.SRC) {
|
} else if kit.HasPrefix(value, nfs.USR, nfs.SRC) {
|
||||||
value = m.Option(ice.MSG_USERHOST) + "/require/" + value
|
value = m.Option(ice.MSG_USERHOST) + nfs.REQUIRE + value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return value
|
return value
|
||||||
})
|
}).Action(s.Dream, "filter:text").Options(ice.MSG_PROCESS, "")
|
||||||
}
|
}
|
||||||
func (s relay) ForEach(m *ice.Message, arg ...string) *ice.Message {
|
func (s relay) ForEach(m *ice.Message, arg ...string) *ice.Message {
|
||||||
s.foreach(m, func(msg *ice.Message, cmd []string) {
|
s.foreach(m, func(msg *ice.Message, cmd []string) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user