forked from x/icebergs
opt some
This commit is contained in:
parent
082cf02461
commit
0d84e0c9ad
@ -44,6 +44,7 @@ const (
|
|||||||
UDP4 = "udp4"
|
UDP4 = "udp4"
|
||||||
SEND = "send"
|
SEND = "send"
|
||||||
RECV = "recv"
|
RECV = "recv"
|
||||||
|
ECHO = "echo"
|
||||||
DIRECT = "direct"
|
DIRECT = "direct"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -337,7 +337,6 @@ func init() {
|
|||||||
cli.BUILD: {Name: "build name", Hand: func(m *ice.Message, arg ...string) {
|
cli.BUILD: {Name: "build name", Hand: func(m *ice.Message, arg ...string) {
|
||||||
compile := cli.SystemFindGo(m)
|
compile := cli.SystemFindGo(m)
|
||||||
m.Option(ice.MSG_TITLE, kit.Keys(m.Option(ice.MSG_USERPOD0), m.Option(ice.MSG_USERPOD), m.CommandKey(), m.ActionKey()))
|
m.Option(ice.MSG_TITLE, kit.Keys(m.Option(ice.MSG_USERPOD0), m.Option(ice.MSG_USERPOD), m.CommandKey(), m.ActionKey()))
|
||||||
m.Option("dream.simple", ice.TRUE)
|
|
||||||
m.Cmd("", FOR_FLOW, m.Option(mdb.NAME), kit.JoinWord(cli.SH, ice.ETC_MISS_SH), func(p string) bool {
|
m.Cmd("", FOR_FLOW, m.Option(mdb.NAME), kit.JoinWord(cli.SH, ice.ETC_MISS_SH), func(p string) bool {
|
||||||
if compile && nfs.Exists(m, path.Join(p, ice.SRC_MAIN_GO)) {
|
if compile && nfs.Exists(m, path.Join(p, ice.SRC_MAIN_GO)) {
|
||||||
return false
|
return false
|
||||||
@ -370,11 +369,7 @@ func init() {
|
|||||||
VERSION: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy("web.code.version") }},
|
VERSION: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy("web.code.version") }},
|
||||||
FOR_FLOW: {Name: "forFlow name cmd*='sh etc/miss.sh'", Help: "流程", Icon: "bi bi-terminal", Hand: func(m *ice.Message, arg ...string) {
|
FOR_FLOW: {Name: "forFlow name cmd*='sh etc/miss.sh'", Help: "流程", Icon: "bi bi-terminal", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Options(ctx.DISPLAY, html.PLUGIN_XTERM, cli.CMD_OUTPUT, nfs.NewWriteCloser(func(buf []byte) (int, error) {
|
m.Options(ctx.DISPLAY, html.PLUGIN_XTERM, cli.CMD_OUTPUT, nfs.NewWriteCloser(func(buf []byte) (int, error) {
|
||||||
PushNoticeGrow(m.Options(
|
PushNoticeGrow(m.Options(ice.MSG_COUNT, "0", ice.LOG_DEBUG, ice.FALSE, ice.LOG_DISABLE, ice.TRUE), strings.ReplaceAll(string(buf), lex.NL, "\r\n"))
|
||||||
ice.MSG_COUNT, "0",
|
|
||||||
ice.LOG_DEBUG, ice.FALSE,
|
|
||||||
ice.LOG_DISABLE, ice.TRUE,
|
|
||||||
), strings.ReplaceAll(string(buf), lex.NL, "\r\n"))
|
|
||||||
return len(buf), nil
|
return len(buf), nil
|
||||||
}, nil))
|
}, nil))
|
||||||
msg := m.Spawn(ice.Maps{ice.MSG_DEBUG: ice.FALSE})
|
msg := m.Spawn(ice.Maps{ice.MSG_DEBUG: ice.FALSE})
|
||||||
@ -476,7 +471,7 @@ func init() {
|
|||||||
ctx.TOOLS, kit.Simple(SPIDE, ROUTE), ONLINE, ice.TRUE,
|
ctx.TOOLS, kit.Simple(SPIDE, ROUTE), ONLINE, ice.TRUE,
|
||||||
)), Hand: func(m *ice.Message, arg ...string) {
|
)), Hand: func(m *ice.Message, arg ...string) {
|
||||||
if len(arg) == 0 {
|
if len(arg) == 0 {
|
||||||
simple := m.Option("dream.simple") == ice.TRUE
|
simple := m.Option(ice.DREAM_SIMPLE) == ice.TRUE
|
||||||
if ice.Info.NodeType != WORKER {
|
if ice.Info.NodeType != WORKER {
|
||||||
_dream_list(m, simple)
|
_dream_list(m, simple)
|
||||||
_dream_list_icon(m)
|
_dream_list_icon(m)
|
||||||
@ -552,7 +547,7 @@ func DreamEach(m *ice.Message, name string, status string, cb func(string)) *ice
|
|||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
msg := m.Spawn()
|
msg := m.Spawn()
|
||||||
m.Cmds(DREAM, kit.Dict("dream.simple", ice.TRUE)).Table(func(value ice.Maps) {
|
m.Cmds(DREAM, kit.Dict(ice.DREAM_SIMPLE, ice.TRUE)).Table(func(value ice.Maps) {
|
||||||
if value[mdb.STATUS] == kit.Select(cli.START, status) && value[mdb.TYPE] == WORKER && (value[mdb.NAME] == name || reg.MatchString(kit.Format("%s:%s=%s@%d", value[mdb.NAME], value[mdb.TYPE], value[nfs.MODULE], value[nfs.VERSION]))) {
|
if value[mdb.STATUS] == kit.Select(cli.START, status) && value[mdb.TYPE] == WORKER && (value[mdb.NAME] == name || reg.MatchString(kit.Format("%s:%s=%s@%d", value[mdb.NAME], value[mdb.TYPE], value[nfs.MODULE], value[nfs.VERSION]))) {
|
||||||
msg.Push(mdb.NAME, value[mdb.NAME])
|
msg.Push(mdb.NAME, value[mdb.NAME])
|
||||||
}
|
}
|
||||||
@ -570,7 +565,7 @@ func DreamListSpide(m *ice.Message, list []string, types string, cb func(dev, or
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
func DreamList(m *ice.Message) *ice.Message {
|
func DreamList(m *ice.Message) *ice.Message {
|
||||||
return AdminCmd(m.Options("dream.simple", ice.TRUE), DREAM)
|
return AdminCmd(m.Options(ice.DREAM_SIMPLE, ice.TRUE), DREAM)
|
||||||
}
|
}
|
||||||
func DreamStat(m *ice.Message, name string) (res string) {
|
func DreamStat(m *ice.Message, name string) (res string) {
|
||||||
if cli.SystemFindGit(m) {
|
if cli.SystemFindGit(m) {
|
||||||
|
@ -23,7 +23,7 @@ func _matrix_list(m *ice.Message, domain, typ string, meta ice.Maps, fields ...s
|
|||||||
compile := kit.Select("", kit.Select(COMPILE, UPGRADE, typ == SERVER), istech)
|
compile := kit.Select("", kit.Select(COMPILE, UPGRADE, typ == SERVER), istech)
|
||||||
vimer := kit.Select("", VIMER, istech && isdebug)
|
vimer := kit.Select("", VIMER, istech && isdebug)
|
||||||
|
|
||||||
button := []ice.Any{PORTAL, DESKTOP, DREAM, ADMIN, OPEN, compile}
|
button := []ice.Any{PORTAL, DESKTOP, DREAM, ADMIN, OPEN, compile, MESSAGE}
|
||||||
kit.If(istech, func() { button = append(button, WORD, STATUS) })
|
kit.If(istech, func() { button = append(button, WORD, STATUS) })
|
||||||
kit.If(istech && isdebug, func() { button = append(button, vimer, cli.RUNTIME, XTERM) })
|
kit.If(istech && isdebug, func() { button = append(button, vimer, cli.RUNTIME, XTERM) })
|
||||||
m.PushRecord(value, fields...).PushButton(button...)
|
m.PushRecord(value, fields...).PushButton(button...)
|
||||||
|
@ -38,7 +38,7 @@ func _space_dial(m *ice.Message, dev, name string, arg ...string) {
|
|||||||
redial := kit.Dict(mdb.Configv(m, REDIAL))
|
redial := kit.Dict(mdb.Configv(m, REDIAL))
|
||||||
a, b, _c := kit.Int(redial["a"]), kit.Int(redial["b"]), kit.Int(redial["c"])
|
a, b, _c := kit.Int(redial["a"]), kit.Int(redial["b"]), kit.Int(redial["c"])
|
||||||
for i := 1; i < _c; i++ {
|
for i := 1; i < _c; i++ {
|
||||||
next := time.Duration(rand.Intn(a*(i+1))+b*i) * time.Millisecond
|
next := time.Duration(rand.Intn(a*i*i)+b*(i+1)) * time.Millisecond
|
||||||
m.Cmd(tcp.CLIENT, tcp.DIAL, args, func(c net.Conn) {
|
m.Cmd(tcp.CLIENT, tcp.DIAL, args, func(c net.Conn) {
|
||||||
if c, e := websocket.NewClient(c, u); !m.WarnNotValid(e, tcp.DIAL, dev, SPACE, u.String()) {
|
if c, e := websocket.NewClient(c, u); !m.WarnNotValid(e, tcp.DIAL, dev, SPACE, u.String()) {
|
||||||
defer mdb.HashCreateDeferRemove(m, kit.SimpleKV("", ORIGIN, dev, origin), kit.Dict(mdb.TARGET, c))()
|
defer mdb.HashCreateDeferRemove(m, kit.SimpleKV("", ORIGIN, dev, origin), kit.Dict(mdb.TARGET, c))()
|
||||||
@ -125,9 +125,10 @@ func _space_handle(m *ice.Message, safe bool, name string, c *websocket.Conn) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
msg := m.Spawn(b)
|
msg := m.Spawn(b)
|
||||||
if safe { // 下行权限
|
if safe && msg.Option(ice.MSG_UNSAFE) != ice.TRUE { // 下行权限
|
||||||
kit.If(kit.IsIn(msg.Option(ice.MSG_USERROLE), "", aaa.VOID), func() { msg.Option(ice.MSG_USERROLE, aaa.UserRole(msg, msg.Option(ice.MSG_USERNAME))) })
|
kit.If(kit.IsIn(msg.Option(ice.MSG_USERROLE), "", aaa.VOID), func() { msg.Option(ice.MSG_USERROLE, aaa.UserRole(msg, msg.Option(ice.MSG_USERNAME))) })
|
||||||
} else { // 上行权限
|
} else { // 上行权限
|
||||||
|
msg.Option(ice.MSG_UNSAFE, ice.TRUE)
|
||||||
kit.If(msg.Option(ice.MSG_USERROLE), func() { msg.Option(ice.MSG_USERROLE, aaa.VOID) })
|
kit.If(msg.Option(ice.MSG_USERROLE), func() { msg.Option(ice.MSG_USERROLE, aaa.VOID) })
|
||||||
}
|
}
|
||||||
source, target := kit.Simple(msg.Optionv(ice.MSG_SOURCE), name), kit.Simple(msg.Optionv(ice.MSG_TARGET))
|
source, target := kit.Simple(msg.Optionv(ice.MSG_SOURCE), name), kit.Simple(msg.Optionv(ice.MSG_TARGET))
|
||||||
@ -141,18 +142,23 @@ func _space_handle(m *ice.Message, safe bool, name string, c *websocket.Conn) {
|
|||||||
_space_exec(msg, name, source, target, c)
|
_space_exec(msg, name, source, target, c)
|
||||||
}, strings.Join(kit.Simple(SPACE, name, msg.Detailv()), lex.SP))
|
}, strings.Join(kit.Simple(SPACE, name, msg.Detailv()), lex.SP))
|
||||||
} else {
|
} else {
|
||||||
m.WarnNotFound(!mdb.HashSelectDetail(m, next, func(value ice.Map) {
|
for i := 0; i < 5; i++ {
|
||||||
switch c := value[mdb.TARGET].(type) {
|
if !m.WarnNotFoundSpace(!mdb.HashSelectDetail(m, next, func(value ice.Map) {
|
||||||
case (*websocket.Conn): // 转发报文
|
switch c := value[mdb.TARGET].(type) {
|
||||||
kit.If(value[mdb.TYPE] == ORIGIN && msg.Option(ice.MSG_HANDLE) == ice.FALSE, func() {
|
case (*websocket.Conn): // 转发报文
|
||||||
msg.Optionv(ice.MSG_USERWEB, kit.Simple(value[mdb.TEXT], msg.Optionv(ice.MSG_USERWEB)))
|
kit.If(value[mdb.TYPE] == ORIGIN && msg.Option(ice.MSG_HANDLE) == ice.FALSE, func() {
|
||||||
msg.Optionv(ice.MSG_USERPOD, kit.Simple(kit.Keys(target[1:]), msg.Optionv(ice.MSG_USERPOD)))
|
msg.Optionv(ice.MSG_USERWEB, kit.Simple(value[mdb.TEXT], msg.Optionv(ice.MSG_USERWEB)))
|
||||||
})
|
msg.Optionv(ice.MSG_USERPOD, kit.Simple(kit.Keys(target[1:]), msg.Optionv(ice.MSG_USERPOD)))
|
||||||
_space_echo(msg, source, target, c)
|
})
|
||||||
case ice.Handler: // 接收响应
|
_space_echo(msg, source, target, c)
|
||||||
msg.Go(func() { c(msg) })
|
case ice.Handler: // 接收响应
|
||||||
|
msg.Go(func() { c(msg) })
|
||||||
|
}
|
||||||
|
}), SPACE, next) {
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}), SPACE, next)
|
m.Sleep3s()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -184,6 +190,7 @@ func _space_exec(m *ice.Message, name string, source, target []string, c *websoc
|
|||||||
}
|
}
|
||||||
m.OptionDefault(ice.MSG_COUNT, "0")
|
m.OptionDefault(ice.MSG_COUNT, "0")
|
||||||
kit.If(m.Option(ice.MSG_DAEMON), func(p string) {
|
kit.If(m.Option(ice.MSG_DAEMON), func(p string) {
|
||||||
|
m.Option(ice.MSG_DAEMON0, m.Option(ice.MSG_DAEMON))
|
||||||
m.Option(ice.MSG_DAEMON, kit.Keys(kit.Slice(kit.Reverse(kit.Simple(source)), 0, -1), p))
|
m.Option(ice.MSG_DAEMON, kit.Keys(kit.Slice(kit.Reverse(kit.Simple(source)), 0, -1), p))
|
||||||
})
|
})
|
||||||
m.Option(ice.FROM_SPACE, kit.Keys(kit.Reverse(kit.Simple(source[1:]))))
|
m.Option(ice.FROM_SPACE, kit.Keys(kit.Reverse(kit.Simple(source[1:]))))
|
||||||
@ -191,6 +198,9 @@ 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))) })
|
||||||
}
|
}
|
||||||
m.Option(ice.MSG_HANDLE, ice.TRUE)
|
m.Option(ice.MSG_HANDLE, ice.TRUE)
|
||||||
|
if m.Option(ice.SPACE_NOECHO) == ice.TRUE {
|
||||||
|
return
|
||||||
|
}
|
||||||
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()))
|
||||||
m.Options(ice.MSG_USERWEB, m.Optionv(ice.MSG_USERWEB), ice.MSG_USERPOD, m.Optionv(ice.MSG_USERPOD))
|
m.Options(ice.MSG_USERWEB, m.Optionv(ice.MSG_USERWEB), ice.MSG_USERPOD, m.Optionv(ice.MSG_USERPOD))
|
||||||
_space_echo(m.Set(ice.MSG_OPTS).Options(m.OptionSimple(ice.MSG_HANDLE, ice.LOG_DEBUG, ice.LOG_DISABLE, ice.LOG_TRACEID)), []string{}, kit.Reverse(kit.Simple(source)), c)
|
_space_echo(m.Set(ice.MSG_OPTS).Options(m.OptionSimple(ice.MSG_HANDLE, ice.LOG_DEBUG, ice.LOG_DISABLE, ice.LOG_TRACEID)), []string{}, kit.Reverse(kit.Simple(source)), c)
|
||||||
@ -199,14 +209,14 @@ func _space_echo(m *ice.Message, source, target []string, c *websocket.Conn) {
|
|||||||
defer func() { m.WarnNotValid(recover()) }()
|
defer func() { m.WarnNotValid(recover()) }()
|
||||||
if m.Options(ice.MSG_SOURCE, source, ice.MSG_TARGET, target[1:]); !m.WarnNotValid(c.WriteMessage(1, []byte(m.FormatMeta()))) {
|
if m.Options(ice.MSG_SOURCE, source, ice.MSG_TARGET, target[1:]); !m.WarnNotValid(c.WriteMessage(1, []byte(m.FormatMeta()))) {
|
||||||
if source != nil {
|
if source != nil {
|
||||||
m.Log(tcp.SEND, "%v->%v %v %v", source, target, kit.ReplaceAll(kit.Format("%v", m.Detailv()), "\r\n", "\\r\\n", "\t", "\\t", "\n", "\\n"), m.FormatsMeta(nil))
|
m.Log(kit.Select(tcp.SEND, tcp.ECHO, m.Option(ice.MSG_HANDLE) == ice.TRUE), "%v->%v %v %v", source, target, kit.ReplaceAll(kit.Format("%v", m.Detailv()), "\r\n", "\\r\\n", "\t", "\\t", "\n", "\\n"), m.FormatsMeta(nil))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func _space_send(m *ice.Message, name string, arg ...string) (h string) {
|
func _space_send(m *ice.Message, name string, arg ...string) (h string) {
|
||||||
withecho := m.Option("space.noecho") != ice.TRUE
|
withecho := m.Option(ice.SPACE_NOECHO) != ice.TRUE
|
||||||
kit.If(len(arg) > 0 && arg[0] == TOAST, func() { withecho = false; m.Option(ice.MSG_DEBUG, ice.FALSE) })
|
kit.If(len(arg) > 0 && arg[0] == TOAST, func() { withecho = false; m.Option(ice.MSG_DEBUG, ice.FALSE) })
|
||||||
wait, done := m.Wait(kit.Select("", m.OptionDefault("space.timeout", "180s"), withecho), func(msg *ice.Message, arg ...string) {
|
wait, done := m.Wait(kit.Select("", m.OptionDefault(ice.SPACE_TIMEOUT, "180s"), withecho), func(msg *ice.Message, arg ...string) {
|
||||||
m.Cost(kit.Format("%v->[%v] %v %v", m.Optionv(ice.MSG_SOURCE), name, m.Detailv(), msg.FormatSize())).Copy(msg)
|
m.Cost(kit.Format("%v->[%v] %v %v", m.Optionv(ice.MSG_SOURCE), name, m.Detailv(), msg.FormatSize())).Copy(msg)
|
||||||
})
|
})
|
||||||
if withecho {
|
if withecho {
|
||||||
@ -221,7 +231,7 @@ func _space_send(m *ice.Message, name string, arg ...string) (h string) {
|
|||||||
m.Options(ice.MSG_USERHOST, "", ice.MSG_USERWEB0, m.Option(ice.MSG_USERWEB), ice.MSG_USERPOD0, name)
|
m.Options(ice.MSG_USERHOST, "", ice.MSG_USERWEB0, m.Option(ice.MSG_USERWEB), ice.MSG_USERPOD0, name)
|
||||||
})
|
})
|
||||||
m.Option(ice.MSG_HANDLE, ice.FALSE)
|
m.Option(ice.MSG_HANDLE, ice.FALSE)
|
||||||
kit.For([]string{ice.MSG_USERROLE, ice.LOG_TRACEID, "space.noecho"}, func(k string) { m.Optionv(k, m.Optionv(k)) })
|
kit.For([]string{ice.MSG_USERROLE, ice.LOG_TRACEID, ice.SPACE_NOECHO}, func(k string) { m.Optionv(k, m.Optionv(k)) })
|
||||||
kit.For(kit.Filters(kit.Simple(m.Optionv(ice.MSG_OPTS)), "task.id", "work.id"), func(k string) { m.Optionv(k, m.Optionv(k)) })
|
kit.For(kit.Filters(kit.Simple(m.Optionv(ice.MSG_OPTS)), "task.id", "work.id"), func(k string) { m.Optionv(k, m.Optionv(k)) })
|
||||||
if withecho {
|
if withecho {
|
||||||
_space_echo(m.Set(ice.MSG_DETAIL, arg...), []string{h}, target, c)
|
_space_echo(m.Set(ice.MSG_DETAIL, arg...), []string{h}, target, c)
|
||||||
@ -230,16 +240,12 @@ func _space_send(m *ice.Message, name string, arg ...string) (h string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}) {
|
}) {
|
||||||
if target[0] == ice.OPS {
|
if name == ice.OPS && ice.Info.NodeType == SERVER {
|
||||||
if ice.Info.NodeType == SERVER {
|
m.Cmdy(arg)
|
||||||
if name == ice.OPS {
|
return
|
||||||
m.Cmdy(arg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
kit.If(m.IsDebug(), func() {
|
kit.If(m.IsDebug(), func() {
|
||||||
m.WarnNotFound(kit.IndexOf([]string{ice.OPS, ice.DEV}, target[0]) == -1, SPACE, name)
|
m.WarnNotFoundSpace(kit.IndexOf([]string{ice.OPS, ice.DEV}, target[0]) == -1, SPACE, name)
|
||||||
})
|
})
|
||||||
} else if withecho {
|
} else if withecho {
|
||||||
m.Warn(!wait(), kit.Format("space %v %v time out", name, arg))
|
m.Warn(!wait(), kit.Format("space %v %v time out", name, arg))
|
||||||
@ -327,7 +333,11 @@ func init() {
|
|||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
nfs.PS: {Hand: func(m *ice.Message, arg ...string) { _space_fork(m) }},
|
nfs.PS: {Hand: func(m *ice.Message, arg ...string) { _space_fork(m) }},
|
||||||
}, gdb.EventsAction(SPACE_LOGIN), mdb.HashAction(mdb.LIMIT, 1000, mdb.LEAST, 500, mdb.SHORT, mdb.NAME, mdb.FIELD, "time,type,name,text,module,version,agent,system,ip,usernick,username,userrole", ctx.ACTION, OPEN, REDIAL, kit.Dict("a", 3000, "b", 1000, "c", 1000)), mdb.ClearOnExitHashAction()), Hand: func(m *ice.Message, arg ...string) {
|
}, gdb.EventsAction(SPACE_LOGIN), mdb.HashAction(
|
||||||
|
mdb.LIMIT, 1000, mdb.LEAST, 500,
|
||||||
|
mdb.SHORT, mdb.NAME, mdb.FIELD, "time,type,name,text,module,version,agent,system,ip,usernick,username,userrole",
|
||||||
|
ctx.ACTION, OPEN, REDIAL, kit.Dict("a", 1000, "b", 100, "c", 1000),
|
||||||
|
), mdb.ClearOnExitHashAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||||
if len(arg) < 2 {
|
if len(arg) < 2 {
|
||||||
if len(arg) == 1 && strings.Contains(arg[0], nfs.PT) {
|
if len(arg) == 1 && strings.Contains(arg[0], nfs.PT) {
|
||||||
ls := kit.Split(arg[0], nfs.PT)
|
ls := kit.Split(arg[0], nfs.PT)
|
||||||
@ -353,12 +363,11 @@ func init() {
|
|||||||
})
|
})
|
||||||
m.Sort("", kit.Simple(aaa.LOGIN, WEIXIN, PORTAL, WORKER, SERVER, ORIGIN))
|
m.Sort("", kit.Simple(aaa.LOGIN, WEIXIN, PORTAL, WORKER, SERVER, ORIGIN))
|
||||||
} else {
|
} else {
|
||||||
// m.OptionDefault(ice.MSG_USERPOD, arg[0])
|
|
||||||
for i := 0; i < 5; i++ {
|
for i := 0; i < 5; i++ {
|
||||||
if _space_send(m, arg[0], kit.Simple(kit.Split(arg[1]), arg[2:])...); !m.IsErrNotFound() {
|
if _space_send(m, arg[0], kit.Simple(kit.Split(arg[1]), arg[2:])...); !m.IsErrNotFoundSpace() {
|
||||||
break
|
break
|
||||||
} else if i < 4 {
|
} else if i < 4 {
|
||||||
m.SetAppend().SetResult().Sleep("10s")
|
m.SetAppend().SetResult().Sleep3s()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -412,7 +421,9 @@ func init() {
|
|||||||
case "target":
|
case "target":
|
||||||
m.AdminCmd(MATRIX).Table(func(value ice.Maps) {
|
m.AdminCmd(MATRIX).Table(func(value ice.Maps) {
|
||||||
m.Push(arg[0], kit.Keys(kit.Select("", ice.OPS, ice.Info.NodeType == WORKER), value[DOMAIN], value[mdb.NAME]))
|
m.Push(arg[0], kit.Keys(kit.Select("", ice.OPS, ice.Info.NodeType == WORKER), value[DOMAIN], value[mdb.NAME]))
|
||||||
|
m.Push(mdb.TYPE, value[mdb.TYPE])
|
||||||
})
|
})
|
||||||
|
m.Sort("type,target", []string{MYSELF, SERVER, ORIGIN, WORKER}, ice.STR_R)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
ice.Info.AdminCmd = AdminCmd
|
ice.Info.AdminCmd = AdminCmd
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
ice "shylinux.com/x/icebergs"
|
ice "shylinux.com/x/icebergs"
|
||||||
|
"shylinux.com/x/icebergs/base/aaa"
|
||||||
"shylinux.com/x/icebergs/base/cli"
|
"shylinux.com/x/icebergs/base/cli"
|
||||||
"shylinux.com/x/icebergs/base/ctx"
|
"shylinux.com/x/icebergs/base/ctx"
|
||||||
"shylinux.com/x/icebergs/base/gdb"
|
"shylinux.com/x/icebergs/base/gdb"
|
||||||
@ -33,10 +34,10 @@ func init() {
|
|||||||
mdb.HashCreate(_stream_subkey(m), ParseUA(m))
|
mdb.HashCreate(_stream_subkey(m), ParseUA(m))
|
||||||
mdb.HashSelect(m)
|
mdb.HashSelect(m)
|
||||||
}},
|
}},
|
||||||
PUSH: {Hand: func(m *ice.Message, arg ...string) {
|
PUSH: {Role: aaa.VOID, Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Options(ice.MSG_SPACE, arg[0], ice.MSG_INDEX, arg[1])
|
m.Options(ice.MSG_SPACE, arg[0], ice.MSG_INDEX, arg[1])
|
||||||
mdb.HashSelect(_stream_subkey(m)).Table(func(value ice.Maps) {
|
mdb.HashSelect(_stream_subkey(m)).Table(func(value ice.Maps) {
|
||||||
if value[cli.DAEMON] != m.Option(ice.MSG_DAEMON) {
|
if !kit.IsIn(value[cli.DAEMON], strings.TrimPrefix(m.Option(ice.MSG_DAEMON), "ops."), m.Option(ice.MSG_DAEMON0)) {
|
||||||
m.Options(mdb.SUBKEY, "").Cmd(SPACE, value[cli.DAEMON], arg[2:])
|
m.Options(mdb.SUBKEY, "").Cmd(SPACE, value[cli.DAEMON], arg[2:])
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -67,10 +68,11 @@ func StreamPush(m *ice.Message, arg ...string) {
|
|||||||
}
|
}
|
||||||
func StreamPushRefresh(m *ice.Message, arg ...string) {
|
func StreamPushRefresh(m *ice.Message, arg ...string) {
|
||||||
StreamPush(m.Spawn(ice.Maps{"space.noecho": ice.TRUE}), kit.Simple(html.REFRESH, arg)...)
|
StreamPush(m.Spawn(ice.Maps{"space.noecho": ice.TRUE}), kit.Simple(html.REFRESH, arg)...)
|
||||||
|
if strings.Contains(m.Option(ice.MSG_USERPOD), ".") {
|
||||||
|
AdminCmd(m.Spawn(ice.Maps{"space.noecho": ice.TRUE}), SPACE, ice.DEV, STREAM, PUSH, m.Option(ice.MSG_USERPOD), m.ShortKey(), kit.Simple(html.REFRESH, arg))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
func StreamPushRefreshConfirm(m *ice.Message, arg ...string) {
|
func StreamPushRefreshConfirm(m *ice.Message, arg ...string) {
|
||||||
if len(arg) == 0 {
|
kit.If(len(arg) == 0, func() { arg = append(arg, m.Trans("refresh for new data ", "刷新列表,查看最新数据 ")) })
|
||||||
arg = append(arg, m.Trans("refresh for new data ", "刷新列表,查看最新数据 "))
|
|
||||||
}
|
|
||||||
StreamPushRefresh(m, kit.Simple(html.CONFIRM, arg)...)
|
StreamPushRefresh(m, kit.Simple(html.CONFIRM, arg)...)
|
||||||
}
|
}
|
||||||
|
7
conf.go
7
conf.go
@ -233,6 +233,8 @@ const ( // MSG
|
|||||||
MSG_STORM = "sess.storm"
|
MSG_STORM = "sess.storm"
|
||||||
MSG_COUNT = "sess.count"
|
MSG_COUNT = "sess.count"
|
||||||
MSG_DAEMON = "sess.daemon"
|
MSG_DAEMON = "sess.daemon"
|
||||||
|
MSG_DAEMON0 = "sess.daemon0"
|
||||||
|
MSG_UNSAFE = "sess.unsafe"
|
||||||
MSG_ONLINE = "sess.online"
|
MSG_ONLINE = "sess.online"
|
||||||
MSG_REFERER = "sess.referer"
|
MSG_REFERER = "sess.referer"
|
||||||
MSG_CHECKER = "aaa.checker"
|
MSG_CHECKER = "aaa.checker"
|
||||||
@ -249,6 +251,9 @@ const ( // MSG
|
|||||||
FROM_DAEMON = "from.daemon"
|
FROM_DAEMON = "from.daemon"
|
||||||
TABLE_CHECKBOX = "table.checkbox"
|
TABLE_CHECKBOX = "table.checkbox"
|
||||||
TOAST_DURATION = "toast.duration"
|
TOAST_DURATION = "toast.duration"
|
||||||
|
DREAM_SIMPLE = "dream.simple"
|
||||||
|
SPACE_NOECHO = "space.noecho"
|
||||||
|
SPACE_TIMEOUT = "space.timeout"
|
||||||
)
|
)
|
||||||
const ( // RENDER
|
const ( // RENDER
|
||||||
RENDER_BUTTON = "_button"
|
RENDER_BUTTON = "_button"
|
||||||
@ -329,6 +334,8 @@ const ( // Err
|
|||||||
ErrNotValid = "not valid: "
|
ErrNotValid = "not valid: "
|
||||||
ErrNotStart = "not start: "
|
ErrNotStart = "not start: "
|
||||||
|
|
||||||
|
ErrNotFoundSpace = "not found space: "
|
||||||
|
ErrNotFoundIndex = "not found index: "
|
||||||
ErrAlreadyExists = "already exists: "
|
ErrAlreadyExists = "already exists: "
|
||||||
ErrNotImplement = "not implement: "
|
ErrNotImplement = "not implement: "
|
||||||
ErrTooDeepCount = "too deep count: "
|
ErrTooDeepCount = "too deep count: "
|
||||||
|
@ -97,7 +97,7 @@ func init() {
|
|||||||
if arg[0] == mdb.INPUTS || arg[0] == mdb.ACTION && arg[1] == mdb.INPUTS {
|
if arg[0] == mdb.INPUTS || arg[0] == mdb.ACTION && arg[1] == mdb.INPUTS {
|
||||||
m.Cmdy(web.Space(m, m.Option(ice.POD)), MESSAGE, arg)
|
m.Cmdy(web.Space(m, m.Option(ice.POD)), MESSAGE, arg)
|
||||||
} else {
|
} else {
|
||||||
m.Cmdy(web.Space(m, m.Option(ice.POD)), MESSAGE, mdb.INSERT, arg).ToastSuccess()
|
m.Cmdy(web.Space(m, m.Option(ice.POD)), MESSAGE, tcp.SEND, arg).ToastSuccess()
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
aaa.LOGOUT: {Hand: aaa.SessLogout},
|
aaa.LOGOUT: {Hand: aaa.SessLogout},
|
||||||
|
@ -142,11 +142,14 @@ Volcanos(chat.ONFIGURE, {
|
|||||||
value._space = list.concat(_list).join(".").replaceAll("..", "."), value._commands = {direct: value.direct, target: can.db.zone.target}
|
value._space = list.concat(_list).join(".").replaceAll("..", "."), value._commands = {direct: value.direct, target: can.db.zone.target}
|
||||||
value.title = value.name; if (value.text) { var msg = can.request(); msg._xhr = {responseText: value.text}, value.msg = msg, msg.Copy(JSON.parse(value.text)) }
|
value.title = value.name; if (value.text) { var msg = can.request(); msg._xhr = {responseText: value.text}, value.msg = msg, msg.Copy(JSON.parse(value.text)) }
|
||||||
can.onappend.plugin(can, value, function(sub) { sub.onimport.size(sub, height, width, false)
|
can.onappend.plugin(can, value, function(sub) { sub.onimport.size(sub, height, width, false)
|
||||||
sub.Conf("_plugin_action", [{view: "item.button.pluginCreate.icons.state", _init: function(target) {
|
sub.Conf("_plugin_action", [{view: "item.button.localCreate.icons.state", _init: function(target) {
|
||||||
can.page.Append(can, target, [{icon: "bi bi-box-arrow-in-down", onclick: function(event) {
|
can.page.Append(can, target, [{icon: icon.localCreate, title: "localCreate", onclick: function(event) {
|
||||||
can.core.Next(sub._msg.Table(), function(value, next, index, list) { can.user.toastProcess(can, "create "+index+"/"+list.length, sub.ConfIndex())
|
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(event, sub.Option(), value), ctx.RUN, ["", sub.ConfIndex(), mdb.CREATE], function() { next() })
|
||||||
}, function() { can.user.toastSuccess(can, mdb.CREATE) })
|
}, function() {
|
||||||
|
can.user.toastSuccess(can, mdb.CREATE)
|
||||||
|
can.onappend._float(can, sub.ConfIndex(), [])
|
||||||
|
})
|
||||||
}}])
|
}}])
|
||||||
}}])
|
}}])
|
||||||
sub.onexport.output = function() { sub.onimport.size(sub, height, width, false)
|
sub.onexport.output = function() { sub.onimport.size(sub, height, width, false)
|
||||||
|
4
exec.go
4
exec.go
@ -131,7 +131,7 @@ func (m *Message) CmdHand(cmd *Command, key string, arg ...string) *Message {
|
|||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
func (m *Message) ActionHand(cmd *Command, key, sub string, arg ...string) *Message {
|
func (m *Message) ActionHand(cmd *Command, key, sub string, arg ...string) *Message {
|
||||||
if action, ok := cmd.Actions[sub]; !m.WarnNotFound(!ok, sub, cmd.FileLines()) {
|
if action, ok := cmd.Actions[sub]; !m.WarnNotFoundIndex(!ok, sub, cmd.FileLines()) {
|
||||||
return m.Target()._action(m, cmd, key, sub, action, arg...)
|
return m.Target()._action(m, cmd, key, sub, action, arg...)
|
||||||
}
|
}
|
||||||
return m
|
return m
|
||||||
@ -192,7 +192,7 @@ func (m *Message) _command(arg ...Any) *Message {
|
|||||||
run(m.Spawn(s), s, cmd, key, list[1:]...)
|
run(m.Spawn(s), s, cmd, key, list[1:]...)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
m.WarnNotFound(!ok, kit.Format(list))
|
m.WarnNotFoundIndex(!ok, kit.Format(list))
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
func (c *Context) _command(m *Message, cmd *Command, key string, arg ...string) *Message {
|
func (c *Context) _command(m *Message, cmd *Command, key string, arg ...string) *Message {
|
||||||
|
2
go.mod
2
go.mod
@ -5,6 +5,6 @@ go 1.13
|
|||||||
require (
|
require (
|
||||||
shylinux.com/x/go-git/v5 v5.6.7
|
shylinux.com/x/go-git/v5 v5.6.7
|
||||||
shylinux.com/x/go-qrcode v0.0.3
|
shylinux.com/x/go-qrcode v0.0.3
|
||||||
shylinux.com/x/toolkits v1.0.2
|
shylinux.com/x/toolkits v1.0.3
|
||||||
shylinux.com/x/websocket v0.0.3
|
shylinux.com/x/websocket v0.0.3
|
||||||
)
|
)
|
||||||
|
2
go.sum
2
go.sum
@ -6,5 +6,7 @@ shylinux.com/x/toolkits v0.7.10 h1:65d5rkQXQ71MD8FzYnZ9DFxb1XcOYSYfmRc4j8qQsUw=
|
|||||||
shylinux.com/x/toolkits v0.7.10/go.mod h1:CHDJarGlDkg60kVsvMLYL/a5hAnRLEOShiEsMOuEp0Q=
|
shylinux.com/x/toolkits v0.7.10/go.mod h1:CHDJarGlDkg60kVsvMLYL/a5hAnRLEOShiEsMOuEp0Q=
|
||||||
shylinux.com/x/toolkits v1.0.2 h1:7MD8jovLnOurumZaujhkoD68pBxzTmRM5sskMLARhwA=
|
shylinux.com/x/toolkits v1.0.2 h1:7MD8jovLnOurumZaujhkoD68pBxzTmRM5sskMLARhwA=
|
||||||
shylinux.com/x/toolkits v1.0.2/go.mod h1:CHDJarGlDkg60kVsvMLYL/a5hAnRLEOShiEsMOuEp0Q=
|
shylinux.com/x/toolkits v1.0.2/go.mod h1:CHDJarGlDkg60kVsvMLYL/a5hAnRLEOShiEsMOuEp0Q=
|
||||||
|
shylinux.com/x/toolkits v1.0.3 h1:fEr0lBEy45ovqkzJ3e/ZTeOgNmkfGJnyOUIc19yVPn4=
|
||||||
|
shylinux.com/x/toolkits v1.0.3/go.mod h1:CHDJarGlDkg60kVsvMLYL/a5hAnRLEOShiEsMOuEp0Q=
|
||||||
shylinux.com/x/websocket v0.0.3 h1:edhLwCp0Mv1ITXqIwbVWdXdX2+vui/jRnS25K89k68I=
|
shylinux.com/x/websocket v0.0.3 h1:edhLwCp0Mv1ITXqIwbVWdXdX2+vui/jRnS25K89k68I=
|
||||||
shylinux.com/x/websocket v0.0.3/go.mod h1:3UGWkjTu3ie5NAZen7J+uLPBrO7DFeKloj6Jxo13Oiw=
|
shylinux.com/x/websocket v0.0.3/go.mod h1:3UGWkjTu3ie5NAZen7J+uLPBrO7DFeKloj6Jxo13Oiw=
|
||||||
|
9
logs.go
9
logs.go
@ -144,6 +144,12 @@ func (m *Message) WarnNotAllow(err Any, arg ...Any) bool {
|
|||||||
func (m *Message) WarnNotFound(err Any, arg ...Any) bool {
|
func (m *Message) WarnNotFound(err Any, arg ...Any) bool {
|
||||||
return m.Warn(err, ErrNotFound, kit.Simple(arg...), logs.FileLineMeta(2))
|
return m.Warn(err, ErrNotFound, kit.Simple(arg...), logs.FileLineMeta(2))
|
||||||
}
|
}
|
||||||
|
func (m *Message) WarnNotFoundSpace(err Any, arg ...Any) bool {
|
||||||
|
return m.Warn(err, ErrNotFoundSpace, kit.Simple(arg...), logs.FileLineMeta(2))
|
||||||
|
}
|
||||||
|
func (m *Message) WarnNotFoundIndex(err Any, arg ...Any) bool {
|
||||||
|
return m.Warn(err, ErrNotFoundIndex, kit.Simple(arg...), logs.FileLineMeta(2))
|
||||||
|
}
|
||||||
func (m *Message) WarnNotValid(err Any, arg ...Any) bool {
|
func (m *Message) WarnNotValid(err Any, arg ...Any) bool {
|
||||||
return m.Warn(err, ErrNotValid, kit.Simple(arg...), logs.FileLineMeta(2))
|
return m.Warn(err, ErrNotValid, kit.Simple(arg...), logs.FileLineMeta(2))
|
||||||
}
|
}
|
||||||
@ -178,7 +184,8 @@ func (m *Message) IsOk() bool { return m.Result() == OK }
|
|||||||
func (m *Message) IsErr(arg ...string) bool {
|
func (m *Message) IsErr(arg ...string) bool {
|
||||||
return len(arg) == 0 && m.index(MSG_RESULT, 0) == ErrWarn || len(arg) > 0 && m.index(MSG_RESULT, 1) == arg[0]
|
return len(arg) == 0 && m.index(MSG_RESULT, 0) == ErrWarn || len(arg) > 0 && m.index(MSG_RESULT, 1) == arg[0]
|
||||||
}
|
}
|
||||||
func (m *Message) IsErrNotFound() bool { return m.IsErr(ErrNotFound) }
|
func (m *Message) IsErrNotFound() bool { return m.IsErr(ErrNotFound) }
|
||||||
|
func (m *Message) IsErrNotFoundSpace() bool { return m.IsErr(ErrNotFoundSpace) }
|
||||||
func (m *Message) Debug(str string, arg ...Any) {
|
func (m *Message) Debug(str string, arg ...Any) {
|
||||||
if m.Option(MSG_DEBUG) == TRUE {
|
if m.Option(MSG_DEBUG) == TRUE {
|
||||||
kit.Format(str == "", func() { str = m.FormatMeta() })
|
kit.Format(str == "", func() { str = m.FormatMeta() })
|
||||||
|
Loading…
x
Reference in New Issue
Block a user