From 5a21d380dd2712bffa5952ab2c7146cc90ce6012 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=BDiga=20Kokelj?= Date: Wed, 11 Dec 2024 08:38:50 +0100 Subject: [PATCH] use wss instead of ws if tlcConfig is provided --- lib/gethfork/node/rpcstack.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/gethfork/node/rpcstack.go b/lib/gethfork/node/rpcstack.go index 254611ccc..c0b13c8b7 100644 --- a/lib/gethfork/node/rpcstack.go +++ b/lib/gethfork/node/rpcstack.go @@ -175,17 +175,24 @@ func (h *httpServer) start() error { h.listener = listener go h.server.Serve(listener) + // Determine the scheme for WebSockets based on TLS presence if h.wsAllowed() { - url := fmt.Sprintf("ws://%v", listener.Addr()) + scheme := "ws" + if h.tlsConfig != nil { + scheme = "wss" + } + url := fmt.Sprintf("%s://%v", scheme, listener.Addr()) if h.wsConfig.prefix != "" { url += h.wsConfig.prefix } h.log.Info("WebSocket enabled", "url", url) } - // if server is websocket only, return after logging + + // If server is websocket only, return after logging if !h.rpcAllowed() { return nil } + // Log http endpoint. h.log.Info("HTTP server started", "endpoint", listener.Addr(), "auth", (h.httpConfig.jwtSecret != nil),