How to implement UDP Hole Punching?

393 views Asked by At

So I am trying to create a p2p file sharing application in Golang. I am running a globally accessible server for the purpose of sharing IP addresses of 2 clients. When both the clients have each other's IP addresses, they can use hole punching to share the files.

But I am facing some problems in the hole punching part. When I send a request to server, the server is going to store the address of the client and it will later relay this address to other client. Problem is that the address being stored on the server is different than the address that is being is used for Hole punching. Suppose that address being stored on server is NATrouterIP1:PORT-A for first client and NATrouterIP2:PORT-B for the second. But when I am using the first client to send a message to second client, it shows that the message was sent from NATRouterIP1:PORT-C. PORT-A generally stays around 65000. But this PORT-C is 1024. For my application to work these ports should be same. Can someone explain what the issue is?

Github: https://github.com/killtheverse/go-send

0

There are 0 answers