forked from hairyhenderson/gomplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
net.go
59 lines (46 loc) · 1.17 KB
/
net.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
package funcs
import (
stdnet "net"
"sync"
"github.com/hairyhenderson/gomplate/conv"
"github.com/hairyhenderson/gomplate/net"
)
var (
netNS *NetFuncs
netNSInit sync.Once
)
// NetNS - the net namespace
func NetNS() *NetFuncs {
netNSInit.Do(func() { netNS = &NetFuncs{} })
return netNS
}
// AddNetFuncs -
func AddNetFuncs(f map[string]interface{}) {
f["net"] = NetNS
}
// NetFuncs -
type NetFuncs struct{}
// LookupIP -
func (f *NetFuncs) LookupIP(name interface{}) (string, error) {
return net.LookupIP(conv.ToString(name))
}
// LookupIPs -
func (f *NetFuncs) LookupIPs(name interface{}) ([]string, error) {
return net.LookupIPs(conv.ToString(name))
}
// LookupCNAME -
func (f *NetFuncs) LookupCNAME(name interface{}) (string, error) {
return net.LookupCNAME(conv.ToString(name))
}
// LookupSRV -
func (f *NetFuncs) LookupSRV(name interface{}) (*stdnet.SRV, error) {
return net.LookupSRV(conv.ToString(name))
}
// LookupSRVs -
func (f *NetFuncs) LookupSRVs(name interface{}) ([]*stdnet.SRV, error) {
return net.LookupSRVs(conv.ToString(name))
}
// LookupTXT -
func (f *NetFuncs) LookupTXT(name interface{}) ([]string, error) {
return net.LookupTXT(conv.ToString(name))
}