-
Notifications
You must be signed in to change notification settings - Fork 2
/
awsvpnclient.go
91 lines (82 loc) · 2.33 KB
/
awsvpnclient.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package main
import (
"os"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"github.com/urfave/cli/v2"
)
const (
appName = "aws-vpn-client"
repoUrl = "https://github.com/ajm113/unix-aws-vpn-client"
bugReportUrl = "https://github.com/ajm113/unix-aws-vpn-client/issues"
errorSuffix = "Questions? Please visit our issue tracker: " + bugReportUrl
defaultConfigFilename = "awsvpnclient.yml"
defaultConfigDirectoryName = "awsvpnclient"
)
func main() {
app := cli.NewApp()
app.Name = appName
app.Usage = "Connects to AWS VPN service via cli without the official VPN Client hassle."
app.EnableBashCompletion = true
app.Commands = []*cli.Command{
{
Name: "setup",
Aliases: []string{"build"},
Usage: "Compiles openvpn for your unix environment and checking if baseline dependencies are installed.",
Action: setupAction,
Flags: []cli.Flag{
&cli.StringFlag{
TakesFile: true,
Required: false,
Aliases: []string{"s"},
Name: "source",
Usage: "OpenVPN (ideally v2.5.1) source code directory. Will download source code to tmp directory by default",
},
&cli.StringFlag{
TakesFile: true,
Required: false,
Name: "out",
Aliases: []string{"o"},
Value: ".",
Usage: "compiled openvpn binary location",
},
&cli.StringFlag{
TakesFile: true,
Required: false,
Name: "patch",
Aliases: []string{"p"},
Value: "scripts/openvpn-v2.5.1-aws.patch",
Usage: "patch file to use against openvpn source code",
},
},
},
{
Name: "serve",
Aliases: []string{"host", "start"},
Usage: "Loads openvpn configuration file and runs SAML server and openvpn.",
Action: serveAction,
Flags: []cli.Flag{
&cli.StringFlag{
TakesFile: true,
Required: true,
Name: "config",
Aliases: []string{"c"},
Usage: "raw openvpn configuration",
},
&cli.StringFlag{
TakesFile: true,
Name: "configTmpDir",
Aliases: []string{"t"},
Value: os.TempDir(),
Usage: "Temp folder location of formatted openvpn configurations.",
},
},
},
}
// Setup logging
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr})
err := app.Run(os.Args)
if err != nil {
log.Fatal().Err(err).Msg("closed to unexpected error")
}
}