all: update client and server

This commit is contained in:
Aleksandr Razumov
2016-05-11 16:53:35 +03:00
parent 1f6a032d28
commit 7434b6616c
8 changed files with 329 additions and 7 deletions

View File

@@ -158,3 +158,30 @@ func TestClientSend(t *testing.T) {
}
}
}
func TestClient_Do(t *testing.T) {
skipIfNotFlagged(t, envExternalBlackbox)
client := Client{}
m := AcquireMessage()
m.Type = MessageType{Method: MethodBinding, Class: ClassRequest}
m.TransactionID = NewTransactionID()
m.AddSoftware("cydev/stun alpha")
m.WriteHeader()
request := Request{
Target: "stun.l.google.com:19302",
Message: m,
}
if err := client.Do(request, func(r Response) error {
if r.Message.TransactionID != m.TransactionID {
t.Error("transaction id messmatch")
}
ip, port, err := r.Message.GetXORMappedAddress()
if err != nil {
t.Error(err)
}
log.Println("got", ip, port)
return nil
}); err != nil {
t.Fatal(err)
}
}