mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2025-10-26 11:27:18 +00:00
Squashed commit of the following: commit 9324a0066202f1677bfd033d40d3a82fa9756ed9 Merge:8a1b5cad4f9da40e39Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Oct 23 17:48:01 2025 +0300 Merge branch 'master' into AGDNS-3224-aghhttp-register-slog commit8a1b5cad4cAuthor: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 21 15:51:48 2025 +0300 filtering: imp code commitfe569166efMerge:9a101a2f59be4ca90eAuthor: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 21 15:45:42 2025 +0300 Merge branch 'master' into AGDNS-3224-aghhttp-register-slog commit9a101a2f5fAuthor: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Oct 15 18:52:22 2025 +0300 home: imp code commit727e1663baAuthor: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Oct 15 10:19:56 2025 +0300 all: imp code commit113a9017dfAuthor: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Oct 13 23:10:06 2025 +0300 home: fix typo commit6588dd2dadAuthor: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Oct 13 22:46:28 2025 +0300 all: imp naming commit44278505a9Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Oct 10 16:20:17 2025 +0300 home: fix typo commit7b4b57628bAuthor: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Oct 10 15:58:07 2025 +0300 all: web mw commit93168142cbAuthor: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Oct 8 22:20:07 2025 +0300 all: aghhttp slog commit9155edef67Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Oct 8 15:38:01 2025 +0300 aghhttp: registrar commita356473855Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 7 15:32:30 2025 +0300 all: http registrar
52 lines
2.2 KiB
Go
52 lines
2.2 KiB
Go
//go:build windows
|
|
|
|
package dhcpd
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/AdguardTeam/AdGuardHome/internal/aghhttp"
|
|
"github.com/AdguardTeam/AdGuardHome/internal/aghos"
|
|
)
|
|
|
|
// jsonError is a generic JSON error response.
|
|
//
|
|
// TODO(a.garipov): Merge together with the implementations in .../home and
|
|
// other packages after refactoring the web handler registering.
|
|
type jsonError struct {
|
|
// Message is the error message, an opaque string.
|
|
Message string `json:"message"`
|
|
}
|
|
|
|
// notImplemented is a handler that replies to any request with an HTTP 501 Not
|
|
// Implemented status and a JSON error with the provided message msg.
|
|
//
|
|
// TODO(a.garipov): Either take the logger from the server after we've
|
|
// refactored logging or make this not a method of *Server.
|
|
func (s *server) notImplemented(w http.ResponseWriter, r *http.Request) {
|
|
ctx := r.Context()
|
|
|
|
aghhttp.WriteJSONResponse(ctx, s.conf.Logger, w, r, http.StatusNotImplemented, &jsonError{
|
|
Message: aghos.Unsupported("dhcp").Error(),
|
|
})
|
|
}
|
|
|
|
// registerHandlers sets the handlers for DHCP HTTP API that always respond with
|
|
// an HTTP 501, since DHCP server doesn't work on Windows yet.
|
|
//
|
|
// TODO(a.garipov): This needs refactoring. We shouldn't even try and
|
|
// initialize a DHCP server on Windows, but there are currently too many
|
|
// interconnected parts--such as HTTP handlers and frontend--to make that work
|
|
// properly.
|
|
func (s *server) registerHandlers() {
|
|
s.conf.HTTPReg.Register(http.MethodGet, "/control/dhcp/status", s.notImplemented)
|
|
s.conf.HTTPReg.Register(http.MethodGet, "/control/dhcp/interfaces", s.notImplemented)
|
|
s.conf.HTTPReg.Register(http.MethodPost, "/control/dhcp/set_config", s.notImplemented)
|
|
s.conf.HTTPReg.Register(http.MethodPost, "/control/dhcp/find_active_dhcp", s.notImplemented)
|
|
s.conf.HTTPReg.Register(http.MethodPost, "/control/dhcp/add_static_lease", s.notImplemented)
|
|
s.conf.HTTPReg.Register(http.MethodPost, "/control/dhcp/remove_static_lease", s.notImplemented)
|
|
s.conf.HTTPReg.Register(http.MethodPost, "/control/dhcp/update_static_lease", s.notImplemented)
|
|
s.conf.HTTPReg.Register(http.MethodPost, "/control/dhcp/reset", s.notImplemented)
|
|
s.conf.HTTPReg.Register(http.MethodPost, "/control/dhcp/reset_leases", s.notImplemented)
|
|
}
|