mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-11-22 04:55:33 +03:00
Pull request: 3824 fix DHCP empty form validation
Closes #3824 Squashed commit of the following: commit 24d5770e2f276f710c011bf94e36702881ccbf1a Merge: 8f53990032294407
Author: Ildar Kamalov <ik@adguard.com> Date: Wed Nov 24 12:21:23 2021 +0300 Merge branch 'master' into 3824-empty-values commit 8f539900489c940c6d7068d672420a553a1da299 Merge: 4be7726851f11d2f
Author: Ildar Kamalov <ik@adguard.com> Date: Tue Nov 23 19:06:44 2021 +0300 Merge branch 'master' into 3824-empty-values commit 4be77268ab1b3dc99b754b8002320a615db2d99e Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Tue Nov 23 19:04:06 2021 +0300 all: use new consts commit 701fd9a2b82d69c6b813a4a1889c65404ac3571b Author: Ildar Kamalov <ik@adguard.com> Date: Tue Nov 23 18:58:03 2021 +0300 client: get status on reset commit a20734cbf26a57ec96fdb6e0f868a8656751e80a Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Tue Nov 23 18:31:59 2021 +0300 dhcpd: fix reset defaults commit e2cb0cb0995e7b2dd3e194c5bb9fe944cf7be8f5 Author: Ildar Kamalov <ik@adguard.com> Date: Tue Nov 23 17:33:22 2021 +0300 client: fix DHCP empty form validation
This commit is contained in:
parent
322944073e
commit
936a7057fd
4 changed files with 32 additions and 13 deletions
|
@ -102,6 +102,7 @@ const Dhcp = () => {
|
|||
Object.values(DHCP_FORM_NAMES)
|
||||
.forEach((formName) => dispatch(destroy(formName)));
|
||||
dispatch(resetDhcp());
|
||||
dispatch(getDhcpStatus());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -68,6 +68,10 @@ export const validateIpv4 = (value) => {
|
|||
* @param allValues
|
||||
*/
|
||||
export const validateNotInRange = (value, allValues) => {
|
||||
if (!allValues.v4) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const { range_start, range_end } = allValues.v4;
|
||||
|
||||
if (range_start && validateIpv4(range_start)) {
|
||||
|
|
|
@ -8,10 +8,12 @@ import (
|
|||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/AdguardTeam/AdGuardHome/internal/aghnet"
|
||||
"github.com/AdguardTeam/golibs/errors"
|
||||
"github.com/AdguardTeam/golibs/log"
|
||||
"github.com/AdguardTeam/golibs/timeutil"
|
||||
)
|
||||
|
||||
func httpError(r *http.Request, w http.ResponseWriter, code int, format string, args ...interface{}) {
|
||||
|
@ -533,6 +535,13 @@ func (s *Server) handleDHCPRemoveStaticLease(w http.ResponseWriter, r *http.Requ
|
|||
}
|
||||
}
|
||||
|
||||
const (
|
||||
// DefaultDHCPLeaseTTL is the default time-to-live for leases.
|
||||
DefaultDHCPLeaseTTL = uint32(timeutil.Day / time.Second)
|
||||
// DefaultDHCPTimeoutICMP is the default timeout for waiting ICMP responses.
|
||||
DefaultDHCPTimeoutICMP = 1000
|
||||
)
|
||||
|
||||
func (s *Server) handleReset(w http.ResponseWriter, r *http.Request) {
|
||||
err := s.Stop()
|
||||
if err != nil {
|
||||
|
@ -547,19 +556,24 @@ func (s *Server) handleReset(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
oldconf := s.conf
|
||||
s.conf = ServerConfig{}
|
||||
s.conf.WorkDir = oldconf.WorkDir
|
||||
s.conf.HTTPRegister = oldconf.HTTPRegister
|
||||
s.conf.ConfigModified = oldconf.ConfigModified
|
||||
s.conf.DBFilePath = oldconf.DBFilePath
|
||||
s.conf = ServerConfig{
|
||||
WorkDir: oldconf.WorkDir,
|
||||
HTTPRegister: oldconf.HTTPRegister,
|
||||
ConfigModified: oldconf.ConfigModified,
|
||||
DBFilePath: oldconf.DBFilePath,
|
||||
}
|
||||
|
||||
v4conf := V4ServerConf{}
|
||||
v4conf.ICMPTimeout = 1000
|
||||
v4conf.notify = s.onNotify
|
||||
v4conf := V4ServerConf{
|
||||
LeaseDuration: DefaultDHCPLeaseTTL,
|
||||
ICMPTimeout: DefaultDHCPTimeoutICMP,
|
||||
notify: s.onNotify,
|
||||
}
|
||||
s.srv4, _ = v4Create(v4conf)
|
||||
|
||||
v6conf := V6ServerConf{}
|
||||
v6conf.notify = s.onNotify
|
||||
v6conf := V6ServerConf{
|
||||
LeaseDuration: DefaultDHCPLeaseTTL,
|
||||
notify: s.onNotify,
|
||||
}
|
||||
s.srv6, _ = v6Create(v6conf)
|
||||
|
||||
s.conf.ConfigModified()
|
||||
|
|
|
@ -232,9 +232,9 @@ func initConfig() {
|
|||
config.DNS.DnsfilterConf.CacheTime = 30
|
||||
config.Filters = defaultFilters()
|
||||
|
||||
config.DHCP.Conf4.LeaseDuration = 86400
|
||||
config.DHCP.Conf4.ICMPTimeout = 1000
|
||||
config.DHCP.Conf6.LeaseDuration = 86400
|
||||
config.DHCP.Conf4.LeaseDuration = dhcpd.DefaultDHCPLeaseTTL
|
||||
config.DHCP.Conf4.ICMPTimeout = dhcpd.DefaultDHCPTimeoutICMP
|
||||
config.DHCP.Conf6.LeaseDuration = dhcpd.DefaultDHCPLeaseTTL
|
||||
|
||||
if ch := version.Channel(); ch == version.ChannelEdge || ch == version.ChannelDevelopment {
|
||||
config.BetaBindPort = 3001
|
||||
|
|
Loading…
Reference in a new issue