-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.go
86 lines (77 loc) · 1.68 KB
/
api.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// package dnsinfo provides dns reports
package dnsinfo
// import
import (
"paepcke.de/dnsresolver"
"paepcke.de/reportstyle"
)
//
// SIMPLE API
//
// ReportText ...
func ReportText(hostname string) string {
r := &Report{
Query: hostname,
Type: dnsresolver.TypeAll,
Resolver: dnsresolver.ResolverAuto(),
Summary: true,
Style: reportstyle.StyleText(),
}
return r.Generate()
}
// ReportAnsi ...
func ReportAnsi(hostname string) string {
r := &Report{
Query: hostname,
Type: dnsresolver.TypeAll,
Resolver: dnsresolver.ResolverAuto(),
Summary: true,
Style: reportstyle.StyleAnsi(),
}
return r.Generate()
}
// ReportMarkdown ...
func ReportMarkdown(hostname string) string {
r := &Report{
Query: hostname,
Type: dnsresolver.TypeAll,
Resolver: dnsresolver.ResolverAuto(),
Summary: true,
Style: reportstyle.StyleMarkdown(),
}
return r.Generate()
}
// ReportHTML ...
func ReportHTML(hostname string) string {
r := &Report{
Query: hostname,
Type: dnsresolver.TypeAll,
Resolver: dnsresolver.ResolverAuto(),
Summary: true,
Style: reportstyle.StyleHTML(),
}
return r.Generate()
}
//
//
// GENERIC BACKEND
//
// Report ...
type Report struct {
// Hostname is the name to query
Query string
// Target is the DNS type(s) to query
Type []uint16
// Resolver is the DNS Nameserver profile for the query
Resolver *dnsresolver.Resolver
// Summary decides if the Summary is part of the Report
Summary bool
// Raw decides if the Raw Traces are part of the Report
Raw bool
// Style is the Report style (text, html, ...)
Style *reportstyle.Style
}
// Generate ...
func (r *Report) Generate() string {
return r.generateAll()
}