diff --git a/pkg/handler/dbpaginator.go b/pkg/handler/dbpaginator.go index 2f3817907..527ac44cf 100644 --- a/pkg/handler/dbpaginator.go +++ b/pkg/handler/dbpaginator.go @@ -16,16 +16,16 @@ type DatabasePaginator interface { SearchKeys() []string } -func NewLocalDatabasePaginator(data [] model.Database, pageSize int) DatabasePaginator { +func NewLocalDatabasePaginator(data []model.Database, pageSize int) DatabasePaginator { p := localDatabasePaginator{ allData: data, currentData: data, - pageSize: pageSize, currentOffset: 0, currentPage: 1, search: make([]string, 0, 4), lock: new(sync.RWMutex), } + p.SetPageSize(pageSize) return &p } @@ -177,7 +177,7 @@ func searchFromLocalDBs(dbs []model.Database, key string) []model.Database { displayDBs := make([]model.Database, 0, len(dbs)) key = strings.ToLower(key) for _, db := range dbs { - contents := []string{strings.ToLower(db.Name),strings.ToLower(db.DBName), + contents := []string{strings.ToLower(db.Name), strings.ToLower(db.DBName), strings.ToLower(db.Host), strings.ToLower(db.Comment)} if isSubstring(contents, key) { displayDBs = append(displayDBs, db) diff --git a/pkg/httpd/websshws.go b/pkg/httpd/websshws.go index 96a92641a..5250e9de2 100644 --- a/pkg/httpd/websshws.go +++ b/pkg/httpd/websshws.go @@ -45,10 +45,8 @@ func OnNamespaceConnected(ns *neffos.NSConn, msg neffos.Message) error { userConn, err := NewUserWebsocketConnWithSession(ns) if err != nil { - ns.Emit("data", neffos.Marshal(err.Error())) - ns.Emit("disconnect", []byte("")) - ns.Conn.Close() - return err + logger.Errorf("Ws %s check session failed, may use token", ns.Conn.ID()) + return nil } logger.Infof("Accepted user %s connect ssh ws", userConn.User.Username) websocketManager.AddUserCon(ns.Conn.ID(), userConn) @@ -203,13 +201,14 @@ func OnTokenHandler(ns *neffos.NSConn, msg neffos.Message) (err error) { } userConn, err := NewUserWebsocketConnWithTokenUser(ns, tokenUser) if err != nil { - msg := "User id error" + msg := "check token error" dataMsg := DataMsg{Data: msg, Room: roomID} ns.Emit("data", neffos.Marshal(dataMsg)) ns.Emit("disconnect", neffos.Marshal([]byte(""))) logger.Error("Token Event: ", msg) return errors.New("user id error") } + logger.Infof("Ws %s accepted user %s connect by token", ns.Conn.ID(), userConn.User.Username) websocketManager.AddUserCon(ns.Conn.ID(), userConn) go userConn.loopHandler() hostMsg := HostMsg{ diff --git a/pkg/koko/koko.go b/pkg/koko/koko.go index 0e03ef50c..17e62bf64 100644 --- a/pkg/koko/koko.go +++ b/pkg/koko/koko.go @@ -17,7 +17,7 @@ import ( "github.com/jumpserver/koko/pkg/sshd" ) -const Version = "1.5.9" +const Version = "2.0.0" type Coco struct { } diff --git a/pkg/model/assets.go b/pkg/model/assets.go index cb9892b8c..0925c9320 100644 --- a/pkg/model/assets.go +++ b/pkg/model/assets.go @@ -295,14 +295,10 @@ const ( ) type SystemUserFilterRule struct { - Priority int `json:"priority"` - Type struct { - Value string `json:"value"` - } `json:"type"` - Content string `json:"content"` - Action struct { - Value RuleAction `json:"value"` - } `json:"action"` + Priority int `json:"priority"` + Type string `json:"type"` + Content string `json:"content"` + Action RuleAction `json:"action"` pattern *regexp.Regexp compiled bool @@ -313,7 +309,7 @@ func (sf *SystemUserFilterRule) Pattern() *regexp.Regexp { return sf.pattern } var regexs string - if sf.Type.Value == TypeCmd { + if sf.Type == TypeCmd { var regex []string for _, cmd := range strings.Split(sf.Content, "\r\n") { cmd = regexp.QuoteMeta(cmd) @@ -346,5 +342,5 @@ func (sf *SystemUserFilterRule) Match(cmd string) (RuleAction, string) { if found == "" { return ActionUnknown, "" } - return sf.Action.Value, found + return sf.Action, found }