+ clients: parse 'arp -a' output; periodically update info

* prioritize a client source: etc/hosts > ARP > rDNS
This commit is contained in:
Simon Zolin
2019-06-25 17:51:53 +03:00
parent b4b11406cf
commit db7efc24d3
2 changed files with 90 additions and 9 deletions

View File

@@ -104,17 +104,29 @@ func TestClients(t *testing.T) {
}
// add host client
b, e = clientAddHost("1.1.1.1", "host", ClientSourceHostsFile)
b, e = clientAddHost("1.1.1.1", "host", ClientSourceARP)
if !b || e != nil {
t.Fatalf("clientAddHost")
}
// failed add - ip exists
b, e = clientAddHost("1.1.1.1", "host", ClientSourceHostsFile)
b, e = clientAddHost("1.1.1.1", "host1", ClientSourceRDNS)
if b || e != nil {
t.Fatalf("clientAddHost - ip exists")
}
// overwrite with new data
b, e = clientAddHost("1.1.1.1", "host2", ClientSourceARP)
if !b || e != nil {
t.Fatalf("clientAddHost - overwrite with new data")
}
// overwrite with new data (higher priority)
b, e = clientAddHost("1.1.1.1", "host3", ClientSourceHostsFile)
if !b || e != nil {
t.Fatalf("clientAddHost - overwrite with new data (higher priority)")
}
// get
if !clientExists("1.1.1.1") {
t.Fatalf("clientAddHost")