mirror of
https://shylinux.com/x/icebergs
synced 2025-04-26 01:24:05 +08:00
opt ice.MSG_DAEMON
This commit is contained in:
parent
0223a40087
commit
97bcf318c6
@ -14,9 +14,8 @@ import (
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
func _port_right(m *ice.Message, arg ...string) string {
|
||||
current, end := kit.Int(kit.Select(mdb.Config(m, CURRENT), arg, 0)), kit.Int(mdb.Config(m, END))
|
||||
kit.If(current >= end, func() { current = kit.Int(mdb.Config(m, BEGIN)) })
|
||||
func _port_right(m *ice.Message, current, begin, end int) string {
|
||||
kit.If(current >= end, func() { current = begin })
|
||||
for i := current; i < end; i++ {
|
||||
if p := path.Join(ice.USR_LOCAL_DAEMON, kit.Format(i)); nfs.Exists(m, p) {
|
||||
|
||||
@ -106,9 +105,11 @@ func init() {
|
||||
m.Assert(m.Option(PORT) != "")
|
||||
nfs.Trash(m, path.Join(ice.USR_LOCAL_DAEMON, m.Option(PORT)))
|
||||
}},
|
||||
aaa.RIGHT: {Hand: func(m *ice.Message, arg ...string) { m.Echo(_port_right(m, arg...)) }},
|
||||
CURRENT: {Hand: func(m *ice.Message, arg ...string) { m.Echo(mdb.Config(m, CURRENT)) }},
|
||||
}, mdb.HashAction(BEGIN, 10000, CURRENT, 10000, END, 20000)), Hand: func(m *ice.Message, arg ...string) {
|
||||
aaa.RIGHT: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Echo(PortRight(m, arg...))
|
||||
}},
|
||||
CURRENT: {Hand: func(m *ice.Message, arg ...string) { m.Echo(mdb.Config(m, CURRENT)) }},
|
||||
}, mdb.HashAction(BEGIN, 10000, END, 20000)), Hand: func(m *ice.Message, arg ...string) {
|
||||
if len(arg) > 0 {
|
||||
m.Cmdy(nfs.DIR, arg[1:], kit.Dict(nfs.DIR_ROOT, path.Join(ice.USR_LOCAL_DAEMON, arg[0])))
|
||||
return
|
||||
@ -126,3 +127,7 @@ func init() {
|
||||
}},
|
||||
})
|
||||
}
|
||||
func PortRight(m *ice.Message, arg ...string) string {
|
||||
current, begin, end := mdb.Config(m, CURRENT), mdb.Config(m, BEGIN), mdb.Config(m, END)
|
||||
return _port_right(m, kit.Int(kit.Select(kit.Select(begin, current), arg, 0)), kit.Int(kit.Select(begin, arg, 1)), kit.Int(kit.Select(end, arg, 2)))
|
||||
}
|
||||
|
@ -74,9 +74,9 @@ func _dream_start(m *ice.Message, name string) {
|
||||
cli.CTX_ROOT, kit.Path(""), cli.PATH, cli.BinPath(p, ""), cli.USER, ice.Info.Username,
|
||||
)...), cli.CMD_OUTPUT, path.Join(p, ice.VAR_LOG_BOOT_LOG), mdb.CACHE_CLEAR_ONEXIT, ice.TRUE)
|
||||
gdb.Event(m, DREAM_CREATE, m.OptionSimple(mdb.NAME, mdb.TYPE))
|
||||
if m.Option(nfs.BINARY) == "" && os.Getenv(cli.CTX_DEV) != "" && os.Getenv(cli.CTX_POD) != "" {
|
||||
m.Option(nfs.BINARY, os.Getenv(cli.CTX_DEV)+S(os.Getenv(cli.CTX_POD)))
|
||||
}
|
||||
// if m.Option(nfs.BINARY) == "" && os.Getenv(cli.CTX_DEV) != "" && os.Getenv(cli.CTX_POD) != "" {
|
||||
// m.Option(nfs.BINARY, os.Getenv(cli.CTX_DEV)+S(os.Getenv(cli.CTX_POD)))
|
||||
// }
|
||||
kit.If(m.Option(nfs.BINARY), func(p string) { _dream_binary(m, p) })
|
||||
kit.If(m.Option(nfs.TEMPLATE), func(p string) { _dream_template(m, p) })
|
||||
bin := kit.Select(kit.Path(os.Args[0]), cli.SystemFind(m, ice.ICE_BIN, nfs.PWD+path.Join(p, ice.BIN), nfs.PWD+ice.BIN))
|
||||
|
@ -97,15 +97,14 @@ func PushNotice(m *ice.Message, arg ...ice.Any) {
|
||||
})
|
||||
if m.Option(ice.MSG_DAEMON) == "" {
|
||||
return
|
||||
} else if m.Option(ice.MSG_USERPOD) == "" {
|
||||
m.Cmd(SPACE, m.Option(ice.MSG_DAEMON), arg, opts)
|
||||
} else {
|
||||
m.Cmd(SPACE, kit.Keys(m.Option("__target"), m.Option(ice.MSG_DAEMON)), arg, opts)
|
||||
m.Cmd(SPACE, m.Option(ice.MSG_DAEMON), arg, opts)
|
||||
}
|
||||
}
|
||||
func PushNoticeToast(m *ice.Message, arg ...ice.Any) { PushNotice(m, kit.List("toast", arg)...) }
|
||||
func PushNoticeGrow(m *ice.Message, arg ...ice.Any) { PushNotice(m, kit.List("grow", arg)...) }
|
||||
func PushNoticeRich(m *ice.Message, arg ...ice.Any) { PushNotice(m, kit.Simple("rich", arg)) }
|
||||
func PushNoticeRefresh(m *ice.Message, arg ...ice.Any) { PushNotice(m, kit.List("refresh", arg)...) }
|
||||
func PushNoticeToast(m *ice.Message, arg ...ice.Any) { PushNotice(m, kit.List("toast", arg)...) }
|
||||
func PushNoticeGrow(m *ice.Message, arg ...ice.Any) { PushNotice(m, kit.List("grow", arg)...) }
|
||||
func PushNoticeRich(m *ice.Message, arg ...ice.Any) { PushNotice(m, kit.Simple("rich", arg)) }
|
||||
func PushStream(m *ice.Message) *ice.Message {
|
||||
m.Options(cli.CMD_OUTPUT, file.NewWriteCloser(func(buf []byte) { PushNoticeGrow(m, string(buf)) }, nil)).ProcessHold(toastContent(m, ice.SUCCESS))
|
||||
return m
|
||||
|
@ -68,7 +68,6 @@ func _space_fork(m *ice.Message) {
|
||||
addr := kit.Select(m.R.RemoteAddr, m.R.Header.Get(ice.MSG_USERADDR))
|
||||
text := strings.ReplaceAll(kit.Select(addr, m.Option(mdb.TEXT)), "%2F", nfs.PS)
|
||||
name := kit.ReplaceAll(kit.Select(addr, m.Option(mdb.NAME)), "[", "_", "]", "_", nfs.DF, "_", nfs.PT, "_")
|
||||
|
||||
if kit.IsIn(m.Option(mdb.TYPE), WORKER) && IsLocalHost(m) || m.Option(TOKEN) != "" && m.Cmdv(TOKEN, m.Option(TOKEN), mdb.TIME) > m.Time() {
|
||||
|
||||
} else if kit.IsIn(m.Option(mdb.TYPE), PORTAL, aaa.LOGIN) && len(name) == 32 && kit.IsIn(mdb.HashSelects(m.Spawn(), name).Append(aaa.IP), "", m.Option(ice.MSG_USERIP)) {
|
||||
@ -77,11 +76,15 @@ func _space_fork(m *ice.Message) {
|
||||
name, text = kit.Hashs(name), kit.Select(addr, m.Option(mdb.NAME), m.Option(mdb.TEXT))
|
||||
}
|
||||
|
||||
if kit.IsIn(m.Option(mdb.TYPE), WORKER, PORTAL) && tcp.IsLocalHost(m, m.Option(ice.MSG_USERIP)) {
|
||||
aaa.SessAuth(m, kit.Dict(m.Cmd(aaa.USER, m.Option(ice.MSG_USERNAME, ice.Info.Username)).AppendSimple()))
|
||||
if kit.IsIn(m.Option(mdb.TYPE), WORKER, PORTAL) {
|
||||
if tcp.IsLocalHost(m, m.Option(ice.MSG_USERIP)) {
|
||||
aaa.SessAuth(m, kit.Dict(m.Cmd(aaa.USER, m.Option(ice.MSG_USERNAME, ice.Info.Username)).AppendSimple()))
|
||||
}
|
||||
} else if m.Option(TOKEN) != "" {
|
||||
msg := m.Cmd(TOKEN, m.Option(TOKEN))
|
||||
aaa.SessAuth(m, kit.Dict(m.Cmd(aaa.USER, m.Option(ice.MSG_USERNAME, msg.Append(mdb.NAME))).AppendSimple()))
|
||||
} else {
|
||||
m.Option(ice.MSG_USERNAME, "")
|
||||
}
|
||||
if m.Option(mdb.TYPE) == WORKER {
|
||||
if p := nfs.USR_LOCAL_WORK + m.Option(mdb.NAME); nfs.Exists(m, p) {
|
||||
@ -183,6 +186,7 @@ func _space_exec(m *ice.Message, name string, source, target []string, c *websoc
|
||||
m.Push(mdb.LINK, m.MergePod(kit.Select("", source, -1)))
|
||||
default:
|
||||
m.Options("__target", kit.Reverse(kit.Simple(source))).OptionDefault(ice.MSG_COUNT, "0")
|
||||
m.Option(ice.MSG_DAEMON, kit.Keys(kit.Slice(kit.Simple(m.Optionv("__target")), 0, -1), m.Option(ice.MSG_DAEMON)))
|
||||
kit.If(aaa.Right(m, m.Detailv()), func() { m.TryCatch(true, func(_ *ice.Message) { m = m.Cmd() }) })
|
||||
}
|
||||
defer m.Cost(kit.Format("%v->%v %v %v", source, target, m.Detailv(), m.FormatSize()))
|
||||
|
@ -98,7 +98,7 @@ func init() {
|
||||
mdb.MODIFY: {Hand: func(m *ice.Message, arg ...string) { mdb.HashModify(m, m.OptionSimple(mdb.NAME), arg) }},
|
||||
ice.DEMO: {Help: "体验", Hand: func(m *ice.Message, arg ...string) {
|
||||
if kit.IsIn(m.Option(ice.MSG_USERROLE), aaa.TECH, aaa.ROOT) {
|
||||
m.Cmd("", mdb.CREATE, mdb.TYPE, mdb.PLUGIN, mdb.NAME, "免登录体验", mdb.ORDER, "2", ctx.INDEX, HEADER, ctx.ARGS, ice.DEMO)
|
||||
m.Cmd("", mdb.CREATE, mdb.TYPE, mdb.PLUGIN, mdb.NAME, "免登录体验", mdb.ORDER, "12", ctx.INDEX, HEADER, ctx.ARGS, ice.DEMO)
|
||||
mdb.Config(m, ice.DEMO, ice.TRUE)
|
||||
} else if mdb.Config(m, ice.DEMO) == ice.TRUE {
|
||||
web.RenderCookie(m, aaa.SessCreate(m, ice.Info.Username))
|
||||
|
@ -21,11 +21,8 @@ import (
|
||||
|
||||
func _xterm_get(m *ice.Message, h string) xterm.XTerm {
|
||||
h = kit.Select(m.Option(mdb.HASH), h)
|
||||
if m.Assert(h != ""); m.Option(ice.MSG_USERPOD) == "" {
|
||||
mdb.HashModify(m, mdb.TIME, m.Time(), cli.DAEMON, kit.Keys(m.Option(ice.MSG_DAEMON)))
|
||||
} else {
|
||||
mdb.HashModify(m, mdb.TIME, m.Time(), cli.DAEMON, kit.Keys(kit.Slice(kit.Simple(m.Optionv("__target")), 0, -1), m.Option(ice.MSG_DAEMON)))
|
||||
}
|
||||
m.Assert(h != "")
|
||||
mdb.HashModify(m, mdb.TIME, m.Time(), cli.DAEMON, m.Option(ice.MSG_DAEMON))
|
||||
return mdb.HashSelectTarget(m, h, func(value ice.Maps) ice.Any {
|
||||
text := strings.Split(value[mdb.TEXT], lex.NL)
|
||||
ls := kit.Split(strings.Split(kit.Select(ISH, value[mdb.TYPE]), " # ")[0])
|
||||
@ -54,7 +51,7 @@ func _xterm_get(m *ice.Message, h string) xterm.XTerm {
|
||||
}).(xterm.XTerm)
|
||||
}
|
||||
func _xterm_echo(m *ice.Message, h string, str string) {
|
||||
m.Options(ice.MSG_DAEMON, mdb.HashSelectField(m, h, cli.DAEMON), ice.MSG_COUNT, "0", "__target", "")
|
||||
m.Options(ice.MSG_DAEMON, mdb.HashSelectField(m, h, cli.DAEMON), ice.MSG_COUNT, "0")
|
||||
// m.Options(ice.LOG_DISABLE, ice.TRUE)
|
||||
web.PushNoticeGrow(m, h, str)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user