1
0
mirror of https://shylinux.com/x/icebergs synced 2025-04-26 01:24:05 +08:00
This commit is contained in:
harveyshao 2021-04-29 23:59:15 +08:00
parent e3ed4d0944
commit a24e75a232
5 changed files with 24 additions and 13 deletions

View File

@ -57,15 +57,9 @@ func _serve_main(m *ice.Message, w http.ResponseWriter, r *http.Request) bool {
// 主页接口
if r.Method == "GET" && r.URL.Path == "/" {
msg, repos := m.Spawn(), ice.INTSHELL
if msg.W, msg.R = w, r; strings.Contains(r.Header.Get("User-Agent"), "curl") {
repos = ice.INTSHELL
} else {
repos = ice.VOLCANOS
if ice.DumpBinPack(w, r.URL.Path, func(name string) { RenderType(w, name, "") }) {
return false
}
}
msg := m.Spawn()
msg.W, msg.R = w, r
repos := kit.Select(ice.INTSHELL, ice.VOLCANOS, strings.Contains(r.Header.Get("User-Agent"), "Mozilla/5.0"))
Render(msg, ice.RENDER_DOWNLOAD, path.Join(m.Conf(SERVE, kit.Keym(repos, kit.SSH_PATH)), m.Conf(SERVE, kit.Keym(repos, kit.SSH_INDEX))))
return false
}

View File

@ -253,10 +253,16 @@ func init() {
m.Event(SPACE_START, args...)
defer m.Event(SPACE_STOP, args...)
}
switch kind {
case "chrome":
case CHROME:
if m.Option(ice.MSG_USERNAME) != "" {
break
}
link := kit.MergeURL(m.Conf(SHARE, kit.Keym(kit.MDB_DOMAIN)), "auth", name)
m.Cmd(SPACE, name, "pwd", name, link, m.Cmdx(cli.QRCODE, link))
go func() {
m.Sleep("100ms").Cmd(SPACE, name, "pwd", name, link, m.Cmdx(cli.QRCODE, link))
}()
}
frame := m.Target().Server().(*Frame)

View File

@ -121,7 +121,7 @@ func init() {
}},
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if len(arg) < 2 || arg[0] == "" || (len(arg) > 3 && arg[3] == "") {
m.Option(mdb.FIELDS, kit.Select("time,client.name,client.method,client.url", mdb.DETAIL, len(arg) > 0 && arg[0] != ""))
m.Fields(len(arg) == 0 || arg[0] == "", "time,client.name,client.url")
m.Cmdy(mdb.SELECT, SPIDE, "", mdb.HASH, "client.name", arg)
m.PushAction(mdb.REMOVE)
return

View File

@ -60,6 +60,7 @@ func init() {
return
}
m.Cmd(aaa.ROLE, kit.Select(aaa.TECH, aaa.VOID, m.Option(ice.MSG_USERROLE) == aaa.VOID), m.Option(ice.MSG_USERNAME))
m.Cmd(web.SPACE, m.Option(web.SPACE), ice.MSG_SESSID, aaa.SessCreate(m, m.Option(ice.MSG_USERNAME)))
}},
web.SHARE: {Name: "share type", Help: "共享", Hand: func(m *ice.Message, arg ...string) {

12
misc.go
View File

@ -109,8 +109,12 @@ func (m *Message) PushSearchWeb(cmd string, name string) {
})
}
func (m *Message) IsTermUA() bool {
return m.Option(MSG_USERUA) == "" || strings.Contains(m.Option(MSG_USERUA), "curl")
}
func Render(m *Message, cmd string, args ...interface{}) string {
if m.Option(MSG_USERUA) == "" || strings.Contains(m.Option(MSG_USERUA), "curl") {
if m.IsTermUA() {
switch arg := kit.Simple(args...); cmd {
case RENDER_QRCODE: // text [size]
return m.Cmdx("cli.qrcode", arg[0])
@ -181,9 +185,15 @@ func (m *Message) PushDownload(key string, arg ...interface{}) { // [name] file
m.Push(key, Render(m, RENDER_DOWNLOAD, arg...))
}
func (m *Message) PushAnchor(arg ...interface{}) { // [name] link
if m.IsTermUA() {
return
}
m.Push(kit.MDB_LINK, Render(m, RENDER_ANCHOR, arg...))
}
func (m *Message) PushButton(arg ...string) {
if m.IsTermUA() {
return
}
m.Push(kit.MDB_ACTION, Render(m, RENDER_BUTTON, strings.Join(arg, ",")))
}
func (m *Message) PushScript(arg ...string) *Message { // [type] text...