mirror of
https://shylinux.com/x/icebergs
synced 2025-04-26 17:44:05 +08:00
opt some
This commit is contained in:
parent
1355ba9432
commit
0c50d80214
@ -56,8 +56,7 @@ func _dream_show(m *ice.Message, name string) {
|
|||||||
cli.CTX_OPS, "http://localhost:"+m.CmdAppend(SERVE, tcp.PORT),
|
cli.CTX_OPS, "http://localhost:"+m.CmdAppend(SERVE, tcp.PORT),
|
||||||
cli.PATH, cli.BinPath(kit.Path(p, ice.BIN)), cli.USER, ice.Info.UserName,
|
cli.PATH, cli.BinPath(kit.Path(p, ice.BIN)), cli.USER, ice.Info.UserName,
|
||||||
kit.EnvSimple(cli.HOME, cli.TERM, cli.SHELL), m.Configv(cli.ENV),
|
kit.EnvSimple(cli.HOME, cli.TERM, cli.SHELL), m.Configv(cli.ENV),
|
||||||
))
|
), cli.CMD_OUTPUT, path.Join(p, ice.BIN_BOOT_LOG))
|
||||||
m.Optionv(cli.CMD_OUTPUT, path.Join(p, ice.BIN_BOOT_LOG))
|
|
||||||
defer m.Options(cli.CMD_DIR, "", cli.CMD_ENV, "", cli.CMD_OUTPUT, "")
|
defer m.Options(cli.CMD_DIR, "", cli.CMD_ENV, "", cli.CMD_OUTPUT, "")
|
||||||
gdb.Event(m, DREAM_CREATE, m.OptionSimple(mdb.NAME, mdb.TYPE))
|
gdb.Event(m, DREAM_CREATE, m.OptionSimple(mdb.NAME, mdb.TYPE))
|
||||||
bin := kit.Select(os.Args[0], cli.SystemFind(m, ice.ICE_BIN, nfs.PWD+path.Join(p, ice.BIN), nfs.PWD+ice.BIN))
|
bin := kit.Select(os.Args[0], cli.SystemFind(m, ice.ICE_BIN, nfs.PWD+path.Join(p, ice.BIN), nfs.PWD+ice.BIN))
|
||||||
|
@ -20,22 +20,14 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func _share_render(m *ice.Message, arg ...string) {
|
func _share_render(m *ice.Message, arg ...string) {
|
||||||
ice.AddRender(ice.RENDER_DOWNLOAD, func(msg *ice.Message, args ...ice.Any) string {
|
ice.AddRender(ice.RENDER_DOWNLOAD, func(msg *ice.Message, arg ...ice.Any) string {
|
||||||
list := []string{}
|
args := kit.Simple(arg...)
|
||||||
if msg.Option(ice.MSG_USERPOD) != "" {
|
list := []string{ice.POD, msg.Option(ice.MSG_USERPOD), "filename", kit.Select("", args[0], len(args) > 1)}
|
||||||
list = append(list, ice.POD, msg.Option(ice.MSG_USERPOD))
|
return fmt.Sprintf(`<a href="%s" download="%s">%s</a>`, _share_link(msg, kit.Select(args[0], args, 1), list), path.Base(args[0]), args[0])
|
||||||
}
|
|
||||||
|
|
||||||
arg := kit.Simple(args...)
|
|
||||||
if len(arg) > 1 {
|
|
||||||
list = append(list, "filename", arg[0])
|
|
||||||
}
|
|
||||||
return fmt.Sprintf(`<a href="%s" download="%s">%s</a>`,
|
|
||||||
_share_link(msg, kit.Select(arg[0], arg, 1), list), path.Base(arg[0]), arg[0])
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
func _share_link(m *ice.Message, p string, arg ...ice.Any) string {
|
func _share_link(m *ice.Message, p string, arg ...ice.Any) string {
|
||||||
p = kit.Select("", SHARE_LOCAL, !strings.HasPrefix(p, ice.PS)) + p
|
p = kit.Select("", SHARE_LOCAL, !strings.HasPrefix(p, ice.PS) && !strings.HasPrefix(p, ice.HTTP)) + p
|
||||||
return tcp.PublishLocalhost(m, MergeLink(m, p, arg...))
|
return tcp.PublishLocalhost(m, MergeLink(m, p, arg...))
|
||||||
}
|
}
|
||||||
func _share_cache(m *ice.Message, arg ...string) {
|
func _share_cache(m *ice.Message, arg ...string) {
|
||||||
@ -54,45 +46,33 @@ func _share_cache(m *ice.Message, arg ...string) {
|
|||||||
func _share_local(m *ice.Message, arg ...string) {
|
func _share_local(m *ice.Message, arg ...string) {
|
||||||
p := path.Join(arg...)
|
p := path.Join(arg...)
|
||||||
switch ls := strings.Split(p, ice.PS); ls[0] {
|
switch ls := strings.Split(p, ice.PS); ls[0] {
|
||||||
case ice.ETC, ice.VAR: // 私有文件
|
case ice.ETC, ice.VAR:
|
||||||
if m.Option(ice.MSG_USERROLE) == aaa.VOID {
|
if m.Warn(m.Option(ice.MSG_USERROLE) == aaa.VOID, ice.ErrNotRight, p) {
|
||||||
m.Render(STATUS, http.StatusUnauthorized, ice.ErrNotRight)
|
return
|
||||||
return // 没有权限
|
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
if !aaa.Right(m, ls) && m.Option(ice.POD) == "" {
|
if m.Option(ice.POD) == "" && !aaa.Right(m, ls) {
|
||||||
m.Render(STATUS, http.StatusUnauthorized, ice.ErrNotRight)
|
return
|
||||||
return // 没有权限
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if m.Option(ice.POD) == "" {
|
if m.Option(ice.POD) == "" {
|
||||||
m.RenderDownload(p)
|
m.RenderDownload(p)
|
||||||
return // 本地文件
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
pp := path.Join(ice.VAR_PROXY, m.Option(ice.POD), p)
|
pp := path.Join(ice.VAR_PROXY, m.Option(ice.POD), p)
|
||||||
cache, size := time.Now().Add(-time.Hour*240000), int64(0)
|
cache, size := time.Now().Add(-time.Hour*24), int64(0)
|
||||||
if s, e := file.StatFile(pp); e == nil {
|
if s, e := file.StatFile(pp); e == nil {
|
||||||
cache, size = s.ModTime(), s.Size()
|
cache, size = s.ModTime(), s.Size()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 上传文件
|
|
||||||
if p == ice.BIN_ICE_BIN {
|
if p == ice.BIN_ICE_BIN {
|
||||||
aaa.UserRoot(m).Cmd(SPACE, m.Option(ice.POD), SPIDE, "submit", MergeURL2(m, SHARE_PROXY, nfs.PATH, ""), m.Option(ice.POD), p, size, cache.Format(ice.MOD_TIME))
|
aaa.UserRoot(m).Cmd(SPACE, m.Option(ice.POD), SPIDE, "submit", MergeURL2(m, SHARE_PROXY, nfs.PATH, ""), m.Option(ice.POD), p, size, cache.Format(ice.MOD_TIME))
|
||||||
} else {
|
} else {
|
||||||
m.Cmd(SPACE, m.Option(ice.POD), SPIDE, ice.DEV, SPIDE_RAW, MergeURL2(m, SHARE_PROXY, nfs.PATH, ""),
|
m.Cmd(SPACE, m.Option(ice.POD), SPIDE, ice.DEV, SPIDE_RAW, MergeURL2(m, SHARE_PROXY, nfs.PATH, ""),
|
||||||
SPIDE_PART, m.OptionSimple(ice.POD), nfs.PATH, p, nfs.SIZE, size, CACHE, cache.Format(ice.MOD_TIME), UPLOAD, "@"+p)
|
SPIDE_PART, m.OptionSimple(ice.POD), nfs.PATH, p, nfs.SIZE, size, CACHE, cache.Format(ice.MOD_TIME), UPLOAD, "@"+p)
|
||||||
}
|
}
|
||||||
if s, e := file.StatFile(pp); e == nil && !s.IsDir() {
|
if !m.Warn(!file.ExistsFile(pp), ice.ErrNotFound, pp) {
|
||||||
p = pp
|
m.RenderDownload(pp)
|
||||||
}
|
}
|
||||||
|
|
||||||
if m.Warn(!file.ExistsFile(p)) {
|
|
||||||
m.RenderStatusNotFound()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
m.RenderDownload(p)
|
|
||||||
}
|
}
|
||||||
func _share_proxy(m *ice.Message) {
|
func _share_proxy(m *ice.Message) {
|
||||||
switch p := path.Join(ice.VAR_PROXY, m.Option(ice.POD), m.Option(nfs.PATH)); m.R.Method {
|
switch p := path.Join(ice.VAR_PROXY, m.Option(ice.POD), m.Option(nfs.PATH)); m.R.Method {
|
||||||
@ -166,8 +146,8 @@ func init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
}, mdb.HashAction(mdb.FIELD, "time,hash,userrole,username,usernick,river,storm,type,name,text", mdb.EXPIRE, "72h"), ServeAction(), aaa.WhiteAction()), Hand: func(m *ice.Message, arg ...string) {
|
}, mdb.HashAction(mdb.FIELD, "time,hash,username,usernick,userrole,river,storm,type,name,text", mdb.EXPIRE, "72h"), ServeAction(), aaa.WhiteAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||||
if ctx.PodCmd(m, SHARE, arg) && m.Length() > 0 {
|
if ctx.PodCmd(m, SHARE, arg) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if mdb.HashSelect(m, arg...); len(arg) > 0 {
|
if mdb.HashSelect(m, arg...); len(arg) > 0 {
|
||||||
@ -181,7 +161,7 @@ func init() {
|
|||||||
}},
|
}},
|
||||||
PP(SHARE): {Name: "/share/", Help: "共享链", Hand: func(m *ice.Message, arg ...string) {
|
PP(SHARE): {Name: "/share/", Help: "共享链", Hand: func(m *ice.Message, arg ...string) {
|
||||||
msg := m.Cmd(SHARE, m.Option(SHARE, kit.Select(m.Option(SHARE), arg, 0)))
|
msg := m.Cmd(SHARE, m.Option(SHARE, kit.Select(m.Option(SHARE), arg, 0)))
|
||||||
if m.Warn(msg.Append(mdb.TIME) < msg.Time(), ice.ErrNotValid, kit.Select(m.Option(SHARE), arg, 0), msg.Append(mdb.TIME)) {
|
if IsNotValidShare(m, msg.Append(mdb.TIME)) {
|
||||||
m.RenderResult(kit.Format("共享超时, 请联系 %s(%s), 重新分享 %s %s",
|
m.RenderResult(kit.Format("共享超时, 请联系 %s(%s), 重新分享 %s %s",
|
||||||
msg.Append(aaa.USERNAME), msg.Append(aaa.USERNICK), msg.Append(mdb.TYPE), msg.Append(mdb.NAME)))
|
msg.Append(aaa.USERNAME), msg.Append(aaa.USERNICK), msg.Append(mdb.TYPE), msg.Append(mdb.NAME)))
|
||||||
return
|
return
|
||||||
@ -218,10 +198,6 @@ func init() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsNotValidShare(m *ice.Message, value ice.Maps) bool {
|
func IsNotValidShare(m *ice.Message, time string) bool {
|
||||||
_source := logs.FileLineMeta(logs.FileLine(2))
|
return m.Warn(time < m.Time(), ice.ErrNotValid, m.Option(SHARE), time, m.Time(), logs.FileLineMeta(2))
|
||||||
if m.Warn(value[mdb.TIME] < m.Time(), ice.ErrNotValid, m.Option(SHARE), value[mdb.TIME], m.Time(), _source) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
@ -106,19 +106,7 @@ func init() {
|
|||||||
web.WEBSITE: {Name: "website", Help: "网页", Hand: func(m *ice.Message, arg ...string) {
|
web.WEBSITE: {Name: "website", Help: "网页", Hand: func(m *ice.Message, arg ...string) {
|
||||||
web.ProcessWebsite(m, "", "", m.OptionSimple(mdb.HASH))
|
web.ProcessWebsite(m, "", "", m.OptionSimple(mdb.HASH))
|
||||||
}},
|
}},
|
||||||
web.DREAM_TABLES: {Hand: func(m *ice.Message, arg ...string) {
|
}, mdb.HashAction(mdb.FIELD, "time,hash,type,name,text,view", mdb.TOOLS, FAVOR), ctx.CmdAction(), ctx.ProcessAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||||
switch m.Option(mdb.TYPE) {
|
|
||||||
case web.SERVER, web.WORKER:
|
|
||||||
m.PushButton(kit.Dict(m.CommandKey(), "终端"))
|
|
||||||
}
|
|
||||||
}},
|
|
||||||
web.DREAM_ACTION: {Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
if arg[1] == m.CommandKey() {
|
|
||||||
web.ProcessIframe(m, web.MergePodCmd(m, m.Option(mdb.NAME), m.PrefixKey(), mdb.HASH, m.Cmdx(SPACE, m.Option(mdb.NAME), m.PrefixKey(), mdb.CREATE, mdb.TYPE, nfs.SH, m.OptionSimple(mdb.NAME))), arg...)
|
|
||||||
// web.ProcessWebsite(m, m.Option(mdb.NAME), m.PrefixKey(), mdb.HASH, m.Cmdx(SPACE, m.Option(mdb.NAME), m.PrefixKey(), mdb.CREATE, mdb.TYPE, nfs.SH, m.OptionSimple(mdb.NAME)))
|
|
||||||
}
|
|
||||||
}},
|
|
||||||
}, mdb.HashAction(mdb.FIELD, "time,hash,type,name,text,view", mdb.TOOLS, FAVOR), ctx.CmdAction(), ctx.ProcessAction(), web.DreamAction()), Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
if mdb.HashSelect(m, arg...); len(arg) == 0 {
|
if mdb.HashSelect(m, arg...); len(arg) == 0 {
|
||||||
m.PushAction(web.WEBSITE, mdb.REMOVE)
|
m.PushAction(web.WEBSITE, mdb.REMOVE)
|
||||||
m.Action(mdb.CREATE, mdb.PRUNES)
|
m.Action(mdb.CREATE, mdb.PRUNES)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user