forked from x/icebergs
add web.stream
This commit is contained in:
parent
9bc165866f
commit
d7116def5b
@ -9,9 +9,19 @@ import (
|
||||
|
||||
func _sess_create(m *ice.Message, username string, arg ...string) {
|
||||
if msg := m.Cmd(USER, username); msg.Length() > 0 {
|
||||
mdb.HashCreate(m, msg.AppendSimple(USERNICK, USERNAME, USERROLE), arg)
|
||||
mdb.HashCreate(m, msg.AppendSimple(
|
||||
USERROLE,
|
||||
USERNAME,
|
||||
USERNICK,
|
||||
AVATAR,
|
||||
), arg)
|
||||
} else {
|
||||
mdb.HashCreate(m, m.OptionSimple(USERNICK, USERNAME, USERROLE), arg)
|
||||
mdb.HashCreate(m, m.OptionSimple(
|
||||
USERROLE,
|
||||
USERNAME,
|
||||
USERNICK,
|
||||
AVATAR,
|
||||
), arg)
|
||||
}
|
||||
}
|
||||
func _sess_check(m *ice.Message, sessid string) {
|
||||
@ -38,7 +48,7 @@ func init() {
|
||||
_sess_create(m, m.Option(USERNAME), UA, m.Option(ice.MSG_USERUA), IP, m.Option(ice.MSG_USERIP))
|
||||
}},
|
||||
CHECK: {Name: "check sessid*", Hand: func(m *ice.Message, arg ...string) { _sess_check(m, m.Option(ice.MSG_SESSID)) }},
|
||||
}, mdb.ImportantHashAction(mdb.EXPIRE, mdb.MONTH, mdb.SHORT, mdb.UNIQ, mdb.FIELD, "time,hash,usernick,username,userrole,ip,ua"))},
|
||||
}, mdb.ImportantHashAction(mdb.EXPIRE, mdb.MONTH, mdb.SHORT, mdb.UNIQ, mdb.FIELD, "time,hash,userrole,username,usernick,avatar,ip,ua"))},
|
||||
})
|
||||
}
|
||||
|
||||
@ -60,6 +70,7 @@ func SessAuth(m *ice.Message, value ice.Any, arg ...string) *ice.Message {
|
||||
USERROLE, m.Option(ice.MSG_USERROLE, kit.Format(kit.Value(value, USERROLE))),
|
||||
USERNAME, m.Option(ice.MSG_USERNAME, kit.Format(kit.Value(value, USERNAME))),
|
||||
USERNICK, m.Option(ice.MSG_USERNICK, kit.Format(kit.Value(value, USERNICK))),
|
||||
AVATAR, m.Option(ice.MSG_AVATAR, kit.Format(kit.Value(value, AVATAR))),
|
||||
LANGUAGE, m.OptionDefault(ice.MSG_LANGUAGE, kit.Format(kit.Value(value, LANGUAGE))),
|
||||
arg, logs.FileLineMeta(kit.Select(logs.FileLine(-1), m.Option("aaa.checker"))),
|
||||
)
|
||||
|
@ -55,7 +55,7 @@ func init() {
|
||||
mdb.CREATE: {Name: "create usernick username* userrole=void,tech userzone language", Hand: func(m *ice.Message, arg ...string) {
|
||||
_user_create(m, m.Option(USERNAME), m.OptionSimple(USERNICK, USERROLE, USERZONE, LANGUAGE, EMAIL, BACKGROUND, AVATAR)...)
|
||||
}},
|
||||
}, mdb.ImportantHashAction(mdb.SHORT, USERNAME, mdb.FIELD, "time,usernick,username,userrole,userzone,language", html.CHECKBOX, ice.TRUE))},
|
||||
}, mdb.ImportantHashAction(mdb.SHORT, USERNAME, mdb.FIELD, "time,userrole,username,usernick,avatar,language,userzone", html.CHECKBOX, ice.TRUE))},
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,14 @@ import (
|
||||
|
||||
func _dream_list(m *ice.Message, simple bool) *ice.Message {
|
||||
list := m.CmdMap(SPACE, mdb.NAME)
|
||||
mdb.HashSelects(m).Table(func(value ice.Maps) {
|
||||
mdb.HashSelects(m.Spawn()).Table(func(value ice.Maps, index int, head []string) {
|
||||
if value["access"] == "private" {
|
||||
// return
|
||||
}
|
||||
if value["access"] == "private" && !aaa.IsTechOrRoot(m) {
|
||||
return
|
||||
}
|
||||
m.Push("", value, kit.Slice(head, 0, -1))
|
||||
if space, ok := list[value[mdb.NAME]]; ok {
|
||||
if m.IsCliUA() || simple {
|
||||
m.Push(mdb.TYPE, space[mdb.TYPE]).Push(cli.STATUS, cli.START)
|
||||
@ -414,11 +421,14 @@ func init() {
|
||||
DREAM_TABLES: {Hand: func(m *ice.Message, arg ...string) {
|
||||
switch m.Option(mdb.TYPE) {
|
||||
case WORKER:
|
||||
m.PushButton(cli.RUNTIME, tcp.SEND, OPEN)
|
||||
m.PushButton(cli.RUNTIME, tcp.SEND, OPEN, "settings")
|
||||
default:
|
||||
m.PushButton(cli.RUNTIME, DREAM, OPEN)
|
||||
}
|
||||
}},
|
||||
"settings": {Name: "settings restart=manual,always access=public,private", Help: "设置", Hand: func(m *ice.Message, arg ...string) {
|
||||
mdb.HashModify(m, m.OptionSimple(mdb.NAME, "restart", "access"))
|
||||
}},
|
||||
STATS_TABLES: {Hand: func(m *ice.Message, arg ...string) {
|
||||
if msg := _dream_list(m.Spawn(), true); msg.Length() > 0 {
|
||||
stat := map[string]int{}
|
||||
@ -429,7 +439,7 @@ func init() {
|
||||
}
|
||||
}},
|
||||
}, StatsAction(), DreamAction(), DreamTablesAction(), mdb.ImportantHashAction(
|
||||
mdb.SHORT, mdb.NAME, mdb.FIELD, "time,name,icons,repos,binary,template,restart",
|
||||
mdb.SHORT, mdb.NAME, mdb.FIELD, "time,name,icons,repos,binary,template,restart,access",
|
||||
html.BUTTON, kit.JoinWord(PORTAL, DESKTOP, ADMIN, MESSAGE, WORD, STATUS, VIMER, COMPILE, XTERM, DREAM),
|
||||
ctx.TOOLS, kit.Simple(SPIDE, ROUTE, STORE, MATRIX),
|
||||
)), Hand: func(m *ice.Message, arg ...string) {
|
||||
|
@ -13,6 +13,7 @@ Volcanos(chat.ONIMPORT, {
|
||||
})}
|
||||
})},
|
||||
] }]), can.onmotion.delay(can, function() { can.Status(mdb.COUNT, can.core.Item(list).length+"x"+can.core.List(domain).length) })
|
||||
can.onimport._online(can)
|
||||
},
|
||||
void: function(can, name, domain, list) { var worker = list[name][""], server = list[""][domain]
|
||||
return {view: html.ACTION, _init: function(target) {
|
||||
|
@ -268,20 +268,24 @@ func IsLocalHost(m *ice.Message) bool {
|
||||
return (m.R == nil || m.R.Header.Get(html.XForwardedFor) == "") && tcp.IsLocalHost(m, m.Option(ice.MSG_USERIP))
|
||||
}
|
||||
func ParseUA(m *ice.Message) (res []string) {
|
||||
res = append(res, aaa.IP, m.Option(ice.MSG_USERIP), aaa.UA, m.Option(ice.MSG_USERUA))
|
||||
res = append(res, aaa.USERROLE, m.Option(ice.MSG_USERROLE))
|
||||
res = append(res, aaa.USERNAME, m.Option(ice.MSG_USERNAME))
|
||||
res = append(res, aaa.USERNICK, m.Option(ice.MSG_USERNICK))
|
||||
res = append(res, aaa.AVATAR, m.Option(ice.MSG_AVATAR))
|
||||
res = append(res, cli.DAEMON, m.Option(ice.MSG_DAEMON))
|
||||
for _, p := range html.AgentList {
|
||||
if strings.Contains(m.Option(ice.MSG_USERUA), p) {
|
||||
res = append(res, mdb.ICONS, agentIcons[p], AGENT, p)
|
||||
break
|
||||
}
|
||||
}
|
||||
for _, p := range html.SystemList {
|
||||
if strings.Contains(m.Option(ice.MSG_USERUA), p) {
|
||||
res = append(res, cli.SYSTEM, p)
|
||||
break
|
||||
}
|
||||
}
|
||||
for _, p := range html.AgentList {
|
||||
if strings.Contains(m.Option(ice.MSG_USERUA), p) {
|
||||
res = append(res, AGENT, p, mdb.ICONS, agentIcons[p])
|
||||
break
|
||||
}
|
||||
}
|
||||
return
|
||||
return append(res, aaa.IP, m.Option(ice.MSG_USERIP), aaa.UA, m.Option(ice.MSG_USERUA))
|
||||
}
|
||||
func Script(m *ice.Message, str string, arg ...ice.Any) string {
|
||||
return ice.Render(m, ice.RENDER_SCRIPT, kit.Format(str, arg...))
|
||||
|
39
base/web/stream.go
Normal file
39
base/web/stream.go
Normal file
@ -0,0 +1,39 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/cli"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
const STREAM = "stream"
|
||||
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
STREAM: {Name: "stream hash daemon auto", Help: "在线", Actions: ice.MergeActions(ice.Actions{
|
||||
ONLINE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
mdb.HashCreate(m, SPACE, m.Option(ice.MSG_SPACE), ctx.INDEX, m.Option(ice.MSG_INDEX),
|
||||
mdb.SHORT, cli.DAEMON, mdb.FIELD, mdb.Config(m, mdb.FIELDS))
|
||||
m.Option(mdb.SUBKEY, kit.Keys(mdb.HASH, kit.Hashs(kit.Fields(m.Option(ice.MSG_SPACE), m.Option(ice.MSG_INDEX)))))
|
||||
mdb.HashCreate(m, ParseUA(m))
|
||||
mdb.HashSelect(m.Options(ice.MSG_FIELDS, mdb.Config(m, mdb.FIELDS)))
|
||||
}},
|
||||
"push": {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Option(mdb.SUBKEY, kit.Keys(mdb.HASH, kit.Hashs(kit.Fields(m.Option(ice.MSG_SPACE), m.Option(ice.MSG_INDEX)))))
|
||||
mdb.HashSelect(m).Table(func(value ice.Maps) { m.Cmd(SPACE, value[cli.DAEMON], arg) })
|
||||
}},
|
||||
}, mdb.HashAction(
|
||||
mdb.SHORT, "space,index", mdb.FIELD, "time,hash,space,index",
|
||||
mdb.FIELDS, "time,daemon,userrole,username,usernick,avatar,icons,agent,system,ip,ua",
|
||||
)), Hand: func(m *ice.Message, arg ...string) {
|
||||
if len(arg) == 0 {
|
||||
mdb.HashSelect(m)
|
||||
} else {
|
||||
m.Option(mdb.SUBKEY, kit.Keys(mdb.HASH, arg[0]))
|
||||
mdb.HashSelect(m.Options(ice.MSG_FIELDS, mdb.Config(m, mdb.FIELDS)), arg[1:]...)
|
||||
}
|
||||
}},
|
||||
})
|
||||
}
|
@ -82,6 +82,7 @@ func init() {
|
||||
BROAD, SERVE, SPACE, DREAM, ROUTE,
|
||||
SHARE, TOKEN, STATS, COUNT, TOAST,
|
||||
SPIDE, CACHE, STORE, ADMIN, MATRIX,
|
||||
STREAM,
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -101,6 +101,7 @@ func init() {
|
||||
}
|
||||
}},
|
||||
aaa.LOGOUT: {Hand: aaa.SessLogout},
|
||||
web.ONLINE: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(web.STREAM, web.ONLINE) }},
|
||||
cli.QRCODE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
link := tcp.PublishLocalhost(m, m.Option(ice.MSG_USERWEB))
|
||||
m.Push(mdb.NAME, link).PushQRCode(mdb.TEXT, kit.MergeURL(link, ice.FROM_DAEMON, m.Option(ice.MSG_DAEMON)))
|
||||
|
@ -2,6 +2,7 @@ Volcanos(chat.ONIMPORT, {
|
||||
_init: function(can, msg) {
|
||||
// if (can.isCmdMode()) { can.onappend.style(can, html.OUTPUT) }
|
||||
can.ui = can.onappend.layout(can), can.onimport._project(can, msg)
|
||||
can.onimport._online(can)
|
||||
},
|
||||
_project: function(can, msg) { var select, current = can.db.hash[0]||ice.DEV
|
||||
can.page.insertBefore(can, [{view: wiki.TITLE, list: [
|
||||
|
Loading…
x
Reference in New Issue
Block a user