From 7b87b62fbcc3c9482ddea6675f63874fbf67a8b7 Mon Sep 17 00:00:00 2001 From: shaoying Date: Wed, 3 Jun 2020 08:12:58 +0800 Subject: [PATCH] add some --- base/ctx/ctx.go | 10 ++++++++++ base/web/story.go | 16 ++++++++++------ base/web/web.go | 16 +++++++++++++--- core/chat/action.go | 3 +++ core/chat/chat.go | 8 ++++++-- info.go | 4 ++++ 6 files changed, 46 insertions(+), 11 deletions(-) diff --git a/base/ctx/ctx.go b/base/ctx/ctx.go index c5b38707..f9b638b8 100644 --- a/base/ctx/ctx.go +++ b/base/ctx/ctx.go @@ -91,6 +91,12 @@ func _config_make(m *ice.Message, chain string, arg ...string) { m.Echo(kit.Formats(msg.Confv(chain))) } } +func _config_rich(m *ice.Message, name string, key string, arg ...string) { + m.Rich(name, key, kit.Dict(arg)) +} +func _config_grow(m *ice.Message, name string, key string, arg ...string) { + m.Grow(name, key, kit.Dict(arg)) +} func _command_list(m *ice.Message, all bool) { p := m.Spawn(m.Source()) @@ -252,6 +258,10 @@ var Index = &ice.Context{Name: "ctx", Help: "配置模块", _config_save(m, arg[1], arg[2:]...) case "load": _config_load(m, arg[1], arg[2:]...) + case "grow": + _config_grow(m, arg[1], arg[2], arg[3:]...) + case "rich": + _config_rich(m, arg[1], arg[2], arg[3:]...) default: _config_make(m, arg[0], arg[1:]...) } diff --git a/base/web/story.go b/base/web/story.go index a64b3972..29eadc06 100644 --- a/base/web/story.go +++ b/base/web/story.go @@ -264,10 +264,10 @@ func _story_catch(m *ice.Message, arg ...string) { _story_add(m, arg...) } func _story_add(m *ice.Message, arg ...string) { - if len(arg) > 3 && (arg[3] == "" || m.Richs(ice.WEB_CACHE, nil, arg[3], func(key string, value map[string]interface{}) { + if len(arg) < 4 || arg[3] == "" || m.Richs(ice.WEB_CACHE, nil, arg[3], func(key string, value map[string]interface{}) { // 复用缓存 arg[3] = key - }) == nil) { + }) == nil { // 添加缓存 m.Cmdy(ice.WEB_CACHE, arg) arg = []string{arg[0], m.Append("type"), m.Append("name"), m.Append("data")} @@ -305,11 +305,15 @@ func _story_add(m *ice.Message, arg ...string) { } // 分发数据 - if p := kit.Select(m.Conf(ice.WEB_FAVOR, "meta.proxy"), m.Option("you")); p != "" { - m.Option("you", "") - m.Cmd(ice.WEB_PROXY, p, ice.WEB_STORY, ice.STORY_PULL, arg[2], "dev", arg[2]) + for _, k := range []string{"you", "pod"} { + if p := m.Option(k); p != "" { + m.Option(k, "") + m.Cmd(ice.WEB_PROXY, p, ice.WEB_STORY, ice.STORY_PULL, arg[2], "dev", arg[2]) + return + } } - + m.Cmd(ice.WEB_PROXY, m.Conf(ice.WEB_FAVOR, "meta.proxy"), + ice.WEB_STORY, ice.STORY_PULL, arg[2], "dev", arg[2]) } func _story_index(m *ice.Message, name string) { diff --git a/base/web/web.go b/base/web/web.go index f4585cc6..38eb1401 100644 --- a/base/web/web.go +++ b/base/web/web.go @@ -24,6 +24,8 @@ import ( "time" ) +var SERVE = ice.Name("serve", Index) + type Frame struct { *http.Client *http.Server @@ -99,6 +101,13 @@ func IsLocalIP(msg *ice.Message, ip string) (ok bool) { if ip == "::1" || strings.HasPrefix(ip, "127.") { return true } + + msg.Log_AUTH("ip", ip) + if msg.Richs(SERVE, kit.Keys("meta.white"), ip, nil) != nil { + msg.Log_AUTH("ip", ip) + return true + } + msg.Cmd("tcp.ifconfig").Table(func(index int, value map[string]string, head []string) { if value["ip"] == ip { ok = true @@ -159,7 +168,7 @@ func (web *Frame) HandleWSS(m *ice.Message, safe bool, c *websocket.Conn, name s socket, msg := c, m.Spawns(b) target := kit.Simple(msg.Optionv(ice.MSG_TARGET)) source := kit.Simple(msg.Optionv(ice.MSG_SOURCE), name) - msg.Info("recv %v<-%v %s %v", target, source, msg.Detailv(), msg.Format("meta")) + msg.Info("recv %v<-%v %s %v", target, source, msg.Detailv(), msg.Formats("meta")) if len(target) == 0 { msg.Option(ice.MSG_USERROLE, msg.Cmdx(ice.AAA_ROLE, "check", msg.Option(ice.MSG_USERNAME))) @@ -205,7 +214,7 @@ func (web *Frame) HandleWSS(m *ice.Message, safe bool, c *websocket.Conn, name s msg.Optionv(ice.MSG_TARGET, target) socket.WriteMessage(t, []byte(msg.Format("meta"))) target = append([]string{name}, target...) - msg.Info("send %v %v->%v %v", t, source, target, msg.Format("meta")) + msg.Info("send %v %v->%v %v %v", t, source, target, msg.Detailv(), msg.Formats("meta")) msg.Cost("%v->%v %v %v", source, target, msg.Detailv(), msg.Format("append")) } } @@ -470,6 +479,7 @@ var Index = &ice.Context{Name: "web", Help: "网络模块", `{{define "raw"}}{{.Result}}{{end}}`, }), "logheaders", "false", "init", "false", + "black", kit.Dict(), )}, ice.WEB_SPACE: {Name: "space", Help: "空间站", Value: kit.Data(kit.MDB_SHORT, kit.MDB_NAME, "redial.a", 3000, "redial.b", 1000, "redial.c", 1000, @@ -948,7 +958,7 @@ var Index = &ice.Context{Name: "web", Help: "网络模块", m.Set(ice.MSG_DETAIL, arg[1:]...) m.Optionv(ice.MSG_TARGET, target[1:]) m.Optionv(ice.MSG_SOURCE, []string{id}) - m.Info("send [%s]->%v %s", id, target, m.Format("meta")) + m.Info("send [%s]->%v %v %s", id, target, m.Detailv(), m.Formats("meta")) // 下发命令 m.Target().Server().(*Frame).send[id] = m diff --git a/core/chat/action.go b/core/chat/action.go index 8d4787fc..3c65940c 100644 --- a/core/chat/action.go +++ b/core/chat/action.go @@ -75,6 +75,8 @@ func _action_action(m *ice.Message, action string, arg ...string) bool { msg := m.Cmd(ice.WEB_STORY, "upload") m.Option("name", msg.Append("name")) m.Option("data", msg.Append("data")) + m.Debug("what", m.Option("name")) + m.Debug("what", m.Option("data")) } return false } @@ -89,6 +91,7 @@ func _action_order(m *ice.Message, arg ...string) { m.Render("status", 403, "not auth") return } + m.Add("option", "_option", "data", "name") m.Cmdy(_action_proxy(m), cmds).Option("cmds", cmds) } diff --git a/core/chat/chat.go b/core/chat/chat.go index ce8a7b3a..fbd489c0 100644 --- a/core/chat/chat.go +++ b/core/chat/chat.go @@ -167,7 +167,7 @@ var Index = &ice.Context{Name: "chat", Help: "聊天中心", default: // 群组检查 - m.Richs(ice.CHAT_RIVER, nil, arg[0], func(key string, value map[string]interface{}) { + if m.Richs(ice.CHAT_RIVER, nil, arg[0], func(key string, value map[string]interface{}) { m.Richs(ice.CHAT_RIVER, kit.Keys(kit.MDB_HASH, arg[0], "user"), m.Option(ice.MSG_USERNAME), func(key string, value map[string]interface{}) { if m.Option(ice.MSG_RIVER, arg[0]); len(arg) > 1 { // 应用检查 @@ -177,7 +177,11 @@ var Index = &ice.Context{Name: "chat", Help: "聊天中心", } m.Logs(ice.LOG_AUTH, "river", m.Option(ice.MSG_RIVER), "storm", m.Option(ice.MSG_STORM)) }) - }) + }) == nil { + // 前端应用 + // m.Option(ice.MSG_RIVER, arg[0]) + // m.Option(ice.MSG_STORM, arg[1]) + } } } switch m.Option(ice.MSG_USERURL) { diff --git a/info.go b/info.go index cf8c0141..4e81dcc1 100644 --- a/info.go +++ b/info.go @@ -118,3 +118,7 @@ func (m *Message) Log_REMOVE(arg ...interface{}) *Message { func (m *Message) Log_CREATE(arg ...interface{}) *Message { return m.log(LOG_CREATE, log_fields(arg...)) } + +func (m *Message) Log_AUTH(arg ...interface{}) *Message { + return m.log(LOG_AUTH, log_fields(arg...)) +}