Alejandro Mery
1 year ago
7 changed files with 167 additions and 48 deletions
@ -0,0 +1,12 @@
|
||||
package dns |
||||
|
||||
import "errors" |
||||
|
||||
var ( |
||||
// ErrNoDNSProvider indicates a [libdns.Provider] wasn't assigned
|
||||
// to the [Manager]
|
||||
ErrNoDNSProvider = errors.New("dns provider not specified") |
||||
|
||||
// ErrNoDomain indicates a domain wasn't specified
|
||||
ErrNoDomain = errors.New("domain not specified") |
||||
) |
@ -0,0 +1,29 @@
|
||||
package dns |
||||
|
||||
import ( |
||||
"context" |
||||
"fmt" |
||||
"time" |
||||
|
||||
"darvaza.org/core" |
||||
) |
||||
|
||||
// Show shows current DNS entries
|
||||
func (mgr *Manager) Show(ctx context.Context, names ...string) error { |
||||
recs, err := mgr.GetRecords(ctx, names...) |
||||
if err != nil { |
||||
return core.Wrap(err, "GetRecords") |
||||
} |
||||
|
||||
for _, rr := range recs { |
||||
_, _ = fmt.Printf("%s\t%v\tIN\t%s\t%s\t; %s\n", |
||||
rr.Name, |
||||
int(rr.TTL/time.Second), |
||||
rr.Type, |
||||
rr.Value, |
||||
rr.ID) |
||||
} |
||||
|
||||
_, _ = fmt.Printf("; %v records\n", len(recs)) |
||||
return nil |
||||
} |
Loading…
Reference in new issue