telnet设置超时时间

This commit is contained in:
linxiaozhi
2019-02-18 02:35:22 +08:00
parent 4f7f536e97
commit 3bfcf57330
2 changed files with 4 additions and 4 deletions

View File

@@ -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()

View File

@@ -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()