summary refs log tree commit diff stats
path: root/svc
diff options
context:
space:
mode:
authorBen Morrison <ben@gbmor.dev>2020-03-16 02:42:35 -0400
committerBen Morrison <ben@gbmor.dev>2020-03-16 02:42:35 -0400
commit31c992e6eaa8f4afe90ec95c5c778412fb887146 (patch)
treedfbbc9651772c51fa4bb74bef03ea37de9d27380 /svc
parent271ba7ca8dc513ba240c0b0290efd0957a16125a (diff)
downloadgetwtxt-31c992e6eaa8f4afe90ec95c5c778412fb887146.tar.gz
removed experimental host matching and tls support
Diffstat (limited to 'svc')
-rw-r--r--svc/conf.go31
-rw-r--r--svc/svc.go31
2 files changed, 3 insertions, 59 deletions
diff --git a/svc/conf.go b/svc/conf.go
index f3797c6..ae52219 100644
--- a/svc/conf.go
+++ b/svc/conf.go
@@ -36,7 +36,6 @@ var reqLog *log.Logger
 // this struct.
 type Configuration struct {
 	Mu            sync.RWMutex
-	IsProxied     bool          `yaml:"BehindProxy"`
 	Port          int           `yaml:"ListenPort"`
 	MsgLog        string        `yaml:"MessageLog"`
 	ReqLog        string        `yaml:"RequestLog"`
@@ -47,7 +46,6 @@ type Configuration struct {
 	CacheInterval time.Duration `yaml:"StatusFetchInterval"`
 	DBInterval    time.Duration `yaml:"DatabasePushInterval"`
 	Instance      `yaml:"Instance"`
-	TLS
 }
 
 // Instance refers to meta data about
@@ -61,14 +59,6 @@ type Instance struct {
 	Desc  string `yaml:"Instance.Description"`
 }
 
-// TLS holds the tls config from the
-// config file
-type TLS struct {
-	Use  bool   `yaml:"UseTLS"`
-	Cert string `yaml:"TLSCert"`
-	Key  string `yaml:"TLSKey"`
-}
-
 // Called on start-up. Initializes everything
 // related to configuration values.
 func initConfig() {
@@ -125,10 +115,6 @@ func initLogging() {
 // Default values should a config file
 // not be available.
 func setConfigDefaults() {
-	viper.SetDefault("BehindProxy", true)
-	viper.SetDefault("UseTLS", false)
-	viper.SetDefault("TLSCert", "cert.pem")
-	viper.SetDefault("TLSKey", "key.pem")
 	viper.SetDefault("ListenPort", 9001)
 	viper.SetDefault("MessageLog", "logs/message.log")
 	viper.SetDefault("RequestLog", "logs/request.log")
@@ -175,7 +161,6 @@ func parseConfigFlag() {
 func bindConfig() {
 	confObj.Mu.Lock()
 
-	confObj.IsProxied = viper.GetBool("BehindProxy")
 	confObj.Port = viper.GetInt("ListenPort")
 	confObj.MsgLog = viper.GetString("MessageLog")
 	confObj.ReqLog = viper.GetString("RequestLog")
@@ -193,12 +178,6 @@ func bindConfig() {
 	confObj.Instance.Mail = viper.GetString("Instance.Email")
 	confObj.Instance.Desc = viper.GetString("Instance.Description")
 
-	confObj.TLS.Use = viper.GetBool("UseTLS")
-	if confObj.TLS.Use {
-		confObj.TLS.Cert = viper.GetString("TLSCert")
-		confObj.TLS.Key = viper.GetString("TLSKey")
-	}
-
 	if *flagDBType != "" {
 		confObj.DBType = *flagDBType
 	}
@@ -219,16 +198,6 @@ func announceConfig() {
 	confObj.Mu.RLock()
 	defer confObj.Mu.RUnlock()
 
-	if confObj.IsProxied {
-		log.Printf("Behind reverse proxy, not using host matching\n")
-	} else {
-		log.Printf("Matching host: %v\n", confObj.Instance.URL)
-	}
-	if confObj.TLS.Use {
-		log.Printf("Using TLS\n")
-		log.Printf("Cert: %v\n", confObj.TLS.Cert)
-		log.Printf("Key: %v\n", confObj.TLS.Key)
-	}
 	if confObj.StdoutLogging {
 		log.Printf("Logging to: stdout\n")
 	} else {
diff --git a/svc/svc.go b/svc/svc.go
index 01dd0d7..4e98c94 100644
--- a/svc/svc.go
+++ b/svc/svc.go
@@ -20,7 +20,6 @@ along with Getwtxt.  If not, see <https://www.gnu.org/licenses/>.
 package svc // import "github.com/getwtxt/getwtxt/svc"
 
 import (
-	"crypto/tls"
 	"fmt"
 	"log"
 	"net/http"
@@ -45,32 +44,13 @@ func Start() {
 
 	confObj.Mu.RLock()
 	portnum := fmt.Sprintf(":%v", confObj.Port)
-	if !confObj.IsProxied {
-		index.Host(confObj.Instance.URL)
-	}
-	TLS := confObj.TLS.Use
-	TLSCert := confObj.TLS.Cert
-	TLSKey := confObj.TLS.Key
 	confObj.Mu.RUnlock()
 
 	server := newServer(portnum, index)
 
-	if TLS {
-		cert, err := tls.LoadX509KeyPair(TLSCert, TLSKey)
-		errFatal("", err)
-
-		cfg := &tls.Config{Certificates: []tls.Certificate{cert}}
-		lstnr, err := tls.Listen("tcp", portnum, cfg)
-		errFatal("", err)
-
-		server.TLSConfig = cfg
-		startAnnounce(portnum, before)
-		errLog("", server.ServeTLS(lstnr, "", ""))
-
-	} else {
-		startAnnounce(portnum, before)
-		errLog("", server.ListenAndServe())
-	}
+	log.Printf("*** Listening on %v\n", portnum)
+	log.Printf("*** getwtxt %v Startup finished at %v, took %v\n\n", Vers, time.Now().Format(time.RFC3339), time.Since(before))
+	errLog("", server.ListenAndServe())
 
 	closeLog <- struct{}{}
 	killTickers()
@@ -79,11 +59,6 @@ func Start() {
 	close(closeLog)
 }
 
-func startAnnounce(portnum string, before time.Time) {
-	log.Printf("*** Listening on %v\n", portnum)
-	log.Printf("*** getwtxt %v Startup finished at %v, took %v\n\n", Vers, time.Now().Format(time.RFC3339), time.Since(before))
-}
-
 func newServer(port string, index *mux.Router) *http.Server {
 	// handlers.CompressHandler gzips all responses.
 	// ipMiddleware passes the request IP along.