1
0
mirror of https://shylinux.com/x/icebergs synced 2025-05-03 12:07:00 +08:00
This commit is contained in:
IT 老营长 @云轩领航-创始人 2023-03-19 22:34:37 +08:00
parent 7f7ab6d62e
commit 9ff9b4ddd7
4 changed files with 19 additions and 19 deletions

View File

@ -46,7 +46,6 @@ func Render(m *ice.Message, cmd string, args ...ice.Any) bool {
if cmd != "" && cmd != ice.RENDER_DOWNLOAD { if cmd != "" && cmd != ice.RENDER_DOWNLOAD {
defer func() { m.Logs("Render", cmd, args) }() defer func() { m.Logs("Render", cmd, args) }()
} }
m.W.Header().Add("Access-Control-Allow-Origin", "http://localhost:9020")
switch cmd { switch cmd {
case COOKIE: // value [name [path [expire]]] case COOKIE: // value [name [path [expire]]]
RenderCookie(m, arg[0], arg[1:]...) RenderCookie(m, arg[0], arg[1:]...)

View File

@ -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) { 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 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) } action.Hand = func(m *ice.Message, arg ...string) { m.Cmdy(key, arg) }
} }
actions := ice.Actions{} actions := ice.Actions{}

View File

@ -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 { 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._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, m.Log(LOG_CMDS, "%s.%s %s %d %v", c.Name, key, sub, len(arg), arg, logs.FileLineMeta(m._fileline()))
logs.FileLineMeta(m._fileline()))
h.Hand(m, arg...) h.Hand(m, arg...)
return m return m
} }

View File

@ -15,23 +15,25 @@ const TOKEN = "token"
func init() { func init() {
Index.MergeCommands(ice.Commands{ Index.MergeCommands(ice.Commands{
web.PP(TOKEN, "get"): {Name: "get", Hand: func(m *ice.Message, arg ...string) { TOKEN: {Name: "token username auto prunes", Actions: ice.MergeActions(ice.Actions{
m.Cmd(nfs.CAT, kit.HomePath(".git-credentials"), func(text string) { web.PP("get"): {Hand: func(m *ice.Message, arg ...string) {
if strings.HasSuffix(text, ice.AT+arg[0]) { m.Cmd(nfs.CAT, kit.HomePath(".git-credentials"), func(text string) {
u := kit.ParseURL(text).User if strings.HasSuffix(text, ice.AT+arg[0]) {
if p, ok := u.Password(); ok { u := kit.ParseURL(text)
m.Echo(u.Username()).Echo(p) 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)
} }
}) }},
}}, }, mdb.HashAction(mdb.EXPIRE, mdb.MONTH, mdb.SHORT, aaa.USERNAME, mdb.FIELD, "time,username,token")), Hand: func(m *ice.Message, arg ...string) {
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) {
if mdb.HashSelect(m, arg...); len(arg) > 0 && m.Length() > 0 { 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(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))) 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)))