This is an automated email from the git hooks/post-receive script.
itchyonion pushed a change to branch wrap-client-NAT-errors in repository pluggable-transports/snowflake.
at e4c01f0 Wrap client NAT log
This branch includes the following new commits:
new e4c01f0 Wrap client NAT log
The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference.
This is an automated email from the git hooks/post-receive script.
itchyonion pushed a commit to branch wrap-client-NAT-errors in repository pluggable-transports/snowflake.
commit e4c01f0595f4f9bd5e87c4f1ef83132ce88c7ee2 Author: itchyonion itchyonion@torproject.com AuthorDate: Mon May 16 14:59:47 2022 -0700
Wrap client NAT log --- client/lib/snowflake.go | 7 +++++-- common/nat/nat.go | 29 +++++++---------------------- 2 files changed, 12 insertions(+), 24 deletions(-)
diff --git a/client/lib/snowflake.go b/client/lib/snowflake.go index dd78c12..7231d86 100644 --- a/client/lib/snowflake.go +++ b/client/lib/snowflake.go @@ -237,7 +237,7 @@ func (conn *SnowflakeConn) Close() error { }
// loop through all provided STUN servers until we exhaust the list or find -// one that is compatable with RFC 5780 +// one that is compatible with RFC 5780 func updateNATType(servers []webrtc.ICEServer, broker *BrokerChannel) {
var restrictedNAT bool @@ -245,7 +245,10 @@ func updateNATType(servers []webrtc.ICEServer, broker *BrokerChannel) { for _, server := range servers { addr := strings.TrimPrefix(server.URLs[0], "stun:") restrictedNAT, err = nat.CheckIfRestrictedNAT(addr) - if err == nil { + + if err != nil { + log.Printf("Warning: NAT checking failed for server at %s: %s", addr, err) + } else { if restrictedNAT { broker.SetNATType(nat.NATRestricted) } else { diff --git a/common/nat/nat.go b/common/nat/nat.go index 552ed45..81a82bc 100644 --- a/common/nat/nat.go +++ b/common/nat/nat.go @@ -49,8 +49,7 @@ func isRestrictedMapping(addrStr string) (bool, error) {
mapTestConn, err := connect(addrStr) if err != nil { - log.Printf("Error creating STUN connection: %s", err.Error()) - return false, err + return false, fmt.Errorf("Error creating STUN connection: %w", err) }
defer mapTestConn.Close() @@ -59,48 +58,34 @@ func isRestrictedMapping(addrStr string) (bool, error) { message := stun.MustBuild(stun.TransactionID, stun.BindingRequest)
resp, err := mapTestConn.RoundTrip(message, mapTestConn.PrimaryAddr) - if err == ErrTimedOut { - log.Printf("Error: no response from server") - return false, err - } if err != nil { - log.Printf("Error receiving response from server: %s", err.Error()) - return false, err + return false, fmt.Errorf("Error completing roundtrip map test: %w", err) }
// Decoding XOR-MAPPED-ADDRESS attribute from message. if err = xorAddr1.GetFrom(resp); err != nil { - log.Printf("Error retrieving XOR-MAPPED-ADDRESS resonse: %s", err.Error()) - return false, err + return false, fmt.Errorf("Error retrieving XOR-MAPPED-ADDRESS resonse: %w", err) }
// Decoding OTHER-ADDRESS attribute from message. var otherAddr stun.OtherAddress if err = otherAddr.GetFrom(resp); err != nil { - log.Println("NAT discovery feature not supported by this server") - return false, err + return false, fmt.Errorf("NAT discovery feature not supported: %w", err) }
if err = mapTestConn.AddOtherAddr(otherAddr.String()); err != nil { - log.Printf("Failed to resolve address %s\t", otherAddr.String()) - return false, err + return false, fmt.Errorf("Error resolving address %s: %w", otherAddr.String(), err) }
// Test II: Send binding request to other address resp, err = mapTestConn.RoundTrip(message, mapTestConn.OtherAddr) - if err == ErrTimedOut { - log.Printf("Error: no response from server") - return false, err - } if err != nil { - log.Printf("Error retrieving server response: %s", err.Error()) - return false, err + return false, fmt.Errorf("Error retrieveing server response: %w", err) }
// Decoding XOR-MAPPED-ADDRESS attribute from message. if err = xorAddr2.GetFrom(resp); err != nil { - log.Printf("Error retrieving XOR-MAPPED-ADDRESS resonse: %s", err.Error()) - return false, err + return false, fmt.Errorf("Error retrieving XOR-MAPPED-ADDRESS resonse: %w", err) }
return xorAddr1.String() != xorAddr2.String(), nil
tor-commits@lists.torproject.org