From 4813b4de25e81d03533ccfa23dedccbb132462db Mon Sep 17 00:00:00 2001 From: Ainar Garipov Date: Fri, 28 Jan 2022 17:44:10 +0300 Subject: [PATCH] all: upd chlog, minimize diff to master --- CHANGELOG.md | 14 +++++++------- internal/aghnet/dhcp_unix.go | 2 +- internal/dhcpd/nullbool_test.go | 14 +++++++------- internal/dhcpd/options_unix.go | 22 ++++++++++------------ internal/dhcpd/server.go | 1 - internal/dhcpd/v4.go | 9 ++++----- scripts/install.sh | 19 +++++++------------ 7 files changed, 36 insertions(+), 45 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c404f7a0..233bc204 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,11 +27,6 @@ and this project adheres to --> - Go 1.17 support. v0.109.0 will require at least Go 1.18 to build. -## Fixed - -- Unnecessarily complex hosts-related logic leading to infinite recursion in - some cases ([#4216]). - ### Removed - Go 1.16 support. @@ -40,9 +35,14 @@ and this project adheres to - + +### Fixed + +- Unnecessarily complex hosts-related logic leading to infinite recursion in + some cases ([#4216]). + +[#4216]: https://github.com/AdguardTeam/AdGuardHome/issues/4216 diff --git a/internal/aghnet/dhcp_unix.go b/internal/aghnet/dhcp_unix.go index 554d68c6..fd2b9b93 100644 --- a/internal/aghnet/dhcp_unix.go +++ b/internal/aghnet/dhcp_unix.go @@ -111,7 +111,7 @@ func discover4(iface *net.Interface, dstAddr *net.UDPAddr, hostname string) (ok // is spoiled. // // It's also known that listening on the specified interface's address - // ignores broadcasted packets when reading. + // ignores broadcast packets when reading. var c net.PacketConn if c, err = listenPacketReusable(iface.Name, "udp4", ":68"); err != nil { return false, fmt.Errorf("couldn't listen on :68: %w", err) diff --git a/internal/dhcpd/nullbool_test.go b/internal/dhcpd/nullbool_test.go index 32c9f9f4..549df608 100644 --- a/internal/dhcpd/nullbool_test.go +++ b/internal/dhcpd/nullbool_test.go @@ -12,33 +12,33 @@ import ( func TestNullBool_UnmarshalJSON(t *testing.T) { testCases := []struct { name string - data []byte wantErrMsg string + data []byte want nullBool }{{ name: "empty", - data: []byte{}, wantErrMsg: "", + data: []byte{}, want: nbNull, }, { name: "null", - data: []byte("null"), wantErrMsg: "", + data: []byte("null"), want: nbNull, }, { name: "true", - data: []byte("true"), wantErrMsg: "", + data: []byte("true"), want: nbTrue, }, { name: "false", - data: []byte("false"), wantErrMsg: "", + data: []byte("false"), want: nbFalse, }, { name: "invalid", - data: []byte("flase"), - wantErrMsg: `invalid nullBool value "flase"`, + wantErrMsg: `invalid nullBool value "invalid"`, + data: []byte("invalid"), want: nbNull, }} diff --git a/internal/dhcpd/options_unix.go b/internal/dhcpd/options_unix.go index 07375eaf..4e15ccce 100644 --- a/internal/dhcpd/options_unix.go +++ b/internal/dhcpd/options_unix.go @@ -130,21 +130,19 @@ func parseDHCPOption(s string) (opt dhcpv4.Option, err error) { // prepareOptions builds the set of DHCP options according to host requirements // document and values from conf. func prepareOptions(conf V4ServerConf) (opts dhcpv4.Options) { + // Set default values for host configuration parameters listed in Appendix + // A of RFC-2131. Those parameters, if requested by client, should be + // returned with values defined by Host Requirements Document. + // + // See https://datatracker.ietf.org/doc/html/rfc2131#appendix-A. + // + // See also https://datatracker.ietf.org/doc/html/rfc1122, + // https://datatracker.ietf.org/doc/html/rfc1123, and + // https://datatracker.ietf.org/doc/html/rfc2132. opts = dhcpv4.Options{ - // Set default values for host configuration parameters listed - // in Appendix A of RFC-2131. Those parameters, if requested by - // client, should be returned with values defined by Host - // Requirements Document. - // - // See https://datatracker.ietf.org/doc/html/rfc2131#appendix-A. - // - // See also https://datatracker.ietf.org/doc/html/rfc1122, - // https://datatracker.ietf.org/doc/html/rfc1123, and - // https://datatracker.ietf.org/doc/html/rfc2132. - // IP-Layer Per Host - dhcpv4.OptionNonLocalSourceRouting.Code(): []byte{0}, + // Set the current recommended default time to live for the // Internet Protocol which is 64, see // https://datatracker.ietf.org/doc/html/rfc1700. diff --git a/internal/dhcpd/server.go b/internal/dhcpd/server.go index 83127aa0..a359e740 100644 --- a/internal/dhcpd/server.go +++ b/internal/dhcpd/server.go @@ -27,7 +27,6 @@ type DHCPServer interface { Start() (err error) // Stop - stop server Stop() (err error) - getLeasesRef() []*Lease } diff --git a/internal/dhcpd/v4.go b/internal/dhcpd/v4.go index e7dc0571..4e2a3a25 100644 --- a/internal/dhcpd/v4.go +++ b/internal/dhcpd/v4.go @@ -969,11 +969,10 @@ func (s *v4Server) send(peer net.Addr, conn net.PacketConn, req, resp *dhcpv4.DH Port: dhcpv4.ServerPort, } if mtype == dhcpv4.MessageTypeNak { - // Set the broadcast bit in the DHCPNAK, so that the - // relay agent broadcasted it to the client, because the - // client may not have a correct network address or - // subnet mask, and the client may not be answering ARP - // requests. + // Set the broadcast bit in the DHCPNAK, so that the relay agent + // broadcasts it to the client, because the client may not have + // a correct network address or subnet mask, and the client may not + // be answering ARP requests. resp.SetBroadcast() } case mtype == dhcpv4.MessageTypeNak: diff --git a/scripts/install.sh b/scripts/install.sh index af80adfe..3b1777ed 100644 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -384,16 +384,15 @@ rerun_with_root() { log 'restarting with root privileges' - # Group curl together with an echo, so that if curl fails before - # producing any output, the echo prints an exit command for the - # following shell to execute to prevent it from getting an empty input - # and exiting with a zero code in that case. + # Group curl together with an echo, so that if curl fails before producing + # any output, the echo prints an exit command for the following shell to + # execute to prevent it from getting an empty input and exiting with a zero + # code in that case. { curl -L -S -s "$script_url" || echo 'exit 1'; }\ | $sudo_cmd sh -s -- -c "$channel" -C "$cpu" -O "$os" -o "$out_dir" "$r" "$u" "$v" - # Exit the script. Since if the code of the previous pipeline is - # non-zero, the execution won't reach this point thanks to set -e, exit - # with zero. + # Exit the script. Since if the code of the previous pipeline is non-zero, + # the execution won't reach this point thanks to set -e, exit with zero. exit 0 } @@ -483,11 +482,7 @@ handle_existing() { # Function install_service tries to install AGH as service. install_service() { - # Installing as root is required at least on FreeBSD. - # - # TODO(e.burkov): Think about AGH's output suppressing with no verbose - # flag. - if ( cd "$agh_dir" && $sudo_cmd ./AdGuardHome -s install ) + if ( cd "$agh_dir" && ./AdGuardHome -s install ) then return 0 fi