Pull request: 2582 invalid hostname vol.2
Merge in DNS/adguard-home from 2582-invalid-hostname-2 to master
Updates #2582.
Squashed commit of the following:
commit 9d3ceb289e3869b2c3d12e91ec104fb25d7931ee
Merge: 91c68e46 90054974
Author: Eugene Burkov <e.burkov@adguard.com>
Date: Fri Mar 5 19:11:49 2021 +0300
Merge branch 'master' into 2582-invalid-hostname-2
commit 91c68e468c5f5b12a2fb509ff391133483c9d915
Author: Eugene Burkov <e.burkov@adguard.com>
Date: Fri Mar 5 18:28:14 2021 +0300
all: mv trimming from home to dhcpd
commit f51faf35288577b6f610f172b26e7ac13aa24f72
Author: Eugene Burkov <e.burkov@adguard.com>
Date: Fri Mar 5 16:28:00 2021 +0300
home: add more host sanitizings
This commit is contained in:
@@ -586,22 +586,9 @@ func (clients *clientsContainer) SetWhoisInfo(ip string, info [][]string) {
|
||||
log.Debug("clients: set whois info for auto-client with IP %s: %q", ip, info)
|
||||
}
|
||||
|
||||
// sanitizeHost proccesses a host to remove some special symbols causing errors.
|
||||
// Logic may be expanded in the future.
|
||||
func sanitizeHost(host string) (processed string) {
|
||||
// cutset brings together all the deprecated sets.
|
||||
//
|
||||
// See https://github.com/AdguardTeam/AdGuardHome/issues/2582.
|
||||
const cutset = "\x00"
|
||||
|
||||
return strings.TrimRight(host, cutset)
|
||||
}
|
||||
|
||||
// AddHost adds a new IP-hostname pairing. The priorities of the sources is
|
||||
// taken into account. ok is true if the pairing was added.
|
||||
func (clients *clientsContainer) AddHost(ip, host string, src clientSource) (ok bool, err error) {
|
||||
host = sanitizeHost(host)
|
||||
|
||||
clients.lock.Lock()
|
||||
ok = clients.addHostLocked(ip, host, src)
|
||||
clients.lock.Unlock()
|
||||
|
||||
Reference in New Issue
Block a user