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

[tor-commits] [snowflake/master] Move handling of -ice option into main.



commit 0c02af35d0a09ec1616ab8e23e6d833842d4f05e
Author: David Fifield <david@xxxxxxxxxxxxxxx>
Date:   Mon Aug 14 12:27:45 2017 -0700

    Move handling of -ice option into main.
    
    Rather than having it happen as a side effect of flag parsing.
    
    Having it happen as a side effect of flag parsing caused log messages
    related to handling the option (e.g. "IceServerList:") to always go to
    stderr, despite the presence of a -log option. This is because the
    requested log file had not been opened yet.
---
 client/snowflake.go | 13 +++++++++++--
 client/util.go      | 13 -------------
 2 files changed, 11 insertions(+), 15 deletions(-)

diff --git a/client/snowflake.go b/client/snowflake.go
index 764efb3..647e40e 100644
--- a/client/snowflake.go
+++ b/client/snowflake.go
@@ -10,6 +10,7 @@ import (
 	"net"
 	"os"
 	"os/signal"
+	"strings"
 	"sync"
 	"syscall"
 	"time"
@@ -121,8 +122,7 @@ func copyLoop(a, b io.ReadWriter) {
 }
 
 func main() {
-	var iceServers IceServerList
-	flag.Var(&iceServers, "ice", "comma-separated list of ICE servers")
+	iceServersCommas := flag.String("ice", "", "comma-separated list of ICE servers")
 	brokerURL := flag.String("url", "", "URL of signaling broker")
 	frontDomain := flag.String("front", "", "front domain")
 	logFilename := flag.String("log", "", "name of log file")
@@ -144,6 +144,15 @@ func main() {
 
 	log.Println("\n\n\n --- Starting Snowflake Client ---")
 
+	var iceServers IceServerList
+	log.Println("IceServerList:")
+	for _, server := range strings.Split(*iceServersCommas, ",") {
+		// TODO: STUN / TURN url format validation?
+		log.Println(server)
+		option := webrtc.OptionIceServer(server)
+		iceServers = append(iceServers, option)
+	}
+
 	// Prepare to collect remote WebRTC peers.
 	snowflakes := NewPeers(*max)
 	if "" != *brokerURL {
diff --git a/client/util.go b/client/util.go
index 74cd669..c90e17d 100644
--- a/client/util.go
+++ b/client/util.go
@@ -1,9 +1,7 @@
 package main
 
 import (
-	"fmt"
 	"log"
-	"strings"
 	"time"
 
 	"github.com/keroserene/go-webrtc"
@@ -19,17 +17,6 @@ func (i *IceServerList) String() string {
 	return fmt.Sprint(*i)
 }
 
-func (i *IceServerList) Set(s string) error {
-	log.Println("IceServerList:")
-	for _, server := range strings.Split(s, ",") {
-		// TODO: STUN / TURN url format validation?
-		log.Println(server)
-		option := webrtc.OptionIceServer(server)
-		*i = append(*i, option)
-	}
-	return nil
-}
-
 type BytesLogger interface {
 	Log()
 	AddOutbound(int)

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