mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
libnetwork/resolvconf: removed unused GetIfChanged() and GetLastModified()
These functions were used in63a7ccdd23, which was part of Docker v1.5.0 and v1.6.0, but removed in Docker v1.7.0 when the network stack was replaced with libnetwork ind18919e304. Signed-off-by: Sebastiaan van Stijn <github@gone.nl> (cherry picked from commit49de15cdcc) Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -85,12 +85,6 @@ var (
|
|||||||
optionsRegexp = regexp.MustCompile(`^\s*options\s*(([^\s]+\s*)*)$`)
|
optionsRegexp = regexp.MustCompile(`^\s*options\s*(([^\s]+\s*)*)$`)
|
||||||
)
|
)
|
||||||
|
|
||||||
var lastModified struct {
|
|
||||||
sync.Mutex
|
|
||||||
sha256 string
|
|
||||||
contents []byte
|
|
||||||
}
|
|
||||||
|
|
||||||
// File contains the resolv.conf content and its hash
|
// File contains the resolv.conf content and its hash
|
||||||
type File struct {
|
type File struct {
|
||||||
Content []byte
|
Content []byte
|
||||||
@@ -115,39 +109,6 @@ func GetSpecific(path string) (*File, error) {
|
|||||||
return &File{Content: resolv, Hash: hash}, nil
|
return &File{Content: resolv, Hash: hash}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetIfChanged retrieves the host /etc/resolv.conf file, checks against the last hash
|
|
||||||
// and, if modified since last check, returns the bytes and new hash.
|
|
||||||
// This feature is used by the resolv.conf updater for containers
|
|
||||||
func GetIfChanged() (*File, error) {
|
|
||||||
lastModified.Lock()
|
|
||||||
defer lastModified.Unlock()
|
|
||||||
|
|
||||||
resolv, err := os.ReadFile(Path())
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
newHash, err := hashData(bytes.NewReader(resolv))
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if lastModified.sha256 != newHash {
|
|
||||||
lastModified.sha256 = newHash
|
|
||||||
lastModified.contents = resolv
|
|
||||||
return &File{Content: resolv, Hash: newHash}, nil
|
|
||||||
}
|
|
||||||
// nothing changed, so return no data
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetLastModified retrieves the last used contents and hash of the host resolv.conf.
|
|
||||||
// Used by containers updating on restart
|
|
||||||
func GetLastModified() *File {
|
|
||||||
lastModified.Lock()
|
|
||||||
defer lastModified.Unlock()
|
|
||||||
|
|
||||||
return &File{Content: lastModified.contents, Hash: lastModified.sha256}
|
|
||||||
}
|
|
||||||
|
|
||||||
// FilterResolvDNS cleans up the config in resolvConf. It has two main jobs:
|
// FilterResolvDNS cleans up the config in resolvConf. It has two main jobs:
|
||||||
// 1. It looks for localhost (127.*|::1) entries in the provided
|
// 1. It looks for localhost (127.*|::1) entries in the provided
|
||||||
// resolv.conf, removing local nameserver entries, and, if the resulting
|
// resolv.conf, removing local nameserver entries, and, if the resulting
|
||||||
|
|||||||
Reference in New Issue
Block a user