STUN process response

Hi,

I want to build a P2P network. For that I need the remote address of the listen clients. It seems like STUN ist the usual system to get those.

I set up a quick UDP socket for the communication and it works and I even get a response with my remote address, I checked that with Wireshark.

But I have a few problems. The response contains the “XOR-MAPPED-ADDRESS”, but I have no clue on how to get my hands on the data. I think I know which bytes I have to xor with each other, but I don’t understand how I get them from the ArrayReaderPtr.


void AMatchmakerActor::Recv(const FArrayReaderPtr& ArrayReaderPtr, const FIPv4Endpoint& EndPt)
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Cyan, "Recieved Data on UDP Socket: "+FString::FromInt(ArrayReaderPtr->Num()));

uint32 remoteIp = ?;
int32 remotePort = ?;
}

Oh and the engine always crashes after sending the STUN request and I really don’t understand why.