-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
52 lines (43 loc) · 949 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
45
46
47
48
49
50
51
52
package main
import (
"fmt"
"github.com/habibiefaried/mtls-tcp-proxy/proxy"
"os"
)
//isValid will return string if corresponding env is not set. will return empty if all set
func isValid() string {
if os.Getenv("CERT_PATH") == "" {
return "CERT_PATH"
}
if os.Getenv("KEY_PATH") == "" {
return "KEY_PATH"
}
if os.Getenv("ROOT_CERT_PATH") == "" {
return "ROOT_CERT_PATH"
}
if os.Getenv("BIND_PORT") == "" {
return "BIND_PORT"
}
if os.Getenv("REMOTE_ADDR_PAIR") == "" {
return "REMOTE_ADDR_PAIR"
}
return ""
}
func main() {
if len(os.Args) != 2 {
fmt.Println("Usage: ./main <encryptor|decryptor>. And set env var accordingly")
} else {
s := isValid()
if s == "" {
if os.Args[1] == "encryptor" {
proxy.Encrypt()
} else if os.Args[1] == "decryptor" {
proxy.Decrypt()
} else {
fmt.Println(os.Args[1] + " is not recognized")
}
} else {
fmt.Printf("Env var %v is not set\n", s)
}
}
}