forked from x/icebergs
add some
This commit is contained in:
parent
e29a4fa6b8
commit
2f4e941aa0
@ -323,6 +323,22 @@ func ServeCmdAction() ice.Actions {
|
|||||||
func IsLocalHost(m *ice.Message) bool {
|
func IsLocalHost(m *ice.Message) bool {
|
||||||
return (m.R == nil || m.R.Header.Get(html.XForwardedFor) == "") && tcp.IsLocalHost(m, m.Option(ice.MSG_USERIP))
|
return (m.R == nil || m.R.Header.Get(html.XForwardedFor) == "") && tcp.IsLocalHost(m, m.Option(ice.MSG_USERIP))
|
||||||
}
|
}
|
||||||
|
func ParseURL(m *ice.Message, p string) []string {
|
||||||
|
if u, e := url.Parse(p); e == nil {
|
||||||
|
arg := strings.Split(strings.TrimPrefix(u.Path, nfs.PS), nfs.PS)
|
||||||
|
for i := 0; i < len(arg); i += 2 {
|
||||||
|
switch arg[i] {
|
||||||
|
case "s":
|
||||||
|
m.Option(ice.POD, kit.Select("", arg, i+1))
|
||||||
|
case "c":
|
||||||
|
m.Option(ice.CMD, kit.Select("", arg, i+1))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
kit.For(u.Query(), func(k string, v []string) { m.Optionv(k, v) })
|
||||||
|
return kit.Split(u.Fragment, ":")
|
||||||
|
}
|
||||||
|
return []string{}
|
||||||
|
}
|
||||||
func ParseUA(m *ice.Message) (res []string) {
|
func ParseUA(m *ice.Message) (res []string) {
|
||||||
res = append(res, aaa.USERROLE, m.Option(ice.MSG_USERROLE))
|
res = append(res, aaa.USERROLE, m.Option(ice.MSG_USERROLE))
|
||||||
res = append(res, aaa.USERNAME, m.Option(ice.MSG_USERNAME))
|
res = append(res, aaa.USERNAME, m.Option(ice.MSG_USERNAME))
|
||||||
|
@ -112,7 +112,8 @@ func (s Client) User(m *ice.Message, arg ...string) {
|
|||||||
}
|
}
|
||||||
m.Info("user info %v", kit.Format(res))
|
m.Info("user info %v", kit.Format(res))
|
||||||
if m.Option(USER_CMD) != "" {
|
if m.Option(USER_CMD) != "" {
|
||||||
m.Cmdy(kit.Split(m.Option(USER_CMD)), m.OptionSimple("openid"), kit.Simple(res))
|
m.Options("open_id", m.Option("openid"), aaa.USERNICK, m.Option("nickname"), aaa.AVATAR, m.Option("headimgurl"))
|
||||||
|
m.Cmdy(kit.Split(m.Option(USER_CMD)), m.OptionSimple("open_id"), kit.Simple(res))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
username := m.Option(aaa.USERNAME, m.Option(kit.Select(aaa.USERNAME, m.Option(USER_KEY))))
|
username := m.Option(aaa.USERNAME, m.Option(kit.Select(aaa.USERNAME, m.Option(USER_KEY))))
|
||||||
@ -167,7 +168,7 @@ func (s Client) Login2(m *ice.Message, arg ...string) {
|
|||||||
msg.Option(EXPIRES_IN, m.Time(kit.Format("%vs", kit.Int(msg.Option(EXPIRES_IN)))))
|
msg.Option(EXPIRES_IN, m.Time(kit.Format("%vs", kit.Int(msg.Option(EXPIRES_IN)))))
|
||||||
if s.User(msg, msg.OptionSimple("openid")...); !m.Warn(msg.Option(aaa.USERNAME) == "" && msg.Option("user_uid") == "") {
|
if s.User(msg, msg.OptionSimple("openid")...); !m.Warn(msg.Option(aaa.USERNAME) == "" && msg.Option("user_uid") == "") {
|
||||||
if msg.Option(SESS_CMD) != "" {
|
if msg.Option(SESS_CMD) != "" {
|
||||||
m.Cmdy(kit.Split(msg.Option(SESS_CMD)), msg.OptionSimple("user_uid"))
|
m.Cmdy(kit.Split(msg.Option(SESS_CMD)), kit.Dict("user_uid", msg.Option("user_uid")))
|
||||||
} else {
|
} else {
|
||||||
m.ProcessCookie(ice.MSG_SESSID, aaa.SessCreate(m.Message, msg.Option(aaa.USERNAME)), "-2")
|
m.ProcessCookie(ice.MSG_SESSID, aaa.SessCreate(m.Message, msg.Option(aaa.USERNAME)), "-2")
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user