[tor-commits] [snowflake/master] Add -log option to proxy-go.

dcf at torproject.org dcf at torproject.org
Thu Jun 29 23:17:46 UTC 2017


commit c3f87281be36076d61a454b18e1f13ad9e4ad4d4
Author: David Fifield <david at bamsoftware.com>
Date:   Thu Jun 29 15:11:14 2017 -0700

    Add -log option to proxy-go.
---
 proxy-go/snowflake.go | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/proxy-go/snowflake.go b/proxy-go/snowflake.go
index c7ee24a..5342ab1 100644
--- a/proxy-go/snowflake.go
+++ b/proxy-go/snowflake.go
@@ -12,6 +12,7 @@ import (
 	"net"
 	"net/http"
 	"net/url"
+	"os"
 	"strings"
 	"sync"
 	"time"
@@ -291,13 +292,24 @@ func runSession(sid string) {
 }
 
 func main() {
+	var logFilename string
 	opt = new(snowflakeOptions)
 	flag.IntVar(&opt.capacity, "capacity", 10, "maximum concurrent clients")
 	flag.StringVar(&opt.broker, "broker", "https://snowflake-reg.appspot.com/", "broker URL")
 	flag.StringVar(&opt.relay, "relay", "wss://snowflake.bamsoftware.com/", "websocket relay URL")
 	flag.StringVar(&opt.stun, "stun", "stun:stun.l.google.com:19302", "stun URL")
+	flag.StringVar(&logFilename, "log", "", "log filename")
 	flag.Parse()
 
+	if logFilename != "" {
+		f, err := os.OpenFile(logFilename, os.O_WRONLY | os.O_APPEND, 0600)
+		if err != nil {
+			log.Fatal(err)
+		}
+		defer f.Close()
+		log.SetOutput(io.MultiWriter(os.Stderr, f))
+	}
+
 	var err error
 	opt.brokerURL, err = url.Parse(opt.broker)
 	if err != nil {





More information about the tor-commits mailing list