From 828ee14b4e903bbda9291bc9ee09ff98b66003c7 Mon Sep 17 00:00:00 2001 From: "kali kaneko (leap communications)" Date: Tue, 11 Feb 2020 17:13:53 +0100 Subject: [feat] metrics listen in separate port --- pkg/config/config.go | 6 ++++-- pkg/web/handlers.go | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'pkg') diff --git a/pkg/config/config.go b/pkg/config/config.go index 76b4e4e..2e5eac7 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -30,6 +30,7 @@ type Opts struct { TlsCrt string TlsKey string Port string + MetricsPort string Auth string AuthSecret string ApiPath string @@ -87,8 +88,8 @@ func initializeFlags(opts *Opts) { flag.StringVar(&opts.TlsCrt, "tlsCrt", "", "Path to the cert file for TLS") flag.StringVar(&opts.TlsKey, "tlsKey", "", "Path to the key file for TLS") flag.StringVar(&opts.Port, "port", "", "Port where the server will listen (default: 8000)") - flag.StringVar(&opts.Auth, "auth", "", "Authentication module (ano, sip2)") - flag.StringVar(&opts.AuthSecret, "authSecret", "", "Authentication secret (optional)") + flag.StringVar(&opts.MetricsPort, "metricsPort", "", "Port where the metrics server will listen (default: 8001)") + flag.StringVar(&opts.Auth, "auth", "", "Authentication module (anon, sip2)") flag.StringVar(&opts.ApiPath, "apiPath", "", "Path to the API public files") flag.StringVar(&opts.ProviderCaPath, "providerCaCrt", "", "Path to the provider CA certificate") flag.Parse() @@ -98,6 +99,7 @@ func initializeFlags(opts *Opts) { FallbackToEnv(&opts.TlsCrt, "VPNWEB_TLSCRT", "") FallbackToEnv(&opts.TlsKey, "VPNWEB_TLSKEY", "") FallbackToEnv(&opts.Port, "VPNWEB_PORT", "8000") + FallbackToEnv(&opts.MetricsPort, "VPNWEB_METRICS_PORT", "8001") FallbackToEnv(&opts.Auth, "VPNWEB_AUTH", DefaultAuthenticationModule) FallbackToEnv(&opts.AuthSecret, "VPNWEB_AUTH_SECRET", "") FallbackToEnv(&opts.ApiPath, "VPNWEB_API_PATH", "/etc/leap/config/vpn") diff --git a/pkg/web/handlers.go b/pkg/web/handlers.go index 633ae95..9c4e91b 100644 --- a/pkg/web/handlers.go +++ b/pkg/web/handlers.go @@ -33,8 +33,8 @@ func (ch *CertHandler) CertResponder(w http.ResponseWriter, r *http.Request) { ch.Cainfo.CertWriter(w) } -func HttpFileHandler(route string, path string) { - http.HandleFunc(route, func(w http.ResponseWriter, r *http.Request) { +func HttpFileHandler(mux *http.ServeMux, route string, path string) { + mux.HandleFunc(route, func(w http.ResponseWriter, r *http.Request) { http.ServeFile(w, r, path) }) } -- cgit v1.2.3