diff --git a/base/aaa/totp.go b/base/aaa/totp.go index 609b0810..2cddfb45 100644 --- a/base/aaa/totp.go +++ b/base/aaa/totp.go @@ -71,6 +71,7 @@ func init() { m.PushQRCode(mdb.SCAN, kit.Format(m.Config(mdb.LINK), value[mdb.NAME], value[SECRET])) m.Echo(m.Append(mdb.VALUE)) } else { + m.PushAction(mdb.REMOVE) m.StatusTimeCount() } }) diff --git a/base/ssh/script.go b/base/ssh/script.go index 22f5649d..b9add60f 100644 --- a/base/ssh/script.go +++ b/base/ssh/script.go @@ -117,7 +117,7 @@ func (f *Frame) parse(m *ice.Message, h, line string) string { func (f *Frame) scan(m *ice.Message, h, line string) *Frame { f.ps1 = kit.Simple(m.Confv(PROMPT, kit.Keym(PS1))) f.ps2 = kit.Simple(m.Confv(PROMPT, kit.Keym(PS2))) - // m.Options(MESSAGE, m, ice.LOG_DISABLE, ice.TRUE) + m.Options(MESSAGE, m, ice.LOG_DISABLE, ice.TRUE) m.I, m.O = f.stdin, f.stdout ps, bio := f.ps1, bufio.NewScanner(f.stdin) for f.prompt(m, ps...); f.stdin != nil && bio.Scan(); f.prompt(m, ps...) { diff --git a/base/web/dream.go b/base/web/dream.go index 1572686d..87888b51 100644 --- a/base/web/dream.go +++ b/base/web/dream.go @@ -111,7 +111,8 @@ func init() { gdb.Event(m, "", arg) } }}, - mdb.CREATE: {Name: "create name=hi repos template", Hand: func(m *ice.Message, arg ...string) { + mdb.CREATE: {Name: "create name*=hi repos template", Hand: func(m *ice.Message, arg ...string) { + m.Option(nfs.REPOS, kit.Slice(kit.Split(m.Option(nfs.REPOS)), -1)[0]) _dream_show(m, m.OptionDefault(mdb.NAME, path.Base(m.Option(nfs.REPOS)))) }}, cli.START: {Hand: func(m *ice.Message, arg ...string) { diff --git a/base/web/serve.go b/base/web/serve.go index 65ab6c9d..81b23cc3 100644 --- a/base/web/serve.go +++ b/base/web/serve.go @@ -110,8 +110,11 @@ func _serve_handle(key string, cmd *ice.Command, m *ice.Message, w http.Response if m.Option(ice.MSG_USERWEB, _serve_domain(m)); m.Option(ice.POD) != "" { m.Option(ice.MSG_USERPOD, m.Option(ice.POD)) } - u := OptionUserWeb(m) - m.Option(ice.MSG_USERHOST, tcp.PublishLocalhost(m, u.Scheme+"://"+u.Host)) + if u := OptionUserWeb(m); strings.Contains(u.Host, tcp.LOCALHOST) { + m.Option(ice.MSG_USERHOST, tcp.PublishLocalhost(m, u.Scheme+"://"+u.Host)) + } else { + m.Option(ice.MSG_USERHOST, u.Scheme+"://"+u.Host) + } m.Option(ice.MSG_SESSID, kit.Select(m.Option(ice.MSG_SESSID), m.Option(CookieName(m.Option(ice.MSG_USERWEB))))) if m.Optionv(ice.MSG_CMDS) == nil { if p := strings.TrimPrefix(r.URL.Path, key); p != "" { @@ -234,9 +237,9 @@ func init() { m.RenderDownload(p) }}, PP(ice.REQUIRE, ice.NODE_MODULES): {Name: "/require/node_modules/", Help: "依赖库", Hand: func(m *ice.Message, arg ...string) { - p := path.Join(ice.SRC, ice.NODE_MODULES, path.Join(arg...)) + p := path.Join(ice.USR, ice.NODE_MODULES, path.Join(arg...)) if !nfs.ExistsFile(m, p) { - m.Cmd(cli.SYSTEM, "npm", "install", arg[0], kit.Dict(cli.CMD_DIR, ice.SRC)) + m.Cmd(cli.SYSTEM, "npm", "install", arg[0], kit.Dict(cli.CMD_DIR, ice.USR)) } m.RenderDownload(p) }}, diff --git a/base/web/spide.go b/base/web/spide.go index cf9ddb67..3d60b592 100644 --- a/base/web/spide.go +++ b/base/web/spide.go @@ -282,7 +282,7 @@ func init() { mdb.CREATE: {Name: "create name address", Hand: func(m *ice.Message, arg ...string) { _spide_create(m, m.Option(mdb.NAME), m.Option(ADDRESS)) }}, tcp.CLIENT: {Hand: func(m *ice.Message, arg ...string) { msg := m.Cmd("", kit.Select(ice.DEV, arg, 0)) - ls := kit.Split(msg.Append(CLIENT_HOSTNAME), ice.DF) + ls := kit.Split(msg.Append(kit.Keys(SPIDE_CLIENT, tcp.HOST)), ice.DF) m.Push(tcp.HOST, ls[0]).Push(tcp.PORT, kit.Select(kit.Select("443", "80", msg.Append(CLIENT_PROTOCOL) == ice.HTTP), ls, 1)) m.Push(DOMAIN, msg.Append(CLIENT_PROTOCOL)+"://"+msg.Append(CLIENT_HOSTNAME)+kit.Select("", arg, 1)) m.Push(tcp.PROTOCOL, msg.Append(CLIENT_PROTOCOL)).Push(tcp.HOSTNAME, msg.Append(CLIENT_HOSTNAME)) diff --git a/conf.go b/conf.go index 509a3a49..76434385 100644 --- a/conf.go +++ b/conf.go @@ -120,33 +120,31 @@ const ( // DIR USR_LOCAL_EXPORT = "usr/local/export/" USR_LOCAL_REPOS = "usr/local/repos/" - VAR_RUN = "var/run/" - VAR_TMP = "var/tmp/" - VAR_LOG = "var/log/" - VAR_CONF = "var/conf/" - VAR_DATA = "var/data/" - VAR_FILE = "var/file/" - VAR_PROXY = "var/proxy/" - VAR_TRASH = "var/trash/" - BIN_ICE_BIN = "bin/ice.bin" - BIN_BOOT_LOG = "bin/boot.log" - ETC_INIT_SHY = "etc/init.shy" - ETC_LOCAL_SHY = "etc/local.shy" - ETC_EXIT_SHY = "etc/exit.shy" - ETC_MISS_SH = "etc/miss.sh" - ETC_PATH = "etc/path" - + VAR_RUN = "var/run/" + VAR_TMP = "var/tmp/" + VAR_LOG = "var/log/" + VAR_CONF = "var/conf/" + VAR_DATA = "var/data/" + VAR_FILE = "var/file/" + VAR_PROXY = "var/proxy/" + VAR_TRASH = "var/trash/" + BIN_ICE_BIN = "bin/ice.bin" + BIN_BOOT_LOG = "bin/boot.log" + ETC_INIT_SHY = "etc/init.shy" + ETC_LOCAL_SHY = "etc/local.shy" + ETC_EXIT_SHY = "etc/exit.shy" + ETC_MISS_SH = "etc/miss.sh" + ETC_PATH = "etc/path" SRC_HELP = "src/help/" SRC_DEBUG = "src/debug/" SRC_RELEASE = "src/release/" - SRC_MAIN_SVG = "src/main.svg" SRC_MAIN_SHY = "src/main.shy" + SRC_MAIN_SH = "src/main.sh" SRC_MAIN_JS = "src/main.js" SRC_MAIN_GO = "src/main.go" - SRC_VERSION_GO = "src/version.go" SRC_BINPACK_GO = "src/binpack.go" + SRC_VERSION_GO = "src/version.go" SRC_WEBVIEW_GO = "src/webview.go" - SRC_RELAY_GO = "src/relay.go" README_MD = "README.md" MAKEFILE = "Makefile" LICENSE = "LICENSE" diff --git a/core/code/autogen.go b/core/code/autogen.go index d0f18ca3..94643914 100644 --- a/core/code/autogen.go +++ b/core/code/autogen.go @@ -7,7 +7,6 @@ import ( ice "shylinux.com/x/icebergs" "shylinux.com/x/icebergs/base/aaa" "shylinux.com/x/icebergs/base/cli" - "shylinux.com/x/icebergs/base/ctx" "shylinux.com/x/icebergs/base/mdb" "shylinux.com/x/icebergs/base/nfs" "shylinux.com/x/icebergs/base/ssh" @@ -104,25 +103,8 @@ const AUTOGEN = "autogen" func init() { Index.MergeCommands(ice.Commands{ - AUTOGEN: {Name: "autogen path auto module binpack script relay", Help: "生成", Actions: ice.Actions{ + AUTOGEN: {Name: "autogen path auto module binpack script", Help: "生成", Actions: ice.Actions{ mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { - if m.Option(ctx.ACTION) == RELAY { - switch arg[0] { - case nfs.ALIAS: - m.Cmdy(web.SPIDE).CutTo("client.name", arg[0]) - case aaa.USERNAME: - m.Cmdy(aaa.USER).Cut(aaa.USERNAME) - m.Push(arg[0], "shy") - case tcp.HOST: - m.Option(ice.MSG_FIELDS, "client.hostname") - m.Cmdy(web.SPIDE) - case tcp.PORT: - m.Push(arg[0], "22") - case ice.INIT: - m.Push(arg[0], "tmux attach -t miss") - } - return - } switch arg[0] { case cli.MAIN: m.Cmdy(nfs.DIR, nfs.PWD, nfs.DIR_CLI_FIELDS, kit.Dict(nfs.DIR_ROOT, m.Option(nfs.PATH), nfs.DIR_REG, `.*\.go$`)).RenameAppend(nfs.PATH, arg[0]) @@ -165,13 +147,6 @@ func init() { _autogen_version(m) m.Cmdy(nfs.CAT, ice.SRC_VERSION_GO) }}, - RELAY: {Name: "relay alias username host port=22 init", Help: "跳板", Hand: func(m *ice.Message, arg ...string) { - m.Cmdy(COMPILE, RELAY) - // m.Cmdy(nfs.LINK, ice.USR_PUBLISH+m.Option(mdb.ALIAS), ice.USR_PUBLISH+RELAY) - m.Cmdy(cli.SYSTEM, "ln", "-s", RELAY, ice.USR_PUBLISH+m.Option(mdb.ALIAS)) - m.Cmd(nfs.SAVE, path.Join(kit.Env(cli.HOME), ".ssh/"+m.Option(mdb.ALIAS)+".json"), - kit.Formats(kit.Dict(m.OptionSimple("username,host,port,init")))) - }}, }, Hand: func(m *ice.Message, arg ...string) { m.Cmdy(nfs.CAT, kit.Select(path.Base(ice.SRC_VERSION_GO), arg, 0), kit.Dict(nfs.DIR_ROOT, ice.SRC)) }}, diff --git a/core/code/binpack.go b/core/code/binpack.go index 65ac6bf8..c35e5f57 100644 --- a/core/code/binpack.go +++ b/core/code/binpack.go @@ -16,38 +16,21 @@ import ( ) func _binpack_file(m *ice.Message, w io.Writer, arg ...string) { + switch arg[0] { + case ice.SRC_BINPACK_GO, ice.SRC_VERSION_GO, ice.ETC_LOCAL_SHY: + return + } if f, e := nfs.OpenFile(m, arg[0]); !m.Warn(e, ice.ErrNotFound, arg[0]) { defer f.Close() - if b, e := ioutil.ReadAll(f); !m.Warn(e, ice.ErrNotValid, arg[0]) && len(b) > 0 || strings.Contains(arg[0], "/cache.") { + if b, e := ioutil.ReadAll(f); !m.Warn(e, ice.ErrNotValid, arg[0]) { fmt.Fprintf(w, " \"%s\": \"%s\",\n", kit.Select(arg[0], arg, 1), base64.StdEncoding.EncodeToString(b)) } } } func _binpack_dir(m *ice.Message, w io.Writer, dir string) { nfs.DirDeepAll(m, dir, nfs.PWD, func(value ice.Maps) { - switch path.Base(value[nfs.PATH]) { - case ice.GO_MOD, ice.GO_SUM, "binpack.go", "version.go": - return - } - switch strings.Split(value[nfs.PATH], ice.PS)[0] { - case ice.BIN, ice.VAR, "website", "polaris": - return - } _binpack_file(m, w, path.Join(dir, value[nfs.PATH])) }) - fmt.Fprintln(w) -} - -func _binpack_can(m *ice.Message, w io.Writer, dir string) { - for _, k := range []string{ice.INDEX_CSS, ice.PROTO_JS, ice.FRAME_JS} { - _binpack_file(m, w, path.Join(dir, k)) - } - for _, k := range []string{LIB, PAGE, PANEL, PLUGIN, "publish/client/nodejs/"} { - nfs.DirDeepAll(m, dir, k, func(value ice.Maps) { - _binpack_file(m, w, path.Join(dir, value[nfs.PATH])) - }) - } - fmt.Fprintln(w) } func _binpack_all(m *ice.Message) { nfs.OptionFiles(m, nfs.DiskFile) @@ -56,23 +39,15 @@ func _binpack_all(m *ice.Message) { defer m.Echo(p) fmt.Fprintln(w, _binpack_template) defer fmt.Fprintln(w, _binpack_template_end) - if m.Option(ice.MSG_USERPOD) == "" { - if nfs.ExistsFile(m, ice.USR_VOLCANOS) { - _binpack_can(m, w, ice.USR_VOLCANOS) - } - if nfs.ExistsFile(m, ice.USR_INTSHELL) { - _binpack_dir(m, w, ice.USR_INTSHELL) - } - } + _binpack_dir(m, w, ice.USR_VOLCANOS) + _binpack_dir(m, w, ice.USR_INTSHELL) _binpack_dir(m, w, ice.SRC) _binpack_file(m, w, ice.ETC_MISS_SH) _binpack_file(m, w, ice.ETC_INIT_SHY) _binpack_file(m, w, ice.ETC_EXIT_SHY) - fmt.Fprintln(w) - _binpack_file(m, w, ice.LICENSE) - _binpack_file(m, w, ice.MAKEFILE) _binpack_file(m, w, ice.README_MD) - fmt.Fprintln(w) + _binpack_file(m, w, ice.MAKEFILE) + _binpack_file(m, w, ice.LICENSE) list := map[string]bool{} ctx.TravelCmd(m, func(key, file, line string) { dir := path.Dir(file) @@ -126,15 +101,12 @@ import ( ) func init() { - pack := ice.Maps{ -` -var _binpack_template_end = ` - } + pack := ice.Maps{` +var _binpack_template_end = ` } nfs.PackFile.RemoveAll(ice.SRC) for k, v := range pack { if b, e := base64.StdEncoding.DecodeString(v); e == nil { nfs.PackFile.WriteFile(k, b) } } -} -` +}` diff --git a/core/code/compile.go b/core/code/compile.go index deffc0dc..3058a716 100644 --- a/core/code/compile.go +++ b/core/code/compile.go @@ -35,14 +35,11 @@ func _compile_target(m *ice.Message, arg ...string) (string, string, string, str return main, file, goos, arch } -const ( - RELAY = "relay" -) const COMPILE = "compile" func init() { Index.MergeCommands(ice.Commands{ - COMPILE: {Name: "compile arch=amd64,386,mipsle,arm,arm64 os=linux,darwin,windows src=src/main.go@key run relay binpack", Help: "编译", Actions: ice.MergeActions(ice.Actions{ + COMPILE: {Name: "compile arch=amd64,386,arm,arm64,mipsle os=linux,darwin,windows src=src/main.go@key run binpack", Help: "编译", Actions: ice.MergeActions(ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { kit.Fetch([]string{"curl", "make", "gcc", "vim", "tmux"}, func(cmd string) { cli.IsSystem(m, cmd) }) if cli.IsAlpine(m, "git"); !cli.IsAlpine(m, "go", "go git") { @@ -53,7 +50,6 @@ func init() { m.Cmdy(nfs.DIR, ice.SRC, nfs.DIR_CLI_FIELDS, kit.Dict(nfs.DIR_REG, kit.ExtReg(GO))) }}, BINPACK: {Help: "打包", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(AUTOGEN, BINPACK) }}, - RELAY: {Help: "跳板", Hand: func(m *ice.Message, arg ...string) { m.Cmdy("", ice.SRC_RELAY_GO, path.Join(ice.USR_PUBLISH, RELAY)) }}, }, ctx.ConfAction(cli.ENV, kit.Dict("GOPRIVATE", "shylinux.com,github.com", "GOPROXY", "https://goproxy.cn,direct", "CGO_ENABLED", "0"))), Hand: func(m *ice.Message, arg ...string) { _autogen_version(m.Spawn()) main, file, goos, arch := _compile_target(m, arg...) diff --git a/core/code/publish.go b/core/code/publish.go index c4b6f2c7..64b4b07a 100644 --- a/core/code/publish.go +++ b/core/code/publish.go @@ -61,9 +61,6 @@ func _publish_contexts(m *ice.Message, arg ...string) { m.Option(web.DOMAIN, fmt.Sprintf("%s://%s:%s", u.Scheme, host, kit.Select(kit.Select("443", "80", u.Scheme == ice.HTTP), strings.Split(u.Host, ice.DF), 1))) for _, k := range kit.Default(arg, ice.MISC) { switch k { - case INSTALL: - m.Echo(kit.Renders(`export ctx_dev={{.Option "domain"}}{{.Option "ctx_env"}}; ctx_temp=$(mktemp); wget -O $ctx_temp -q $ctx_dev; source $ctx_temp app username {{.Option "user.name"}}`, m)) - return case ice.MISC: _publish_file(m, ice.ICE_BIN) case ice.CORE: @@ -85,13 +82,9 @@ const PUBLISH = "publish" func init() { Index.MergeCommands(ice.Commands{ - PUBLISH: {Name: "publish path auto create volcanos icebergs intshell relay", Help: "发布", Actions: ice.MergeActions(ice.Actions{ + PUBLISH: {Name: "publish path auto create volcanos icebergs intshell", Help: "发布", Actions: ice.MergeActions(ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { m.Config(ice.CONTEXTS, _contexts) }}, mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { - if m.Option(ctx.ACTION) == RELAY { - m.Cmdy(AUTOGEN, mdb.INPUTS, arg) - return - } m.Cmdy(nfs.DIR, arg[1:]).Cut("path,size,time").ProcessAgain() }}, web.SERVE_START: {Hand: func(m *ice.Message, arg ...string) { @@ -115,10 +108,7 @@ func init() { }}, ice.CONTEXTS: {Hand: func(m *ice.Message, arg ...string) { _publish_contexts(m, arg...) }}, mdb.CREATE: {Name: "create file", Help: "添加", Hand: func(m *ice.Message, arg ...string) { _publish_file(m, m.Option(nfs.FILE)) }}, - RELAY: {Name: "relay alias username host port=22 init", Help: "跳板", Hand: func(m *ice.Message, arg ...string) { - m.Cmdy(AUTOGEN, RELAY, arg) - }}, - nfs.TRASH: {Hand: func(m *ice.Message, arg ...string) { nfs.Trash(m, path.Join(ice.USR_PUBLISH, m.Option(nfs.PATH))) }}, + nfs.TRASH: {Hand: func(m *ice.Message, arg ...string) { nfs.Trash(m, path.Join(ice.USR_PUBLISH, m.Option(nfs.PATH))) }}, }, ctx.ConfAction(ice.CONTEXTS, _contexts), aaa.RoleAction()), Hand: func(m *ice.Message, arg ...string) { m.Cmdy(nfs.DIR, kit.Select("", arg, 0), nfs.DIR_WEB_FIELDS, kit.Dict(nfs.DIR_ROOT, ice.USR_PUBLISH)).SortTimeR(mdb.TIME) }}, @@ -127,10 +117,10 @@ func init() { var _contexts = kit.Dict( ice.MISC, ` -# 下载工具 wget Alpine +# 下载应用 wget Alpine / Busybox export ctx_dev={{.Option "domain"}}{{.Option "ctx_env"}}; ctx_temp=$(mktemp); wget -O $ctx_temp -q $ctx_dev; source $ctx_temp app username {{.Option "user.name"}} usernick {{.Option "user.nick"}} -# 下载工具 curl Centos / MacOS +# 下载应用 curl Centos / MacOS export ctx_dev={{.Option "domain"}}{{.Option "ctx_env"}}; ctx_temp=$(mktemp); curl -o $ctx_temp -fsSL $ctx_dev; source $ctx_temp app username {{.Option "user.name"}} usernick {{.Option "user.nick"}} `, ice.CORE, ` diff --git a/core/team/plan.go b/core/team/plan.go index f05baa84..d5182a3d 100644 --- a/core/team/plan.go +++ b/core/team/plan.go @@ -56,7 +56,7 @@ const PLAN = "plan" func init() { Index.MergeCommands(ice.Commands{ - PLAN: {Name: "plan scale=week,day,week,month,year,long begin_time@date place@province img@img list", Help: "计划", Actions: ice.MergeActions(ice.Actions{ + PLAN: {Name: "plan scale=week,day,week,month,year,long begin_time@date place@province img@img list", Help: "任务计划", Actions: ice.MergeActions(ice.Actions{ mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(TODO, mdb.INPUTS, arg) }}, mdb.PLUGIN: {Name: "plugin extra.index extra.args", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(TASK, mdb.MODIFY, arg) }}, mdb.INSERT: {Name: "insert zone* type=once,step,week name* text begin_time@date close_time@date", Hand: func(m *ice.Message, arg ...string) { diff --git a/misc/git/status.go b/misc/git/status.go index 1c02b525..4a9fcca8 100644 --- a/misc/git/status.go +++ b/misc/git/status.go @@ -176,7 +176,7 @@ const STATUS = "status" func init() { Index.MergeCommands(ice.Commands{ - STATUS: {Name: "status repos:text auto", Help: "状态机", Actions: ice.MergeActions(ice.Actions{ + STATUS: {Name: "status repos:text auto", Help: "代码库", Actions: ice.MergeActions(ice.Actions{ mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { switch arg[0] { case COMMENT: diff --git a/misc/ssh/service.go b/misc/ssh/service.go index 67d80e1a..7776f36b 100644 --- a/misc/ssh/service.go +++ b/misc/ssh/service.go @@ -192,7 +192,7 @@ func init() { )), Hand: func(m *ice.Message, arg ...string) { m.Fields(len(arg), m.Config(mdb.FIELD), m.Config(mdb.FIELDS)) if mdb.ZoneSelect(m, arg...); len(arg) == 0 { - m.PushAction(aaa.INVITE, mdb.INSERT, ctx.LOAD, ctx.SAVE) + m.PushAction(aaa.INVITE, mdb.INSERT, ctx.LOAD, ctx.SAVE, mdb.REMOVE) } }}, }) diff --git a/misc/ssh/ssh.shy b/misc/ssh/ssh.shy index b47cc0b9..0db878b1 100644 --- a/misc/ssh/ssh.shy +++ b/misc/ssh/ssh.shy @@ -1,9 +1,4 @@ chapter "ssh" -refer ` -官网 http://www.openssh.com/ -文档 https://man.openbsd.org/ssh -源码 https://github.com/openssh/openssh-portable -` field "连接" ssh.connect field "会话" ssh.session