mirror of
https://github.com/fosrl/newt.git
synced 2026-05-07 00:20:00 -05:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
57aa2e2e2c | ||
|
|
9e92c42876 | ||
|
|
ffd26f9a6d | ||
|
|
bf33a66043 | ||
|
|
df3aa60cf5 | ||
|
|
cc663f1636 | ||
|
|
af2ecf486a | ||
|
|
a0d2bb999a |
14
common.go
14
common.go
@@ -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 {
|
if consecutiveFailures >= failureThreshold && currentInterval < maxInterval {
|
||||||
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,14 +309,12 @@ func startPingCheck(tnet *netstack.Net, serverIP string, client *websocket.Clien
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if currentInterval < maxInterval {
|
currentInterval = time.Duration(float64(currentInterval) * 1.3) // Slower increase
|
||||||
currentInterval = time.Duration(float64(currentInterval) * 1.3) // Slower increase
|
if currentInterval > maxInterval {
|
||||||
if currentInterval > maxInterval {
|
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
|
||||||
|
|||||||
@@ -356,16 +356,16 @@ func (h *HTTPHandler) handleRequest(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the rule is HTTPS and a TLS certificate is configured, but the
|
// If the rule is plain HTTP but has a TLS certificate configured, redirect
|
||||||
// incoming request arrived over plain HTTP, redirect to HTTPS.
|
// the client to the HTTPS equivalent of the requested URL.
|
||||||
if rule.Protocol == "https" && rule.TLSCert != "" && rule.TLSKey != "" && r.TLS == nil {
|
if rule.Protocol == "http" && rule.TLSCert != "" && rule.TLSKey != "" {
|
||||||
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.StatusPermanentRedirect)
|
http.Redirect(w, r, httpsURL, http.StatusMovedPermanently)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user