mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20:11:19 -04:00
Add testing environment helpers
This commit is contained in:
parent
457c4fbf15
commit
93d303b47b
2 changed files with 11 additions and 1 deletions
|
@ -271,7 +271,11 @@ func main() {
|
||||||
switch methodName {
|
switch methodName {
|
||||||
case "snowflake":
|
case "snowflake":
|
||||||
// TODO: Be able to recover when SOCKS dies.
|
// TODO: Be able to recover when SOCKS dies.
|
||||||
ln, err := pt.ListenSocks("tcp", "127.0.0.1:0")
|
listenAddr := "127.0.0.1:0"
|
||||||
|
if forcedListenAddr := os.Getenv("SNOWFLAKE_TEST_FORCELISTENADDR"); forcedListenAddr != "" {
|
||||||
|
listenAddr = forcedListenAddr
|
||||||
|
}
|
||||||
|
ln, err := pt.ListenSocks("tcp", listenAddr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
pt.CmethodError(methodName, err.Error())
|
pt.CmethodError(methodName, err.Error())
|
||||||
break
|
break
|
||||||
|
|
|
@ -35,6 +35,7 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
@ -849,6 +850,11 @@ func (sf *SnowflakeProxy) Stop() {
|
||||||
func (sf *SnowflakeProxy) checkNATType(config webrtc.Configuration, probeURL string) error {
|
func (sf *SnowflakeProxy) checkNATType(config webrtc.Configuration, probeURL string) error {
|
||||||
log.Printf("Checking our NAT type, contacting NAT check probe server at \"%v\"...", probeURL)
|
log.Printf("Checking our NAT type, contacting NAT check probe server at \"%v\"...", probeURL)
|
||||||
|
|
||||||
|
if os.Getenv("SNOWFLAKE_TEST_ASSUMEUNRESTRICTED") != "" {
|
||||||
|
currentNATType = NATUnrestricted
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
probe, err := newSignalingServer(probeURL)
|
probe, err := newSignalingServer(probeURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Error parsing url: %w", err)
|
return fmt.Errorf("Error parsing url: %w", err)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue