/
option.go
78 lines (65 loc) · 1.52 KB
/
option.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
package engine
import (
"github.com/gin-gonic/gin"
)
// Option server option
type Option struct {
tcpAddr string
udpAddr string
httpDNSAddr string
httpAPIAddr string
dnsHandle *Engine
httpAPIHandle *gin.Engine
httpDNSHandle *gin.Engine
}
// OptionsFunc option func
type OptionsFunc func(c *Option)
// WithDNSAddr option set tcp and udp Addr
func WithDNSAddr(addr string) OptionsFunc {
return func(c *Option) {
c.tcpAddr = addr
c.udpAddr = addr
}
}
// WithTCPAddr option set tcpAddr
func WithTCPAddr(tcpAddr string) OptionsFunc {
return func(c *Option) {
c.tcpAddr = tcpAddr
}
}
// WithUDPAddr option set udpAddr
func WithUDPAddr(udpAddr string) OptionsFunc {
return func(c *Option) {
c.udpAddr = udpAddr
}
}
// WithHTTPDNSAddr option set httpDNSAddr
func WithHTTPDNSAddr(httpDNSAddr string) OptionsFunc {
return func(c *Option) {
c.httpDNSAddr = httpDNSAddr
}
}
// WithHTTPAPIAddr option set httpAPIAddr
func WithHTTPAPIAddr(httpAPIAddr string) OptionsFunc {
return func(c *Option) {
c.httpAPIAddr = httpAPIAddr
}
}
// WithDNSHandle option set dnsHandle
func WithDNSHandle(dnsHandle *Engine) OptionsFunc {
return func(c *Option) {
c.dnsHandle = dnsHandle
}
}
// WithHttpAPIHandle option set httpAPIHandle
func WithHttpAPIHandle(httpAPIHandle *gin.Engine) OptionsFunc {
return func(c *Option) {
c.httpAPIHandle = httpAPIHandle
}
}
// WithHttpDNSHandle option set httpDNSHandle
func WithHttpDNSHandle(httpDNSHandle *gin.Engine) OptionsFunc {
return func(c *Option) {
c.httpDNSHandle = httpDNSHandle
}
}