diff --git a/.DS_Store b/.DS_Store index 5a9b600..f3f8a5d 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/Docs/NAT-Traveral.md b/Docs/NAT-Traveral.md new file mode 100644 index 0000000..4508a46 --- /dev/null +++ b/Docs/NAT-Traveral.md @@ -0,0 +1,40 @@ +# NAT Traversal +P2PRC currently supports TURN for NAT traversal. + +## TURN +The current TURN implementation used is FRP. The TURN server is also required when +a P2PRC node is acting as a Server. The TURN server is determined based on the Node +with the least amount of latency based on the Nodes available on the IPTable. +Once a TURN server is determined there are 2 actions performed. The first one is +```/FRPPort``` to the TURN server to receive a port which is used to generate the external +port from the TURN server. The flow below describes the workflow. + +### Client mode +- Call ```/FRPPort``` +``` +http://:/FRPport +``` +- Call the TURN server in the following manner. The following is a sample code snippet below. +```go +import ( + "github.com/Akilan1999/p2p-rendering-computation/p2p/frp" +) + +func main() { + serverPort, err := frp.GetFRPServerPort("http://" + + ":" + lowestLatencyIpAddress.ServerPort) + if err != nil { + return nil, err + } + // Create 1 second delay to allow FRP server to start + time.Sleep(1 * time.Second) + // Starts FRP as a client with + proxyPort, err := frp.StartFRPClientForServer(, serverPort, ) + if err != nil { + return nil, err + } +} +``` + +// todo diagram representation of the interaction with +nodes spawned in the p2p network. +