mirror of
https://shylinux.com/x/icebergs
synced 2025-04-26 01:24:05 +08:00
opt broad
This commit is contained in:
parent
9860966b10
commit
18ec7a9329
@ -114,10 +114,10 @@ func _serve_domain(m *ice.Message) string {
|
||||
)
|
||||
}
|
||||
func _serve_auth(m *ice.Message, key string, cmds []string, w http.ResponseWriter, r *http.Request) ([]string, bool) {
|
||||
defer func() { m.Options(ice.MSG_CMDS, "", ice.MSG_SESSID, "") }()
|
||||
if r.URL.Path == PP(SPACE) {
|
||||
return cmds, true
|
||||
}
|
||||
defer func() { m.Options(ice.MSG_CMDS, "", ice.MSG_SESSID, "") }()
|
||||
if aaa.SessCheck(m, m.Option(ice.MSG_SESSID)); m.Option(SHARE) != "" {
|
||||
switch msg := m.Cmd(SHARE, m.Option(SHARE)); msg.Append(mdb.TYPE) {
|
||||
case FIELD, STORM:
|
||||
@ -145,10 +145,8 @@ const (
|
||||
HTTP = "http"
|
||||
HTTPS = "https"
|
||||
DOMAIN = "domain"
|
||||
INDEX = "index"
|
||||
FORM = "form"
|
||||
BODY = "body"
|
||||
SSO = "sso"
|
||||
|
||||
ApplicationJSON = "Application/json"
|
||||
)
|
||||
@ -157,10 +155,7 @@ const SERVE = "serve"
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{"/exit": {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(ice.EXIT) }},
|
||||
SERVE: {Name: "serve name auto start", Help: "服务器", Actions: ice.MergeActions(ice.Actions{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||
ice.Info.Localhost = mdb.Config(m, tcp.LOCALHOST) == ice.TRUE
|
||||
cli.NodeInfo(m, ice.Info.Pathname, WORKER)
|
||||
}},
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { cli.NodeInfo(m, ice.Info.Pathname, WORKER) }},
|
||||
DOMAIN: {Hand: func(m *ice.Message, arg ...string) {
|
||||
kit.If(len(arg) > 0, func() { ice.Info.Domain, ice.Info.Localhost = arg[0], false })
|
||||
m.Echo(ice.Info.Domain)
|
||||
@ -179,7 +174,7 @@ func init() {
|
||||
kit.If(!opened, func() { cli.Opens(m, _serve_address(m)) })
|
||||
})
|
||||
}},
|
||||
}, mdb.HashAction(mdb.SHORT, mdb.NAME, mdb.FIELD, "time,status,name,proto,host,port", tcp.LOCALHOST, ice.TRUE), mdb.ClearOnExitHashAction())},
|
||||
}, mdb.HashAction(mdb.SHORT, mdb.NAME, mdb.FIELD, "time,status,name,proto,host,port"), mdb.ClearOnExitHashAction())},
|
||||
})
|
||||
ice.AddMergeAction(func(c *ice.Context, key string, cmd *ice.Command, sub string, action *ice.Action) {
|
||||
if strings.HasPrefix(sub, ice.PS) {
|
||||
|
@ -50,7 +50,7 @@ func _share_proxy(m *ice.Message) {
|
||||
}
|
||||
|
||||
const (
|
||||
THEME = "tospic"
|
||||
THEME = "theme"
|
||||
LOGIN = "login"
|
||||
RIVER = "river"
|
||||
STORM = "storm"
|
||||
@ -70,7 +70,7 @@ func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
SHARE: {Name: "share hash auto login prunes", Help: "共享链", Actions: ice.MergeActions(ice.Actions{
|
||||
mdb.CREATE: {Name: "create type name text", Hand: func(m *ice.Message, arg ...string) {
|
||||
mdb.HashCreate(m, arg, aaa.USERNAME, m.Option(ice.MSG_USERNAME), aaa.USERNICK, m.Option(ice.MSG_USERNICK), aaa.USERROLE, m.Option(ice.MSG_USERROLE))
|
||||
mdb.HashCreate(m, arg, aaa.USERNICK, m.Option(ice.MSG_USERNICK), aaa.USERNAME, m.Option(ice.MSG_USERNAME), aaa.USERROLE, m.Option(ice.MSG_USERROLE))
|
||||
m.Option(mdb.LINK, _share_link(m, P(SHARE, m.Result())))
|
||||
}},
|
||||
LOGIN: {Hand: func(m *ice.Message, arg ...string) {
|
||||
@ -83,7 +83,7 @@ func init() {
|
||||
msg := m.Cmd(SHARE, m.Option(SHARE, arg[0]))
|
||||
if IsNotValidShare(m, msg.Append(mdb.TIME)) {
|
||||
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.USERNICK), msg.Append(aaa.USERNAME), msg.Append(mdb.TYPE), msg.Append(mdb.NAME)))
|
||||
return
|
||||
}
|
||||
switch msg.Append(mdb.TYPE) {
|
||||
@ -93,7 +93,7 @@ func init() {
|
||||
RenderMain(m)
|
||||
}
|
||||
}},
|
||||
}, mdb.HashAction(mdb.FIELD, "time,hash,username,usernick,userrole,river,storm,type,name,text", mdb.EXPIRE, mdb.DAYS), aaa.WhiteAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||
}, mdb.HashAction(mdb.FIELD, "time,hash,type,name,text,river,storm,usernick,username,userrole", mdb.EXPIRE, mdb.DAYS), aaa.WhiteAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||
if ctx.PodCmd(m, SHARE, arg) {
|
||||
return
|
||||
}
|
||||
@ -113,7 +113,7 @@ func init() {
|
||||
m.RenderDownload(strings.TrimPrefix(m.Cmdv(aaa.USER, m.Option(ice.MSG_USERNAME), aaa.BACKGROUND), SHARE_LOCAL))
|
||||
}},
|
||||
SHARE_PROXY: {Hand: func(m *ice.Message, arg ...string) { _share_proxy(m) }},
|
||||
SHARE_TOAST: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(SPACE, arg[0], kit.UnMarshal(m.Option("arg"))) }},
|
||||
SHARE_TOAST: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(SPACE, arg[0], kit.UnMarshal(m.Option(ice.ARG))) }},
|
||||
})
|
||||
}
|
||||
func IsNotValidShare(m *ice.Message, time string) bool {
|
||||
@ -140,13 +140,8 @@ func ShareLocalFile(m *ice.Message, arg ...string) {
|
||||
if s, e := file.StatFile(pp); e == nil {
|
||||
cache, size = s.ModTime(), s.Size()
|
||||
}
|
||||
if p == ice.BIN_ICE_BIN {
|
||||
m.Option(ice.MSG_USERROLE, aaa.TECH)
|
||||
}
|
||||
m.Cmd(SPACE, m.Option(ice.POD), SPIDE, ice.DEV, SPIDE_RAW, MergeLink(m, SHARE_PROXY), SPIDE_PART, m.OptionSimple(ice.POD), nfs.PATH, p, nfs.SIZE, size, CACHE, cache.Format(ice.MOD_TIME), UPLOAD, "@"+p)
|
||||
if file.ExistsFile(pp) {
|
||||
m.RenderDownload(pp)
|
||||
} else {
|
||||
m.RenderDownload(p)
|
||||
}
|
||||
kit.If(p == ice.BIN_ICE_BIN, func() { m.Option(ice.MSG_USERROLE, aaa.TECH) })
|
||||
m.Cmd(SPACE, m.Option(ice.POD), SPIDE, ice.DEV, SPIDE_RAW, MergeLink(m, SHARE_PROXY),
|
||||
SPIDE_PART, m.OptionSimple(ice.POD), nfs.PATH, p, nfs.SIZE, size, CACHE, cache.Format(ice.MOD_TIME), UPLOAD, ice.AT+p)
|
||||
m.RenderDownload(kit.Select(p, pp, file.ExistsFile(pp)))
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ func _space_handle(m *ice.Message, safe bool, name string, c *websocket.Conn) {
|
||||
}
|
||||
msg := m.Spawn(b)
|
||||
source, target := kit.Simple(msg.Optionv(ice.MSG_SOURCE), name), kit.Simple(msg.Optionv(ice.MSG_TARGET))
|
||||
msg.Log("recv", "%v->%v %v %v", source, target, msg.Detailv(), msg.FormatsMeta(nil))
|
||||
msg.Log(tcp.RECV, "%v->%v %v %v", source, target, msg.Detailv(), msg.FormatsMeta(nil))
|
||||
if next := msg.Option(ice.MSG_TARGET); next == "" || len(target) == 0 {
|
||||
if safe { // 下行命令
|
||||
msg.Option(ice.MSG_USERROLE, aaa.UserRole(msg, msg.Option(ice.MSG_USERNAME)))
|
||||
@ -120,14 +120,14 @@ func _space_exec(m *ice.Message, source, target []string, c *websocket.Conn) {
|
||||
}
|
||||
func _space_echo(m *ice.Message, source, target []string, c *websocket.Conn) {
|
||||
if m.Options(ice.MSG_SOURCE, source, ice.MSG_TARGET, target[1:]); !m.Warn(c.WriteMessage(1, []byte(m.FormatMeta()))) {
|
||||
m.Log("send", "%v->%v %v %v", source, target, m.Detailv(), m.FormatsMeta(nil))
|
||||
m.Log(tcp.SEND, "%v->%v %v %v", source, target, m.Detailv(), m.FormatsMeta(nil))
|
||||
}
|
||||
}
|
||||
func _space_send(m *ice.Message, name string, arg ...string) {
|
||||
wait, done := m.Wait(func(msg *ice.Message, arg ...string) {
|
||||
m.Cost(kit.Format("%v->[%v] %v %v", m.Optionv(ice.MSG_SOURCE), name, m.Detailv(), msg.FormatSize())).Copy(msg)
|
||||
})
|
||||
h := mdb.HashCreate(m.Spawn(), mdb.TYPE, "send", mdb.NAME, kit.Keys(name, m.Target().ID()), mdb.TEXT, kit.Join(arg, ice.SP), kit.Dict(mdb.TARGET, done))
|
||||
h := mdb.HashCreate(m.Spawn(), mdb.TYPE, tcp.SEND, mdb.NAME, kit.Keys(name, m.Target().ID()), mdb.TEXT, kit.Join(arg, ice.SP), kit.Dict(mdb.TARGET, done))
|
||||
defer mdb.HashRemove(m, mdb.HASH, h)
|
||||
if target := kit.Split(name, ice.PT, ice.PT); mdb.HashSelectDetail(m, target[0], func(value ice.Map) {
|
||||
if c, ok := value[mdb.TARGET].(*websocket.Conn); !m.Warn(!ok, ice.ErrNotValid, mdb.TARGET) {
|
||||
|
@ -52,8 +52,8 @@ func _header_check(m *ice.Message, arg ...string) bool {
|
||||
if m.Option(ice.MSG_USERNAME) != "" {
|
||||
return true
|
||||
}
|
||||
if ctx.OptionFromConfig(m, web.SSO) == "" && ctx.OptionFromConfig(m, web.LOGIN) == "" {
|
||||
m.Option(web.SSO, GetSSO(m))
|
||||
if ctx.OptionFromConfig(m, SSO) == "" && ctx.OptionFromConfig(m, web.LOGIN) == "" {
|
||||
m.Option(SSO, GetSSO(m))
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user