-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
60 lines (51 loc) · 1.24 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
package main
import (
"fmt"
"log"
"net"
"github.com/voxelbrain/goptions"
"isucdc.com/keyescrow-server/escrow"
"isucdc.com/keyescrow-server/server"
)
const (
PUBKEY_NAME = "%v"
PRIVKEY_NAME = "%v.priv"
)
func main() {
options := struct {
Host *net.TCPAddr `goptions:"-s, --server"`
Help goptions.Help `goptions:"-h, --help, description='Show this help'"`
goptions.Verbs
Server struct {
KeyDir string `goptions:"-k, --keydir, description='Key Directory'"`
} `goptions:"server"`
}{ // Default values go here
Host: &net.TCPAddr{
IP: net.ParseIP("0.0.0.0"),
Port: 7654,
},
}
//options.Host.IP = net.ParseIP(os.Getenv("KE_HOST"))
fmt.Println("CDC Key Escrow Server v1")
goptions.ParseAndFail(&options)
if len(options.Verbs) <= 0 {
fmt.Println("You must specify a verb")
return
}
switch options.Verbs {
case "server":
if options.Server.KeyDir == "" {
options.Server.KeyDir = "./keys"
}
//log.Printf("Using %v for key storage\n", options.KeyDir)
escrow.Keydir = options.Server.KeyDir
serv, err := server.New(options.Host)
defer serv.Close()
if err != nil {
log.Fatalf("There was an error starting the server: %v", err.Error())
}
serv.Keydir = options.Server.KeyDir
serv.Loop()
break
}
}