From 580abeee23a998bb44befd51d14012e75236b8a0 Mon Sep 17 00:00:00 2001 From: richie Date: Tue, 4 Jun 2019 11:17:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0log=E5=AD=97=E6=AE=B5serviceN?= =?UTF-8?q?ame?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/api/controller.go | 2 ++ pkg/utils/logger.go | 1 + pkg/ws/connection.go | 3 +-- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/api/controller.go b/pkg/api/controller.go index 2f2d1cf..0a727e4 100644 --- a/pkg/api/controller.go +++ b/pkg/api/controller.go @@ -68,6 +68,7 @@ func (handler *streamHandler) Read(p []byte) (size int, err error) { if err = json.Unmarshal(msg.Data, &xtermMsg); err != nil { return } + // web ssh 调整了终端大小 if xtermMsg.MsgType == "resize" { // 放到channel里, 等remotecommand executor 调用我们的Next取走 @@ -78,6 +79,7 @@ func (handler *streamHandler) Read(p []byte) (size int, err error) { copy(p, xtermMsg.Input) } + return } diff --git a/pkg/utils/logger.go b/pkg/utils/logger.go index a0f6f35..9c54045 100644 --- a/pkg/utils/logger.go +++ b/pkg/utils/logger.go @@ -94,6 +94,7 @@ func GinRus(logger loggerEntryWithfields, timeFormat string, utc bool) gin.Handl } entry := logger.WithFields(logrus.Fields{ + "serviceName": "k8s-webshell", "status": c.Writer.Status(), "method": c.Request.Method, "path": requestPath, diff --git a/pkg/ws/connection.go b/pkg/ws/connection.go index 6e495d8..4c455d7 100644 --- a/pkg/ws/connection.go +++ b/pkg/ws/connection.go @@ -10,7 +10,7 @@ import ( ) var wsUpgrader = websocket.Upgrader{ - ReadBufferSize: 16384, + ReadBufferSize: 16384, WriteBufferSize: 16384, // 允许所有CORS跨域访问 CheckOrigin: func(r *http.Request) bool { @@ -55,7 +55,6 @@ func (wsConn *WsConnection) wsReadLoop() { MessageType: msgType, Data: data, } - select { case wsConn.inChan <- msg: case <-wsConn.closeChan: