Support "insistent" queries in the mDNS client, used for obtaining all possible responses from mDNS servers.
Support for multiple responses from Lookup*() methods Support for multiple records when building packets with make*() methods Use a common "ZoneRecord" interface for structs that contain names and IPs
This commit is contained in:
1 parent
ec29c2c776
commit
58c8945b32
17 files changed
+504
-216
No files matched your search
@@ -0,0 +1,54 @@
|
||||
package nameserver
|
||||
|
||||
import (
|
||||
. "github.com/weaveworks/weave/common"
|
||||
"net"
|
||||
)
|
||||
|
||||
// Warn about some methods that some day should be implemented...
|
||||
func notImplWarn() { Warning.Printf("Mocked method. Not implemented.") }
|
||||
|
||||
// A mocked Zone that always returns the same record
|
||||
type mockedZone struct {
|
||||
record ZoneRecord
|
||||
|
||||
// Statistics
|
||||
NumLookupsName int
|
||||
NumLookupsInaddr int
|
||||
}
|
||||
|
||||
func NewMockedZone(zr ZoneRecord) *mockedZone { return &mockedZone{record: zr} }
|
||||
func (mz mockedZone) Domain() string { return DefaultLocalDomain }
|
||||
func (mz mockedZone) LookupName(name string) ([]ZoneRecord, error) {
|
||||
Debug.Printf("[mocked zone]: LookupName: returning record %s", mz.record)
|
||||
mz.NumLookupsName += 1
|
||||
return []ZoneRecord{mz.record}, nil
|
||||
}
|
||||
func (mz mockedZone) LookupInaddr(inaddr string) ([]ZoneRecord, error) {
|
||||
Debug.Printf("[mocked zone]: LookupInaddr: returning record %s", mz.record)
|
||||
mz.NumLookupsInaddr += 1
|
||||
return []ZoneRecord{mz.record}, nil
|
||||
}
|
||||
|
||||
// the following methods are not currently needed...
|
||||
func (mz mockedZone) Status() string { notImplWarn(); return "nothing" }
|
||||
func (mz mockedZone) AddRecord(ident string, name string, ip net.IP) error { notImplWarn(); return nil }
|
||||
func (mz mockedZone) DeleteRecord(ident string, ip net.IP) error { notImplWarn(); return nil }
|
||||
func (mz mockedZone) DeleteRecordsFor(ident string) error { notImplWarn(); return nil }
|
||||
func (mz mockedZone) DomainLookupName(name string) ([]ZoneRecord, error) {
|
||||
notImplWarn()
|
||||
return nil, nil
|
||||
}
|
||||
func (mz mockedZone) DomainLookupInaddr(inaddr string) ([]ZoneRecord, error) {
|
||||
notImplWarn()
|
||||
return nil, nil
|
||||
}
|
||||
func (mz mockedZone) ObserveName(name string, observer ZoneRecordObserver) error {
|
||||
notImplWarn()
|
||||
return nil
|
||||
}
|
||||
func (mz mockedZone) ObserveInaddr(inaddr string, observer ZoneRecordObserver) error {
|
||||
notImplWarn()
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user