Include zone records in status
This commit is contained in:
1 parent
50f6402774
commit
6f57774d15
3 files changed
+16
No files matched your search
@@ -5,6 +5,8 @@ import (
|
||||
. "github.com/zettio/weave/common"
|
||||
"net"
|
||||
"sync"
|
||||
"bytes"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -20,6 +22,7 @@ type Lookup interface {
|
||||
}
|
||||
|
||||
type Zone interface {
|
||||
Status() string
|
||||
AddRecord(ident string, name string, ip net.IP) error
|
||||
DeleteRecord(ident string, ip net.IP) error
|
||||
DeleteRecordsFor(ident string) error
|
||||
@@ -61,6 +64,17 @@ func (zone *ZoneDb) indexOf(match func(Record) bool) int {
|
||||
return -1
|
||||
}
|
||||
|
||||
func (zone *ZoneDb) Status() string {
|
||||
zone.mx.RLock()
|
||||
defer zone.mx.RUnlock()
|
||||
var buf bytes.Buffer
|
||||
buf.WriteString("Records:\n")
|
||||
for _, r := range zone.recs {
|
||||
buf.WriteString(fmt.Sprintf("%s %s %v\n", r.Ident, r.IP, r.Name))
|
||||
}
|
||||
return buf.String()
|
||||
}
|
||||
|
||||
func (zone *ZoneDb) LookupName(name string) (net.IP, error) {
|
||||
zone.mx.RLock()
|
||||
defer zone.mx.RUnlock()
|
||||
|
||||
Reference in new issue
Block a user