diff --git a/base/aaa/user.go b/base/aaa/user.go
index 580a43b5..75705a8b 100644
--- a/base/aaa/user.go
+++ b/base/aaa/user.go
@@ -96,8 +96,9 @@ func UserRoot(m *ice.Message, arg ...string) *ice.Message {
username := kit.Select(ice.Info.Username, arg, 0)
usernick := kit.Select(UserNick(m, username), arg, 1)
userrole := kit.Select(ROOT, arg, 2)
+ userzone := kit.Select("", arg, 3)
if len(arg) > 0 {
- m.Cmd(USER, mdb.CREATE, username, "", usernick, "", userrole)
+ m.Cmd(USER, mdb.CREATE, username, "", usernick, userzone, userrole)
ice.Info.Username = username
}
return SessAuth(m, kit.Dict(USERNAME, username, USERNICK, usernick, USERROLE, userrole))
diff --git a/base/cli/qrcode.go b/base/cli/qrcode.go
index db494524..7a205a9d 100644
--- a/base/cli/qrcode.go
+++ b/base/cli/qrcode.go
@@ -12,6 +12,7 @@ import (
ice "shylinux.com/x/icebergs"
"shylinux.com/x/icebergs/base/mdb"
"shylinux.com/x/icebergs/base/nfs"
+ "shylinux.com/x/icebergs/base/tcp"
kit "shylinux.com/x/toolkits"
)
@@ -79,13 +80,14 @@ func _qrcode_cli(m *ice.Message, text string) {
}
m.Echo(text).Echo(ice.NL)
}
-func _qrcode_web(m *ice.Message, text string) {
+func _qrcode_web(m *ice.Message, text string) string {
qr, _ := qrcode.New(text, qrcode.Medium)
qr.ForegroundColor = _parse_color(m.Option(FG))
qr.BackgroundColor = _parse_color(m.Option(BG))
if data, err := qr.PNG(kit.Int(m.Option(SIZE))); m.Assert(err) {
m.Echo(`
`, base64.StdEncoding.EncodeToString(data), text)
}
+ return text
}
const (
@@ -133,8 +135,7 @@ func init() {
_qrcode_cli(m, kit.Select(kit.Select(ice.Info.Make.Domain, ice.Info.Domain), arg, 0))
} else {
m.Option(SIZE, kit.Select(kit.Format(kit.Max(240, kit.Min(480, kit.Int(m.Option(ice.MSG_HEIGHT)), kit.Int(m.Option(ice.MSG_WIDTH))))), arg, 3))
- _qrcode_web(m, kit.Select(m.Option(ice.MSG_USERWEB), arg, 0))
- m.StatusTime(mdb.LINK, kit.Select(m.Option(ice.MSG_USERWEB), arg, 0))
+ m.StatusTime(mdb.LINK, _qrcode_web(m, tcp.PublishLocalhost(m, kit.Select(m.Option(ice.MSG_USERWEB), arg, 0))))
}
}},
})
diff --git a/base/cli/runtime.go b/base/cli/runtime.go
index 05849b98..f1e949e2 100644
--- a/base/cli/runtime.go
+++ b/base/cli/runtime.go
@@ -19,6 +19,7 @@ func _runtime_init(m *ice.Message) {
kit.Fetch(kit.UnMarshal(kit.Format(ice.Info.Make)), func(key string, value ice.Any) {
m.Conf(RUNTIME, kit.Keys(MAKE, strings.ToLower(key)), value)
})
+ aaa.UserRoot(ice.Pulse, ice.Info.Make.Username, "", aaa.TECH, ice.DEV)
m.Conf(RUNTIME, kit.Keys(HOST, GOARCH), runtime.GOARCH)
m.Conf(RUNTIME, kit.Keys(HOST, GOOS), runtime.GOOS)
m.Conf(RUNTIME, kit.Keys(HOST, OSID), release(m))
@@ -48,7 +49,7 @@ func _runtime_init(m *ice.Message) {
ice.Info.Hostname = m.Conf(RUNTIME, kit.Keys(BOOT, HOSTNAME))
ice.Info.Pathname = m.Conf(RUNTIME, kit.Keys(BOOT, PATHNAME))
ice.Info.Username = m.Conf(RUNTIME, kit.Keys(BOOT, USERNAME))
- aaa.UserRoot(ice.Pulse, ice.Info.Username)
+ aaa.UserRoot(ice.Pulse, ice.Info.Username, "", "", ice.OPS)
msg := m.Cmd(nfs.DIR, _system_find(m, os.Args[0]), "time,path,size,hash")
m.Conf(RUNTIME, kit.Keys(BOOT, ice.BIN), msg.Append(nfs.PATH))
m.Conf(RUNTIME, kit.Keys(BOOT, nfs.SIZE), msg.Append(nfs.SIZE))
diff --git a/base/nfs/dir.go b/base/nfs/dir.go
index 440ecbbd..54fe19c1 100644
--- a/base/nfs/dir.go
+++ b/base/nfs/dir.go
@@ -104,7 +104,7 @@ func _dir_list(m *ice.Message, root string, dir string, level int, deep bool, di
m.Push(mdb.HASH, kit.Select(h[:6], h[:], field == mdb.HASH))
case mdb.LINK:
if strings.Contains(p, "ice.windows.") {
- m.PushDownload(mdb.LINK, kit.Select("", f.Name(), !isDir)+".exe", p)
+ m.PushDownload(mdb.LINK, "ice.exe", p)
} else {
m.PushDownload(mdb.LINK, kit.Select("", f.Name(), !isDir), p)
}
diff --git a/base/web/serve.go b/base/web/serve.go
index 6e91aa0d..9dc44784 100644
--- a/base/web/serve.go
+++ b/base/web/serve.go
@@ -15,7 +15,6 @@ import (
"shylinux.com/x/icebergs/base/gdb"
"shylinux.com/x/icebergs/base/mdb"
"shylinux.com/x/icebergs/base/nfs"
- "shylinux.com/x/icebergs/base/ssh"
"shylinux.com/x/icebergs/base/tcp"
kit "shylinux.com/x/toolkits"
)
@@ -184,13 +183,23 @@ func init() {
_serve_start(m)
}},
SERVE_START: {Hand: func(m *ice.Message, arg ...string) {
- if domain := m.Cmdx(SPACE, DOMAIN); ice.Info.Colors && m.Option(ice.DEV) == "" {
- m.Sleep30ms().Cmd(ssh.PRINTF, kit.Dict(nfs.CONTENT, "\r"+ice.Render(m, ice.RENDER_QRCODE, domain))).Cmd(ssh.PROMPT)
- }
- switch runtime.GOOS {
- case cli.WINDOWS:
- m.Cmd(cli.SYSTEM, "explorer.exe", "http://localhost:"+m.Option(tcp.PORT))
- }
+ m.Go(func() {
+ opened := false
+ m.Sleep("1s").Cmd(SPACE, func(values ice.Maps) {
+ if values[mdb.TYPE] == CHROME {
+ opened = true
+ }
+ })
+ if opened {
+ return
+ }
+ switch host := "http://localhost:" + m.Option(tcp.PORT); runtime.GOOS {
+ case cli.WINDOWS:
+ m.Cmd(cli.SYSTEM, "explorer.exe", host)
+ case cli.DARWIN:
+ m.Cmd(cli.SYSTEM, "open", host)
+ }
+ })
}},
SERVE_REWRITE: {Hand: func(m *ice.Message, arg ...string) {
if arg[0] != http.MethodGet {
diff --git a/base/web/space.go b/base/web/space.go
index 80b514d7..e954bef0 100644
--- a/base/web/space.go
+++ b/base/web/space.go
@@ -32,7 +32,7 @@ func _space_dial(m *ice.Message, dev, name string, arg ...string) {
m.Cmd(tcp.CLIENT, tcp.DIAL, args, func(c net.Conn) {
if conn, _, e := websocket.NewClient(c, uri, nil, kit.Int(redial["r"]), kit.Int(redial["w"])); !m.Warn(e, tcp.DIAL, dev, SPACE, uri.String()) {
defer mdb.HashCreateDeferRemove(m, kit.SimpleKV("", MASTER, dev, msg.Append(tcp.HOSTNAME)), kit.Dict(mdb.TARGET, conn))()
- if !prints {
+ if !prints && ice.Info.Colors {
m.Go(func() {
m.Sleep30ms().Cmd(ssh.PRINTF, kit.Dict(nfs.CONTENT, "\r"+ice.Render(m, ice.RENDER_QRCODE, m.CmdAppend(SPACE, dev, cli.PWD, mdb.LINK)))).Cmd(ssh.PROMPT)
})
@@ -197,7 +197,14 @@ func init() {
m.Cmd(SPACE, arg[0], ice.MSG_SESSID, aaa.SessCreate(m, m.Option(ice.MSG_USERNAME)))
}},
DOMAIN: {Hand: func(m *ice.Message, arg ...string) { m.Echo(_space_domain(m)) }},
- OPEN: {Hand: func(m *ice.Message, arg ...string) { ctx.ProcessOpen(m, MergePod(m, m.Option(mdb.NAME), arg)) }},
+ OPEN: {Hand: func(m *ice.Message, arg ...string) {
+ switch m.Option(mdb.TYPE) {
+ case MASTER:
+ ctx.ProcessOpen(m, m.Cmd(SPIDE, m.Option(mdb.NAME)).Append(CLIENT_ORIGIN))
+ default:
+ ctx.ProcessOpen(m, MergePod(m, m.Option(mdb.NAME), arg))
+ }
+ }},
ice.PS: {Hand: func(m *ice.Message, arg ...string) { _space_fork(m) }},
}, mdb.HashAction(mdb.SHORT, mdb.NAME, mdb.FIELD, "time,type,name,text", ctx.ACTION, OPEN,
REDIAL, kit.Dict("a", 3000, "b", 1000, "c", 1000), TIMEOUT, kit.Dict("c", "10s"),
diff --git a/conf.go b/conf.go
index 12752548..aad63086 100644
--- a/conf.go
+++ b/conf.go
@@ -5,6 +5,7 @@ const (
SP = " "
DF = ":"
EQ = "="
+ QS = "?"
AT = "@"
PS = "/"
PT = "."
diff --git a/core/chat/footer.go b/core/chat/footer.go
index cd227360..a073351b 100644
--- a/core/chat/footer.go
+++ b/core/chat/footer.go
@@ -6,6 +6,7 @@ import (
"shylinux.com/x/icebergs/base/cli"
"shylinux.com/x/icebergs/base/ctx"
"shylinux.com/x/icebergs/base/web"
+ kit "shylinux.com/x/toolkits"
)
const FOOTER = "footer"
@@ -20,8 +21,8 @@ func init() {
}
}
}},
- }, ctx.CmdAction(TITLE, `shylinuxc@gmail.com`), aaa.WhiteAction(ctx.COMMAND, ice.RUN)), Hand: func(m *ice.Message, arg ...string) {
- m.Result(m.Configv(TITLE))
+ }, ctx.CmdAction(), aaa.WhiteAction(ctx.COMMAND, ice.RUN)), Hand: func(m *ice.Message, arg ...string) {
+ m.Result(kit.Select(m.Config(TITLE), ice.Info.Make.Email))
}},
})
}
diff --git a/core/chat/header.go b/core/chat/header.go
index ec20a26d..c5df8a62 100644
--- a/core/chat/header.go
+++ b/core/chat/header.go
@@ -94,7 +94,7 @@ func init() {
m.Option(k, web.SHARE_LOCAL+k)
}
}
- m.Echo(m.Config(TITLE)).OptionFromConfig(MENUS)
+ m.Echo(kit.Select(kit.Select("", strings.SplitN(ice.Info.Make.Remote, "://", 2), 1), m.Config(TITLE))).OptionFromConfig(MENUS)
}},
})
}
diff --git a/core/code/autogen.go b/core/code/autogen.go
index 0be79cf9..c09b9a97 100644
--- a/core/code/autogen.go
+++ b/core/code/autogen.go
@@ -58,7 +58,7 @@ func _autogen_version(m *ice.Message) {
}
m.Cmd(nfs.DEFS, ".gitignore", _git_ignore)
m.Cmd(nfs.DEFS, ice.SRC_BINPACK_GO, `package main`+ice.NL)
- m.Cmd(nfs.SAVE, ice.SRC_VERSION_GO, kit.Format(_version_template, _autogen_gits(m, nfs.MODULE, _autogen_mod(m, ice.GO_MOD), tcp.HOSTNAME, ice.Info.Hostname, aaa.USERNAME, ice.Info.Username)))
+ m.Cmd(nfs.SAVE, ice.SRC_VERSION_GO, kit.Format(_version_template, _autogen_gits(m, nfs.MODULE, _autogen_mod(m, ice.GO_MOD), tcp.HOSTNAME, ice.Info.Hostname)))
m.Cmd(cli.SYSTEM, "gofmt", "-w", ice.SRC_VERSION_GO)
m.Cmdy(nfs.DIR, ice.SRC_BINPACK_GO)
m.Cmdy(nfs.DIR, ice.SRC_VERSION_GO)
@@ -77,7 +77,9 @@ func _autogen_git(m *ice.Message, arg ...string) ice.Map {
nfs.REMOTE, m.Cmdx(cli.SYSTEM, GIT, "config", "remote.origin.url"),
nfs.BRANCH, m.Cmdx(cli.SYSTEM, GIT, "rev-parse", "--abbrev-ref", "HEAD"),
nfs.VERSION, m.Cmdx(cli.SYSTEM, GIT, "describe", "--tags"),
- web.DOMAIN, tcp.PublishLocalhost(m, kit.Split(m.Option(ice.MSG_USERWEB), "?")[0]),
+ aaa.EMAIL, m.Cmdx(cli.SYSTEM, GIT, "config", "user.email"),
+ aaa.USERNAME, kit.Select(ice.Info.Username, m.Cmdx(cli.SYSTEM, GIT, "config", "user.name")),
+ web.DOMAIN, tcp.PublishLocalhost(m, kit.Split(m.Option(ice.MSG_USERWEB), ice.QS)[0]),
)
}
func _autogen_mod(m *ice.Message, file string) (mod string) {
diff --git a/core/code/publish.go b/core/code/publish.go
index 559faf97..76f104f0 100644
--- a/core/code/publish.go
+++ b/core/code/publish.go
@@ -62,7 +62,7 @@ func _publish_contexts(m *ice.Message, arg ...string) {
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"}} usernick {{.Option "user.nick"}}`, m))
+ m.Echo(kit.Renders(strings.TrimSpace(m.Config(kit.Keys(ice.CONTEXTS, ice.MISC))), m))
return
case ice.MISC:
_publish_file(m, ice.ICE_BIN)
@@ -118,27 +118,12 @@ func init() {
var _contexts = kit.Dict(
ice.MISC, `
-# 下载应用 wget Alpine / Busybox
-export ctx_dev={{.Option "domain"}}{{.Option "ctx_env"}}; temp=$(mktemp); wget -O $temp -q $ctx_dev; source $temp app username {{.Option "user.name"}} usernick {{.Option "user.nick"}}
-
-# 下载应用 curl Centos / MacOS
-export ctx_dev={{.Option "domain"}}{{.Option "ctx_env"}}; temp=$(mktemp); curl -o $temp -fsSL $ctx_dev; source $temp app username {{.Option "user.name"}} usernick {{.Option "user.nick"}}
+export ctx_dev={{.Option "domain"}}{{.Option "ctx_env"}}; temp=$(mktemp); if curl -h &>/dev/null; then curl -o $temp -fsSL $ctx_dev; else wget -O $temp -q $ctx_dev; fi; source $temp app username {{.Option "user.name"}} usernick {{.Option "user.nick"}}
`,
ice.CORE, `
-# 下载命令 wget Busybox
-temp=$(mktemp); wget -O $temp -q http://contexts.com.cn; source $temp binary
-
-# 下载命令 wget Alpine
-temp=$(mktemp); wget -O $temp -q {{.Option "domain"}}; source $temp binary
-
-# 下载命令 curl Centos / MacOS
-temp=$(mktemp); curl -o $temp -fsSL {{.Option "domain"}}; source $temp binary
+temp=$(mktemp); if curl -h &>/dev/null; then curl -o $temp -fsSL {{.Option "domain"}}; else wget -O $temp -q {{.Option "domain"}}; fi; source $temp binary
`,
ice.BASE, `
-# 下载源码 wget Alpine
-temp=$(mktemp); wget -O $temp -q {{.Option "domain"}}; source $temp source
-
-# 下载源码 curl Centos / MacOS
-temp=$(mktemp); curl -o $temp -fsSL {{.Option "domain"}}; source $temp source
+temp=$(mktemp); if curl -h &>/dev/null; then curl -o $temp -fsSL {{.Option "domain"}}; else wget -O $temp -q {{.Option "domain"}}; fi; source $temp source
`,
)
diff --git a/info.go b/info.go
index 54da0eea..356aa02f 100644
--- a/info.go
+++ b/info.go
@@ -11,6 +11,7 @@ type MakeInfo struct {
Version string
Hostname string
Username string
+ Email string
}
var Info = struct {
diff --git a/init.go b/init.go
index e84de1e3..1da0df8f 100644
--- a/init.go
+++ b/init.go
@@ -93,9 +93,7 @@ func Run(arg ...string) string {
arg = kit.Simple(os.Args[1:], kit.Split(kit.Env(CTX_ARG)))
}
if len(arg) == 0 && runtime.GOOS == "windows" {
- arg = append(arg, SERVE, START, DEV, SHY)
- logs.Disable(true)
- os.Stderr.Close()
+ arg = append(arg, SERVE, START, DEV, DEV)
}
Pulse.meta[MSG_DETAIL] = arg
kit.Fetch(kit.Sort(os.Environ()), func(env string) {
@@ -110,6 +108,7 @@ func Run(arg ...string) string {
case SERVE, SPACE:
if os.Getenv("ctx_log") == "" {
logs.Disable(true)
+ os.Stderr.Close()
}
if Index.Start(Pulse, arg...) {
conf.Wait()