Pull request 2342: 7627-dhcp-client-hostname

Updates #7627.

Squashed commit of the following:

commit 5eb677f5b91d2664094d759b4b07c64c1889c57b
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Fri Feb 14 17:21:35 2025 +0300

    client: fix test

commit e7c6ee81ef9aa6627538c82f150f4707df92d820
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Fri Feb 14 17:00:00 2025 +0300

    client: imp test

commit b59ca8b3ca4d00007d5c48b96fcc630342414ae7
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Fri Feb 14 16:53:02 2025 +0300

    client: fix dhcp
This commit is contained in:
Ainar Garipov
2025-02-18 14:09:14 +03:00
parent 2fe2d254b5
commit da8132e127
4 changed files with 135 additions and 18 deletions

View File

@@ -591,17 +591,21 @@ func (s *Storage) ClientRuntime(ip netip.Addr) (rc *Runtime) {
defer s.mu.Unlock()
rc = s.runtimeIndex.client(ip)
if rc != nil {
if !s.runtimeSourceDHCP {
return rc.clone()
}
if !s.runtimeSourceDHCP {
return nil
// SourceHostsFile > SourceDHCP, so return immediately if the client is from
// the hosts file.
if rc != nil && rc.hostsFile != nil {
return rc.clone()
}
// Otherwise, check the DHCP server and add the client information if there
// is any.
host := s.dhcp.HostByIP(ip)
if host == "" {
return nil
return rc.clone()
}
rc = s.runtimeIndex.setInfo(ip, SourceDHCP, []string{host})