-
Notifications
You must be signed in to change notification settings - Fork 18
/
main.go
44 lines (36 loc) · 899 Bytes
/
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
package main
import (
"context"
"fmt"
"os"
"os/signal"
"syscall"
"github.com/miekg/dns"
)
const agentConfigFilePath = "agent.json"
func main() {
ctx := context.Background()
ctx, cancel := context.WithCancel(ctx)
signalChan := make(chan os.Signal, 1)
signal.Notify(signalChan, syscall.SIGINT, syscall.SIGTERM)
defer func() {
signal.Stop(signalChan)
cancel()
}()
go func() {
for {
select {
case <-signalChan:
WriteAnnotation(fmt.Sprintf("%s Received SIGTERM signal", StepSecurityAnnotationPrefix))
case <-ctx.Done():
WriteLog("called ctx.Done()")
os.Exit(1)
}
}
}()
if err := Run(ctx, agentConfigFilePath, &dns.Server{Addr: "127.0.0.1:53", Net: "udp"},
&dns.Server{Addr: "172.17.0.1:53", Net: "udp"}, nil, nil, nil, resolvedConfigPath, dockerDaemonConfigPath, os.TempDir()); err != nil {
fmt.Fprintf(os.Stderr, "%s\n", err)
os.Exit(1)
}
}