forked from x/icebergs
opt space.go
This commit is contained in:
parent
a0ec7370b1
commit
ee976ee357
@ -32,7 +32,7 @@ func init() {
|
|||||||
content := []byte(kit.JoinKV(DF, NL, "From", m.Option(USERNAME), "To", m.Option(TO), "Subject", m.Option(SUBJECT), "Content-Type", "text/html; charset=UTF-8") + NL + NL + m.Option(CONTENT))
|
content := []byte(kit.JoinKV(DF, NL, "From", m.Option(USERNAME), "To", m.Option(TO), "Subject", m.Option(SUBJECT), "Content-Type", "text/html; charset=UTF-8") + NL + NL + m.Option(CONTENT))
|
||||||
auth := smtp.PlainAuth("", m.Option(USERNAME), m.Option(PASSWORD), kit.Split(m.Option(SERVICE), ice.DF)[0])
|
auth := smtp.PlainAuth("", m.Option(USERNAME), m.Option(PASSWORD), kit.Split(m.Option(SERVICE), ice.DF)[0])
|
||||||
m.Warn(smtp.SendMail(m.Option(SERVICE), auth, m.Option(USERNAME), kit.Split(m.Option(TO)), content))
|
m.Warn(smtp.SendMail(m.Option(SERVICE), auth, m.Option(USERNAME), kit.Split(m.Option(TO)), content))
|
||||||
m.Debug("email send %v %v", auth, string(content))
|
m.Logs(mdb.EXPORT, EMAIL, auth, string(content))
|
||||||
}},
|
}},
|
||||||
}, mdb.HashAction(mdb.SHORT, mdb.NAME, mdb.FIELD, "time,name,service,username,password")), Hand: func(m *ice.Message, arg ...string) {
|
}, mdb.HashAction(mdb.SHORT, mdb.NAME, mdb.FIELD, "time,name,service,username,password")), Hand: func(m *ice.Message, arg ...string) {
|
||||||
mdb.HashSelect(m, arg...).PushAction(SEND, mdb.REMOVE)
|
mdb.HashSelect(m, arg...).PushAction(SEND, mdb.REMOVE)
|
||||||
|
@ -48,7 +48,6 @@ func _system_cmd(m *ice.Message, arg ...string) *exec.Cmd {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
cmd := exec.Command(bin, arg[1:]...)
|
cmd := exec.Command(bin, arg[1:]...)
|
||||||
m.Debug("what %v", m.Option("cmd_dir"))
|
|
||||||
if cmd.Dir = kit.TrimPath(m.Option(CMD_DIR)); len(cmd.Dir) > 0 {
|
if cmd.Dir = kit.TrimPath(m.Option(CMD_DIR)); len(cmd.Dir) > 0 {
|
||||||
if m.Logs(mdb.EXPORT, CMD_DIR, cmd.Dir); !nfs.ExistsFile(m, cmd.Dir) {
|
if m.Logs(mdb.EXPORT, CMD_DIR, cmd.Dir); !nfs.ExistsFile(m, cmd.Dir) {
|
||||||
file.MkdirAll(cmd.Dir, ice.MOD_DIR)
|
file.MkdirAll(cmd.Dir, ice.MOD_DIR)
|
||||||
|
@ -87,8 +87,8 @@ func _dream_template(m *ice.Message, p string) {
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
DREAM_CREATE = "dream.create"
|
DREAM_CREATE = "dream.create"
|
||||||
DREAM_START = "dream.start"
|
DREAM_OPEN = "dream.open"
|
||||||
DREAM_STOP = "dream.stop"
|
DREAM_CLOSE = "dream.close"
|
||||||
|
|
||||||
DREAM_INPUTS = "dream.inputs"
|
DREAM_INPUTS = "dream.inputs"
|
||||||
DREAM_TABLES = "dream.tables"
|
DREAM_TABLES = "dream.tables"
|
||||||
@ -121,13 +121,15 @@ func init() {
|
|||||||
nfs.TRASH: {Hand: func(m *ice.Message, arg ...string) {
|
nfs.TRASH: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
nfs.Trash(m, path.Join(ice.USR_LOCAL_WORK, m.Option(mdb.NAME)))
|
nfs.Trash(m, path.Join(ice.USR_LOCAL_WORK, m.Option(mdb.NAME)))
|
||||||
}},
|
}},
|
||||||
DREAM_STOP: {Hand: func(m *ice.Message, arg ...string) {
|
DREAM_OPEN: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
if m.CmdAppend(SPACE, m.Option(mdb.NAME), mdb.STATUS) != cli.STOP {
|
if m.Option(cli.DAEMON) == ice.OPS {
|
||||||
m.Go(func() { m.Sleep3s(DREAM, cli.START, m.OptionSimple(mdb.NAME)) })
|
if m.CmdAppend(SPACE, m.Option(mdb.NAME), mdb.STATUS) != cli.STOP {
|
||||||
|
m.Go(func() { m.Sleep3s(DREAM, cli.START, m.OptionSimple(mdb.NAME)) })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
OPEN: {Hand: func(m *ice.Message, arg ...string) { ProcessIframe(m, MergePod(m, m.Option(mdb.NAME)), arg...) }},
|
OPEN: {Hand: func(m *ice.Message, arg ...string) { ProcessIframe(m, MergePod(m, m.Option(mdb.NAME)), arg...) }},
|
||||||
}, ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) {
|
}, ctx.CmdAction(), gdb.EventsAction(DREAM_OPEN)), Hand: func(m *ice.Message, arg ...string) {
|
||||||
if len(arg) == 0 {
|
if len(arg) == 0 {
|
||||||
_dream_list(m)
|
_dream_list(m)
|
||||||
} else if arg[0] == ctx.ACTION {
|
} else if arg[0] == ctx.ACTION {
|
||||||
|
@ -71,8 +71,7 @@ func Toast(m *ice.Message, text string, arg ...ice.Any) { // [title [duration [p
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
m.Go(func() { PushNoticeToast(m, text, arg) })
|
||||||
PushNoticeToast(m, text, arg)
|
|
||||||
}
|
}
|
||||||
func Toast3s(m *ice.Message, text string, arg ...ice.Any) {
|
func Toast3s(m *ice.Message, text string, arg ...ice.Any) {
|
||||||
Toast(m, text, kit.List(kit.Select("", arg, 0), kit.Select("3s", arg, 1))...)
|
Toast(m, text, kit.List(kit.Select("", arg, 0), kit.Select("3s", arg, 1))...)
|
||||||
|
@ -9,7 +9,6 @@ import (
|
|||||||
ice "shylinux.com/x/icebergs"
|
ice "shylinux.com/x/icebergs"
|
||||||
"shylinux.com/x/icebergs/base/aaa"
|
"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/gdb"
|
"shylinux.com/x/icebergs/base/gdb"
|
||||||
"shylinux.com/x/icebergs/base/mdb"
|
"shylinux.com/x/icebergs/base/mdb"
|
||||||
"shylinux.com/x/icebergs/base/tcp"
|
"shylinux.com/x/icebergs/base/tcp"
|
||||||
@ -18,54 +17,44 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func _space_dial(m *ice.Message, dev, name string, arg ...string) {
|
func _space_dial(m *ice.Message, dev, name string, arg ...string) {
|
||||||
msg := m.Cmd(SPIDE, dev)
|
msg := m.Cmd(SPIDE, tcp.CLIENT, dev, PP(SPACE))
|
||||||
proto, host := strings.Replace(msg.Append(kit.Keys(tcp.CLIENT, tcp.PROTOCOL)), ice.HTTP, "ws", 1), msg.Append(kit.Keys(tcp.CLIENT, tcp.HOSTNAME))
|
uri := kit.ParseURL(strings.Replace(kit.MergeURL(msg.Append(DOMAIN), mdb.TYPE, ice.Info.NodeType, mdb.NAME, name, SHARE, ice.Info.CtxShare, RIVER, ice.Info.CtxRiver, arg), ice.HTTP, "ws", 1))
|
||||||
uri := kit.ParseURL(kit.MergeURL(proto+"://"+host+PP(SPACE), mdb.TYPE, ice.Info.NodeType, mdb.NAME, name, SHARE, ice.Info.CtxShare, RIVER, ice.Info.CtxRiver, arg))
|
args := kit.SimpleKV("type,name,host,port", msg.Append(tcp.PROTOCOL), dev, msg.Append(tcp.HOST), msg.Append(tcp.PORT))
|
||||||
m.Go(func() {
|
m.Go(func() {
|
||||||
ls := strings.Split(host, ice.DF)
|
redial := kit.Dict(m.Configv(REDIAL))
|
||||||
args := kit.SimpleKV("type,name,host,port", proto, dev, ls[0], kit.Select(kit.Select("443", "80", proto == "ws"), ls, 1))
|
|
||||||
redial, _ := m.Configv(REDIAL).(ice.Map)
|
|
||||||
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 := 0; i >= 0 && i < c; i++ {
|
for i := 0; i < c; i++ {
|
||||||
next := time.Duration(rand.Intn(a*(i+1))+b*i) * time.Millisecond
|
next := time.Duration(rand.Intn(a*(i+1))+b*i) * 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 conn, _, e := websocket.NewClient(c, uri, nil, kit.Int(redial["r"]), kit.Int(redial["w"])); !m.Warn(e) {
|
if conn, _, e := websocket.NewClient(c, uri, nil, kit.Int(redial["r"]), kit.Int(redial["w"])); !m.Warn(e, tcp.DIAL, dev, SPACE, uri.String()) {
|
||||||
mdb.HashCreate(m, kit.SimpleKV("", MASTER, dev, host), kit.Dict(mdb.TARGET, conn))
|
mdb.HashCreate(m, kit.SimpleKV("", MASTER, dev, msg.Append(tcp.HOSTNAME)), kit.Dict(mdb.TARGET, conn))
|
||||||
defer mdb.HashRemove(m, mdb.NAME, name)
|
defer mdb.HashRemove(m, dev)
|
||||||
if i = 0; _space_handle(m, true, dev, conn, m.Target().Server().(*Frame)) {
|
_space_handle(m, true, dev, conn)
|
||||||
i = -2
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}).Cost("order", i, "sleep", next, "redial", dev).Sleep(next)
|
}).Cost("order", i, "sleep", next, "redial", dev).Sleep(next)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
func _space_fork(m *ice.Message) {
|
func _space_fork(m *ice.Message) {
|
||||||
buffer, _ := m.Configv(BUFFER).(ice.Map)
|
buffer := kit.Dict(m.Configv(BUFFER))
|
||||||
if conn, e := websocket.Upgrade(m.W, m.R, nil, kit.Int(buffer["r"]), kit.Int(buffer["w"])); m.Assert(e) {
|
if conn, e := websocket.Upgrade(m.W, m.R, nil, kit.Int(buffer["r"]), kit.Int(buffer["w"])); m.Assert(e) {
|
||||||
text := kit.Select(m.Option(ice.MSG_USERADDR), m.Option(mdb.TEXT))
|
text := kit.Select(m.Option(ice.MSG_USERADDR), m.Option(mdb.TEXT))
|
||||||
name := strings.ToLower(kit.ReplaceAll(kit.Select(m.Option(ice.MSG_USERADDR), m.Option(mdb.NAME)), ice.PT, "_", ice.DF, "_"))
|
name := strings.ToLower(kit.ReplaceAll(kit.Select(m.Option(ice.MSG_USERADDR), m.Option(mdb.NAME)), ice.PT, "_", ice.DF, "_"))
|
||||||
args := append([]string{mdb.TYPE, kit.Select(WORKER, m.Option(mdb.TYPE)), mdb.NAME, name, mdb.TEXT, text}, m.OptionSimple(SHARE, RIVER, ice.MSG_USERUA)...)
|
args := kit.Simple(mdb.TYPE, kit.Select(WORKER, m.Option(mdb.TYPE)), mdb.NAME, name, mdb.TEXT, text, m.OptionSimple(SHARE, RIVER, ice.MSG_USERUA))
|
||||||
m.Go(func() {
|
m.Go(func() {
|
||||||
mdb.HashCreate(m, args, kit.Dict(mdb.TARGET, conn))
|
defer kit.BeginEnd(func() { mdb.HashCreate(m, args, kit.Dict(mdb.TARGET, conn)) }, func() { mdb.HashRemove(m, name) })()
|
||||||
defer mdb.HashRemove(m, m.OptionSimple(mdb.NAME))
|
defer kit.BeginEnd(func() { gdb.Event(m, SPACE_OPEN, args) }, func() { gdb.Event(m, SPACE_CLOSE, args) })()
|
||||||
gdb.Event(m, SPACE_OPEN, args)
|
|
||||||
defer gdb.Event(m, SPACE_CLOSE, args)
|
|
||||||
switch m.Option(mdb.TYPE) {
|
switch m.Option(mdb.TYPE) {
|
||||||
|
case WORKER:
|
||||||
|
defer kit.BeginEnd(func() { gdb.Event(m, DREAM_OPEN, args) }, func() { gdb.Event(m, DREAM_CLOSE, args) })()
|
||||||
case CHROME:
|
case CHROME:
|
||||||
m.Cmd(SPACE, name, cli.PWD, name)
|
m.Cmd(SPACE, name, cli.PWD, name)
|
||||||
case WORKER:
|
|
||||||
gdb.Event(m, DREAM_START, args)
|
|
||||||
defer gdb.Event(m, DREAM_STOP, args)
|
|
||||||
if m.Option(cli.DAEMON) == ice.OPS {
|
|
||||||
defer m.Cmd(DREAM, DREAM_STOP, args)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_space_handle(m, false, name, conn, m.Target().Server().(*Frame))
|
_space_handle(m, false, name, conn)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func _space_handle(m *ice.Message, safe bool, name string, conn *websocket.Conn, f *Frame) bool {
|
func _space_handle(m *ice.Message, safe bool, name string, conn *websocket.Conn) {
|
||||||
for {
|
for {
|
||||||
_, b, e := conn.ReadMessage()
|
_, b, e := conn.ReadMessage()
|
||||||
if m.Warn(e, SPACE, name) {
|
if m.Warn(e, SPACE, name) {
|
||||||
@ -73,34 +62,37 @@ func _space_handle(m *ice.Message, safe bool, name string, conn *websocket.Conn,
|
|||||||
}
|
}
|
||||||
msg := m.Spawn(b)
|
msg := m.Spawn(b)
|
||||||
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))
|
||||||
msg.Log("recv", "%v->%v %s %v", source, target, msg.Detailv(), msg.FormatMeta())
|
msg.Log("recv", "%v->%v %v %v", source, target, msg.Detailv(), msg.FormatMeta())
|
||||||
if len(target) == 0 {
|
if next := msg.Option(ice.MSG_TARGET); next == "" || len(target) == 0 {
|
||||||
if msg.Optionv(ice.MSG_HANDLE, ice.TRUE); safe { // 下行命令
|
if msg.Optionv(ice.MSG_HANDLE, ice.TRUE); safe { // 下行命令
|
||||||
gdb.Event(msg, SPACE_LOGIN)
|
gdb.Event(msg, SPACE_LOGIN)
|
||||||
} else { // 上行请求
|
} else { // 上行请求
|
||||||
msg.Option(ice.MSG_USERROLE, aaa.VOID)
|
msg.Option(ice.MSG_USERROLE, aaa.VOID)
|
||||||
}
|
}
|
||||||
msg.Go(func() { _space_exec(msg, source, target, conn) })
|
msg.Go(func() { _space_exec(msg, source, target, conn) })
|
||||||
} else if mdb.HashSelectDetail(msg, target[0], func(value ice.Map) {
|
} else if mdb.HashSelectDetail(msg, next, func(value ice.Map) {
|
||||||
if conn, ok := value[mdb.TARGET].(*websocket.Conn); !m.Warn(!ok, ice.ErrNotValid, target[0]) {
|
if conn, ok := value[mdb.TARGET].(*websocket.Conn); !m.Warn(!ok, ice.ErrNotValid, next) {
|
||||||
_space_echo(msg, source, target, conn) // 转发报文
|
_space_echo(msg, source, target, conn) // 转发报文
|
||||||
}
|
}
|
||||||
}) {
|
}) {
|
||||||
} else if res, ok := f.getSend(msg.Option(ice.MSG_TARGET)); !m.Warn(!ok || len(target) != 1) {
|
} else if res := getSend(m, next); !m.Warn(res == nil || len(target) != 1, ice.ErrNotFound, next) {
|
||||||
res.Cost(kit.Format("[%v]->%v %v %v", f.delSend(res.Option(ice.MSG_SOURCE)), res.Option(ice.MSG_TARGET), res.Detailv(), msg.FormatSize()))
|
res.Cost(kit.Format("[%v]->%v %v %v", next, res.Optionv(ice.MSG_TARGET), res.Detailv(), msg.FormatSize()))
|
||||||
back(res, msg) // 接收响应
|
back(res, msg) // 接收响应
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
func _space_domain(m *ice.Message) (link string) {
|
func _space_domain(m *ice.Message) (link string) {
|
||||||
return kit.GetValid(
|
return kit.GetValid(
|
||||||
func() string { return ice.Info.Domain },
|
func() string { return ice.Info.Domain },
|
||||||
func() string { return m.CmdAppend(SPACE, ice.OPS, cli.PWD, kit.Dict(ice.MSG_OPTS, ice.MSG_USERNAME), mdb.LINK) },
|
func() string {
|
||||||
|
return m.CmdAppend(SPACE, ice.OPS, cli.PWD, kit.Dict(ice.MSG_OPTS, ice.MSG_USERNAME), mdb.LINK)
|
||||||
|
},
|
||||||
func() string { return m.CmdAppend(SPACE, ice.DEV, cli.PWD, mdb.LINK) },
|
func() string { return m.CmdAppend(SPACE, ice.DEV, cli.PWD, mdb.LINK) },
|
||||||
func() string { return m.CmdAppend(SPACE, ice.SHY, cli.PWD, mdb.LINK) },
|
func() string { return m.CmdAppend(SPACE, ice.SHY, cli.PWD, mdb.LINK) },
|
||||||
func() string { return tcp.PublishLocalhost(m, m.Option(ice.MSG_USERWEB)) },
|
func() string { return tcp.PublishLocalhost(m, m.Option(ice.MSG_USERWEB)) },
|
||||||
func() string { return kit.Format("http://%s:%s", m.CmdAppend(tcp.HOST, aaa.IP), kit.Select(m.Option(tcp.PORT), m.CmdAppend(SERVE, tcp.PORT))) })
|
func() string {
|
||||||
|
return kit.Format("http://%s:%s", m.CmdAppend(tcp.HOST, aaa.IP), kit.Select(m.Option(tcp.PORT), m.CmdAppend(SERVE, tcp.PORT)))
|
||||||
|
})
|
||||||
}
|
}
|
||||||
func _space_exec(msg *ice.Message, source, target []string, conn *websocket.Conn) {
|
func _space_exec(msg *ice.Message, source, target []string, conn *websocket.Conn) {
|
||||||
switch kit.Select(cli.PWD, msg.Detailv(), 0) {
|
switch kit.Select(cli.PWD, msg.Detailv(), 0) {
|
||||||
@ -122,7 +114,7 @@ func _space_echo(m *ice.Message, source, target []string, conn *websocket.Conn)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
func _space_send(m *ice.Message, space string, arg ...string) {
|
func _space_send(m *ice.Message, space string, arg ...string) {
|
||||||
if space == "" || space == MYSELF || space == ice.Info.NodeName {
|
if space == "" || space == ice.Info.NodeName {
|
||||||
m.Cmdy(arg)
|
m.Cmdy(arg)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -134,10 +126,9 @@ func _space_send(m *ice.Message, space string, arg ...string) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
m.Set(ice.MSG_DETAIL, arg...).Optionv(ice.MSG_OPTION, m.Optionv(ice.MSG_OPTS, m.Optionv(ice.MSG_OPTS)))
|
m.Set(ice.MSG_DETAIL, arg...).Optionv(ice.MSG_OPTION, m.Optionv(ice.MSG_OPTS, m.Optionv(ice.MSG_OPTS)))
|
||||||
target, f := kit.Split(space, ice.PT, ice.PT), m.Target().Server().(*Frame)
|
if target := kit.Split(space, ice.PT, ice.PT); !m.Warn(!mdb.HashSelectDetail(m, target[0], func(value ice.Map) {
|
||||||
if !m.Warn(!mdb.HashSelectDetail(m, target[0], func(value ice.Map) {
|
|
||||||
if conn, ok := value[mdb.TARGET].(*websocket.Conn); !m.Warn(!ok, ice.ErrNotValid, mdb.TARGET) {
|
if conn, ok := value[mdb.TARGET].(*websocket.Conn); !m.Warn(!ok, ice.ErrNotValid, mdb.TARGET) {
|
||||||
_space_echo(m, []string{f.addSend(kit.Format(m.Target().ID()), m)}, target, conn)
|
_space_echo(m, []string{addSend(m, m)}, target, conn)
|
||||||
}
|
}
|
||||||
}), ice.ErrNotFound, space) {
|
}), ice.ErrNotFound, space) {
|
||||||
call(m, m.Config(kit.Keys(TIMEOUT, "c")), func(res *ice.Message) { m.Copy(res) })
|
call(m, m.Config(kit.Keys(TIMEOUT, "c")), func(res *ice.Message) { m.Copy(res) })
|
||||||
@ -167,7 +158,6 @@ const SPACE = "space"
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
PP(SPACE): {Hand: func(m *ice.Message, arg ...string) { _space_fork(m) }},
|
|
||||||
SPACE: {Name: "space name cmd auto", Help: "空间站", Actions: ice.MergeActions(ice.Actions{
|
SPACE: {Name: "space name cmd auto", Help: "空间站", Actions: ice.MergeActions(ice.Actions{
|
||||||
ice.CTX_EXIT: {Hand: func(m *ice.Message, arg ...string) { m.Conf("", mdb.HASH, "") }},
|
ice.CTX_EXIT: {Hand: func(m *ice.Message, arg ...string) { m.Conf("", mdb.HASH, "") }},
|
||||||
tcp.DIAL: {Name: "dial dev=ops name", Hand: func(m *ice.Message, arg ...string) {
|
tcp.DIAL: {Name: "dial dev=ops name", Hand: func(m *ice.Message, arg ...string) {
|
||||||
@ -188,53 +178,23 @@ func init() {
|
|||||||
} else {
|
} else {
|
||||||
m.Option(ice.MSG_USERROLE, kit.Select(m.Option(ice.MSG_USERROLE), m.CmdAppend(aaa.USER, m.Option(ice.MSG_USERNAME), aaa.USERROLE)))
|
m.Option(ice.MSG_USERROLE, kit.Select(m.Option(ice.MSG_USERROLE), m.CmdAppend(aaa.USER, m.Option(ice.MSG_USERNAME), aaa.USERROLE)))
|
||||||
}
|
}
|
||||||
m.Auth(aaa.USERNAME, m.Option(ice.MSG_USERNAME), aaa.USERNICK, m.Option(ice.MSG_USERNICK), aaa.USERROLE, m.Option(ice.MSG_USERROLE))
|
aaa.SessAuth(m, kit.Dict(aaa.USERNAME, m.Option(ice.MSG_USERNAME), aaa.USERNICK, m.Option(ice.MSG_USERNICK), aaa.USERROLE, m.Option(ice.MSG_USERROLE)))
|
||||||
}},
|
}},
|
||||||
DREAM_TABLES: {Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
switch m.Option(mdb.TYPE) {
|
|
||||||
case CHROME:
|
|
||||||
if m.Option(mdb.NAME) != kit.Select("", kit.Split(m.Option(ice.MSG_DAEMON), ice.PT), 0) {
|
|
||||||
m.PushButton(mdb.REMOVE)
|
|
||||||
}
|
|
||||||
case WORKER, SERVER:
|
|
||||||
m.PushButton(OPEN)
|
|
||||||
}
|
|
||||||
}},
|
|
||||||
DREAM_ACTION: {Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
if arg[1] == m.CommandKey() {
|
|
||||||
ProcessWebsite(m, m.Option(mdb.NAME), m.PrefixKey())
|
|
||||||
}
|
|
||||||
}},
|
|
||||||
OPEN: {Hand: func(m *ice.Message, arg ...string) { ProcessIframe(m, MergePod(m, m.Option(mdb.NAME)), arg...) }},
|
|
||||||
DOMAIN: {Hand: func(m *ice.Message, arg ...string) { m.Echo(_space_domain(m)) }},
|
DOMAIN: {Hand: func(m *ice.Message, arg ...string) { m.Echo(_space_domain(m)) }},
|
||||||
|
ice.PS: {Hand: func(m *ice.Message, arg ...string) { _space_fork(m) }},
|
||||||
}, mdb.HashAction(mdb.SHORT, mdb.NAME, mdb.FIELD, "time,type,name,text",
|
}, mdb.HashAction(mdb.SHORT, mdb.NAME, mdb.FIELD, "time,type,name,text",
|
||||||
REDIAL, kit.Dict("a", 3000, "b", 1000, "c", 1000), TIMEOUT, kit.Dict("c", "30s"),
|
REDIAL, kit.Dict("a", 3000, "b", 1000, "c", 1000), TIMEOUT, kit.Dict("c", "30s"),
|
||||||
BUFFER, kit.Dict("r", ice.MOD_BUFS, "w", ice.MOD_BUFS),
|
BUFFER, kit.Dict("r", ice.MOD_BUFS, "w", ice.MOD_BUFS),
|
||||||
), SpaceAction(), DreamAction(), ctx.CmdAction(), aaa.WhiteAction()), Hand: func(m *ice.Message, arg ...string) {
|
), SpaceAction(), aaa.WhiteAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||||
if len(arg) > 0 && arg[0] == ctx.ACTION {
|
if len(arg) < 2 {
|
||||||
gdb.Event(m, DREAM_ACTION, arg)
|
mdb.HashSelect(m, arg...).Sort("type,name,text")
|
||||||
return
|
} else {
|
||||||
} else if len(arg) > 1 {
|
|
||||||
_space_send(m, strings.ToLower(arg[0]), kit.Simple(kit.Split(arg[1]), arg[2:])...)
|
_space_send(m, strings.ToLower(arg[0]), kit.Simple(kit.Split(arg[1]), arg[2:])...)
|
||||||
return
|
|
||||||
} else if mdb.HashSelect(m, arg...); len(arg) > 0 {
|
|
||||||
m.Sort("type,name,text")
|
|
||||||
}
|
}
|
||||||
if m.IsCliUA() {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
m.Tables(func(value ice.Maps) {
|
|
||||||
if msg := gdb.Event(m.Spawn(), DREAM_TABLES, mdb.NAME, value[mdb.NAME], mdb.TYPE, value[mdb.TYPE]); len(msg.Appendv(ctx.ACTION)) > 0 {
|
|
||||||
m.PushButton(strings.Join(msg.Appendv(ctx.ACTION), ""))
|
|
||||||
} else {
|
|
||||||
m.PushButton("")
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}},
|
}},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func SpaceAction() ice.Actions {
|
func SpaceAction() ice.Actions {
|
||||||
return gdb.EventsAction(SPACE_START, SPACE_OPEN, SPACE_LOGIN, SPACE_CLOSE, SPACE_STOP)
|
return gdb.EventsAction(SPACE_START, SPACE_OPEN, SPACE_LOGIN, SPACE_CLOSE, SPACE_STOP)
|
||||||
}
|
}
|
||||||
@ -267,3 +227,9 @@ func back(m *ice.Message, res *ice.Message) bool {
|
|||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
func addSend(m *ice.Message, msg *ice.Message) string {
|
||||||
|
return m.Target().Server().(*Frame).addSend(kit.Format(m.Target().ID()), msg)
|
||||||
|
}
|
||||||
|
func getSend(m *ice.Message, key string) *ice.Message {
|
||||||
|
return m.Target().Server().(*Frame).getSend(key)
|
||||||
|
}
|
||||||
|
@ -384,6 +384,15 @@ func init() {
|
|||||||
SUBMIT: {Name: "submit dev pod path size cache", Help: "发布", Hand: func(m *ice.Message, arg ...string) {
|
SUBMIT: {Name: "submit dev pod path size cache", Help: "发布", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmdy(SPIDE, ice.DEV, SPIDE_RAW, m.Option(ice.DEV), SPIDE_PART, m.OptionSimple(ice.POD), nfs.PATH, ice.BIN_ICE_BIN, UPLOAD, "@"+ice.BIN_ICE_BIN)
|
m.Cmdy(SPIDE, ice.DEV, SPIDE_RAW, m.Option(ice.DEV), SPIDE_PART, m.OptionSimple(ice.POD), nfs.PATH, ice.BIN_ICE_BIN, UPLOAD, "@"+ice.BIN_ICE_BIN)
|
||||||
}},
|
}},
|
||||||
|
"client": {Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
msg := m.Cmd("", kit.Select(ice.DEV, arg, 0))
|
||||||
|
ls := kit.Split(msg.Append("client.hostname"), ice.DF)
|
||||||
|
m.Push(tcp.HOST, ls[0])
|
||||||
|
m.Push(tcp.PORT, kit.Select(kit.Select("443", "80", msg.Append("client.protocol") == ice.HTTP), ls, 1))
|
||||||
|
m.Push(tcp.HOSTNAME, msg.Append("client.hostname"))
|
||||||
|
m.Push(tcp.PROTOCOL, msg.Append("client.protocol"))
|
||||||
|
m.Push(DOMAIN, msg.Append("client.protocol")+"://"+msg.Append("client.hostname")+kit.Select("", arg, 1))
|
||||||
|
}},
|
||||||
}, mdb.HashAction(mdb.SHORT, CLIENT_NAME, mdb.FIELD, "time,client.name,client.url", LOGHEADERS, ice.FALSE)), Hand: func(m *ice.Message, arg ...string) {
|
}, mdb.HashAction(mdb.SHORT, CLIENT_NAME, mdb.FIELD, "time,client.name,client.url", LOGHEADERS, ice.FALSE)), Hand: func(m *ice.Message, arg ...string) {
|
||||||
if len(arg) < 2 || arg[0] == "" || (len(arg) > 3 && arg[3] == "") {
|
if len(arg) < 2 || arg[0] == "" || (len(arg) > 3 && arg[3] == "") {
|
||||||
mdb.HashSelect(m, kit.Slice(arg, 0, 1)...).Sort(CLIENT_NAME)
|
mdb.HashSelect(m, kit.Slice(arg, 0, 1)...).Sort(CLIENT_NAME)
|
||||||
|
@ -86,20 +86,16 @@ func (f *Frame) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
f.ServeMux.ServeHTTP(w, r)
|
f.ServeMux.ServeHTTP(w, r)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func (f *Frame) getSend(key string) (*ice.Message, bool) {
|
|
||||||
defer f.lock.RLock()()
|
|
||||||
msg, ok := f.send[key]
|
|
||||||
return msg, ok
|
|
||||||
}
|
|
||||||
func (f *Frame) addSend(key string, msg *ice.Message) string {
|
func (f *Frame) addSend(key string, msg *ice.Message) string {
|
||||||
defer f.lock.Lock()()
|
defer f.lock.Lock()()
|
||||||
f.send[key] = msg
|
f.send[key] = msg
|
||||||
return key
|
return key
|
||||||
}
|
}
|
||||||
func (f *Frame) delSend(key string) string {
|
func (f *Frame) getSend(key string) *ice.Message {
|
||||||
defer f.lock.Lock()()
|
defer f.lock.RLock()()
|
||||||
|
msg, _ := f.send[key]
|
||||||
delete(f.send, key)
|
delete(f.send, key)
|
||||||
return key
|
return msg
|
||||||
}
|
}
|
||||||
|
|
||||||
const WEB = "web"
|
const WEB = "web"
|
||||||
|
7
logs.go
7
logs.go
@ -147,10 +147,11 @@ func (m *Message) Error(err bool, arg ...Any) bool {
|
|||||||
}
|
}
|
||||||
func (m *Message) error(arg ...Any) {
|
func (m *Message) error(arg ...Any) {
|
||||||
if len(arg) > 2 {
|
if len(arg) > 2 {
|
||||||
str, meta := m.join(arg[2:]...)
|
str, _ := m.join(arg[2:]...)
|
||||||
arg = append(arg[0:2], str, meta)
|
m.Resultv(ErrWarn, kit.Simple(arg[0], arg[1], SP+str))
|
||||||
|
} else {
|
||||||
|
m.Resultv(ErrWarn, kit.Simple(arg))
|
||||||
}
|
}
|
||||||
m.Resultv(ErrWarn, kit.Simple(arg))
|
|
||||||
}
|
}
|
||||||
func (m *Message) IsOk() bool { return m.Result() == OK }
|
func (m *Message) IsOk() bool { return m.Result() == OK }
|
||||||
func (m *Message) IsErr(arg ...string) bool {
|
func (m *Message) IsErr(arg ...string) bool {
|
||||||
|
@ -76,7 +76,7 @@ func init() {
|
|||||||
_git_cmd(m, CLONE, "-b", kit.Select(MASTER, m.Option(BRANCH)), m.Option(REPOS), m.Option(nfs.PATH))
|
_git_cmd(m, CLONE, "-b", kit.Select(MASTER, m.Option(BRANCH)), m.Option(REPOS), m.Option(nfs.PATH))
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
web.DREAM_START: {Hand: func(m *ice.Message, arg ...string) {
|
web.DREAM_OPEN: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmd("web.code.git.repos", mdb.CREATE, m.OptionSimple(nfs.REPOS), nfs.PATH, m.Option(nfs.PATH))
|
m.Cmd("web.code.git.repos", mdb.CREATE, m.OptionSimple(nfs.REPOS), nfs.PATH, m.Option(nfs.PATH))
|
||||||
}},
|
}},
|
||||||
}, mdb.HashAction(mdb.SHORT, mdb.NAME, mdb.FIELD, "time,name,branch,commit,remote")), Hand: func(m *ice.Message, arg ...string) {
|
}, mdb.HashAction(mdb.SHORT, mdb.NAME, mdb.FIELD, "time,name,branch,commit,remote")), Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
@ -132,7 +132,8 @@ func init() {
|
|||||||
_tmux_cmd(m, KILL_PANE, "-t", _tmux_key(m.Option(SESSION), m.Option(WINDOW), m.Option(PANE)))
|
_tmux_cmd(m, KILL_PANE, "-t", _tmux_key(m.Option(SESSION), m.Option(WINDOW), m.Option(PANE)))
|
||||||
|
|
||||||
} else if m.Option(WINDOW) != "" { // 删除窗口
|
} else if m.Option(WINDOW) != "" { // 删除窗口
|
||||||
_tmux_cmd(m, KILL_WINDOW, "-t", _tmux_key(m.Option(SESSION), m.Option(WINDOW)))
|
// _tmux_cmd(m, KILL_WINDOW, "-t", _tmux_key(m.Option(SESSION), m.Option(WINDOW)))
|
||||||
|
_tmux_cmd(m, KILL_WINDOW, "-t", _tmux_key(m.Option(SESSION), m.Option(mdb.ID)))
|
||||||
|
|
||||||
} else if m.Option(SESSION) != "" { // 删除会话
|
} else if m.Option(SESSION) != "" { // 删除会话
|
||||||
_tmux_cmd(m, KILL_SESSION, "-t", m.Option(SESSION))
|
_tmux_cmd(m, KILL_SESSION, "-t", m.Option(SESSION))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user