fix: telnet连接不一定支持调整窗口大小先移除
This commit is contained in:
@@ -50,11 +50,6 @@ func (c *ConnTelnet) NewClient() (*ConnTelnet, error) {
|
||||
// fmt.Fprintln(client, c.User)
|
||||
// fmt.Fprintln(client, c.Password)
|
||||
|
||||
// 调整窗口大小 (120 列 x 128 行)
|
||||
// 需要确保接收方理解并正确处理发送窗口大小设置命令
|
||||
client.Write([]byte{255, 251, 31})
|
||||
client.Write([]byte{255, 250, 31, byte(120 >> 8), byte(120 & 0xFF), byte(128 >> 8), byte(128 & 0xFF), 255, 240})
|
||||
|
||||
c.Client = &client
|
||||
|
||||
// 排空连接登录的信息
|
||||
@@ -116,6 +111,6 @@ func (c *ConnTelnet) NewClientSession(cols, rows int) (*TelnetClientSession, err
|
||||
s := &TelnetClientSession{
|
||||
Client: *c.Client,
|
||||
}
|
||||
s.WindowChange(cols, rows)
|
||||
// s.WindowChange(cols, rows)
|
||||
return s, nil
|
||||
}
|
||||
@@ -47,11 +47,11 @@ func (s *TelnetClientSession) Read() []byte {
|
||||
buf := make([]byte, 1024)
|
||||
// 设置读取超时时间为100毫秒
|
||||
s.Client.SetReadDeadline(time.Now().Add(100 * time.Millisecond))
|
||||
_, err := s.Client.Read(buf)
|
||||
n, err := s.Client.Read(buf)
|
||||
if err != nil {
|
||||
return []byte{}
|
||||
}
|
||||
return buf
|
||||
return buf[:n]
|
||||
}
|
||||
|
||||
// CombinedOutput 发送命令带结果返回
|
||||
Reference in New Issue
Block a user