Pull request: 2582 invalid hostname vol.3

Merge in DNS/adguard-home from 2582-zero-byte to master

Updates #2582.

Squashed commit of the following:

commit 88db23f26cd6ee9978310c7030f6866b9ef58785
Author: Eugene Burkov <e.burkov@adguard.com>
Date:   Thu Mar 11 13:01:02 2021 +0300

    dhcpd: rm temporary workaround
This commit is contained in:
Eugene Burkov
2021-03-11 14:01:48 +03:00
parent c08bf86b71
commit 94e21e69af
4 changed files with 6 additions and 15 deletions

View File

@@ -7,7 +7,6 @@ import (
"encoding/binary"
"fmt"
"net"
"strings"
"sync"
"time"
@@ -464,16 +463,7 @@ func (s *v4Server) processRequest(req, resp *dhcpv4.DHCPv4) (*Lease, bool) {
}
if lease.Expiry.Unix() != leaseExpireStatic {
// The trimming is required since some devices include trailing
// zero-byte in DHCP option length calculation.
//
// See https://github.com/AdguardTeam/AdGuardHome/issues/2582.
//
// TODO(e.burkov): Remove after the trimming for hostname option
// will be added into github.com/insomniacslk/dhcp module.
hostnameStr := strings.TrimRight(string(hostname), "\x00")
lease.Hostname = hostnameStr
lease.Hostname = string(hostname)
s.commitLease(lease)
} else if len(lease.Hostname) != 0 {
o := &optFQDN{

View File

@@ -46,7 +46,8 @@ func ip6InRange(start, ip net.IP) bool {
if len(start) != 16 {
return false
}
//lint:ignore SA1021 TODO(e.burkov): Ignore this for now, think about using masks.
//lint:ignore SA1021 TODO(e.burkov): Ignore this for now, think about
// using masks.
if !bytes.Equal(start[:15], ip[:15]) {
return false
}