|
|
@ -8,7 +8,9 @@ import (
|
|
|
|
"encoding/json"
|
|
|
|
"encoding/json"
|
|
|
|
"errors"
|
|
|
|
"errors"
|
|
|
|
"io/ioutil"
|
|
|
|
"io/ioutil"
|
|
|
|
|
|
|
|
"log"
|
|
|
|
"net/http"
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
import "golang.org/x/crypto/blowfish"
|
|
|
|
import "golang.org/x/crypto/blowfish"
|
|
|
@ -56,11 +58,13 @@ func NewHttpServer(manager *Manager) *httpServer {
|
|
|
|
|
|
|
|
|
|
|
|
func (it *httpServer) Start() {
|
|
|
|
func (it *httpServer) Start() {
|
|
|
|
http.HandleFunc("/", func(writer http.ResponseWriter, request *http.Request) {
|
|
|
|
http.HandleFunc("/", func(writer http.ResponseWriter, request *http.Request) {
|
|
|
|
|
|
|
|
log.Printf("%s /", strings.ToUpper(request.Method))
|
|
|
|
writer.WriteHeader(200)
|
|
|
|
writer.WriteHeader(200)
|
|
|
|
writer.Write([]byte("Don't"))
|
|
|
|
writer.Write([]byte("Don't"))
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
http.HandleFunc("/create-csr", func(writer http.ResponseWriter, request *http.Request) {
|
|
|
|
http.HandleFunc("/create-csr", func(writer http.ResponseWriter, request *http.Request) {
|
|
|
|
|
|
|
|
log.Printf("%s /create-csr", strings.ToUpper(request.Method))
|
|
|
|
req := &CreateCSRRequest{}
|
|
|
|
req := &CreateCSRRequest{}
|
|
|
|
err := it.verifyRequest(request, req)
|
|
|
|
err := it.verifyRequest(request, req)
|
|
|
|
|
|
|
|
|
|
|
@ -81,6 +85,7 @@ func (it *httpServer) Start() {
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
http.HandleFunc("/deliver-crt", func(writer http.ResponseWriter, request *http.Request) {
|
|
|
|
http.HandleFunc("/deliver-crt", func(writer http.ResponseWriter, request *http.Request) {
|
|
|
|
|
|
|
|
log.Printf("%s /deliver-crt", strings.ToUpper(request.Method))
|
|
|
|
req := &DeliverCertificateRequest{}
|
|
|
|
req := &DeliverCertificateRequest{}
|
|
|
|
err := it.verifyRequest(request, req)
|
|
|
|
err := it.verifyRequest(request, req)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
@ -98,6 +103,7 @@ func (it *httpServer) Start() {
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
http.HandleFunc("/update-openvpn-config", func(writer http.ResponseWriter, request *http.Request) {
|
|
|
|
http.HandleFunc("/update-openvpn-config", func(writer http.ResponseWriter, request *http.Request) {
|
|
|
|
|
|
|
|
log.Printf("%s /update-openvpn-config", strings.ToUpper(request.Method))
|
|
|
|
req := &UpdateOpenVPNConfigRequest{}
|
|
|
|
req := &UpdateOpenVPNConfigRequest{}
|
|
|
|
err := it.verifyRequest(request, req)
|
|
|
|
err := it.verifyRequest(request, req)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|