Include zone records in status
This commit is contained in:
1 parent
50f6402774
commit
6f57774d15
3 files changed
+16
No files matched your search
@@ -24,6 +24,7 @@ func ListenHttp(version string, domain string, db Zone, port int) {
|
|||||||
router.Methods("GET").Path("/status").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
router.Methods("GET").Path("/status").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
io.WriteString(w, fmt.Sprintln("weave DNS", version))
|
io.WriteString(w, fmt.Sprintln("weave DNS", version))
|
||||||
io.WriteString(w, fmt.Sprintln("Serving domain", domain))
|
io.WriteString(w, fmt.Sprintln("Serving domain", domain))
|
||||||
|
io.WriteString(w, db.Status())
|
||||||
})
|
})
|
||||||
|
|
||||||
router.Methods("PUT").Path("/name/{identifier:.+}/{ip:.+}").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
router.Methods("PUT").Path("/name/{identifier:.+}/{ip:.+}").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import (
|
|||||||
. "github.com/zettio/weave/common"
|
. "github.com/zettio/weave/common"
|
||||||
"net"
|
"net"
|
||||||
"sync"
|
"sync"
|
||||||
|
"bytes"
|
||||||
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -20,6 +22,7 @@ type Lookup interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Zone interface {
|
type Zone interface {
|
||||||
|
Status() string
|
||||||
AddRecord(ident string, name string, ip net.IP) error
|
AddRecord(ident string, name string, ip net.IP) error
|
||||||
DeleteRecord(ident string, ip net.IP) error
|
DeleteRecord(ident string, ip net.IP) error
|
||||||
DeleteRecordsFor(ident string) error
|
DeleteRecordsFor(ident string) error
|
||||||
@@ -61,6 +64,17 @@ func (zone *ZoneDb) indexOf(match func(Record) bool) int {
|
|||||||
return -1
|
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) {
|
func (zone *ZoneDb) LookupName(name string) (net.IP, error) {
|
||||||
zone.mx.RLock()
|
zone.mx.RLock()
|
||||||
defer zone.mx.RUnlock()
|
defer zone.mx.RUnlock()
|
||||||
|
|||||||
@@ -556,6 +556,7 @@ case "$COMMAND" in
|
|||||||
;;
|
;;
|
||||||
status)
|
status)
|
||||||
http_call $CONTAINER_NAME $HTTP_PORT GET /status
|
http_call $CONTAINER_NAME $HTTP_PORT GET /status
|
||||||
|
echo
|
||||||
http_call $DNS_CONTAINER_NAME $DNS_HTTP_PORT GET /status
|
http_call $DNS_CONTAINER_NAME $DNS_HTTP_PORT GET /status
|
||||||
;;
|
;;
|
||||||
ps)
|
ps)
|
||||||
|
|||||||
Reference in new issue
Block a user