|
|
@ -9,7 +9,6 @@ import (
|
|
|
|
"fmt"
|
|
|
|
"fmt"
|
|
|
|
"net"
|
|
|
|
"net"
|
|
|
|
"reflect"
|
|
|
|
"reflect"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"testing"
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
|
@ -71,14 +70,13 @@ func TestBasic(t *testing.T) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func TestWorksWhenUDPBlocked(t *testing.T) {
|
|
|
|
func TestWorksWhenUDPBlocked(t *testing.T) {
|
|
|
|
blackhole, err := net.ListenPacket("udp4", ":0")
|
|
|
|
blackhole, err := net.ListenPacket("udp4", "127.0.0.1:0")
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("failed to open blackhole STUN listener: %v", err)
|
|
|
|
t.Fatalf("failed to open blackhole STUN listener: %v", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
defer blackhole.Close()
|
|
|
|
defer blackhole.Close()
|
|
|
|
|
|
|
|
|
|
|
|
stunAddr := blackhole.LocalAddr().String()
|
|
|
|
stunAddr := blackhole.LocalAddr().String()
|
|
|
|
stunAddr = strings.Replace(stunAddr, "0.0.0.0:", "127.0.0.1:", 1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
c := &Client{
|
|
|
|
c := &Client{
|
|
|
|
DERP: derpmap.NewTestWorld(stunAddr),
|
|
|
|
DERP: derpmap.NewTestWorld(stunAddr),
|
|
|
|