perf: ws模块telnet分开处理避免类型指针错误导致panic程序崩溃
This commit is contained in:
@@ -19,6 +19,17 @@ func (s *TelnetClientSession) Close() {
|
||||
}
|
||||
}
|
||||
|
||||
// WindowChange informs the remote host about a terminal window dimension change to h rows and w columns.
|
||||
func (s *TelnetClientSession) WindowChange(h, w int) error {
|
||||
if s.Client == nil {
|
||||
return fmt.Errorf("client is nil to content write failed")
|
||||
}
|
||||
// 需要确保接收方理解并正确处理发送窗口大小设置命令
|
||||
s.Client.Write([]byte{255, 251, 31})
|
||||
s.Client.Write([]byte{255, 250, 31, byte(w >> 8), byte(w & 0xFF), byte(h >> 8), byte(h & 0xFF), 255, 240})
|
||||
return nil
|
||||
}
|
||||
|
||||
// Write 写入命令 不带回车(\n)也会执行根据客户端情况
|
||||
func (s *TelnetClientSession) Write(cmd string) (int, error) {
|
||||
if s.Client == nil {
|
||||
|
||||
Reference in New Issue
Block a user