summaryrefslogtreecommitdiff
path: root/funcs/net.go
blob: 75a47498bfecea9ab697cf528631d59437ca5c92 (plain)
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
package funcs

import (
	stdnet "net"
	"sync"

	"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 string) string {
	return net.LookupIP(name)
}

// LookupIPs -
func (f *NetFuncs) LookupIPs(name string) []string {
	return net.LookupIPs(name)
}

// LookupCNAME -
func (f *NetFuncs) LookupCNAME(name string) string {
	return net.LookupCNAME(name)
}

// LookupSRV -
func (f *NetFuncs) LookupSRV(name string) *stdnet.SRV {
	return net.LookupSRV(name)
}

// LookupSRVs -
func (f *NetFuncs) LookupSRVs(name string) []*stdnet.SRV {
	return net.LookupSRVs(name)
}

// LookupTXT -
func (f *NetFuncs) LookupTXT(name string) []string {
	return net.LookupTXT(name)
}