ssl support
This commit is contained in:
parent
2eb4f9e4ea
commit
b93211cdf2
12
Makefile
12
Makefile
|
@ -1,10 +1,22 @@
|
||||||
all: build
|
all: build
|
||||||
build: fmt lint gobuild
|
build: fmt lint gobuild
|
||||||
|
vendor: govendor
|
||||||
deps: godeps
|
deps: godeps
|
||||||
fmt: gofmt
|
fmt: gofmt
|
||||||
lint: golint
|
lint: golint
|
||||||
test: gotest
|
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:
|
gobuild:
|
||||||
statik -src=./web/
|
statik -src=./web/
|
||||||
go build
|
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 (
|
require (
|
||||||
github.com/pyke369/golang-support v0.0.0-20190703174728-34ca97aa79e9
|
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 h1:H1vjQ+Mfc8dFAOTuF541/tScdKoynzll9iKuWgaLLxM=
|
||||||
github.com/pyke369/golang-support v0.0.0-20190703174728-34ca97aa79e9/go.mod h1:0XGrzgrEp0fa/+JSV8XZePUwyjnU6C3bMc7Xz2bHHKI=
|
github.com/pyke369/golang-support v0.0.0-20190703174728-34ca97aa79e9/go.mod h1:0XGrzgrEp0fa/+JSV8XZePUwyjnU6C3bMc7Xz2bHHKI=
|
||||||
github.com/rakyll/statik v0.1.6 h1:uICcfUXpgqtw2VopbIncslhAmE5hwc4g20TEyEENBNs=
|
github.com/rakyll/statik v0.1.6 h1:uICcfUXpgqtw2VopbIncslhAmE5hwc4g20TEyEENBNs=
|
||||||
|
|
7
httpd.go
7
httpd.go
|
@ -114,7 +114,7 @@ func (h *HttpServer) ajaxHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewHTTPServer(port string, s *OpenVpnMgt) {
|
func NewHTTPServer(port, key, cert string, s *OpenVpnMgt) {
|
||||||
h := &HttpServer{
|
h := &HttpServer{
|
||||||
Port: port,
|
Port: port,
|
||||||
ovpn: s,
|
ovpn: s,
|
||||||
|
@ -128,5 +128,10 @@ func NewHTTPServer(port string, s *OpenVpnMgt) {
|
||||||
http.HandleFunc("/ajax", h.ajaxHandler)
|
http.HandleFunc("/ajax", h.ajaxHandler)
|
||||||
http.Handle("/", http.FileServer(statikFS))
|
http.Handle("/", http.FileServer(statikFS))
|
||||||
|
|
||||||
|
switch {
|
||||||
|
case key == "" && cert == "":
|
||||||
|
log.Fatal(http.ListenAndServeTLS(port, cert, key, nil))
|
||||||
|
default:
|
||||||
log.Fatal(http.ListenAndServe(port, nil))
|
log.Fatal(http.ListenAndServe(port, nil))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
2
main.go
2
main.go
|
@ -43,6 +43,8 @@ func main() {
|
||||||
// time to start the listeners
|
// time to start the listeners
|
||||||
go NewHTTPServer(
|
go NewHTTPServer(
|
||||||
config.GetString("config.http.port", "127.0.0.01:8080"),
|
config.GetString("config.http.port", "127.0.0.01:8080"),
|
||||||
|
config.GetString("config.http.key", ""),
|
||||||
|
config.GetString("config.http.cert", ""),
|
||||||
server)
|
server)
|
||||||
server.Run()
|
server.Run()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue