forked from NXRSE/bank
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.go
65 lines (57 loc) · 1.07 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
63
64
65
package main
import (
"errors"
"flag"
"log"
"os"
)
const (
// This is the FQDN from the certs generated
CONN_HOST = "localhost"
CONN_PORT = "3300"
CONN_TYPE = "tcp"
HTTP_PORT = "8443"
)
func main() {
argClientServer := "http"
// http server is default mode
if flag.Arg(0) != "" {
argClientServer = flag.Arg(0)
}
err := parseArguments(argClientServer)
if err != nil {
log.Fatalf("Error starting, err: %v\n", err)
}
os.Exit(0)
}
func parseArguments(arg string) (err error) {
switch arg {
case "http":
err := RunHttpServer()
if err != nil {
log.Fatalf("Could not start HTTP server. " + err.Error())
}
break
case "client":
// Run client for bank system
runClient("tls")
break
case "clientNoTLS":
// Run client for bank system
runClient("no-tls")
break
case "server":
// Run server for bank system
for {
runServer("tls")
}
case "serverNoTLS":
// Run server for bank system
for {
runServer("no-tls")
}
default:
return errors.New("No valid option chosen. Valid options: client, clientNoTLS, server, serverNoTLS")
}
return
}