[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [snowflake/master] Use safelog scrubber in broker and proxy-go



commit 482d60d9d36cf8df077b01f30fd2e06f70c82739
Author: Cecylia Bocovich <cohosh@xxxxxxxxxxxxxx>
Date:   Thu Apr 11 14:47:31 2019 -0400

    Use safelog scrubber in broker and proxy-go
---
 broker/broker.go      | 7 +++++++
 proxy-go/snowflake.go | 7 ++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/broker/broker.go b/broker/broker.go
index b3a255e..7b998f6 100644
--- a/broker/broker.go
+++ b/broker/broker.go
@@ -10,12 +10,15 @@ import (
 	"crypto/tls"
 	"flag"
 	"fmt"
+	"io"
 	"io/ioutil"
 	"log"
 	"net/http"
+	"os"
 	"strings"
 	"time"
 
+	"git.torproject.org/pluggable-transports/snowflake.git/common/safelog"
 	"golang.org/x/crypto/acme/autocert"
 )
 
@@ -233,6 +236,10 @@ func main() {
 	flag.BoolVar(&disableTLS, "disable-tls", false, "don't use HTTPS")
 	flag.Parse()
 
+	var logOutput io.Writer = os.Stderr
+	//We want to send the log output through our scrubber first
+	log.SetOutput(&safelog.LogScrubber{Output: logOutput})
+
 	log.SetFlags(log.LstdFlags | log.LUTC)
 
 	ctx := NewBrokerContext()
diff --git a/proxy-go/snowflake.go b/proxy-go/snowflake.go
index 50c20a5..dda9a9a 100644
--- a/proxy-go/snowflake.go
+++ b/proxy-go/snowflake.go
@@ -18,6 +18,7 @@ import (
 	"sync"
 	"time"
 
+	"git.torproject.org/pluggable-transports/snowflake.git/common/safelog"
 	"github.com/keroserene/go-webrtc"
 	"golang.org/x/net/websocket"
 )
@@ -26,6 +27,7 @@ const defaultBrokerURL = "https://snowflake-broker.bamsoftware.com/";
 const defaultRelayURL = "wss://snowflake.bamsoftware.com/"
 const defaultSTUNURL = "stun:stun.l.google.com:19302"
 const pollInterval = 5 * time.Second
+
 //amount of time after sending an SDP answer before the proxy assumes the
 //client is not going to connect
 const dataChannelTimeout = time.Minute
@@ -380,6 +382,7 @@ func main() {
 	flag.StringVar(&logFilename, "log", "", "log filename")
 	flag.Parse()
 
+	var logOutput io.Writer = os.Stderr
 	log.SetFlags(log.LstdFlags | log.LUTC)
 	if logFilename != "" {
 		f, err := os.OpenFile(logFilename, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0600)
@@ -387,8 +390,10 @@ func main() {
 			log.Fatal(err)
 		}
 		defer f.Close()
-		log.SetOutput(io.MultiWriter(os.Stderr, f))
+		logOutput = io.MultiWriter(os.Stderr, f)
 	}
+	//We want to send the log output through our scrubber first
+	log.SetOutput(&safelog.LogScrubber{Output: logOutput})
 
 	log.Println("starting")
 



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits