mirror of
https://shylinux.com/x/ContextOS
synced 2025-04-26 09:14:06 +08:00
add some
This commit is contained in:
parent
5c14143fc3
commit
23f0bb07b0
@ -991,8 +991,9 @@ func (nfs *NFS) Start(m *ctx.Message, arg ...string) bool {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
} else { // 接收响应
|
} else { // 接收响应
|
||||||
h := nfs.hand[kit.Int(code)]
|
if h, ok := nfs.hand[kit.Int(code)]; ok {
|
||||||
h.Copy(msg, "result").Copy(msg, "append").Back(h)
|
h.CopyFuck(msg, "result").CopyFuck(msg, "append").Back(h)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
msg, code, head, body = nil, "0", "result", "append"
|
msg, code, head, body = nil, "0", "result", "append"
|
||||||
|
|
||||||
|
@ -41,6 +41,8 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
|||||||
"trust": &ctx.Config{Name: "trust", Value: map[string]interface{}{}, Help: "可信主机"},
|
"trust": &ctx.Config{Name: "trust", Value: map[string]interface{}{}, Help: "可信主机"},
|
||||||
"node": &ctx.Config{Name: "node", Value: map[string]interface{}{}, Help: "主机信息"},
|
"node": &ctx.Config{Name: "node", Value: map[string]interface{}{}, Help: "主机信息"},
|
||||||
"timer": &ctx.Config{Name: "timer", Value: map[string]interface{}{"interval": "10s", "timer": ""}, Help: "断线重连"},
|
"timer": &ctx.Config{Name: "timer", Value: map[string]interface{}{"interval": "10s", "timer": ""}, Help: "断线重连"},
|
||||||
|
|
||||||
|
"cert": &ctx.Config{Name: "cert", Value: map[string]interface{}{}, Help: "用户证书"},
|
||||||
},
|
},
|
||||||
Commands: map[string]*ctx.Command{
|
Commands: map[string]*ctx.Command{
|
||||||
"init": &ctx.Command{Name: "init", Help: "启动", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
"init": &ctx.Command{Name: "init", Help: "启动", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||||
@ -55,6 +57,46 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
|||||||
m.Conf("runtime", "user.name", m.Conf("runtime", "boot.USER"))
|
m.Conf("runtime", "user.name", m.Conf("runtime", "boot.USER"))
|
||||||
return
|
return
|
||||||
}},
|
}},
|
||||||
|
"cert": &ctx.Command{Name: "cert [node|user|work [create [args...]]]", Help: "", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||||
|
if len(arg) == 0 {
|
||||||
|
m.Add("append", "key", "node.cert")
|
||||||
|
m.Add("append", "value", m.Conf("runtime", "node.cert"))
|
||||||
|
m.Add("append", "key", "user.cert")
|
||||||
|
m.Add("append", "value", m.Conf("runtime", "user.cert"))
|
||||||
|
m.Table()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
switch arg[0] {
|
||||||
|
case "node": // 节点证书
|
||||||
|
if len(arg) > 1 && arg[1] == "create" {
|
||||||
|
msg := m.Cmd("aaa.rsa", "gen")
|
||||||
|
m.Conf("runtime", "node.cert", msg.Append("certificate"))
|
||||||
|
m.Conf("runtime", "node.key", msg.Append("private"))
|
||||||
|
}
|
||||||
|
m.Echo(m.Conf("runtime", "node.cert"))
|
||||||
|
|
||||||
|
case "user": // 用户证书
|
||||||
|
if len(arg) > 1 && arg[1] == "create" {
|
||||||
|
msg := m.Cmd("aaa.rsa", "gen")
|
||||||
|
m.Conf("runtime", "user.route", m.Conf("runtime", "node.route"))
|
||||||
|
m.Conf("runtime", "user.cert", msg.Append("certificate"))
|
||||||
|
m.Conf("runtime", "user.key", msg.Append("private"))
|
||||||
|
}
|
||||||
|
m.Echo(m.Conf("runtime", "user.cert"))
|
||||||
|
|
||||||
|
case "work": // 工作证书
|
||||||
|
if len(arg) > 1 && arg[1] == "create" {
|
||||||
|
if name := m.Cmdx("ssh.sh", "node", arg[2], "check", "work", m.Conf("runtime", "user.route"), m.Conf("runtime", "user.cert"), arg[3]); name != "" {
|
||||||
|
m.Conf("runtime", "work.route", arg[2])
|
||||||
|
m.Conf("runtime", "work.name", name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m.Echo(m.Conf("runtime", "work.name"))
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}},
|
||||||
"remote": &ctx.Command{Name: "remote auto|dial|listen args...", Help: "远程连接", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
"remote": &ctx.Command{Name: "remote auto|dial|listen args...", Help: "远程连接", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||||
if len(arg) == 0 {
|
if len(arg) == 0 {
|
||||||
m.Cmdy("ctx.config", "node", "format", "table")
|
m.Cmdy("ctx.config", "node", "format", "table")
|
||||||
@ -97,6 +139,7 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
|||||||
m.Conf("timer", "timer", m.Cmdx("cli.timer", "delete", m.Conf("timer", "timer")))
|
m.Conf("timer", "timer", m.Cmdx("cli.timer", "delete", m.Conf("timer", "timer")))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 注册设备
|
||||||
m.Spawn(nfs.Target()).Call(func(node *ctx.Message) *ctx.Message {
|
m.Spawn(nfs.Target()).Call(func(node *ctx.Message) *ctx.Message {
|
||||||
// 添加网关
|
// 添加网关
|
||||||
m.Confv("node", node.Append("node.name"), map[string]interface{}{
|
m.Confv("node", node.Append("node.name"), map[string]interface{}{
|
||||||
@ -176,6 +219,7 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
|||||||
arg[0] = ""
|
arg[0] = ""
|
||||||
}
|
}
|
||||||
arg[0] = strings.TrimPrefix(arg[0], m.Conf("runtime", "node.route")+".")
|
arg[0] = strings.TrimPrefix(arg[0], m.Conf("runtime", "node.route")+".")
|
||||||
|
arg[0] = strings.TrimPrefix(arg[0], m.Conf("runtime", "node.name")+".")
|
||||||
route, names, arg := arg[0], strings.SplitN(arg[0], ".", 2), arg[1:]
|
route, names, arg := arg[0], strings.SplitN(arg[0], ".", 2), arg[1:]
|
||||||
if len(names) > 1 && names[0] == "" && names[1] != "" {
|
if len(names) > 1 && names[0] == "" && names[1] != "" {
|
||||||
names[0], names[1] = names[1], names[0]
|
names[0], names[1] = names[1], names[0]
|
||||||
@ -200,6 +244,7 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
|||||||
m.Option("node.route", m.Conf("runtime", "node.route")),
|
m.Option("node.route", m.Conf("runtime", "node.route")),
|
||||||
m.Option("user.route", kit.Select(m.Conf("runtime", "node.route"), m.Conf("runtime", "user.route"))),
|
m.Option("user.route", kit.Select(m.Conf("runtime", "node.route"), m.Conf("runtime", "user.route"))),
|
||||||
m.Option("user.name", m.Option("username")),
|
m.Option("user.name", m.Option("username")),
|
||||||
|
m.Option("work.name", m.Conf("runtime", "work.name")),
|
||||||
)
|
)
|
||||||
m.Option("text.rand", meta[0])
|
m.Option("text.rand", meta[0])
|
||||||
|
|
||||||
@ -226,7 +271,7 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
|||||||
return m.Copy(sub, "append").Copy(sub, "result")
|
return m.Copy(sub, "append").Copy(sub, "result")
|
||||||
}, "send", rest, arg)
|
}, "send", rest, arg)
|
||||||
|
|
||||||
}) == nil { // 回溯命令
|
}) == nil { // 上报命令
|
||||||
m.Find(m.Cap("stream"), true).Copy(m, "option").CallBack(sync, func(sub *ctx.Message) *ctx.Message {
|
m.Find(m.Cap("stream"), true).Copy(m, "option").CallBack(sync, func(sub *ctx.Message) *ctx.Message {
|
||||||
return m.Copy(sub, "append").Copy(sub, "result")
|
return m.Copy(sub, "append").Copy(sub, "result")
|
||||||
}, "send", strings.Join(names, "."), arg)
|
}, "send", strings.Join(names, "."), arg)
|
||||||
@ -253,6 +298,28 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
|||||||
m.Echo(m.Cmdx("aaa.rsa", "sign", m.Conf("runtime", "user.key"), arg[3]))
|
m.Echo(m.Cmdx("aaa.rsa", "sign", m.Conf("runtime", "user.key"), arg[3]))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case "work":
|
||||||
|
if len(arg) == 2 { // 查看
|
||||||
|
if cert := m.Confm("cert", arg[2]); cert != nil {
|
||||||
|
m.Echo("%s", cert["user"])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
} else { // 申请
|
||||||
|
if cert := m.Confm("cert", arg[4]); cert != nil {
|
||||||
|
if cert["user"] != arg[2] {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
m.Echo(arg[4])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
m.Conf("cert", arg[4], map[string]interface{}{
|
||||||
|
"create_time": m.Time(),
|
||||||
|
"user": arg[2],
|
||||||
|
})
|
||||||
|
m.Echo(arg[4])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -267,6 +334,7 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
|||||||
m.Option("node.route"),
|
m.Option("node.route"),
|
||||||
m.Option("user.route"),
|
m.Option("user.route"),
|
||||||
m.Option("user.name"),
|
m.Option("user.name"),
|
||||||
|
m.Option("work.name"),
|
||||||
)
|
)
|
||||||
if m.Option("text.hash") != hash {
|
if m.Option("text.hash") != hash {
|
||||||
m.Log("warning", "text error")
|
m.Log("warning", "text error")
|
||||||
@ -348,15 +416,19 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
|||||||
}
|
}
|
||||||
|
|
||||||
if m.Options("remote_code") {
|
if m.Options("remote_code") {
|
||||||
m.Log("info", "username %s", m.Option("user.name"))
|
m.Log("info", "username %s", m.Option("work.name"))
|
||||||
if m.Option("username", m.Option("user.name")); m.Confs("trust", m.Option("node.route")) {
|
if m.Option("username", m.Option("work.name")); m.Confs("trust", m.Option("node.route")) {
|
||||||
m.Log("info", "skip verify user of node %s", m.Option("node.route"))
|
m.Log("info", "skip verify user of node %s", m.Option("node.route"))
|
||||||
} else if m.Confs("trust", "up") && strings.HasPrefix(m.Conf("runtime", "node.route"), m.Option("node.route")) {
|
} else if m.Confs("trust", "up") && strings.HasPrefix(m.Conf("runtime", "node.route"), m.Option("node.route")) {
|
||||||
m.Log("info", "skip verify user of up node %s", m.Option("node.route"))
|
m.Log("info", "skip verify user of up node %s", m.Option("node.route"))
|
||||||
} else {
|
} else {
|
||||||
// 用户签名
|
// 用户签名
|
||||||
hash, _ := kit.Hash("rand", m.Option("text.time", m.Time("stamp")), m.Option("node.route"))
|
hash, _ := kit.Hash("rand", m.Option("text.time", m.Time("stamp")), m.Option("node.route"))
|
||||||
m.Option("user.cert", m.Cmd("aaa.auth", "username", m.Option("user.name"), "cert").Append("meta"))
|
if m.Option("user.cert", m.Cmd("aaa.auth", "username", m.Option("username"), "cert").Append("meta")); !m.Options("user.cert") {
|
||||||
|
m.Option("user.cert", m.Cmd("ssh.remote", m.Option("user.route"), "sync", "check", "user").Append("user.cert"))
|
||||||
|
m.Log("fuck", "user.eert %v", m.Option("user.cert"))
|
||||||
|
m.Log("fuck", "wat %v", m.Cmd("aaa.auth", "username", m.Option("username"), "cert", m.Option("user.cert")))
|
||||||
|
}
|
||||||
m.Option("user.sign", m.Spawn().Cmdx("ssh.remote", m.Option("user.route"), "sync", "check", "user", m.Option("node.route"), hash))
|
m.Option("user.sign", m.Spawn().Cmdx("ssh.remote", m.Option("user.route"), "sync", "check", "user", m.Option("node.route"), hash))
|
||||||
|
|
||||||
// 代理验签
|
// 代理验签
|
||||||
|
@ -7,7 +7,7 @@ fieldset.Tree>div.output>div.tree li {
|
|||||||
fieldset.Tree>div.output>div.tree li div {
|
fieldset.Tree>div.output>div.tree li div {
|
||||||
float:left;
|
float:left;
|
||||||
padding:5px;
|
padding:5px;
|
||||||
border:solid 1px green;
|
border:solid 2px green;
|
||||||
}
|
}
|
||||||
fieldset.Tree>div.output>div.list {
|
fieldset.Tree>div.output>div.list {
|
||||||
clear:both;
|
clear:both;
|
||||||
|
@ -327,12 +327,31 @@ chat模块提供了信息管理。
|
|||||||
- iOS
|
- iOS
|
||||||
- Android
|
- Android
|
||||||
|
|
||||||
|
### 小程序
|
||||||
|
### 开发板
|
||||||
|
|
||||||
## 接口开发
|
## 接口开发
|
||||||
|
### python
|
||||||
|
### java
|
||||||
|
### c
|
||||||
|
|
||||||
## 模块开发
|
## 模块开发
|
||||||
### 应用模块
|
### 应用模块
|
||||||
|
#### 简单模块
|
||||||
|
#### 复杂模块
|
||||||
|
#### 脚本模块
|
||||||
### 插件模块
|
### 插件模块
|
||||||
|
#### 独立插件
|
||||||
|
#### 扩展插件
|
||||||
### 核心模块
|
### 核心模块
|
||||||
|
#### 模块中心ctx
|
||||||
|
#### 命令中心cli
|
||||||
|
#### 认证中心aaa
|
||||||
|
#### 应用中心web
|
||||||
|
#### 网络中心tcp
|
||||||
|
#### 存储中心nfs
|
||||||
|
#### 集群中心ssh
|
||||||
|
#### 数据中心mdb
|
||||||
|
|
||||||
## 系统架构
|
## 系统架构
|
||||||
|
|
||||||
@ -343,7 +362,20 @@ chat模块提供了信息管理。
|
|||||||
|数据层|tcp|nfs|ssh|mdb|
|
|数据层|tcp|nfs|ssh|mdb|
|
||||||
|
|
||||||
### 应用框架
|
### 应用框架
|
||||||
|
#### 模块
|
||||||
|
#### 协程
|
||||||
|
#### 消息
|
||||||
### 解析引擎
|
### 解析引擎
|
||||||
|
#### 文件扫描
|
||||||
|
#### 词法解析
|
||||||
|
#### 语法解析
|
||||||
|
#### 执行命令
|
||||||
### 通信框架
|
### 通信框架
|
||||||
|
#### 节点路由
|
||||||
|
#### 节点认证
|
||||||
|
#### 节点服务
|
||||||
### 存储引擎
|
### 存储引擎
|
||||||
|
#### 配置
|
||||||
|
#### 缓存
|
||||||
|
#### 数据
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user