1
0
forked from x/icebergs
This commit is contained in:
IT 老营长 @云轩领航-创始人 2024-08-05 23:20:52 +08:00
parent 5a4b79b4eb
commit 41cea7f8b0
6 changed files with 16 additions and 15 deletions

View File

@ -96,6 +96,9 @@ func _serve_main(m *ice.Message, w http.ResponseWriter, r *http.Request) bool {
}
func _serve_static(msg *ice.Message, w http.ResponseWriter, r *http.Request) bool {
// _serve_params(msg, r.Header.Get(html.Referer))
if strings.HasPrefix(r.URL.Path, "/.git/") {
return false
}
_serve_params(msg, r.URL.String())
ispod := msg.Option(ice.POD) != ""
if strings.HasPrefix(r.URL.Path, nfs.V) {
@ -122,7 +125,10 @@ func _serve_static(msg *ice.Message, w http.ResponseWriter, r *http.Request) boo
return Render(msg, ice.RENDER_DOWNLOAD, p)
} else if p = path.Join(nfs.USR, r.URL.Path); kit.HasPrefix(r.URL.Path, nfs.VOLCANOS, nfs.INTSHELL) && nfs.Exists(msg, p) {
return Render(msg, ice.RENDER_DOWNLOAD, p)
} else if p = strings.TrimPrefix(r.URL.Path, nfs.REQUIRE); kit.HasPrefix(r.URL.Path, nfs.REQUIRE_SRC, nfs.REQUIRE+ice.USR_ICONS, nfs.REQUIRE+ice.USR_ICEBERGS) && nfs.Exists(msg, p) {
}
return false
p := ""
if p = strings.TrimPrefix(r.URL.Path, nfs.REQUIRE); kit.HasPrefix(r.URL.Path, nfs.REQUIRE_SRC, nfs.REQUIRE+ice.USR_ICONS, nfs.REQUIRE+ice.USR_ICEBERGS) && nfs.Exists(msg, p) {
return !ispod && Render(msg, ice.RENDER_DOWNLOAD, p)
} else if p = path.Join(nfs.USR_MODULES, strings.TrimPrefix(r.URL.Path, nfs.REQUIRE_MODULES)); kit.HasPrefix(r.URL.Path, nfs.REQUIRE_MODULES) && nfs.Exists(msg, p) {
return Render(msg, ice.RENDER_DOWNLOAD, p)
@ -165,11 +171,10 @@ func _serve_handle(key string, cmd *ice.Command, m *ice.Message, w http.Response
r.ParseMultipartForm(kit.Int64(kit.Select("4096", r.Header.Get(html.ContentLength))))
kit.For(r.PostForm, func(k string, v []string) { _log(FORM, k, kit.Join(v, lex.SP)).Optionv(k, v) })
}
kit.For(r.Cookies(), func(k, v string) { _log("cookie", k, v); m.Optionv(k, v) })
kit.For(r.Cookies(), func(k, v string) { m.Optionv(k, v) })
m.Options(ice.MSG_METHOD, r.Method, ice.MSG_COUNT, "0")
m.Options(ice.MSG_REFERER, r.Header.Get(html.Referer))
m.Options(ice.MSG_USERWEB, _serve_domain(m), ice.MSG_USERPOD, m.Option(ice.POD))
// m.Option(ice.POD, "")
m.Options(ice.MSG_USERUA, r.Header.Get(html.UserAgent), ice.MSG_USERIP, r.Header.Get(ice.MSG_USERIP))
m.Options(ice.MSG_SESSID, kit.Select(m.Option(ice.MSG_SESSID), m.Option(CookieName(m.Option(ice.MSG_USERWEB)))))
kit.If(m.Optionv(ice.MSG_CMDS) == nil, func() {
@ -214,6 +219,9 @@ func _serve_auth(m *ice.Message, key string, cmds []string, w http.ResponseWrite
aaa.SessCheck(m, m.Option(ice.MSG_SESSID))
return cmds, true
}
if !aaa.IsTechOrRoot(m) {
m.Option("user_uid", "")
}
defer func() { m.Options(ice.MSG_CMDS, "") }()
if strings.Contains(m.Option(ice.MSG_SESSID), " ") {
m.Cmdy(kit.Split(m.Option(ice.MSG_SESSID)))

View File

@ -99,7 +99,7 @@ func _space_fork(m *ice.Message) {
gdb.Event(m, SPACE_LOGIN, args)
defer gdb.Event(m, SPACE_LOGIN_CLOSE, args)
case PORTAL:
defer gdb.EventDeferEvent(m, PORTAL_OPEN, args)(PORTAL_CLOSE, args)
gdb.EventDeferEvent(m, PORTAL_OPEN, args)
m.Go(func() { m.Cmd(SPACE, name, cli.PWD, name) })
case WORKER:
defer gdb.EventDeferEvent(m, DREAM_OPEN, args)(DREAM_CLOSE, args)

View File

@ -300,6 +300,8 @@ func init() {
m.Cmd("", mdb.CREATE, kit.Select("http://localhost:20000", conf[cli.CTX_DEMO]), ice.DEMO, nfs.USR_ICONS_VOLCANOS)
m.Cmd("", mdb.CREATE, kit.Select("https://mail.shylinux.com", conf[cli.CTX_MAIL]), ice.MAIL, "usr/icons/Mail.png")
m.Cmd("", mdb.CREATE, kit.Select("https://user.shylinux.com"), aaa.USER, "usr/icons/Mail.png")
m.Cmd("", mdb.CREATE, "https://2023-contexts.shylinux.com", "2023-contexts", ice.SRC_MAIN_ICO, nfs.REPOS)
m.Cmd("", mdb.CREATE, "https://2024-contexts.shylinux.com", "2024-contexts", ice.SRC_MAIN_ICO, nfs.REPOS)
}},
mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) {
if mdb.IsSearchPreview(m, arg) {
@ -426,11 +428,9 @@ func init() {
return p + kit.Select("", nfs.PS, len(arg) == 0)
} else {
p := m.FileURI(ctx.GetCmdFile(m, m.PrefixKey()))
m.Info("what %v", p)
if pp := kit.TrimPrefix(path.Join(path.Dir(p), path.Join(arg...)), nfs.P, nfs.REQUIRE); nfs.Exists(m, pp) {
return pp
}
m.Info("what %v", ice.Info.Important)
if ice.Info.Important {
return kit.MergeURL2(SpideOrigin(m, ice.OPS)+p, path.Join(arg...))
}

View File

@ -181,10 +181,6 @@ func (m *Message) _command(arg ...Any) *Message {
}
if list[0] == "" {
run(m.Spawn(), m.target, m._cmd, m._key, list[1:]...)
// } else if cmd, ok := m.target.Commands[strings.TrimPrefix(list[0], m.target.Prefix()+PT)]; ok {
// run(m.Spawn(), m.target, cmd, list[0], list[1:]...)
// } else if cmd, ok := m.source.Commands[strings.TrimPrefix(list[0], m.source.Prefix()+PT)]; ok {
// run(m.Spawn(m.source), m.source, cmd, list[0], list[1:]...)
} else {
_target, _key := m.target, m._key
m.Search(list[0], func(p *Context, s *Context, key string, cmd *Command) {
@ -245,7 +241,7 @@ func formatArg(arg ...string) string {
return kit.Format("%d %v", len(arg), kit.ReplaceAll(kit.Format("%v", arg), "\r\n", "\\r\\n", "\t", "\\t", "\n", "\\n"))
}
func (c *Command) FileLines() string {
return kit.Join(kit.Slice(kit.Split(c.FileLine(), PS), -3), PS)
return kit.Join(kit.Slice(kit.Split(c.FileLine(), PS), -2), PS)
}
func (c *Command) FileLine() string {
if c == nil {

View File

@ -63,7 +63,7 @@ func (m *Message) log(level string, str string, arg ...Any) *Message {
}
args = append(args, v)
}
_source := logs.FileLineMeta(3)
_source := logs.Meta{logs.FILELINE, kit.FileLine(-1, 2)}
kit.If(Info.Log != nil, func() { Info.Log(m, m.FormatPrefix(traceid), level, logs.Format(str, append(args, _source)...)) })
if !strings.Contains(Info.Make.Domain, "debug=true") {
return m

View File

@ -40,12 +40,9 @@ func init() {
Index.MergeCommands(ice.Commands{
AGENT: {Name: "agent auto", Help: "代理", Role: aaa.VOID, Actions: ice.MergeActions(ice.Actions{
chat.HEADER_AGENT: {Hand: func(m *ice.Message, arg ...string) {
m.Info("what %v", m.Option(ice.MSG_USERUA))
kit.If(strings.Index(m.Option(ice.MSG_USERUA), "MicroMessenger") > -1, func() {
m.Info("what %v", m.Option(ice.MSG_USERUA))
m.Optionv(mdb.PLUGIN, m.PrefixKey(), mdb.Config(m, web.SPACE))
})
m.Info("what %v", m.FormatMeta())
}},
"getLocation": {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(location.LOCATION, mdb.CREATE, arg) }},
"scanQRCode1": {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(chat.FAVOR, mdb.CREATE, arg) }},