Files
AdGuardHome/internal/next/websvc/settings.go
Ainar Garipov 5e44582236 Pull request 2431: next-fix-ups-logger
Merge in DNS/adguard-home from next-fix-ups-logger to master

Squashed commit of the following:

commit 94a0c3508cb16e1b4e7f7793b1ee6a8da0c24de7
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Fri Jun 27 18:11:12 2025 +0300

    next: typos

commit 6358dc11c90464b3464d39eb302e5265a3e61cdd
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Fri Jun 27 17:32:03 2025 +0300

    next: imp upstream; add more settings
2025-06-27 18:27:54 +03:00

52 lines
1.5 KiB
Go

package websvc
import (
"net/http"
"github.com/AdguardTeam/AdGuardHome/internal/aghhttp"
)
// All Settings Handlers
// RespGetV1SettingsAll describes the response of the GET /api/v1/settings/all
// HTTP API.
type RespGetV1SettingsAll struct {
// TODO(a.garipov): Add more as we go.
DNS *HTTPAPIDNSSettings `json:"dns"`
HTTP *HTTPAPIHTTPSettings `json:"http"`
}
// handleGetSettingsAll is the handler for the GET /api/v1/settings/all HTTP
// API.
func (svc *Service) handleGetSettingsAll(w http.ResponseWriter, r *http.Request) {
dnsSvc := svc.confMgr.DNS()
dnsConf := dnsSvc.Config()
webSvc := svc.confMgr.Web()
httpConf := webSvc.Config()
// TODO(a.garipov): Add all currently supported parameters.
aghhttp.WriteJSONResponseOK(w, r, &RespGetV1SettingsAll{
DNS: &HTTPAPIDNSSettings{
UpstreamMode: dnsConf.UpstreamMode,
Addresses: dnsConf.Addresses,
BootstrapServers: dnsConf.BootstrapServers,
UpstreamServers: dnsConf.UpstreamServers,
DNS64Prefixes: dnsConf.DNS64Prefixes,
UpstreamTimeout: aghhttp.JSONDuration(dnsConf.UpstreamTimeout),
Ratelimit: dnsConf.Ratelimit,
BootstrapPreferIPv6: dnsConf.BootstrapPreferIPv6,
CacheSize: dnsConf.CacheSize,
RefuseAny: dnsConf.RefuseAny,
UseDNS64: dnsConf.UseDNS64,
},
HTTP: &HTTPAPIHTTPSettings{
Addresses: httpConf.Addresses,
SecureAddresses: httpConf.SecureAddresses,
Timeout: aghhttp.JSONDuration(httpConf.Timeout),
ForceHTTPS: httpConf.ForceHTTPS,
},
})
}