Browse Source

EnableHttp should be spelled EnableHTTP since HTTP is an acronym. See https://github.com/la5nta/pat/pull/163#discussion_r329446190

blockmurder 1 month ago
parent
commit
273ae99e89
2 changed files with 6 additions and 5 deletions
  1. 4 2
      cfg/config.go
  2. 2 3
      http.go

+ 4 - 2
cfg/config.go

@@ -196,7 +196,9 @@ type BeaconConfig struct {
 
 type GPSdConfig struct {
 	// enable GPSd support in web interface
-	EnableHttp bool    `json:"enable_http"`
+	// WARNING: If you enable GPSd http endpoint (enable_http) you might
+	// expose your current position to anyone who has access to Pat!!!
+	EnableHTTP bool    `json:"enable_http"`
 
 	// Use server time instead of timestamp provided by GPSd (e.g for older GPS
 	// device with week roll-over issue)
@@ -246,7 +248,7 @@ var DefaultConfig Config = Config{
 		Password:   "",
 	},
 	GPSd: GPSdConfig{
-		EnableHttp:    false,
+		EnableHTTP:    false, // Default to false to help protect privacy of unknowing users (see github.com//issues/146)
 		UseServerTime: false,
 		Addr:          "localhost:2947", // Default listen address for GPSd
 	},

+ 2 - 3
http.go

@@ -63,8 +63,7 @@ var websocketHub *WSHub
 func ListenAndServe(addr string) error {
 	log.Printf("Starting HTTP service (%s)...", addr)
 
-	if host, _, _ := net.SplitHostPort(addr); host == "" && config.GPSd.EnableHttp {
-		// can't use fmt.Printf as it would not show on the web interface
+	if host, _, _ := net.SplitHostPort(addr); host == "" && config.GPSd.EnableHTTP {
 		// TODO: maybe make a popup showing the warning ont the web UI?
 		log.SetFlags(log.Flags() &^ (log.Ldate | log.Ltime))
 		log.Printf("\nWARNING: You have enable GPSd http endpoint (enable_http). You might expose \n" +
@@ -354,7 +353,7 @@ func statusHandler(w http.ResponseWriter, req *http.Request) { json.NewEncoder(w
 
 func positionHandler(w http.ResponseWriter, req *http.Request) {
 	// Throw error if GPSd http endpoint is not enabled
-	if config.GPSd.EnableHttp && config.GPSd.Addr != "" {
+	if config.GPSd.EnableHTTP && config.GPSd.Addr != "" {
 		host, _, _ := net.SplitHostPort(req.RemoteAddr)
 		log.Printf("Location data from GPSd served to %s", host)