From 554368f282a8c1552cc3c29099a3a4a8cc41d4ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B1=88=E8=BD=A9?= Date: Wed, 18 Dec 2024 18:27:55 +0800 Subject: [PATCH] fix(webconsole): vnc add cookie head (#21827) --- go.mod | 2 +- go.sum | 4 ++-- pkg/webconsole/server/websocketproxy_server.go | 5 +++++ vendor/modules.txt | 2 +- vendor/yunion.io/x/cloudmux/pkg/cloudprovider/instance.go | 3 +++ 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 82eecb50df0..39880b7650c 100644 --- a/go.mod +++ b/go.mod @@ -93,7 +93,7 @@ require ( k8s.io/cri-api v0.22.17 k8s.io/klog/v2 v2.20.0 moul.io/http2curl/v2 v2.3.0 - yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20241216075633-a8665686cf63 + yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20241218101206-5e3f6758dc2c yunion.io/x/executor v0.0.0-20241205080005-48f5b1212256 yunion.io/x/jsonutils v1.0.1-0.20240930100528-1671a2d0d22f yunion.io/x/log v1.0.1-0.20240305175729-7cf2d6cd5a91 diff --git a/go.sum b/go.sum index 18720d617f9..fa89ae9c755 100644 --- a/go.sum +++ b/go.sum @@ -1376,8 +1376,8 @@ sigs.k8s.io/structured-merge-diff/v4 v4.0.1/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q= sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= -yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20241216075633-a8665686cf63 h1:j5XE/WcpbSolZfeQueXmtxiVVxdQWC2Qr9RtNnzEwR0= -yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20241216075633-a8665686cf63/go.mod h1:rj/pb3DitJlQaQD8UW1oxx/KD+PzDZqoywzqRJaFE9A= +yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20241218101206-5e3f6758dc2c h1:h5qhNEV9VsJ6VkbC/lmV+kZW2ZsMT+DRDwb+gGIpr+w= +yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20241218101206-5e3f6758dc2c/go.mod h1:rj/pb3DitJlQaQD8UW1oxx/KD+PzDZqoywzqRJaFE9A= yunion.io/x/executor v0.0.0-20241205080005-48f5b1212256 h1:kLKQ6zbgPDQflRwoHFAjxNChcbhXIFgsUVLkJwiXu/8= yunion.io/x/executor v0.0.0-20241205080005-48f5b1212256/go.mod h1:Uxuou9WQIeJXNpy7t2fPLL0BYLvLiMvGQwY7Qc6aSws= yunion.io/x/jsonutils v0.0.0-20190625054549-a964e1e8a051/go.mod h1:4N0/RVzsYL3kH3WE/H1BjUQdFiWu50JGCFQuuy+Z634= diff --git a/pkg/webconsole/server/websocketproxy_server.go b/pkg/webconsole/server/websocketproxy_server.go index e97d04465a4..79dfdba0941 100644 --- a/pkg/webconsole/server/websocketproxy_server.go +++ b/pkg/webconsole/server/websocketproxy_server.go @@ -30,6 +30,7 @@ import ( type WebsocketProxyServer struct { Session *session.SSession proxy *websocketproxy.WebsocketProxy + cookie string } func NewWebsocketProxyServer(s *session.SSession) (*WebsocketProxyServer, error) { @@ -56,9 +57,13 @@ func NewWebsocketProxyServer(s *session.SSession) (*WebsocketProxyServer, error) return &WebsocketProxyServer{ Session: s, proxy: proxySrv, + cookie: info.Cookie, }, nil } func (s *WebsocketProxyServer) ServeHTTP(w http.ResponseWriter, r *http.Request) { + if len(s.cookie) > 0 { + r.Header.Set("Cookie", s.cookie) + } s.proxy.ServeHTTP(w, r) } diff --git a/vendor/modules.txt b/vendor/modules.txt index 638c641861a..d8b31d8be52 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1785,7 +1785,7 @@ sigs.k8s.io/structured-merge-diff/v4/value # sigs.k8s.io/yaml v1.2.0 ## explicit; go 1.12 sigs.k8s.io/yaml -# yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20241216075633-a8665686cf63 +# yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20241218101206-5e3f6758dc2c ## explicit; go 1.21 yunion.io/x/cloudmux/pkg/apis yunion.io/x/cloudmux/pkg/apis/billing diff --git a/vendor/yunion.io/x/cloudmux/pkg/cloudprovider/instance.go b/vendor/yunion.io/x/cloudmux/pkg/cloudprovider/instance.go index 5966f76bf52..ba1843407ff 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/cloudprovider/instance.go +++ b/vendor/yunion.io/x/cloudmux/pkg/cloudprovider/instance.go @@ -361,6 +361,9 @@ type ServerVncOutput struct { ConnectParams string `json:"connect_params"` Session string `json:"session"` + // sangfor + Cookie string `json:"cookie"` + Hypervisor string `json:"hypervisor"` }