mirror of
https://shylinux.com/x/icebergs
synced 2025-06-26 18:37:29 +08:00
opt some
This commit is contained in:
parent
efa10a2ee7
commit
1f974390c4
@ -131,12 +131,13 @@ func init() {
|
|||||||
})
|
})
|
||||||
}},
|
}},
|
||||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
if len(arg) < 2 {
|
if len(arg) < 2 { // 角色列表
|
||||||
_role_list(m, kit.Select("", arg, 0))
|
_role_list(m, kit.Select("", arg, 0))
|
||||||
m.PushAction(mdb.REMOVE)
|
m.PushAction(mdb.REMOVE)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 设置角色
|
||||||
_role_user(m, arg[0], arg[1:]...)
|
_role_user(m, arg[0], arg[1:]...)
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
|
@ -53,8 +53,6 @@ func SessIsCli(m *ice.Message) bool {
|
|||||||
const (
|
const (
|
||||||
IP = "ip"
|
IP = "ip"
|
||||||
UA = "ua"
|
UA = "ua"
|
||||||
|
|
||||||
SESSID = "sessid"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -33,8 +33,7 @@ func _user_remove(m *ice.Message, name string) {
|
|||||||
}
|
}
|
||||||
func _user_search(m *ice.Message, kind, name, text string) {
|
func _user_search(m *ice.Message, kind, name, text string) {
|
||||||
m.Richs(USER, nil, kit.MDB_FOREACH, func(key string, value map[string]interface{}) {
|
m.Richs(USER, nil, kit.MDB_FOREACH, func(key string, value map[string]interface{}) {
|
||||||
value = kit.GetMeta(value)
|
if value = kit.GetMeta(value); name != "" && name != value[USERNAME] {
|
||||||
if name != "" && name != value[USERNAME] {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
m.PushSearch(kit.SSH_CMD, USER, kit.MDB_TYPE, kit.Format(UserRole(m, value[USERNAME])),
|
m.PushSearch(kit.SSH_CMD, USER, kit.MDB_TYPE, kit.Format(UserRole(m, value[USERNAME])),
|
||||||
@ -144,7 +143,7 @@ func init() {
|
|||||||
m.Table(func(index int, value map[string]string, head []string) {
|
m.Table(func(index int, value map[string]string, head []string) {
|
||||||
m.Push(USERROLE, UserRole(m, value[USERNAME]))
|
m.Push(USERROLE, UserRole(m, value[USERNAME]))
|
||||||
})
|
})
|
||||||
m.PushAction(ROLE, mdb.REMOVE)
|
m.PushAction(mdb.REMOVE)
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -39,8 +39,8 @@ func _command_search(m *ice.Message, kind, name, text string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
m.PushSearch(kit.SSH_CMD, COMMAND, CONTEXT, s.Cap(ice.CTX_FOLLOW), COMMAND, key,
|
m.PushSearch(kit.SSH_CMD, COMMAND, CONTEXT, m.Prefix(), COMMAND, key,
|
||||||
kit.MDB_TYPE, kind, kit.MDB_NAME, key, kit.MDB_TEXT, s.Cap(ice.CTX_FOLLOW),
|
kit.MDB_TYPE, kind, kit.MDB_NAME, key, kit.MDB_TEXT, m.Prefix(),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package log
|
package log
|
||||||
|
|
||||||
import (
|
import (
|
||||||
ice "github.com/shylinux/icebergs"
|
|
||||||
kit "github.com/shylinux/toolkits"
|
|
||||||
|
|
||||||
"bufio"
|
"bufio"
|
||||||
"path"
|
"path"
|
||||||
|
|
||||||
|
ice "github.com/shylinux/icebergs"
|
||||||
|
kit "github.com/shylinux/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Log struct {
|
type Log struct {
|
||||||
@ -35,19 +35,19 @@ func (f *Frame) Start(m *ice.Message, arg ...string) bool {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
file := kit.Select("bench", m.Conf("show", kit.Keys(l.l, "file")))
|
file := kit.Select(BENCH, m.Conf(SHOW, kit.Keys(l.l, FILE)))
|
||||||
view := m.Confm("view", m.Conf("show", kit.Keys(l.l, "view")))
|
view := m.Confm(VIEW, m.Conf(SHOW, kit.Keys(l.l, VIEW)))
|
||||||
bio := m.Confv("file", file+".file").(*bufio.Writer)
|
bio := m.Confv(FILE, kit.Keys(file, FILE)).(*bufio.Writer)
|
||||||
|
|
||||||
bio.WriteString(l.p)
|
bio.WriteString(l.p)
|
||||||
bio.WriteString(" ")
|
bio.WriteString(" ")
|
||||||
if p, ok := view["prefix"].(string); ok {
|
if p, ok := view[PREFIX].(string); ok {
|
||||||
bio.WriteString(p)
|
bio.WriteString(p)
|
||||||
}
|
}
|
||||||
bio.WriteString(l.l)
|
bio.WriteString(l.l)
|
||||||
bio.WriteString(" ")
|
bio.WriteString(" ")
|
||||||
bio.WriteString(l.s)
|
bio.WriteString(l.s)
|
||||||
if p, ok := view["suffix"].(string); ok {
|
if p, ok := view[SUFFIX].(string); ok {
|
||||||
bio.WriteString(p)
|
bio.WriteString(p)
|
||||||
}
|
}
|
||||||
bio.WriteString("\n")
|
bio.WriteString("\n")
|
||||||
@ -60,50 +60,71 @@ func (f *Frame) Close(m *ice.Message, arg ...string) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
PREFIX = "prefix"
|
||||||
|
SUFFIX = "suffix"
|
||||||
|
)
|
||||||
|
const (
|
||||||
|
GREEN = "green"
|
||||||
|
YELLOW = "yellow"
|
||||||
|
RED = "red"
|
||||||
|
)
|
||||||
|
const (
|
||||||
|
WATCH = "watch"
|
||||||
|
BENCH = "bench"
|
||||||
|
ERROR = "error"
|
||||||
|
TRACE = "trace"
|
||||||
|
)
|
||||||
|
const (
|
||||||
|
FILE = "file"
|
||||||
|
VIEW = "view"
|
||||||
|
SHOW = "show"
|
||||||
|
)
|
||||||
|
|
||||||
var Index = &ice.Context{Name: "log", Help: "日志模块",
|
var Index = &ice.Context{Name: "log", Help: "日志模块",
|
||||||
Configs: map[string]*ice.Config{
|
Configs: map[string]*ice.Config{
|
||||||
"file": {Name: "file", Help: "日志文件", Value: kit.Dict(
|
FILE: {Name: FILE, Help: "日志文件", Value: kit.Dict(
|
||||||
"watch", kit.Dict("path", "var/log/watch.log", "list", []string{
|
WATCH, kit.Dict(kit.MDB_PATH, path.Join(ice.VAR_LOG, "watch.log"), kit.MDB_LIST, []string{
|
||||||
ice.LOG_CREATE, ice.LOG_REMOVE,
|
ice.LOG_CREATE, ice.LOG_REMOVE,
|
||||||
ice.LOG_INSERT, ice.LOG_DELETE,
|
ice.LOG_INSERT, ice.LOG_DELETE,
|
||||||
ice.LOG_SELECT, ice.LOG_MODIFY,
|
ice.LOG_SELECT, ice.LOG_MODIFY,
|
||||||
ice.LOG_EXPORT, ice.LOG_IMPORT,
|
ice.LOG_EXPORT, ice.LOG_IMPORT,
|
||||||
}),
|
}),
|
||||||
"bench", kit.Dict("path", "var/log/bench.log", "list", []string{}),
|
BENCH, kit.Dict(kit.MDB_PATH, path.Join(ice.VAR_LOG, "bench.log"), kit.MDB_LIST, []string{}),
|
||||||
"error", kit.Dict("path", "var/log/error.log", "list", []string{
|
ERROR, kit.Dict(kit.MDB_PATH, path.Join(ice.VAR_LOG, "error.log"), kit.MDB_LIST, []string{
|
||||||
ice.LOG_WARN, ice.LOG_ERROR,
|
ice.LOG_WARN, ice.LOG_ERROR,
|
||||||
}),
|
}),
|
||||||
"trace", kit.Dict("path", "var/log/trace.log", "list", []string{}),
|
TRACE, kit.Dict(kit.MDB_PATH, path.Join(ice.VAR_LOG, "trace.log"), kit.MDB_LIST, []string{}),
|
||||||
)},
|
)},
|
||||||
"view": {Name: "view", Help: "日志格式", Value: kit.Dict(
|
VIEW: {Name: VIEW, Help: "日志格式", Value: kit.Dict(
|
||||||
"green", kit.Dict("prefix", "\033[32m", "suffix", "\033[0m", "list", []string{
|
GREEN, kit.Dict(PREFIX, "\033[32m", SUFFIX, "\033[0m", kit.MDB_LIST, []string{
|
||||||
ice.LOG_START, ice.LOG_SERVE,
|
ice.LOG_START, ice.LOG_SERVE,
|
||||||
ice.LOG_CMDS,
|
ice.LOG_CMDS,
|
||||||
}),
|
}),
|
||||||
"yellow", kit.Dict("prefix", "\033[33m", "suffix", "\033[0m", "list", []string{
|
YELLOW, kit.Dict(PREFIX, "\033[33m", SUFFIX, "\033[0m", kit.MDB_LIST, []string{
|
||||||
ice.LOG_AUTH, ice.LOG_COST,
|
ice.LOG_AUTH, ice.LOG_COST,
|
||||||
}),
|
}),
|
||||||
"red", kit.Dict("prefix", "\033[31m", "suffix", "\033[0m", "list", []string{
|
RED, kit.Dict(PREFIX, "\033[31m", SUFFIX, "\033[0m", kit.MDB_LIST, []string{
|
||||||
ice.LOG_WARN, ice.LOG_CLOSE,
|
ice.LOG_WARN, ice.LOG_CLOSE,
|
||||||
}),
|
}),
|
||||||
)},
|
)},
|
||||||
"show": {Name: "show", Help: "日志分流", Value: kit.Dict()},
|
SHOW: {Name: SHOW, Help: "日志分流", Value: kit.Dict()},
|
||||||
},
|
},
|
||||||
Commands: map[string]*ice.Command{
|
Commands: map[string]*ice.Command{
|
||||||
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
m.Confm("view", nil, func(key string, value map[string]interface{}) {
|
m.Confm(VIEW, nil, func(key string, value map[string]interface{}) {
|
||||||
kit.Fetch(value["list"], func(index int, k string) {
|
kit.Fetch(value[kit.MDB_LIST], func(index int, k string) {
|
||||||
m.Conf("show", kit.Keys(k, "view"), key)
|
m.Conf(SHOW, kit.Keys(k, VIEW), key)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
m.Confm("file", nil, func(key string, value map[string]interface{}) {
|
m.Confm(FILE, nil, func(key string, value map[string]interface{}) {
|
||||||
kit.Fetch(value["list"], func(index int, k string) {
|
kit.Fetch(value[kit.MDB_LIST], func(index int, k string) {
|
||||||
m.Conf("show", kit.Keys(k, "file"), key)
|
m.Conf(SHOW, kit.Keys(k, FILE), key)
|
||||||
})
|
})
|
||||||
// 日志文件
|
// 日志文件
|
||||||
if f, p, e := kit.Create(kit.Format(value["path"])); m.Assert(e) {
|
if f, p, e := kit.Create(kit.Format(value[kit.MDB_PATH])); m.Assert(e) {
|
||||||
m.Cap(ice.CTX_STREAM, path.Base(p))
|
m.Cap(ice.CTX_STREAM, path.Base(p))
|
||||||
value["file"] = bufio.NewWriter(f)
|
value[FILE] = bufio.NewWriter(f)
|
||||||
m.Log_CREATE(kit.MDB_FILE, p)
|
m.Log_CREATE(kit.MDB_FILE, p)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
package nfs
|
package nfs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
ice "github.com/shylinux/icebergs"
|
|
||||||
"github.com/shylinux/icebergs/base/aaa"
|
|
||||||
"github.com/shylinux/icebergs/base/mdb"
|
|
||||||
kit "github.com/shylinux/toolkits"
|
|
||||||
|
|
||||||
"bufio"
|
"bufio"
|
||||||
"bytes"
|
"bytes"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
ice "github.com/shylinux/icebergs"
|
||||||
|
"github.com/shylinux/icebergs/base/aaa"
|
||||||
|
"github.com/shylinux/icebergs/base/mdb"
|
||||||
|
kit "github.com/shylinux/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
func _cat_ext(name string) string {
|
func _cat_ext(name string) string {
|
||||||
|
@ -155,8 +155,8 @@ func Dir(m *ice.Message, sort string) {
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
TYPE_ALL = "all"
|
TYPE_ALL = "all"
|
||||||
TYPE_DIR = "dir"
|
|
||||||
TYPE_CAT = "cat"
|
TYPE_CAT = "cat"
|
||||||
|
TYPE_DIR = "dir"
|
||||||
TYPE_BOTH = "both"
|
TYPE_BOTH = "both"
|
||||||
)
|
)
|
||||||
const (
|
const (
|
||||||
@ -185,9 +185,9 @@ func init() {
|
|||||||
mdb.UPLOAD: {Name: "upload", Help: "上传", Hand: func(m *ice.Message, arg ...string) {
|
mdb.UPLOAD: {Name: "upload", Help: "上传", Hand: func(m *ice.Message, arg ...string) {
|
||||||
up := kit.Simple(m.Optionv(ice.MSG_UPLOAD))
|
up := kit.Simple(m.Optionv(ice.MSG_UPLOAD))
|
||||||
if p := path.Join(m.Option(kit.MDB_PATH), up[1]); m.Option(ice.MSG_USERPOD) == "" {
|
if p := path.Join(m.Option(kit.MDB_PATH), up[1]); m.Option(ice.MSG_USERPOD) == "" {
|
||||||
m.Cmdy("cache", "watch", up[0], p)
|
m.Cmdy("web.cache", "watch", up[0], p)
|
||||||
} else {
|
} else {
|
||||||
m.Cmdy("spide", "dev", "save", p, "GET", kit.MergeURL2(m.Option(ice.MSG_USERWEB), "/share/cache/"+up[0]))
|
m.Cmdy("web.spide", "dev", "save", p, "GET", kit.MergeURL2(m.Option(ice.MSG_USERWEB), "/share/cache/"+up[0]))
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
package nfs
|
package nfs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
ice "github.com/shylinux/icebergs"
|
|
||||||
kit "github.com/shylinux/toolkits"
|
|
||||||
|
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
ice "github.com/shylinux/icebergs"
|
||||||
|
kit "github.com/shylinux/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
func _save_file(m *ice.Message, name string, text ...string) {
|
func _save_file(m *ice.Message, name string, text ...string) {
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
package nfs
|
package nfs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bufio"
|
||||||
|
"io"
|
||||||
|
|
||||||
ice "github.com/shylinux/icebergs"
|
ice "github.com/shylinux/icebergs"
|
||||||
"github.com/shylinux/icebergs/base/cli"
|
"github.com/shylinux/icebergs/base/cli"
|
||||||
"github.com/shylinux/icebergs/base/mdb"
|
"github.com/shylinux/icebergs/base/mdb"
|
||||||
kit "github.com/shylinux/toolkits"
|
kit "github.com/shylinux/toolkits"
|
||||||
|
|
||||||
"bufio"
|
|
||||||
"io"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func _tail_create(m *ice.Message, arg ...string) {
|
func _tail_create(m *ice.Message, arg ...string) {
|
||||||
@ -38,23 +38,41 @@ const TAIL = "tail"
|
|||||||
func init() {
|
func init() {
|
||||||
Index.Merge(&ice.Context{
|
Index.Merge(&ice.Context{
|
||||||
Configs: map[string]*ice.Config{
|
Configs: map[string]*ice.Config{
|
||||||
TAIL: {Name: TAIL, Help: "跟踪", Value: kit.Data()},
|
TAIL: {Name: TAIL, Help: "日志流", Value: kit.Data()},
|
||||||
},
|
},
|
||||||
Commands: map[string]*ice.Command{
|
Commands: map[string]*ice.Command{
|
||||||
TAIL: {Name: "tail hash id auto create", Help: "跟踪", Action: map[string]*ice.Action{
|
TAIL: {Name: "tail hash id limit offend auto prev next create", Help: "日志流", Action: map[string]*ice.Action{
|
||||||
mdb.CREATE: {Name: "create file name", Help: "创建", Hand: func(m *ice.Message, arg ...string) {
|
mdb.CREATE: {Name: "create file name", Help: "创建", Hand: func(m *ice.Message, arg ...string) {
|
||||||
_tail_create(m, arg...)
|
_tail_create(m, arg...)
|
||||||
}},
|
}},
|
||||||
mdb.REMOVE: {Name: "remove", Help: "删除", Hand: func(m *ice.Message, arg ...string) {
|
mdb.REMOVE: {Name: "remove", Help: "删除", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmdy(mdb.DELETE, TAIL, "", mdb.HASH, kit.MDB_HASH, m.Option(kit.MDB_HASH))
|
m.Cmdy(mdb.DELETE, TAIL, "", mdb.HASH, kit.MDB_HASH, m.Option(kit.MDB_HASH))
|
||||||
}},
|
}},
|
||||||
|
"prev": {Name: "prev", Help: "上一页", Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
offend := kit.Int(kit.Select("0", arg, 3)) + kit.Int(kit.Select("10", arg, 2))
|
||||||
|
total := kit.Int(m.Conf(TAIL, kit.Keys(kit.MDB_HASH, arg[0], kit.MDB_META, kit.MDB_COUNT)))
|
||||||
|
if offend >= total {
|
||||||
|
offend = total - kit.Int(kit.Select("10", arg, 2))
|
||||||
|
m.Toast("已经是最后一页啦!")
|
||||||
|
}
|
||||||
|
|
||||||
|
m.Process("_rewrite", "offend", offend)
|
||||||
|
}},
|
||||||
|
"next": {Name: "next", Help: "下一页", Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
offend := kit.Int(kit.Select("0", arg, 3)) - kit.Int(kit.Select("10", arg, 2))
|
||||||
|
if offend < 0 {
|
||||||
|
offend = 0
|
||||||
|
m.Toast("已经是第一页啦!")
|
||||||
|
}
|
||||||
|
m.Process("_rewrite", "offend", offend)
|
||||||
|
}},
|
||||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
m.Option(mdb.FIELDS, kit.Select("time,hash,count,name,file", kit.Select("time,id,file,text", mdb.DETAIL, len(arg) > 1), len(arg) > 0))
|
m.Option(mdb.FIELDS, kit.Select("time,hash,count,name,file", kit.Select("time,id,file,text", mdb.DETAIL, len(arg) > 1 && arg[1] != ""), len(arg) > 0))
|
||||||
|
m.Option("cache.limit", kit.Select("10", arg, 2))
|
||||||
|
m.Option("cache.offend", kit.Select("0", arg, 3))
|
||||||
|
|
||||||
if m.Cmdy(mdb.SELECT, TAIL, "", mdb.ZONE, arg); len(arg) == 0 {
|
if m.Cmdy(mdb.SELECT, TAIL, "", mdb.ZONE, arg); len(arg) == 0 {
|
||||||
m.PushAction(mdb.REMOVE)
|
m.PushAction(mdb.REMOVE)
|
||||||
} else if len(arg) == 1 {
|
|
||||||
m.Option(ice.MSG_CONTROL, ice.CONTROL_PAGE)
|
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
package nfs
|
package nfs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
|
"path"
|
||||||
|
|
||||||
ice "github.com/shylinux/icebergs"
|
ice "github.com/shylinux/icebergs"
|
||||||
"github.com/shylinux/icebergs/base/cli"
|
"github.com/shylinux/icebergs/base/cli"
|
||||||
"github.com/shylinux/icebergs/base/mdb"
|
"github.com/shylinux/icebergs/base/mdb"
|
||||||
kit "github.com/shylinux/toolkits"
|
kit "github.com/shylinux/toolkits"
|
||||||
|
|
||||||
"os"
|
|
||||||
"path"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func _trash_create(m *ice.Message, name string) {
|
func _trash_create(m *ice.Message, name string) {
|
||||||
@ -25,7 +25,7 @@ func _trash_create(m *ice.Message, name string) {
|
|||||||
p := path.Join(m.Conf(TRASH, kit.META_PATH), h[:2], h)
|
p := path.Join(m.Conf(TRASH, kit.META_PATH), h[:2], h)
|
||||||
os.MkdirAll(path.Dir(p), ice.MOD_DIR)
|
os.MkdirAll(path.Dir(p), ice.MOD_DIR)
|
||||||
os.Rename(name, p)
|
os.Rename(name, p)
|
||||||
m.Cmdy(mdb.INSERT, TRASH, "", mdb.LIST, kit.MDB_FILE, p, kit.MDB_FROM, name)
|
m.Cmdy(mdb.INSERT, TRASH, "", mdb.HASH, kit.MDB_FILE, p, kit.MDB_FROM, name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -35,17 +35,20 @@ const TRASH = "trash"
|
|||||||
func init() {
|
func init() {
|
||||||
Index.Merge(&ice.Context{
|
Index.Merge(&ice.Context{
|
||||||
Configs: map[string]*ice.Config{
|
Configs: map[string]*ice.Config{
|
||||||
TRASH: {Name: TRASH, Help: "删除", Value: kit.Data(kit.MDB_PATH, "var/trash")},
|
TRASH: {Name: TRASH, Help: "回收站", Value: kit.Data(
|
||||||
|
kit.MDB_SHORT, kit.MDB_FROM, kit.MDB_PATH, ice.VAR_TRASH,
|
||||||
|
)},
|
||||||
},
|
},
|
||||||
Commands: map[string]*ice.Command{
|
Commands: map[string]*ice.Command{
|
||||||
TRASH: {Name: "trash file auto", Help: "删除", Action: map[string]*ice.Action{
|
TRASH: {Name: "trash file auto", Help: "回收站", Action: map[string]*ice.Action{
|
||||||
"recover": {Name: "recover", Help: "恢复", Hand: func(m *ice.Message, arg ...string) {
|
"recover": {Name: "recover", Help: "恢复", Hand: func(m *ice.Message, arg ...string) {
|
||||||
os.Rename(m.Option(kit.MDB_FILE), m.Option(kit.MDB_FROM))
|
os.Rename(m.Option(kit.MDB_FILE), m.Option(kit.MDB_FROM))
|
||||||
|
m.Cmd(mdb.DELETE, TRASH, "", mdb.HASH, kit.MDB_HASH, m.Option(kit.MDB_HASH))
|
||||||
}},
|
}},
|
||||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
if len(arg) == 0 {
|
if len(arg) == 0 {
|
||||||
m.Option(mdb.FIELDS, "time,id,file,from")
|
m.Option(mdb.FIELDS, "time,hash,file,from")
|
||||||
m.Cmdy(mdb.SELECT, TRASH, "", mdb.LIST)
|
m.Cmdy(mdb.SELECT, TRASH, "", mdb.HASH)
|
||||||
m.PushAction("recover")
|
m.PushAction("recover")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
package ssh
|
package ssh
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"io"
|
||||||
|
"net"
|
||||||
|
"os/exec"
|
||||||
|
"strings"
|
||||||
|
|
||||||
ice "github.com/shylinux/icebergs"
|
ice "github.com/shylinux/icebergs"
|
||||||
"github.com/shylinux/icebergs/base/aaa"
|
"github.com/shylinux/icebergs/base/aaa"
|
||||||
"github.com/shylinux/icebergs/base/mdb"
|
"github.com/shylinux/icebergs/base/mdb"
|
||||||
"github.com/shylinux/icebergs/base/tcp"
|
"github.com/shylinux/icebergs/base/tcp"
|
||||||
kit "github.com/shylinux/toolkits"
|
kit "github.com/shylinux/toolkits"
|
||||||
"golang.org/x/crypto/ssh"
|
"golang.org/x/crypto/ssh"
|
||||||
|
|
||||||
"io"
|
|
||||||
"net"
|
|
||||||
"os/exec"
|
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Winsize struct{ Height, Width, x, y uint16 }
|
type Winsize struct{ Height, Width, x, y uint16 }
|
||||||
|
@ -1,16 +1,6 @@
|
|||||||
package ssh
|
package ssh
|
||||||
|
|
||||||
import (
|
import (
|
||||||
ice "github.com/shylinux/icebergs"
|
|
||||||
"github.com/shylinux/icebergs/base/aaa"
|
|
||||||
"github.com/shylinux/icebergs/base/mdb"
|
|
||||||
"github.com/shylinux/icebergs/base/nfs"
|
|
||||||
"github.com/shylinux/icebergs/base/tcp"
|
|
||||||
kit "github.com/shylinux/toolkits"
|
|
||||||
|
|
||||||
"golang.org/x/crypto/ssh"
|
|
||||||
"golang.org/x/crypto/ssh/terminal"
|
|
||||||
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
@ -19,6 +9,15 @@ import (
|
|||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
ice "github.com/shylinux/icebergs"
|
||||||
|
"github.com/shylinux/icebergs/base/aaa"
|
||||||
|
"github.com/shylinux/icebergs/base/mdb"
|
||||||
|
"github.com/shylinux/icebergs/base/nfs"
|
||||||
|
"github.com/shylinux/icebergs/base/tcp"
|
||||||
|
kit "github.com/shylinux/toolkits"
|
||||||
|
"golang.org/x/crypto/ssh"
|
||||||
|
"golang.org/x/crypto/ssh/terminal"
|
||||||
)
|
)
|
||||||
|
|
||||||
func _ssh_tick(m *ice.Message, pw io.Writer) {
|
func _ssh_tick(m *ice.Message, pw io.Writer) {
|
||||||
|
@ -1,14 +1,6 @@
|
|||||||
package ssh
|
package ssh
|
||||||
|
|
||||||
import (
|
import (
|
||||||
ice "github.com/shylinux/icebergs"
|
|
||||||
"github.com/shylinux/icebergs/base/aaa"
|
|
||||||
"github.com/shylinux/icebergs/base/mdb"
|
|
||||||
"github.com/shylinux/icebergs/base/nfs"
|
|
||||||
"github.com/shylinux/icebergs/base/tcp"
|
|
||||||
kit "github.com/shylinux/toolkits"
|
|
||||||
"golang.org/x/crypto/ssh"
|
|
||||||
|
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"errors"
|
"errors"
|
||||||
@ -17,6 +9,14 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
ice "github.com/shylinux/icebergs"
|
||||||
|
"github.com/shylinux/icebergs/base/aaa"
|
||||||
|
"github.com/shylinux/icebergs/base/mdb"
|
||||||
|
"github.com/shylinux/icebergs/base/nfs"
|
||||||
|
"github.com/shylinux/icebergs/base/tcp"
|
||||||
|
kit "github.com/shylinux/toolkits"
|
||||||
|
"golang.org/x/crypto/ssh"
|
||||||
)
|
)
|
||||||
|
|
||||||
func _ssh_meta(conn ssh.ConnMetadata) map[string]string {
|
func _ssh_meta(conn ssh.ConnMetadata) map[string]string {
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package ssh
|
package ssh
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"golang.org/x/crypto/ssh"
|
||||||
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
ice "github.com/shylinux/icebergs"
|
ice "github.com/shylinux/icebergs"
|
||||||
@ -8,10 +10,6 @@ import (
|
|||||||
"github.com/shylinux/icebergs/base/mdb"
|
"github.com/shylinux/icebergs/base/mdb"
|
||||||
"github.com/shylinux/icebergs/base/tcp"
|
"github.com/shylinux/icebergs/base/tcp"
|
||||||
kit "github.com/shylinux/toolkits"
|
kit "github.com/shylinux/toolkits"
|
||||||
|
|
||||||
"io"
|
|
||||||
|
|
||||||
"golang.org/x/crypto/ssh"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func _ssh_sess(m *ice.Message, h string, client *ssh.Client) (*ssh.Session, error) {
|
func _ssh_sess(m *ice.Message, h string, client *ssh.Client) (*ssh.Session, error) {
|
||||||
@ -87,8 +85,7 @@ func init() {
|
|||||||
m.Debug("%v %v", n, e)
|
m.Debug("%v %v", n, e)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
m.Sleep("300ms")
|
m.ProcessRefresh("300ms")
|
||||||
m.Cmdy(SESSION, m.Option(kit.MDB_HASH))
|
|
||||||
}},
|
}},
|
||||||
"bind": {Name: "bind", Help: "绑定", Hand: func(m *ice.Message, arg ...string) {
|
"bind": {Name: "bind", Help: "绑定", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Richs(SESSION, "", m.Option(kit.MDB_HASH), func(key string, value map[string]interface{}) {
|
m.Richs(SESSION, "", m.Option(kit.MDB_HASH), func(key string, value map[string]interface{}) {
|
||||||
|
@ -13,14 +13,16 @@ var Index = &ice.Context{Name: SSH, Help: "终端模块", Commands: map[string]*
|
|||||||
m.Load()
|
m.Load()
|
||||||
m.Conf(SOURCE, kit.Keys(kit.MDB_HASH, STDIO, kit.MDB_META, kit.MDB_NAME), STDIO)
|
m.Conf(SOURCE, kit.Keys(kit.MDB_HASH, STDIO, kit.MDB_META, kit.MDB_NAME), STDIO)
|
||||||
m.Conf(SOURCE, kit.Keys(kit.MDB_HASH, STDIO, kit.MDB_META, kit.MDB_TIME), m.Time())
|
m.Conf(SOURCE, kit.Keys(kit.MDB_HASH, STDIO, kit.MDB_META, kit.MDB_TIME), m.Time())
|
||||||
|
|
||||||
|
m.Richs(SERVICE, "", kit.MDB_FOREACH, func(key string, value map[string]interface{}) {
|
||||||
|
value = kit.GetMeta(value)
|
||||||
|
m.Cmd(SERVICE, tcp.LISTEN, tcp.PORT, value[tcp.PORT], value)
|
||||||
|
})
|
||||||
}},
|
}},
|
||||||
ice.CTX_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
ice.CTX_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
if _, ok := m.Target().Server().(*Frame); ok {
|
if _, ok := m.Target().Server().(*Frame); ok {
|
||||||
m.Done(true)
|
m.Done(true)
|
||||||
}
|
}
|
||||||
m.Richs(SERVICE, "", kit.MDB_FOREACH, func(key string, value map[string]interface{}) {
|
|
||||||
kit.Value(value, "meta.status", tcp.CLOSE)
|
|
||||||
})
|
|
||||||
m.Richs(CHANNEL, "", kit.MDB_FOREACH, func(key string, value map[string]interface{}) {
|
m.Richs(CHANNEL, "", kit.MDB_FOREACH, func(key string, value map[string]interface{}) {
|
||||||
kit.Value(value, "meta.status", tcp.CLOSE)
|
kit.Value(value, "meta.status", tcp.CLOSE)
|
||||||
})
|
})
|
||||||
|
@ -5,9 +5,10 @@ refer `
|
|||||||
源码 https://github.com/openssh/openssh-portable
|
源码 https://github.com/openssh/openssh-portable
|
||||||
`
|
`
|
||||||
|
|
||||||
field "脚本" ssh.source
|
|
||||||
|
|
||||||
field "服务" ssh.service
|
field "服务" ssh.service
|
||||||
field "通道" ssh.channel
|
field "通道" ssh.channel
|
||||||
|
|
||||||
field "连接" ssh.connect
|
field "连接" ssh.connect
|
||||||
field "会话" ssh.session
|
field "会话" ssh.session
|
||||||
|
field "脚本" ssh.source
|
||||||
|
|
||||||
|
2
conf.go
2
conf.go
@ -34,7 +34,9 @@ const ( // DIR
|
|||||||
PROTO_JS = "proto.js"
|
PROTO_JS = "proto.js"
|
||||||
FRAME_JS = "frame.js"
|
FRAME_JS = "frame.js"
|
||||||
|
|
||||||
|
VAR_LOG = "var/log"
|
||||||
VAR_CONF = "var/conf"
|
VAR_CONF = "var/conf"
|
||||||
|
VAR_TRASH = "var/trash"
|
||||||
ETC_MISS = "etc/miss.sh"
|
ETC_MISS = "etc/miss.sh"
|
||||||
ETC_INIT = "etc/init.shy"
|
ETC_INIT = "etc/init.shy"
|
||||||
ETC_EXIT = "etc/exit.shy"
|
ETC_EXIT = "etc/exit.shy"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user