From 3b70ff5879f3217caf5812139cd206e9388f9b44 Mon Sep 17 00:00:00 2001 From: Akilan Date: Tue, 14 Mar 2023 17:31:50 +0000 Subject: [PATCH 1/2] pushed changes for base NAT traversal changes --- .DS_Store | Bin 8196 -> 8196 bytes Docs/NAT-Traveral.md | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 Docs/NAT-Traveral.md diff --git a/.DS_Store b/.DS_Store index 5a9b600b6ef65102eabbeb796ee79b7ef0cf98d0..f3f8a5dd319a12b265eac204c64a4446a02421f8 100644 GIT binary patch delta 44 zcmZp1XmOa}&nUeyU^hRb^kyCbai+=jLL8f;h1Rf6Y%ti&F7b_Jv##hZril%@06N&(VP^&arX~{r diff --git a/Docs/NAT-Traveral.md b/Docs/NAT-Traveral.md new file mode 100644 index 0000000..31249c2 --- /dev/null +++ b/Docs/NAT-Traveral.md @@ -0,0 +1,36 @@ +# 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 +```go +import ( + "github.com/Akilan1999/p2p-rendering-computation/p2p/frp" +) + +func main() { + serverPort, err := frp.GetFRPServerPort("http://" + lowestLatencyIpAddress.Ipv4 + ":" + lowestLatencyIpAddress.ServerPort) + if err != nil { + return nil, err + } + // Create 3 second delay to allow FRP server to start + time.Sleep(1 * time.Second) + // Starts FRP as a client with + proxyPort, err := frp.StartFRPClientForServer(lowestLatencyIpAddress.Ipv4, serverPort, config.ServerPort) + if err != nil { + return nil, err + } +} +``` \ No newline at end of file From c9f007a6527921dfe9991a49998ae6320cbc8081 Mon Sep 17 00:00:00 2001 From: Akilan Date: Wed, 22 Mar 2023 07:03:04 +0000 Subject: [PATCH 2/2] base MD file added for NAT traversal --- Docs/NAT-Traveral.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Docs/NAT-Traveral.md b/Docs/NAT-Traveral.md index 31249c2..4508a46 100644 --- a/Docs/NAT-Traveral.md +++ b/Docs/NAT-Traveral.md @@ -14,23 +14,27 @@ port from the TURN server. The flow below describes the workflow. ``` http://:/FRPport ``` -- Call the TURN server in the following manner +- 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.Ipv4 + ":" + lowestLatencyIpAddress.ServerPort) + serverPort, err := frp.GetFRPServerPort("http://" + + ":" + lowestLatencyIpAddress.ServerPort) if err != nil { return nil, err } - // Create 3 second delay to allow FRP server to start + // 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(lowestLatencyIpAddress.Ipv4, serverPort, config.ServerPort) + proxyPort, err := frp.StartFRPClientForServer(, serverPort, ) if err != nil { return nil, err } } -``` \ No newline at end of file +``` + +// todo diagram representation of the interaction with +nodes spawned in the p2p network. +