ssl support
This commit is contained in:
parent
2eb4f9e4ea
commit
b93211cdf2
12
Makefile
12
Makefile
|
@ -1,10 +1,22 @@
|
|||
all: build
|
||||
build: fmt lint gobuild
|
||||
vendor: govendor
|
||||
deps: godeps
|
||||
fmt: gofmt
|
||||
lint: golint
|
||||
test: gotest
|
||||
|
||||
deb:
|
||||
debuild -e GOROOT -e PATH -i -us -uc -b
|
||||
|
||||
debclean:
|
||||
debuild clean
|
||||
rm -f ../openvpn-mgt
|
||||
|
||||
govendor:
|
||||
GO111MODULE=on go mod tidy
|
||||
GO111MODULE=on go mod vendor
|
||||
|
||||
gobuild:
|
||||
statik -src=./web/
|
||||
go build
|
||||
|
|
2
go.mod
2
go.mod
|
@ -1,4 +1,4 @@
|
|||
module gitlab.dm.gg/vwf/openvpn-dm-mgt-server
|
||||
module git.euclide.org/euclide/openvpn-mgt
|
||||
|
||||
require (
|
||||
github.com/pyke369/golang-support v0.0.0-20190703174728-34ca97aa79e9
|
||||
|
|
1
go.sum
1
go.sum
|
@ -1,4 +1,3 @@
|
|||
git.euclide.org/euclide/openvpn-mgt v0.0.0-20190815091940-a82131c8c881 h1:HXhjoWj3DcY1M5O077Q7kxNhMJmbK6qC8QUSifIUIpU=
|
||||
github.com/pyke369/golang-support v0.0.0-20190703174728-34ca97aa79e9 h1:H1vjQ+Mfc8dFAOTuF541/tScdKoynzll9iKuWgaLLxM=
|
||||
github.com/pyke369/golang-support v0.0.0-20190703174728-34ca97aa79e9/go.mod h1:0XGrzgrEp0fa/+JSV8XZePUwyjnU6C3bMc7Xz2bHHKI=
|
||||
github.com/rakyll/statik v0.1.6 h1:uICcfUXpgqtw2VopbIncslhAmE5hwc4g20TEyEENBNs=
|
||||
|
|
9
httpd.go
9
httpd.go
|
@ -114,7 +114,7 @@ func (h *HttpServer) ajaxHandler(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
func NewHTTPServer(port string, s *OpenVpnMgt) {
|
||||
func NewHTTPServer(port, key, cert string, s *OpenVpnMgt) {
|
||||
h := &HttpServer{
|
||||
Port: port,
|
||||
ovpn: s,
|
||||
|
@ -128,5 +128,10 @@ func NewHTTPServer(port string, s *OpenVpnMgt) {
|
|||
http.HandleFunc("/ajax", h.ajaxHandler)
|
||||
http.Handle("/", http.FileServer(statikFS))
|
||||
|
||||
log.Fatal(http.ListenAndServe(port, nil))
|
||||
switch {
|
||||
case key == "" && cert == "":
|
||||
log.Fatal(http.ListenAndServeTLS(port, cert, key, nil))
|
||||
default:
|
||||
log.Fatal(http.ListenAndServe(port, nil))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue