From 65cec6559772a4236b6237e78ffedbab01eafa77 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Sat, 28 Dec 2024 18:48:29 +0900 Subject: [PATCH] added SetXtermHtml and GetXtermHtml to enable the caller to customize the ssh page --- server-proxy.go | 8 ++++++-- server.go | 12 +++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/server-proxy.go b/server-proxy.go index 9f7ca8c..f8c1266 100644 --- a/server-proxy.go +++ b/server-proxy.go @@ -29,7 +29,7 @@ var xterm_addon_fit_js []byte //go:embed xterm.css var xterm_css []byte //go:embed xterm.html -var xterm_html []byte +var xterm_html string type server_proxy struct { s *Server @@ -547,7 +547,11 @@ func (pxy *server_proxy_xterm_file) ServeHTTP(w http.ResponseWriter, req *http.R } tmpl = template.New("") - _, err = tmpl.Parse(string(xterm_html)) + if s.xterm_html != "" { + _, err = tmpl.Parse(s.xterm_html) + } else { + _, err = tmpl.Parse(xterm_html) + } if err != nil { status_code = http.StatusInternalServerError; w.WriteHeader(status_code) goto oops diff --git a/server.go b/server.go index 5a82fbd..6ae7608 100644 --- a/server.go +++ b/server.go @@ -59,7 +59,6 @@ type Server struct { wpx_addr []string wpx_mux *http.ServeMux wpx []*http.Server // proxy server than handles http/https only - wpx_resp_tf ServerWpxResponseTransformer ctl_addr []string ctl_prefix string @@ -90,6 +89,9 @@ type Server struct { ssh_proxy_sessions atomic.Int64 } + wpx_resp_tf ServerWpxResponseTransformer + xterm_html string + UnimplementedHoduServer } @@ -1123,6 +1125,14 @@ func (s *Server) GetWpxResponseTransformer() ServerWpxResponseTransformer { return s.wpx_resp_tf } +func (s *Server) SetXtermHtml(html string) { + s.xterm_html = html +} + +func (s *Server) GetXtermHtml() string { + return s.xterm_html +} + func (s *Server) run_grpc_server(idx int, wg *sync.WaitGroup) error { var l *net.TCPListener var err error