Skip to content

Commit

Permalink
Merge pull request #302 from jumpserver/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
LeeEirc authored Jun 18, 2020
2 parents 26a3cef + eb35555 commit 2ca831d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 19 deletions.
6 changes: 3 additions & 3 deletions pkg/handler/dbpaginator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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)
Expand Down
9 changes: 4 additions & 5 deletions pkg/httpd/websshws.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion pkg/koko/koko.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"github.com/jumpserver/koko/pkg/sshd"
)

const Version = "1.5.9"
const Version = "2.0.0"

type Coco struct {
}
Expand Down
16 changes: 6 additions & 10 deletions pkg/model/assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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
}

0 comments on commit 2ca831d

Please sign in to comment.