"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "internal/dhcpd/dhcp_http.go" between
AdGuardHome-0.104.1.tar.gz and AdGuardHome-0.104.3.tar.gz

About: AdGuard Home is a network-wide ads & trackers blocking DNS server. It operates as a DNS server that re-routes tracking domains to a "black hole," thus preventing your devices from connecting to those servers.

dhcp_http.go  (AdGuardHome-0.104.1):dhcp_http.go  (AdGuardHome-0.104.3)
skipping to change at line 14 skipping to change at line 14
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"net" "net"
"net/http" "net/http"
"os" "os"
"strings" "strings"
"time" "time"
"github.com/AdguardTeam/AdGuardHome/internal/util" "github.com/AdguardTeam/AdGuardHome/internal/util"
"github.com/AdguardTeam/golibs/jsonutil" "github.com/AdguardTeam/golibs/jsonutil"
"github.com/AdguardTeam/golibs/log" "github.com/AdguardTeam/golibs/log"
) )
func httpError(r *http.Request, w http.ResponseWriter, code int, format string, args ...interface{}) { func httpError(r *http.Request, w http.ResponseWriter, code int, format string, args ...interface{}) {
text := fmt.Sprintf(format, args...) text := fmt.Sprintf(format, args...)
log.Info("DHCP: %s %s: %s", r.Method, r.URL, text) log.Info("DHCP: %s %s: %s", r.Method, r.URL, text)
http.Error(w, text, code) http.Error(w, text, code)
} }
skipping to change at line 502 skipping to change at line 501
s.srv4, _ = v4Create(v4conf) s.srv4, _ = v4Create(v4conf)
v6conf := V6ServerConf{} v6conf := V6ServerConf{}
v6conf.notify = s.onNotify v6conf.notify = s.onNotify
s.srv6, _ = v6Create(v6conf) s.srv6, _ = v6Create(v6conf)
s.conf.ConfigModified() s.conf.ConfigModified()
} }
func (s *Server) registerHandlers() { func (s *Server) registerHandlers() {
s.conf.HTTPRegister("GET", "/control/dhcp/status", s.handleDHCPStatus) s.conf.HTTPRegister(http.MethodGet, "/control/dhcp/status", s.handleDHCPS
s.conf.HTTPRegister("GET", "/control/dhcp/interfaces", s.handleDHCPInterf tatus)
aces) s.conf.HTTPRegister(http.MethodGet, "/control/dhcp/interfaces", s.handleD
s.conf.HTTPRegister("POST", "/control/dhcp/set_config", s.handleDHCPSetCo HCPInterfaces)
nfig) s.conf.HTTPRegister(http.MethodPost, "/control/dhcp/set_config", s.handle
s.conf.HTTPRegister("POST", "/control/dhcp/find_active_dhcp", s.handleDHC DHCPSetConfig)
PFindActiveServer) s.conf.HTTPRegister(http.MethodPost, "/control/dhcp/find_active_dhcp", s.
s.conf.HTTPRegister("POST", "/control/dhcp/add_static_lease", s.handleDHC handleDHCPFindActiveServer)
PAddStaticLease) s.conf.HTTPRegister(http.MethodPost, "/control/dhcp/add_static_lease", s.
s.conf.HTTPRegister("POST", "/control/dhcp/remove_static_lease", s.handle handleDHCPAddStaticLease)
DHCPRemoveStaticLease) s.conf.HTTPRegister(http.MethodPost, "/control/dhcp/remove_static_lease",
s.conf.HTTPRegister("POST", "/control/dhcp/reset", s.handleReset) s.handleDHCPRemoveStaticLease)
s.conf.HTTPRegister(http.MethodPost, "/control/dhcp/reset", s.handleReset
)
}
// jsonError is a generic JSON error response.
type jsonError struct {
// Message is the error message, an opaque string.
Message string `json:"message"`
}
// notImplemented returns 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(msg string) (f func(http.ResponseWriter, *http.R
equest)) {
return func(w http.ResponseWriter, _ *http.Request) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusNotImplemented)
err := json.NewEncoder(w).Encode(&jsonError{
Message: msg,
})
if err != nil {
log.Debug("writing 501 json response: %s", err)
}
}
}
func (s *Server) registerNotImplementedHandlers() {
h := s.notImplemented("dhcp is not supported on windows")
s.conf.HTTPRegister(http.MethodGet, "/control/dhcp/status", h)
s.conf.HTTPRegister(http.MethodGet, "/control/dhcp/interfaces", h)
s.conf.HTTPRegister(http.MethodPost, "/control/dhcp/set_config", h)
s.conf.HTTPRegister(http.MethodPost, "/control/dhcp/find_active_dhcp", h)
s.conf.HTTPRegister(http.MethodPost, "/control/dhcp/add_static_lease", h)
s.conf.HTTPRegister(http.MethodPost, "/control/dhcp/remove_static_lease",
h)
s.conf.HTTPRegister(http.MethodPost, "/control/dhcp/reset", h)
} }
 End of changes. 2 change blocks. 
13 lines changed or deleted 53 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)