Skip to content

Commit

Permalink
Merge pull request #5 from blacknon/v0.1.5
Browse files Browse the repository at this point in the history
V0.1.5
  • Loading branch information
blacknon authored Sep 10, 2024
2 parents 071e8ed + 1601e18 commit e31d634
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 21 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ toolchain go1.22.5

require (
github.com/blacknon/go-sshproc v0.1.1
github.com/blacknon/lssh v0.6.11
github.com/blacknon/lssh v0.6.13
github.com/blacknon/mview v0.1.5
github.com/c9s/goprocinfo v0.0.0-20210130143923-c95fcf8c64a8
github.com/dustin/go-humanize v1.0.0
Expand All @@ -24,7 +24,7 @@ require (
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 // indirect
github.com/blacknon/crypto11 v1.2.7 // indirect
github.com/blacknon/go-nfs-sshlib v0.0.3 // indirect
github.com/blacknon/go-sshlib v0.1.17 // indirect
github.com/blacknon/go-sshlib v0.1.18 // indirect
github.com/blacknon/go-x11auth v0.1.0 // indirect
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
github.com/dchest/bcrypt_pbkdf v0.0.0-20150205184540-83f37f9c154a // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ github.com/blacknon/crypto11 v1.2.7 h1:LKrnCeXAk4jQmpJTeg/tVvNjqEgKHIE+tYSNXQj8F
github.com/blacknon/crypto11 v1.2.7/go.mod h1:Z24sFD9pMX3NdUFzX52ggcV7HurAYAGvxud73BrHudA=
github.com/blacknon/go-nfs-sshlib v0.0.3 h1:tq83kTZibrr99/GCn0pqkJhmBTDMupL/eMI3ZhSM0G4=
github.com/blacknon/go-nfs-sshlib v0.0.3/go.mod h1:jaCmHgFoj8j08rGrBnhJ4nFO7nUWs4xFrUd2vEPwyx8=
github.com/blacknon/go-sshlib v0.1.17 h1:iEMIeYsAJLigapB61i4D3VpdOnFboWpztob0ufhmkhQ=
github.com/blacknon/go-sshlib v0.1.17/go.mod h1:DN5Vkl/FpEzVxGoS0p8uBsBoHpVywiHbALr9UxcfJxw=
github.com/blacknon/go-sshlib v0.1.18 h1:gzkplZuAH2aHARng2YbiEjzGufZomPdGoMQuqmdA2R0=
github.com/blacknon/go-sshlib v0.1.18/go.mod h1:DN5Vkl/FpEzVxGoS0p8uBsBoHpVywiHbALr9UxcfJxw=
github.com/blacknon/go-sshproc v0.1.1 h1:Zhhm/lyC+lotbN8vqXD3fnxVbJP4ILMCu086PuTLXFo=
github.com/blacknon/go-sshproc v0.1.1/go.mod h1:FoW0cVjAxqtJVrhgzif6SOBsZ27EiMF/i2iCqiUPwBY=
github.com/blacknon/go-x11auth v0.1.0 h1:SnljCPWcvglWeGAlKc1RAPMHnOfMpM9+GrTGEUQ1lqQ=
github.com/blacknon/go-x11auth v0.1.0/go.mod h1:SKOCa19LluXHyB+OaLYobquzceE0SWxVW7e/qU5xGBM=
github.com/blacknon/lssh v0.6.11 h1:6LF/X7Fhwyj7zG+RsxF4vpYd0MJIFIw4vgzcBv4waNk=
github.com/blacknon/lssh v0.6.11/go.mod h1:8+Ok3QU0WxDP91XQaCj/VJ8PnYkLwxelqLEFGid+RBg=
github.com/blacknon/lssh v0.6.13 h1:tbBPrQEWZCtOydrNM0AU66+kYP6A8CICC5IZByjUbq4=
github.com/blacknon/lssh v0.6.13/go.mod h1:vATi4lxN/t+8YgOQL8ZktxyJnmA7ZMcct8ZIloCuaxY=
github.com/blacknon/mview v0.1.5 h1:Ojh13uB1MH6Rfg7uaK6BdbsNV05bWik6eFVaG2sD1M8=
github.com/blacknon/mview v0.1.5/go.mod h1:zDpvfOFP8nr541iWsT/QEGSPh78DmkGEVeWYUM5gYSI=
github.com/c9s/goprocinfo v0.0.0-20210130143923-c95fcf8c64a8 h1:SjZ2GvvOononHOpK84APFuMvxqsk3tEIaKH/z4Rpu3g=
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ USAGE:
app.Name = "LsMon"
app.Usage = "TUI list select and parallel ssh client shell."
app.Copyright = "blacknon(blacknon@orebibou.com)"
app.Version = "0.1.3"
app.Version = "0.1.5"

// Set options
app.Flags = []cli.Flag{
Expand Down
18 changes: 12 additions & 6 deletions mon/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,30 +192,36 @@ func (n *Node) Connect(r *sshrun.Run) (err error) {
}

// Create Session and run KeepAlive
con.SetLog("/dev/null", false)
con.SendKeepAliveInterval = 1
con.SendKeepAliveInterval = 10

procCon := &sshproc.ConnectWithProc{Connect: con}
err = procCon.CreateSftpClient()
if err != nil {
con.Client.Close()
log.Printf("CreateSftpClient %s Error: %s", n.ServerName, err)
n.con.Connect = nil
return
}

n.con = procCon

session, err := con.CreateSession()
if err != nil {
procCon.Client.Close()
log.Printf("CreateSession %s Error: %s", n.ServerName, err)
n.con.Connect = nil
procCon.CloseSftpClient()
con.Client.Close()
return
}

// send keepalive
go func() {
log.Println("Start KeepAlive. Server:", n.ServerName)
con.SendKeepAlive(session)

// close sftp client
session.Close()
err := procCon.CloseSftpClient()
if err != nil {
log.Printf("CloseSession Error: %s", err)
}
}()

return
Expand Down
16 changes: 8 additions & 8 deletions mon/panel_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,18 @@ func (m *Monitor) reconnectServer() {
for range ticker.C {
var wg sync.WaitGroup
for _, node := range m.Nodes {
log.Printf("start Reconnect Server: %s", node.ServerName)
wg.Add(1)
// Check client alive
if !node.CheckClientAlive() {
wg.Add(1)

go func(n *Node, r *ssh.Run, wg *sync.WaitGroup) {
defer wg.Done()
if !n.CheckClientAlive() {
go func(n *Node, r *ssh.Run, wgg *sync.WaitGroup) {
defer wgg.Done()
log.Printf("try Reconnect Server: %s", n.ServerName)
err := n.Connect(r)
log.Printf("exit Reconnect Server: %s, err: %s", n.ServerName, err)
}
}(node, m.r, &wg)

log.Printf("exit Reconnect Server: %s, err: %s", n.ServerName, err)
}(node, m.r, &wg)
}
}

wg.Wait()
Expand Down

0 comments on commit e31d634

Please sign in to comment.