-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
53 lines (43 loc) · 1.11 KB
/
main.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
package main
import (
"time"
"github.com/hectodns/cachingproxy/cachingproxy"
"github.com/hectodns/hectodns/hectocorn"
)
type config struct {
To []string `json:"to"`
Except []string `json:"except"`
MaxConcurrent int64 `json:"max_concurrent"`
Policy string `json:"policy"`
Expire string `json:"expire"`
TLSServerName string `json:"tls_servername"`
TLS string `json:"tls"`
PreferUDP bool `json:"prefer_udp"`
ForceTCP bool `json:"force_tcp"`
ProbeTimeout string `json:"health_check"`
MaxFails int `json:"max_fails"`
}
func main() {
var (
C config
err error
)
hectocorn.DecodeConfig(&C)
f := cachingproxy.New()
f.MaxConcurrent = C.MaxConcurrent
f.MaxFails = uint32(C.MaxFails)
f.ExpireTimeout, err = time.ParseDuration(C.Expire)
if err != nil {
hectocorn.Log.Error(err.Error())
return
}
f.ProbeTimeout, err = time.ParseDuration(C.ProbeTimeout)
if err != nil {
hectocorn.Log.Error(err.Error())
return
}
for _, to := range C.To {
f.SetProxy(cachingproxy.NewProxy(to, "dns"))
}
hectocorn.ServeCore(f)
}