Commit acc58e40 authored by Eric's avatar Eric

upgrade jquery related files

parent c2479868
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
<html> <html>
<body style="margin: 0"> <body style="margin: 0">
<script type="text/javascript" src="/coco/static/js/jquery-2.1.1.js"></script> <script type="text/javascript" src="/coco/static/js/jquery-3.3.1.js"></script>
<script type="text/javascript" src="/coco/static/js/jquery-ui-1.10.4.min.js"></script> <script type="text/javascript" src="/coco/static/js/jquery-ui-1.12.1.js"></script>
<script type="text/javascript" src="/coco/static/js/neffos.min.js"></script> <script type="text/javascript" src="/coco/static/js/neffos.min.js"></script>
<script type="text/javascript" src="/coco/static/plugins/elfinder/elfinder.full.js"></script> <script type="text/javascript" src="/coco/static/plugins/elfinder/elfinder.full.js"></script>
<script type="text/javascript" src="/coco/static/plugins/elfinder/i18n/elfinder.pl.js"></script> <script type="text/javascript" src="/coco/static/plugins/elfinder/i18n/elfinder.pl.js"></script>
<link rel="stylesheet" type="text/css" media="screen" href="/coco/static/js/jquery-ui-1.10.4.min.css"> <link rel="stylesheet" type="text/css" media="screen" href="/coco/static/plugins/elfinder/css/jquery-ui-1.12.1.min.css">
<link rel="stylesheet" type="text/css" media="screen" href="/coco/static/plugins/elfinder/css/elfinder.min.css"> <link rel="stylesheet" type="text/css" media="screen" href="/coco/static/plugins/elfinder/css/elfinder.full.css">
<link rel="stylesheet" type="text/css" media="screen" href="/coco/static/plugins/elfinder/css/theme-gray.css"> <link rel="stylesheet" type="text/css" media="screen" href="/coco/static/plugins/elfinder/css/theme-gray.css">
<script type="text/javascript" charset="utf-8"> <script type="text/javascript" charset="utf-8">
var scheme = document.location.protocol == "https:" ? "wss" : "ws"; var scheme = document.location.protocol == "https:" ? "wss" : "ws";
......
...@@ -78,7 +78,16 @@ func (s *SSHClient) Close() error { ...@@ -78,7 +78,16 @@ func (s *SSHClient) Close() error {
return s.client.Close() return s.client.Close()
} }
func KeepAlive(c *gossh.Client, closed <-chan struct{}, keepInterval time.Duration) { func (s *SSHClient) IsClosed() bool {
select {
case <-s.closed:
return true
default:
return false
}
}
func KeepAlive(c *SSHClient, closed <-chan struct{}, keepInterval time.Duration) {
t := time.NewTicker(keepInterval * time.Second) t := time.NewTicker(keepInterval * time.Second)
defer t.Stop() defer t.Stop()
logger.Debugf("SSH client %p keep alive start", c) logger.Debugf("SSH client %p keep alive start", c)
...@@ -88,11 +97,16 @@ func KeepAlive(c *gossh.Client, closed <-chan struct{}, keepInterval time.Durati ...@@ -88,11 +97,16 @@ func KeepAlive(c *gossh.Client, closed <-chan struct{}, keepInterval time.Durati
case <-closed: case <-closed:
return return
case <-t.C: case <-t.C:
_, _, err := c.SendRequest("keepalive@jumpserver.org", true, nil) ok, result, err := c.client.SendRequest("keepalive@openssh.com", true, nil)
if err != nil { if err != nil {
logger.Errorf("SSH client %p keep alive err: ", c, err.Error()) logger.Errorf("SSH client %p keep alive err: %s", c, err.Error())
_ = c.Close()
RecycleClient(c)
logger.Debugf("Recycle Client SSH client %p ", c)
return return
} }
fmt.Println("keep alive ok: ", ok," "," result ", string(result))
} }
} }
...@@ -236,13 +250,14 @@ func newClient(asset *model.Asset, systemUser *model.SystemUser, timeout time.Du ...@@ -236,13 +250,14 @@ func newClient(asset *model.Asset, systemUser *model.SystemUser, timeout time.Du
return nil, err return nil, err
} }
closed := make(chan struct{}) closed := make(chan struct{})
go KeepAlive(conn, closed, 60) client = &SSHClient{
return &SSHClient{
ref: 1, ref: 1,
client: conn, client: conn,
username: systemUser.Username, username: systemUser.Username,
mu: new(sync.RWMutex), mu: new(sync.RWMutex),
closed: closed,}, nil closed: closed,}
go KeepAlive(client, closed, 60)
return client, nil
} }
func NewClient(user *model.User, asset *model.Asset, systemUser *model.SystemUser, timeout time.Duration, func NewClient(user *model.User, asset *model.Asset, systemUser *model.SystemUser, timeout time.Duration,
...@@ -257,7 +272,7 @@ func NewClient(user *model.User, asset *model.Asset, systemUser *model.SystemUse ...@@ -257,7 +272,7 @@ func NewClient(user *model.User, asset *model.Asset, systemUser *model.SystemUse
systemUser.Username = client.username systemUser.Username = client.username
} }
logger.Infof("Reuse connection: %s->%s@%s. SSH client %p current ref: %d", logger.Infof("Reuse connection: %s->%s@%s. SSH client %p current ref: %d",
user.Username, client.username, asset.IP, client.client, client.refCount()) user.Username, client.username, asset.IP, client, client.refCount())
return client, nil return client, nil
} }
} }
...@@ -292,16 +307,16 @@ func RecycleClient(client *SSHClient) { ...@@ -292,16 +307,16 @@ func RecycleClient(client *SSHClient) {
return return
} }
client.decreaseRef() client.decreaseRef()
logger.Debugf("SSH client %p ref -1. current ref: %d", client.client, client.refCount()) logger.Debugf("SSH client %p ref -1. current ref: %d", client, client.refCount())
if client.refCount() == 0 { if client.refCount() == 0 || client.IsClosed() {
clientLock.Lock() clientLock.Lock()
delete(sshClients, client.key) delete(sshClients, client.key)
clientLock.Unlock() clientLock.Unlock()
err := client.Close() err := client.Close()
if err != nil { if err != nil {
logger.Errorf("Failed to close SSH client %p err: %s ", client.client, err.Error()) logger.Errorf("Failed to close SSH client %p err: %s ", client, err.Error())
} else { } else {
logger.Debugf("Success to close SSH client %p", client.client) logger.Debugf("Success to close SSH client %p", client)
} }
} }
} }
...@@ -489,7 +489,7 @@ func (u *UserSftp) GetSFTPAndRealPath(req requestMessage) (conn *SftpConn, realP ...@@ -489,7 +489,7 @@ func (u *UserSftp) GetSFTPAndRealPath(req requestMessage) (conn *SftpConn, realP
if su, ok := host.suMaps[req.su]; ok { if su, ok := host.suMaps[req.su]; ok {
key := fmt.Sprintf("%s@%s", su.Name, req.host) key := fmt.Sprintf("%s@%s", su.Name, req.host)
conn, ok := u.sftpClients[key] conn, ok := u.sftpClients[key]
if !ok { if !ok || conn.conn.IsClosed(){
var err error var err error
conn, err = u.GetSftpClient(host.asset, su) conn, err = u.GetSftpClient(host.asset, su)
if err != nil { if err != nil {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment