2022-10-04 16:02:55 +03:00
|
|
|
package websvc
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
2023-08-29 20:03:40 +03:00
|
|
|
|
|
|
|
"github.com/AdguardTeam/AdGuardHome/internal/aghhttp"
|
2022-10-04 16:02:55 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
// 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.
|
2023-08-29 20:03:40 +03:00
|
|
|
aghhttp.WriteJSONResponseOK(w, r, &RespGetV1SettingsAll{
|
2022-10-04 16:02:55 +03:00
|
|
|
DNS: &HTTPAPIDNSSettings{
|
2023-06-28 12:48:53 +03:00
|
|
|
Addresses: dnsConf.Addresses,
|
|
|
|
BootstrapServers: dnsConf.BootstrapServers,
|
|
|
|
UpstreamServers: dnsConf.UpstreamServers,
|
|
|
|
DNS64Prefixes: dnsConf.DNS64Prefixes,
|
2023-08-29 20:03:40 +03:00
|
|
|
UpstreamTimeout: aghhttp.JSONDuration(dnsConf.UpstreamTimeout),
|
2023-06-28 12:48:53 +03:00
|
|
|
BootstrapPreferIPv6: dnsConf.BootstrapPreferIPv6,
|
|
|
|
UseDNS64: dnsConf.UseDNS64,
|
2022-10-04 16:02:55 +03:00
|
|
|
},
|
|
|
|
HTTP: &HTTPAPIHTTPSettings{
|
|
|
|
Addresses: httpConf.Addresses,
|
|
|
|
SecureAddresses: httpConf.SecureAddresses,
|
2023-08-29 20:03:40 +03:00
|
|
|
Timeout: aghhttp.JSONDuration(httpConf.Timeout),
|
2022-10-04 16:02:55 +03:00
|
|
|
ForceHTTPS: httpConf.ForceHTTPS,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|