From 4835801e7470ae294091f20b572534ee731e6821 Mon Sep 17 00:00:00 2001 From: SS Date: Sat, 16 Aug 2025 11:57:53 +0400 Subject: [PATCH] Resolved maintainer comments: removed examples, reduce log verbosity, and unnecessary recover/defer blocks --- README.md | 22 ---------------------- conf/frpc_full_example.toml | 29 ----------------------------- pkg/util/vhost/https.go | 16 +--------------- pkg/util/vhost/https_proxy.go | 2 +- server/group/https.go | 14 ++++++++++++++ 5 files changed, 16 insertions(+), 67 deletions(-) diff --git a/README.md b/README.md index 9d4ab49f..96b92536 100644 --- a/README.md +++ b/README.md @@ -954,28 +954,6 @@ loadBalancer.group = "web" loadBalancer.groupKey = "123" ``` -For HTTPS load balancing: - -```toml -# frpc.toml - -[[proxies]] -name = "web1" -type = "https" -localPort = 443 -customDomains = ["example.com"] -loadBalancer.group = "web" -loadBalancer.groupKey = "123" - -[[proxies]] -name = "web2" -type = "https" -localPort = 443 -customDomains = ["example.com"] -loadBalancer.group = "web" -loadBalancer.groupKey = "123" -``` - `loadBalancer.groupKey` is used for authentication. Connections to port 80 will be dispatched to proxies in the same group randomly. diff --git a/conf/frpc_full_example.toml b/conf/frpc_full_example.toml index c718c268..d8d93a3f 100644 --- a/conf/frpc_full_example.toml +++ b/conf/frpc_full_example.toml @@ -247,35 +247,6 @@ customDomains = ["web02.yourdomain.com"] # v1 or v2 or empty transport.proxyProtocolVersion = "v2" -# HTTPS load balancing example -[[proxies]] -name = "web_lb_1" -type = "https" -localIP = "127.0.0.1" -localPort = 443 -customDomains = ["app.yourdomain.com"] -loadBalancer.group = "web" -loadBalancer.groupKey = "123" -# Enable health check for load balancing -healthCheck.type = "tcp" -healthCheck.timeoutSeconds = 3 -healthCheck.maxFailed = 3 -healthCheck.intervalSeconds = 10 - -[[proxies]] -name = "web_lb_2" -type = "https" -localIP = "127.0.0.1" -localPort = 8443 -customDomains = ["app.yourdomain.com"] -loadBalancer.group = "web" -loadBalancer.groupKey = "123" -# Enable health check for load balancing -healthCheck.type = "tcp" -healthCheck.timeoutSeconds = 3 -healthCheck.maxFailed = 3 -healthCheck.intervalSeconds = 10 - [[proxies]] name = "tcpmuxhttpconnect" type = "tcpmux" diff --git a/pkg/util/vhost/https.go b/pkg/util/vhost/https.go index 11073b0a..4d201eec 100644 --- a/pkg/util/vhost/https.go +++ b/pkg/util/vhost/https.go @@ -92,14 +92,11 @@ func (h *HTTPSMuxer) handleHTTPS(c net.Conn) { // First check if there's a group route for this domain if h.httpsReverseProxy != nil { if routeConfig := h.httpsReverseProxy.GetRouteConfig(canonicalHostname); routeConfig != nil { - log.Debugf("routing https request for host [%s] to group", hostname) - // SECURITY: Apply authentication check before group routing if routeConfig.Username != "" && routeConfig.Password != "" { if h.checkAuth != nil { ok, err := h.checkAuth(c, routeConfig.Username, routeConfig.Password, reqInfoMap) if !ok || err != nil { - log.Debugf("auth failed for group route user: %s", routeConfig.Username) h.failHook(sConn) return } @@ -123,22 +120,12 @@ func (h *HTTPSMuxer) handleHTTPS(c net.Conn) { // Create connection to backend through group routing remoteConn, err := h.httpsReverseProxy.CreateConnection(canonicalHostname) if err != nil { - log.Debugf("failed to create connection through group: %v", err) h.failHook(sConn) return } // Start proxying data between client and remote - go func() { - defer func() { - if err := recover(); err != nil { - log.Warnf("panic in HTTPS proxy goroutine: %v", err) - } - }() - defer sConn.Close() - defer remoteConn.Close() - libio.Join(sConn, remoteConn) - }() + go libio.Join(sConn, remoteConn) return } } @@ -148,7 +135,6 @@ func (h *HTTPSMuxer) handleHTTPS(c net.Conn) { httpUser := reqInfoMap["HTTPUser"] l, ok := h.getListener(canonicalHostname, path, httpUser) if !ok { - log.Debugf("https request for host [%s] path [%s] httpUser [%s] not found", hostname, path, httpUser) h.failHook(sConn) return } diff --git a/pkg/util/vhost/https_proxy.go b/pkg/util/vhost/https_proxy.go index 90988104..e4b96f7c 100644 --- a/pkg/util/vhost/https_proxy.go +++ b/pkg/util/vhost/https_proxy.go @@ -1,4 +1,4 @@ -// Copyright 2024 fatedier, fatedier@gmail.com +// Copyright 2024 Satyajeet Singh, jeet.0733@gmail.com // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/server/group/https.go b/server/group/https.go index 563bd384..a22c2996 100644 --- a/server/group/https.go +++ b/server/group/https.go @@ -1,3 +1,17 @@ +// Copyright 2024 Satyajeet Singh, jeet.0733@gmail.com +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package group import (