forked from aporeto-inc/trireme-lib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
62 lines (47 loc) · 1.31 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
54
55
56
57
58
59
60
61
62
package main
import (
"flag"
"fmt"
"os"
"os/signal"
"github.com/aporeto-inc/trireme"
"github.com/aporeto-inc/trireme/example/common"
"github.com/aporeto-inc/trireme/monitor"
"github.com/golang/glog"
)
func usage() {
fmt.Fprintf(os.Stderr, "usage: example -stderrthreshold=[INFO|WARN|FATAL] -log_dir=[string]\n")
flag.PrintDefaults()
os.Exit(2)
}
func main() {
flag.Usage = usage
usePKI := *flag.Bool("pki", false, "Use PKI trireme")
certFile := *flag.String("certFile", "cert.pem", "Set the path of certificate.")
keyFile := *flag.String("keyFile", "key.pem", "Set the path of key certificate key to use.")
caCertFile := *flag.String("caCertFile", "ca.crt", "Set the path of certificate authority to use.")
flag.Parse()
var t trireme.Trireme
var m monitor.Monitor
if usePKI {
glog.V(1).Infof("Setting up trireme with PKI")
t, m = common.TriremeWithPKI(keyFile, certFile, caCertFile, []string{"172.17.0.0/24", "10.0.0.0/8"})
} else {
glog.V(1).Infof("Setting up trireme with PSK")
t, m = common.TriremeWithPSK([]string{"172.17.0.0/24", "10.0.0.0/8"})
}
if t == nil {
panic("Failed to create Trireme")
}
if m == nil {
panic("Failed to create Monitor")
}
t.Start()
m.Start()
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
<-c
fmt.Println("Bye!")
m.Stop()
t.Stop()
}