mirror of
https://shylinux.com/x/icebergs
synced 2025-05-03 03:57:01 +08:00
opt some
This commit is contained in:
parent
7f7ab6d62e
commit
9ff9b4ddd7
@ -46,7 +46,6 @@ func Render(m *ice.Message, cmd string, args ...ice.Any) bool {
|
||||
if cmd != "" && cmd != ice.RENDER_DOWNLOAD {
|
||||
defer func() { m.Logs("Render", cmd, args) }()
|
||||
}
|
||||
m.W.Header().Add("Access-Control-Allow-Origin", "http://localhost:9020")
|
||||
switch cmd {
|
||||
case COOKIE: // value [name [path [expire]]]
|
||||
RenderCookie(m, arg[0], arg[1:]...)
|
||||
|
@ -309,7 +309,7 @@ func init() {
|
||||
})
|
||||
ice.AddMerges(func(c *ice.Context, key string, cmd *ice.Command, sub string, action *ice.Action) (ice.Handler, ice.Handler) {
|
||||
if strings.HasPrefix(sub, ice.PS) {
|
||||
if sub = kit.Select(sub, PP(key), sub == ice.PS); action.Hand == nil {
|
||||
if sub = kit.Select(PP(key, sub), PP(key), sub == ice.PS); action.Hand == nil {
|
||||
action.Hand = func(m *ice.Message, arg ...string) { m.Cmdy(key, arg) }
|
||||
}
|
||||
actions := ice.Actions{}
|
||||
|
3
misc.go
3
misc.go
@ -321,8 +321,7 @@ func (c *Context) _action(m *Message, cmd *Command, key string, sub string, h *A
|
||||
if m._target = logs.FileLine(h.Hand); cmd.RawHand != nil {
|
||||
m._target = kit.Join(kit.Slice(kit.Split(kit.Format(cmd.RawHand), PS), -3), PS)
|
||||
}
|
||||
m.Log(LOG_CMDS, "%s.%s %s %d %v", c.Name, key, sub, len(arg), arg,
|
||||
logs.FileLineMeta(m._fileline()))
|
||||
m.Log(LOG_CMDS, "%s.%s %s %d %v", c.Name, key, sub, len(arg), arg, logs.FileLineMeta(m._fileline()))
|
||||
h.Hand(m, arg...)
|
||||
return m
|
||||
}
|
||||
|
@ -15,23 +15,25 @@ const TOKEN = "token"
|
||||
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
web.PP(TOKEN, "get"): {Name: "get", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(nfs.CAT, kit.HomePath(".git-credentials"), func(text string) {
|
||||
if strings.HasSuffix(text, ice.AT+arg[0]) {
|
||||
u := kit.ParseURL(text).User
|
||||
if p, ok := u.Password(); ok {
|
||||
m.Echo(u.Username()).Echo(p)
|
||||
TOKEN: {Name: "token username auto prunes", Actions: ice.MergeActions(ice.Actions{
|
||||
web.PP("get"): {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(nfs.CAT, kit.HomePath(".git-credentials"), func(text string) {
|
||||
if strings.HasSuffix(text, ice.AT+arg[0]) {
|
||||
u := kit.ParseURL(text)
|
||||
if p, ok := u.User.Password(); ok {
|
||||
m.Echo(u.User.Username()).Echo(p)
|
||||
m.W.Header().Add("Access-Control-Allow-Origin", u.Scheme+"://"+arg[0])
|
||||
}
|
||||
}
|
||||
})
|
||||
}},
|
||||
web.PP("sid"): {Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.Cmd(TOKEN, arg[0]).Append(TOKEN) == arg[1] {
|
||||
web.RenderCookie(m, aaa.SessCreate(m, arg[0]))
|
||||
m.Echo(ice.OK)
|
||||
}
|
||||
})
|
||||
}},
|
||||
web.PP(TOKEN, "sid"): {Name: "sid", Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.Cmd(TOKEN, arg[0]).Append(TOKEN) == arg[1] {
|
||||
web.RenderCookie(m, aaa.SessCreate(m, arg[0]))
|
||||
m.Echo(ice.OK)
|
||||
}
|
||||
}},
|
||||
TOKEN: {Name: "token username auto prunes", Actions: mdb.HashAction(mdb.EXPIRE, mdb.MONTH, mdb.SHORT, aaa.USERNAME, mdb.FIELD, "time,username,token"), Hand: func(m *ice.Message, arg ...string) {
|
||||
}},
|
||||
}, mdb.HashAction(mdb.EXPIRE, mdb.MONTH, mdb.SHORT, aaa.USERNAME, mdb.FIELD, "time,username,token")), Hand: func(m *ice.Message, arg ...string) {
|
||||
if mdb.HashSelect(m, arg...); len(arg) > 0 && m.Length() > 0 {
|
||||
m.EchoScript(strings.Replace(m.Option(ice.MSG_USERHOST), "://", kit.Format("://%s:%s@", m.Option(ice.MSG_USERNAME), m.Append(TOKEN)), 1))
|
||||
m.EchoScript(nfs.Template(m, "echo.sh", strings.Replace(m.Option(ice.MSG_USERHOST), "://", kit.Format("://%s:%s@", m.Option(ice.MSG_USERNAME), m.Append(TOKEN)), 1)))
|
||||
|
Loading…
x
Reference in New Issue
Block a user