diff options
author | kali kaneko (leap communications) <kali@leap.se> | 2020-01-24 21:19:19 -0600 |
---|---|---|
committer | kali kaneko (leap communications) <kali@leap.se> | 2020-01-24 21:20:50 -0600 |
commit | d437b73a8c2dda9884c92d2be44727e66c2289e2 (patch) | |
tree | b9936d4e12a14b76d88ba1464a765e5b05ca6159 /cmd/vpnweb/vpnweb.go | |
parent | 12f0aca04bb613cae64d3c438042b85474abb411 (diff) |
refactor into cmd/pkg
Diffstat (limited to 'cmd/vpnweb/vpnweb.go')
-rw-r--r-- | cmd/vpnweb/vpnweb.go | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/cmd/vpnweb/vpnweb.go b/cmd/vpnweb/vpnweb.go new file mode 100644 index 0000000..86fc38c --- /dev/null +++ b/cmd/vpnweb/vpnweb.go @@ -0,0 +1,50 @@ +package main + +import ( + "log" + "net/http" + + //"0xacab.org/leap/pkg/auth" + "0xacab.org/leap/vpnweb/pkg/config" + "0xacab.org/leap/vpnweb/pkg/web" +) + +func main() { + opts := new(config.Opts) + config.InitializeFlags(opts) + config.CheckConfigurationOptions(opts) + + ci := web.NewCaInfo(opts.CaCrt, opts.CaKey) + ch := web.CertHandler{ci} + + /* protected routes */ + + /* TODO ---- + http.HandleFunc("/3/auth", auth.AuthMiddleware(opts.Auth)) + http.HandleFunc("/3/refresh-token", auth.RefreshAuthMiddleware(opts.Auth)) + http.HandleFunc("/3/cert", jwtMiddleware.Handler(ch.certResponder)) + */ + + http.HandleFunc("/3/cert", ch.CertResponder) + + /* static files */ + + /* TODO -- pass static file path in options */ + + web.HttpFileHandler("/3/configs.json", "./public/3/configs.json") + web.HttpFileHandler("/3/service.json", "./public/3/service.json") + web.HttpFileHandler("/3/config/eip-service.json", "./public/3/eip-service.json") + web.HttpFileHandler("/3/ca.crt", "./public/ca.crt") + web.HttpFileHandler("/provider.json", "./public/provider.json") + web.HttpFileHandler("/ca.crt", "./public/ca.crt") + + pstr := ":" + opts.Port + log.Println("Listening in port", opts.Port) + + if opts.Notls == true { + log.Fatal(http.ListenAndServe(pstr, nil)) + } else { + log.Fatal(http.ListenAndServeTLS(pstr, opts.TlsCrt, opts.TlsKey, nil)) + + } +} |