[tor-commits] [pluggable-transports/snowflake] 01/03: proxy: Fix ephemeral ports range CLI flag (again)

gitolite role git at cupani.torproject.org
Mon Oct 17 10:36:34 UTC 2022


This is an automated email from the git hooks/post-receive script.

meskio pushed a commit to branch main
in repository pluggable-transports/snowflake.

commit 10c8173120cd205b54f446c9d0671572e8acc20b
Author: KokaKiwi <kokakiwi+tor at kokakiwi.net>
AuthorDate: Wed Oct 12 19:33:38 2022 +0200

    proxy: Fix ephemeral ports range CLI flag (again)
---
 proxy/lib/snowflake.go |  5 ++++-
 proxy/main.go          | 11 +++++++----
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/proxy/lib/snowflake.go b/proxy/lib/snowflake.go
index 6891be0..f8a0f2c 100644
--- a/proxy/lib/snowflake.go
+++ b/proxy/lib/snowflake.go
@@ -354,7 +354,10 @@ func (sf *SnowflakeProxy) makeWebRTCAPI() *webrtc.API {
 	settingsEngine := webrtc.SettingEngine{}
 
 	if sf.EphemeralMinPort != 0 && sf.EphemeralMaxPort != 0 {
-		settingsEngine.SetEphemeralUDPPortRange(sf.EphemeralMinPort, sf.EphemeralMaxPort)
+		err := settingsEngine.SetEphemeralUDPPortRange(sf.EphemeralMinPort, sf.EphemeralMaxPort)
+		if err != nil {
+			log.Fatal("Invalid port range: min > max")
+		}
 	}
 
 	settingsEngine.SetICEMulticastDNSMode(ice.MulticastDNSModeDisabled)
diff --git a/proxy/main.go b/proxy/main.go
index 38c07b0..146a1f3 100644
--- a/proxy/main.go
+++ b/proxy/main.go
@@ -2,7 +2,6 @@ package main
 
 import (
 	"flag"
-	"fmt"
 	"io"
 	"io/ioutil"
 	"log"
@@ -31,7 +30,7 @@ func main() {
 	SummaryInterval := flag.Duration("summary-interval", time.Hour,
 		"the time interval to output summary, 0s disables summaries. Valid time units are \"s\", \"m\", \"h\". ")
 	verboseLogging := flag.Bool("verbose", false, "increase log verbosity")
-	ephemeralPortsRangeFlag := flag.String("ephemeral-ports-range", "ICE UDP ephemeral ports range (format:\"[min]:[max]\")", "")
+	ephemeralPortsRangeFlag := flag.String("ephemeral-ports-range", "", "ICE UDP ephemeral ports range (format:\"<min>:<max>\")")
 
 	var ephemeralPortsRange []uint16 = []uint16{0, 0}
 
@@ -52,10 +51,14 @@ func main() {
 				log.Fatal(err)
 			}
 
+			if ephemeralMinPort == 0 || ephemeralMaxPort == 0 {
+				log.Fatal("Ephemeral port cannot be zero")
+			}
+
 			ephemeralPortsRange = []uint16{uint16(ephemeralMinPort), uint16(ephemeralMaxPort)}
+		} else {
+			log.Fatalf("Bad range port format: %v", *ephemeralPortsRangeFlag)
 		}
-
-		fmt.Printf("Bad range port format: %v", ephemeralPortsRangeFlag)
 	}
 
 	proxy := sf.SnowflakeProxy{

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the tor-commits mailing list