diff --git a/base/cli/cli.go b/base/cli/cli.go index a90fb57e..03361877 100644 --- a/base/cli/cli.go +++ b/base/cli/cli.go @@ -51,9 +51,10 @@ var Index = &ice.Context{Name: "cli", Help: "命令模块", m.Conf(RUNTIME, "host.pid", os.Getpid()) // 启动信息 - m.Conf(RUNTIME, "boot.username", kit.Select(os.Getenv("USER"), os.Getenv("ctx_user"))) - if user, e := user.Current(); e == nil && user.Name != "" { - m.Conf(RUNTIME, "boot.username", kit.Select(user.Name, os.Getenv("ctx_user"))) + if m.Conf(RUNTIME, "boot.username", kit.Select(os.Getenv("USER"), os.Getenv("ctx_user"))) == "" { + if user, e := user.Current(); e == nil && user.Name != "" { + m.Conf(RUNTIME, "boot.username", kit.Select(user.Name, os.Getenv("ctx_user"))) + } } if name, e := os.Hostname(); e == nil { m.Conf(RUNTIME, "boot.hostname", kit.Select(name, os.Getenv("HOSTNAME"))) diff --git a/base/tcp/tcp.go b/base/tcp/tcp.go index 06c438d1..b0ccff65 100644 --- a/base/tcp/tcp.go +++ b/base/tcp/tcp.go @@ -62,7 +62,11 @@ func _ip_islocal(m *ice.Message, ip string) (ok bool) { return true } - return m.Richs(IP, kit.Keys("meta.white"), ip, nil) != nil + if m.Richs(IP, kit.Keys("meta.white"), ip, nil) == nil { + return false + } + m.Log_AUTH(aaa.White, ip) + return true } func IPIsLocal(m *ice.Message, ip string) bool { return _ip_islocal(m, ip) diff --git a/core/code/code.go b/core/code/code.go index b7991715..a9e8ac48 100644 --- a/core/code/code.go +++ b/core/code/code.go @@ -9,6 +9,7 @@ import ( "github.com/shylinux/icebergs/base/web" kit "github.com/shylinux/toolkits" + "net/url" "os" "path" "runtime" @@ -171,6 +172,25 @@ export %s }) } }}, + + "/miss/": {Name: "/miss/", Help: "任务", Action: map[string]*ice.Action{ + "pwd": {Name: "pwd", Help: "pwd", Hand: func(m *ice.Message, arg ...string) { + m.Render(ice.RENDER_RESULT) + m.Echo("hello world\n") + }}, + }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + u, e := url.QueryUnescape(m.Option("arg")) + m.Assert(e) + args := kit.Split(u) + if len(arg) == 0 || arg[0] == "" { + return + } + + m.Render(ice.RENDER_RESULT) + if m.Cmdy(arg, args); len(m.Resultv()) == 0 { + m.Table() + } + }}, }, } diff --git a/go.mod b/go.mod index 17123ffe..38144668 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,7 @@ go 1.13 require ( github.com/gomarkdown/markdown v0.0.0-20200609195525-3f9352745725 + github.com/gomodule/redigo v2.0.0+incompatible // indirect github.com/gorilla/websocket v1.4.1 github.com/nareix/joy4 v0.0.0-20200507095837-05a4ffbb5369 github.com/shylinux/toolkits v0.1.6 diff --git a/go.sum b/go.sum index 1c75d9df..bd296d3c 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,8 @@ github.com/gomarkdown/markdown v0.0.0-20200609195525-3f9352745725 h1:X6sZdr+t2E2jwajTy/FfXbmAKPFTYxEq9hiFgzMiuPQ= github.com/gomarkdown/markdown v0.0.0-20200609195525-3f9352745725/go.mod h1:aii0r/K0ZnHv7G0KF7xy1v0A7s2Ljrb5byB7MO5p6TU= +github.com/gomodule/redigo v2.0.0+incompatible h1:K/R+8tc58AaqLkqG2Ol3Qk+DR/TlNuhuh457pBFPtt0= +github.com/gomodule/redigo v2.0.0+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4= +github.com/gomodule/redigo/redis v0.0.0-do-not-use h1:J7XIp6Kau0WoyT4JtXHT3Ei0gA1KkSc6bc87j9v9WIo= github.com/google/uuid v1.1.0 h1:Jf4mxPC/ziBnoPIdpQdPJ9OeiomAUHLvxmPRSPH9m4s= github.com/google/uuid v1.1.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM= @@ -12,6 +15,8 @@ github.com/shylinux/toolkits v0.1.4 h1:GW7rRFOSww56x+rUfH0/tho3+FaErxz5+5RwlA8oW github.com/shylinux/toolkits v0.1.4/go.mod h1:Y68Ot6xOmo1bun67YvqC3chDGeU2gDxtsUnvVDGJm4g= github.com/shylinux/toolkits v0.1.5 h1:rGLsEGuPzuib/sOZXCbF8D+JGjqeQJ+a1rX/G6/sc8w= github.com/shylinux/toolkits v0.1.5/go.mod h1:Y68Ot6xOmo1bun67YvqC3chDGeU2gDxtsUnvVDGJm4g= +github.com/shylinux/toolkits v0.1.6 h1:x+Bs+oijuS11TWGAsdCEgwDbCS35uJvnP4jYDETJqig= +github.com/shylinux/toolkits v0.1.6/go.mod h1:Y68Ot6xOmo1bun67YvqC3chDGeU2gDxtsUnvVDGJm4g= github.com/skip2/go-qrcode v0.0.0-20191027152451-9434209cb086 h1:RYiqpb2ii2Z6J4x0wxK46kvPBbFuZcdhS+CIztmYgZs= github.com/skip2/go-qrcode v0.0.0-20191027152451-9434209cb086/go.mod h1:PLPIyL7ikehBD1OAjmKKiOEhbvWyHGaNDjquXMcYABo= github.com/tuotoo/qrcode v0.0.0-20190222102259-ac9c44189bf2 h1:BWVtt2VBY+lmVDu9MGKqLGKl04B+iRHcrW1Ptyi/8tg= diff --git a/logs.go b/logs.go index 0d484241..25f2873e 100644 --- a/logs.go +++ b/logs.go @@ -12,7 +12,7 @@ var ErrWarn = "warn: " var ErrNotFound = "not found " func (m *Message) log(level string, str string, arg ...interface{}) *Message { - if str = strings.TrimSpace(fmt.Sprintf(str, arg...)); Log != nil { + if str = strings.TrimSpace(kit.Format(str, arg...)); Log != nil { // 日志模块 Log(m, level, str) } diff --git a/misc/docker/docker.go b/misc/docker/docker.go index 43209051..d5245a11 100644 --- a/misc/docker/docker.go +++ b/misc/docker/docker.go @@ -61,6 +61,7 @@ var Index = &ice.Context{Name: "docker", Help: "虚拟机", "detail", []string{"进入", "启动", "停止", "重启", "清理", "编辑", "删除"}, ), Action: map[string]*ice.Action{ gdb.OPEN: {Name: "open", Help: "进入", Hand: func(m *ice.Message, arg ...string) { + m.Cmd("web.code.tmux", m.Option("NAMES")) m.Cmdy(cli.SYSTEM, "tmux", "new-window", "-t", m.Option("NAMES"), "-n", m.Option("NAMES"), "-PF", "#{session_name}:#{window_name}.1", "docker exec -it "+m.Option("NAMES")+" bash") }},