yats.git

commit 5180bcb346d33ddd88ed5a987d1c2c438c853a73

Author: Paolo Lulli <paolo@lulli.net>

Rollback to 5afe7695f8c71bda069c2d8fd0e8cffc270d43b7

 server/config/config.go | 1 -
 server/grpc/grpc-tls.go | 7 ++-----
 server/main.go | 3 ++-
 server/rest/mtls.go | 6 ++----
 server/service-rest.go | 4 +---


diff --git a/server/config/config.go b/server/config/config.go
index 6c0529f22a0c7da843382e8a86b3a0152eb96f43..eb79fec7366c8746a75ae7184a2a46688b960c34 100644
--- a/server/config/config.go
+++ b/server/config/config.go
@@ -56,7 +56,6 @@ 	TlsCA          string `json:"tlsCA"`
 
 	LogFile       string `json:"logFile"`
 	GrafanaActive string `json:"grafanaActive"`
-	OpenApiActive string `json:"openapiActive"`
 }
 
 func GetConfig(fileName string) Configuration {




diff --git a/server/grpc/grpc-tls.go b/server/grpc/grpc-tls.go
index cd047de72a0fab9214031f0be32cb6d8ee27252a..4200fb6af0b9c7630865d7d895fc0b76fb54242c 100644
--- a/server/grpc/grpc-tls.go
+++ b/server/grpc/grpc-tls.go
@@ -3,7 +3,6 @@
 import (
 	"context"
 	"crypto/x509"
-	"fmt"
 	"google.golang.org/grpc/credentials"
 	"google.golang.org/grpc/peer"
 )
@@ -20,14 +19,12 @@ 		//v := tlsInfo.State.VerifiedChains[0][0].Subject.CommonName
 		//fmt.Printf("%v - %v\n", peers.Addr.String(), v)
 		return extractCommonName(certificates)
 	}
-	fmt.Println("Could not extract common name")
-	return ""
+	panic("Could not extract common name")
 }
 
 func extractCommonName(certificates []*x509.Certificate) string {
 	if len(certificates) > 0 {
 		return certificates[0].Subject.CommonName
 	}
-	fmt.Println("Could not extract common name")
-	return ""
+	panic("Could not extract common name")
 }




diff --git a/server/main.go b/server/main.go
index 6bda109c1c1ec34a33b4acc19e9781568c699158..3cef44af8e1054c066c14da115b488835db8ea8f 100644
--- a/server/main.go
+++ b/server/main.go
@@ -15,6 +15,7 @@ 	"fmt"
 	"os"
 	"strings"
 	"yats-server/config"
+	"yats-server/db"
 	"yats-server/docs"
 	"yats-server/grpc"
 )
@@ -51,7 +52,7 @@ 		fmt.Printf("Loading instance: [%s] config", instanceName)
 		configuration = config.GetConfig(os.Getenv("HOME") + "/.yats/" + instanceName + ".json")
 	}
 
-	//db.Session = db.InitializeDb(configuration)
+	db.Session = db.InitializeDb(configuration)
 
 	if configuration.IsArchiveNode == "true" {
 		fmt.Println("Starting Archive Node")




diff --git a/server/rest/mtls.go b/server/rest/mtls.go
index b2836e2c91cd3f288138a6d0eb5d149e38e2289f..49d2a01f4bd6f1c51a14b78830863d9f9779aaab 100644
--- a/server/rest/mtls.go
+++ b/server/rest/mtls.go
@@ -11,7 +11,6 @@
 package rest
 
 import (
-	"fmt"
 	"github.com/gin-gonic/gin"
 	"yats-server/config"
 )
@@ -22,7 +21,7 @@ 		s, done := extractCommonName(c)
 		if done {
 			return s
 		}
-		fmt.Println("Could not extract common name")
+		panic("Could not extract common name")
 	}
 	return c.Request.Header.Get("X-SSL-Client-CN")
 }
@@ -32,6 +31,5 @@ 	certificates := c.Request.TLS.PeerCertificates
 	if len(certificates) > 0 {
 		return certificates[0].Subject.CommonName, true
 	}
-	fmt.Println("Could not extract common name")
-	return "", false
+	panic("Could not extract common name")
 }




diff --git a/server/service-rest.go b/server/service-rest.go
index 3b01fe41a7cb50dc7d4600609a706d86018b0798..06a6fc9560a0768f3ea5720ea8934b994b2f4b81 100644
--- a/server/service-rest.go
+++ b/server/service-rest.go
@@ -39,9 +39,7 @@ 	router.GET("/event/:from", rest.GetEventsFrom(cfg))
 
 	router.POST("/position", rest.WritePosition(cfg))
 
-	if cfg.OpenApiActive == "true" {
-		enableSwaggerEndpoint(router)
-	}
+	enableSwaggerEndpoint(router)
 
 	if cfg.GrafanaActive == "true" {
 		enableGrafanaEndpoint(router)