Commit 0c02af35 authored by David Fifield's avatar David Fifield
Browse files

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.
parent 8dcd337c
...@@ -10,6 +10,7 @@ import ( ...@@ -10,6 +10,7 @@ import (
"net" "net"
"os" "os"
"os/signal" "os/signal"
"strings"
"sync" "sync"
"syscall" "syscall"
"time" "time"
...@@ -121,8 +122,7 @@ func copyLoop(a, b io.ReadWriter) { ...@@ -121,8 +122,7 @@ func copyLoop(a, b io.ReadWriter) {
} }
func main() { func main() {
var iceServers IceServerList iceServersCommas := flag.String("ice", "", "comma-separated list of ICE servers")
flag.Var(&iceServers, "ice", "comma-separated list of ICE servers")
brokerURL := flag.String("url", "", "URL of signaling broker") brokerURL := flag.String("url", "", "URL of signaling broker")
frontDomain := flag.String("front", "", "front domain") frontDomain := flag.String("front", "", "front domain")
logFilename := flag.String("log", "", "name of log file") logFilename := flag.String("log", "", "name of log file")
...@@ -144,6 +144,15 @@ func main() { ...@@ -144,6 +144,15 @@ func main() {
log.Println("\n\n\n --- Starting Snowflake Client ---") 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. // Prepare to collect remote WebRTC peers.
snowflakes := NewPeers(*max) snowflakes := NewPeers(*max)
if "" != *brokerURL { if "" != *brokerURL {
......
package main package main
import ( import (
"fmt"
"log" "log"
"strings"
"time" "time"
"github.com/keroserene/go-webrtc" "github.com/keroserene/go-webrtc"
...@@ -19,17 +17,6 @@ func (i *IceServerList) String() string { ...@@ -19,17 +17,6 @@ func (i *IceServerList) String() string {
return fmt.Sprint(*i) 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 { type BytesLogger interface {
Log() Log()
AddOutbound(int) AddOutbound(int)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment