telnet设置超时时间
This commit is contained in:
@@ -16,7 +16,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
"github.com/morganhein/go-telnet"
|
"github.com/linxiaozhi/go-telnet"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -167,7 +167,7 @@ func (self *ServerController) AjaxTestServer() {
|
|||||||
func RemoteCommandByTelnetPassword(servers *models.TaskServer) error {
|
func RemoteCommandByTelnetPassword(servers *models.TaskServer) error {
|
||||||
|
|
||||||
addr := fmt.Sprintf("%s:%d", servers.ServerIp, servers.Port)
|
addr := fmt.Sprintf("%s:%d", servers.ServerIp, servers.Port)
|
||||||
conn, err := gote.Dial("tcp", addr)
|
conn, err := gote.DialTimeout("tcp", addr, time.Second*10)
|
||||||
|
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
|
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ import (
|
|||||||
"golang.org/x/crypto/ssh"
|
"golang.org/x/crypto/ssh"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/axgle/mahonia"
|
"github.com/axgle/mahonia"
|
||||||
"github.com/morganhein/go-telnet"
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"github.com/linxiaozhi/go-telnet"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Job struct {
|
type Job struct {
|
||||||
@@ -232,7 +232,7 @@ func RemoteCommandJobByTelnetPassword(id int, name string, command string, serve
|
|||||||
job.runFunc = func(timeout time.Duration) (string, string, error, bool) {
|
job.runFunc = func(timeout time.Duration) (string, string, error, bool) {
|
||||||
|
|
||||||
addr := fmt.Sprintf("%s:%d", servers.ServerIp, servers.Port)
|
addr := fmt.Sprintf("%s:%d", servers.ServerIp, servers.Port)
|
||||||
conn, err := gote.Dial("tcp", addr)
|
conn, err := gote.DialTimeout("tcp", addr, timeout)
|
||||||
|
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user