From a396865869adc8da415ff2f24d5f5108fe9bac7f Mon Sep 17 00:00:00 2001 From: Ainar Garipov Date: Mon, 13 Dec 2021 13:48:08 +0300 Subject: [PATCH] Pull request: all: do not redirect to https if not necessary Merge in DNS/adguard-home from 3558-https-redirect to master Squashed commit of the following: commit f656563c0b0db6275748de28bc890dcf85b0e398 Author: Ainar Garipov Date: Fri Dec 10 20:44:00 2021 +0300 all: do not redirect to https if not necessary --- CHANGELOG.md | 3 +++ client/src/helpers/helpers.js | 4 ++-- internal/home/config.go | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 044b9688..e27fab44 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -125,6 +125,8 @@ In this release, the schema version has changed from 10 to 12. ### Fixed +- Invalid redirection to the HTTPS web interface after saving enabled encryption + settings ([#3558]). - Incomplete propagation of the client's IP anonymization setting to the statistics ([#3890]). - Incorrect `$dnsrewrite` results for entries from the operating system's hosts @@ -217,6 +219,7 @@ In this release, the schema version has changed from 10 to 12. [#3529]: https://github.com/AdguardTeam/AdGuardHome/issues/3529 [#3538]: https://github.com/AdguardTeam/AdGuardHome/issues/3538 [#3551]: https://github.com/AdguardTeam/AdGuardHome/issues/3551 +[#3558]: https://github.com/AdguardTeam/AdGuardHome/issues/3558 [#3564]: https://github.com/AdguardTeam/AdGuardHome/issues/3564 [#3567]: https://github.com/AdguardTeam/AdGuardHome/issues/3567 [#3568]: https://github.com/AdguardTeam/AdGuardHome/issues/3568 diff --git a/client/src/helpers/helpers.js b/client/src/helpers/helpers.js index 8f4344ee..6753062a 100644 --- a/client/src/helpers/helpers.js +++ b/client/src/helpers/helpers.js @@ -301,10 +301,10 @@ export const redirectToCurrentProtocol = (values, httpPort = 80) => { const { protocol, hostname, hash, port, } = window.location; - const { enabled, port_https } = values; + const { enabled, force_https, port_https } = values; const httpsPort = port_https !== STANDARD_HTTPS_PORT ? `:${port_https}` : ''; - if (protocol !== 'https:' && enabled && port_https) { + if (protocol !== 'https:' && enabled && force_https && port_https) { checkRedirect(`https://${hostname}${httpsPort}/${hash}`); } else if (protocol === 'https:' && enabled && port_https && port_https !== parseInt(port, 10)) { checkRedirect(`https://${hostname}${httpsPort}/${hash}`); diff --git a/internal/home/config.go b/internal/home/config.go index 3465c26f..5d329fe2 100644 --- a/internal/home/config.go +++ b/internal/home/config.go @@ -140,7 +140,7 @@ type dnsConfig struct { type tlsConfigSettings struct { Enabled bool `yaml:"enabled" json:"enabled"` // Enabled is the encryption (DoT/DoH/HTTPS) status ServerName string `yaml:"server_name" json:"server_name,omitempty"` // ServerName is the hostname of your HTTPS/TLS server - ForceHTTPS bool `yaml:"force_https" json:"force_https,omitempty"` // ForceHTTPS: if true, forces HTTP->HTTPS redirect + ForceHTTPS bool `yaml:"force_https" json:"force_https"` // ForceHTTPS: if true, forces HTTP->HTTPS redirect PortHTTPS int `yaml:"port_https" json:"port_https,omitempty"` // HTTPS port. If 0, HTTPS will be disabled PortDNSOverTLS int `yaml:"port_dns_over_tls" json:"port_dns_over_tls,omitempty"` // DNS-over-TLS port. If 0, DoT will be disabled PortDNSOverQUIC int `yaml:"port_dns_over_quic" json:"port_dns_over_quic,omitempty"` // DNS-over-QUIC port. If 0, DoQ will be disabled