Pull request 2354: AGDNS-2690-global-context-tls
Merge in DNS/adguard-home from AGDNS-2690-global-context-tls to master Squashed commit of the following: commit ae1d9e6f3f3b8abefbc5e776eb256577f7fbbb0f Merge: 6f30f488abf9be98c7Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Mar 10 18:15:24 2025 +0300 Merge branch 'master' into AGDNS-2690-global-context-tls commit 6f30f488aa2305e518000dc6c1028ede83bf1cc6 Merge: baa187ab066fba942cAuthor: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Mar 10 15:08:47 2025 +0300 Merge branch 'master' into AGDNS-2690-global-context-tls commit baa187ab0b6db7f41e49dece7b4d0430409e7cae Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Mar 10 15:08:39 2025 +0300 home: imp docs commit 96a09389c5049a84bb30ed285cc5e1df9aaa438f Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Mar 6 20:15:05 2025 +0300 home: imp docs commit 1cd007707af4a7a5160c8fe21b20b84543d59e5a Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Mar 6 18:54:07 2025 +0300 home: imp docs commit ad3d2b6616c2c3aba566a2158ffc597e5802929f Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Mar 4 19:38:45 2025 +0300 home: global context tls
This commit is contained in:
@@ -68,7 +68,8 @@ func appendDNSAddrsWithIfaces(dst []string, src []netip.Addr) (res []string, err
|
||||
|
||||
// collectDNSAddresses returns the list of DNS addresses the server is listening
|
||||
// on, including the addresses on all interfaces in cases of unspecified IPs.
|
||||
func collectDNSAddresses() (addrs []string, err error) {
|
||||
// tlsMgr must not be nil.
|
||||
func collectDNSAddresses(tlsMgr *tlsManager) (addrs []string, err error) {
|
||||
if hosts := config.DNS.BindHosts; len(hosts) == 0 {
|
||||
addrs = appendDNSAddrs(addrs, netutil.IPv4Localhost())
|
||||
} else {
|
||||
@@ -78,7 +79,7 @@ func collectDNSAddresses() (addrs []string, err error) {
|
||||
}
|
||||
}
|
||||
|
||||
de := getDNSEncryption()
|
||||
de := getDNSEncryption(tlsMgr)
|
||||
if de.https != "" {
|
||||
addrs = append(addrs, de.https)
|
||||
}
|
||||
@@ -113,8 +114,8 @@ type statusResponse struct {
|
||||
IsRunning bool `json:"running"`
|
||||
}
|
||||
|
||||
func handleStatus(w http.ResponseWriter, r *http.Request) {
|
||||
dnsAddrs, err := collectDNSAddresses()
|
||||
func (web *webAPI) handleStatus(w http.ResponseWriter, r *http.Request) {
|
||||
dnsAddrs, err := collectDNSAddresses(web.tlsManager)
|
||||
if err != nil {
|
||||
// Don't add a lot of formatting, since the error is already
|
||||
// wrapped by collectDNSAddresses.
|
||||
@@ -167,9 +168,8 @@ func handleStatus(w http.ResponseWriter, r *http.Request) {
|
||||
aghhttp.WriteJSONResponseOK(w, r, resp)
|
||||
}
|
||||
|
||||
// ------------------------
|
||||
// registration of handlers
|
||||
// ------------------------
|
||||
// registerControlHandlers sets up HTTP handlers for various control endpoints.
|
||||
// web must not be nil.
|
||||
func registerControlHandlers(web *webAPI) {
|
||||
globalContext.mux.HandleFunc(
|
||||
"/control/version.json",
|
||||
@@ -177,7 +177,7 @@ func registerControlHandlers(web *webAPI) {
|
||||
)
|
||||
httpRegister(http.MethodPost, "/control/update", web.handleUpdate)
|
||||
|
||||
httpRegister(http.MethodGet, "/control/status", handleStatus)
|
||||
httpRegister(http.MethodGet, "/control/status", web.handleStatus)
|
||||
httpRegister(http.MethodPost, "/control/i18n/change_language", handleI18nChangeLanguage)
|
||||
httpRegister(http.MethodGet, "/control/i18n/current_language", handleI18nCurrentLanguage)
|
||||
httpRegister(http.MethodGet, "/control/profile", handleGetProfile)
|
||||
@@ -189,6 +189,7 @@ func registerControlHandlers(web *webAPI) {
|
||||
RegisterAuthHandlers()
|
||||
}
|
||||
|
||||
// httpRegister registers an HTTP handler.
|
||||
func httpRegister(method, url string, handler http.HandlerFunc) {
|
||||
if method == "" {
|
||||
// "/dns-query" handler doesn't need auth, gzip and isn't restricted by 1 HTTP method
|
||||
|
||||
Reference in New Issue
Block a user