Compare commits

...

3 Commits
1.12.3 ... dev

Author SHA1 Message Date
Owen
27f7ca6bb9 Try to fix failover not working 2026-05-05 11:40:39 -07:00
Owen
5090907307 Update status code 2026-04-30 15:55:52 -07:00
Owen
a6533b3fa0 Fix incorrect redirect logic 2026-04-29 21:11:07 -07:00
2 changed files with 12 additions and 10 deletions

View File

@@ -279,7 +279,7 @@ func startPingCheck(tnet *netstack.Net, serverIP string, client *websocket.Clien
// More lenient threshold for declaring connection lost under load // More lenient threshold for declaring connection lost under load
failureThreshold := 4 failureThreshold := 4
if consecutiveFailures >= failureThreshold && currentInterval < maxInterval { if consecutiveFailures >= failureThreshold {
if !connectionLost { if !connectionLost {
connectionLost = true connectionLost = true
logger.Warn("Connection to server lost after %d failures. Continuous reconnection attempts will be made.", consecutiveFailures) logger.Warn("Connection to server lost after %d failures. Continuous reconnection attempts will be made.", consecutiveFailures)
@@ -309,12 +309,14 @@ func startPingCheck(tnet *netstack.Net, serverIP string, client *websocket.Clien
} }
} }
} }
currentInterval = time.Duration(float64(currentInterval) * 1.3) // Slower increase if currentInterval < maxInterval {
if currentInterval > maxInterval { currentInterval = time.Duration(float64(currentInterval) * 1.3) // Slower increase
currentInterval = maxInterval if currentInterval > maxInterval {
currentInterval = maxInterval
}
ticker.Reset(currentInterval)
logger.Debug("Increased ping check interval to %v due to consecutive failures", currentInterval)
} }
ticker.Reset(currentInterval)
logger.Debug("Increased ping check interval to %v due to consecutive failures", currentInterval)
} }
} else { } else {
// Track recent latencies // Track recent latencies

View File

@@ -356,16 +356,16 @@ func (h *HTTPHandler) handleRequest(w http.ResponseWriter, r *http.Request) {
return return
} }
// If the rule is plain HTTP but has a TLS certificate configured, redirect // If the rule is HTTPS and a TLS certificate is configured, but the
// the client to the HTTPS equivalent of the requested URL. // incoming request arrived over plain HTTP, redirect to HTTPS.
if rule.Protocol == "http" && rule.TLSCert != "" && rule.TLSKey != "" { if rule.Protocol == "https" && rule.TLSCert != "" && rule.TLSKey != "" && r.TLS == nil {
host := r.Host host := r.Host
if host == "" { if host == "" {
host = r.URL.Host host = r.URL.Host
} }
httpsURL := "https://" + host + r.RequestURI httpsURL := "https://" + host + r.RequestURI
logger.Info("HTTP handler: redirecting %s %s -> %s (TLS cert present)", r.Method, r.URL.RequestURI(), httpsURL) logger.Info("HTTP handler: redirecting %s %s -> %s (TLS cert present)", r.Method, r.URL.RequestURI(), httpsURL)
http.Redirect(w, r, httpsURL, http.StatusMovedPermanently) http.Redirect(w, r, httpsURL, http.StatusPermanentRedirect)
return return
} }