From b56063a183d154629f864f9d8e4280e45e1c2220 Mon Sep 17 00:00:00 2001 From: shy Date: Thu, 18 Apr 2024 00:10:56 +0800 Subject: [PATCH] add some --- base/aaa/email.go | 13 +++++++++++++ base/ctx/command.go | 3 ++- base/tcp/port.go | 16 ++++++++++++++++ base/web/space.go | 11 +---------- 4 files changed, 32 insertions(+), 11 deletions(-) diff --git a/base/aaa/email.go b/base/aaa/email.go index b92d2624..e276fce4 100644 --- a/base/aaa/email.go +++ b/base/aaa/email.go @@ -54,6 +54,19 @@ func init() { } }}, }) + ice.Info.Inputs = append(ice.Info.Inputs, func(m *ice.Message, arg ...string) { + switch kit.TrimPrefix(arg[0], "extra.") { + case TO: + if m.Option(ice.ACTION) != EMAIL { + break + } + fallthrough + case EMAIL: + m.Push(arg[0], "shy@shylinux.com", "shylinux@163.com") + case PASSWORD: + m.SetAppend() + } + }) } func SendEmail(m *ice.Message, from, to, cc string, arg ...string) { m.Option(ice.MSG_USERHOST, strings.Split(m.Option(ice.MSG_USERHOST), "://")[1]) diff --git a/base/ctx/command.go b/base/ctx/command.go index ba355bd5..1ea145cb 100644 --- a/base/ctx/command.go +++ b/base/ctx/command.go @@ -18,7 +18,8 @@ func _command_list(m *ice.Message, name string) *ice.Message { return m.Push(mdb.INDEX, name).Push(mdb.NAME, name).Push(mdb.HELP, "").Push(mdb.META, "").Push(mdb.LIST, "") } m.Spawn(m.Source()).Search(name, func(p *ice.Context, s *ice.Context, key string, cmd *ice.Command) { - m.Push(mdb.INDEX, kit.Keys(s.Prefix(), key)).Push(mdb.ICONS, kit.Format(cmd.Icon)) + m.Push(mdb.INDEX, kit.Keys(s.Prefix(), key)) + m.Push(mdb.ICONS, kit.Select(cmd.Icon, kit.Value(cmd.Meta, kit.Keys(ice.CTX_ICONS, key)))) m.Push(mdb.NAME, kit.Format(cmd.Name)).Push(mdb.HELP, kit.Format(cmd.Help)) m.Push(mdb.LIST, kit.Format(cmd.List)).Push(mdb.META, kit.Format(cmd.Meta)) m.Push("_command", ShortCmd(kit.Keys(s.Prefix(), key))) diff --git a/base/tcp/port.go b/base/tcp/port.go index 3ed194b3..d7e9bbc0 100644 --- a/base/tcp/port.go +++ b/base/tcp/port.go @@ -3,6 +3,7 @@ package tcp import ( "net" "path" + "runtime" "strconv" "strings" @@ -61,6 +62,15 @@ func init() { } }) case PORT: + if runtime.GOOS == "darwin" { + ls := kit.SplitLine(m.Cmd("system", "sh", "-c", `lsof -nP -i4TCP | grep LISTEN | awk '{print $1 " " $9 }'`).Result()) + kit.For(ls, func(p string) { + ls := kit.SplitWord(p) + m.Push(arg[0], kit.Split(ls[1], ":")[1]).Push(SERVER, ls[0]) + }) + m.Sort(arg[0], ice.INT) + return + } m.Cmd(PORT, SOCKET, func(value ice.Maps) { switch value[mdb.STATUS] { case "LISTEN": @@ -132,6 +142,12 @@ func init() { m.StatusTimeCount(mdb.ConfigSimple(m, BEGIN, CURRENT, END)).SortInt(PORT) }}, }) + ice.Info.Inputs = append(ice.Info.Inputs, func(m *ice.Message, arg ...string) { + switch arg[0] { + case PORT: + m.SetAppend().Cmdy(PORT, mdb.INPUTS, arg) + } + }) } func PortRight(m *ice.Message, arg ...string) string { current, begin, end := kit.Select("20000", mdb.Config(m, CURRENT)), kit.Select("20000", mdb.Config(m, BEGIN)), kit.Select("30000", mdb.Config(m, END)) diff --git a/base/web/space.go b/base/web/space.go index a48250e4..0348e889 100644 --- a/base/web/space.go +++ b/base/web/space.go @@ -458,20 +458,11 @@ func init() { } else { m.Cmdy(ctx.COMMAND, mdb.INPUTS, m.Option(ctx.INDEX)) } - case aaa.TO: - if m.Option(ctx.ACTION) != aaa.EMAIL { - break - } - fallthrough - case aaa.EMAIL: - m.Push(arg[0], "shy@shylinux.com", "shylinux@163.com") - case aaa.PASSWORD: - m.SetAppend() case tcp.WIFI: m.Cmdy(tcp.WIFI).CutTo(tcp.SSID, arg[0]) case MESSAGE: m.Cmdy(MESSAGE).Cut(mdb.HASH, mdb.ZONE, mdb.ICONS) - case "target": + case TARGET: m.AdminCmd(MATRIX).Table(func(value ice.Maps) { m.Push(arg[0], kit.Keys(kit.Select("", ice.OPS, ice.Info.NodeType == WORKER), value[DOMAIN], value[mdb.NAME])) m.Push(mdb.TYPE, value[mdb.TYPE])