Compare commits
93 Commits
simulation
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 36930be8e4 | |||
| be1f3308ca | |||
| b3fcc10cd8 | |||
|
|
301a87e758 | ||
| c9f4c8b5c7 | |||
| 10b3c6bae3 | |||
| d4e73e9d34 | |||
| 4c7deb948f | |||
| 54a675e0c0 | |||
| 3c3cfac5e2 | |||
| 6a24da74ef | |||
| 0fe1b0c622 | |||
| 7d3fc9b25f | |||
|
|
6281b0f532 | ||
| 1711b01979 | |||
| 438b4d0424 | |||
| 22c5d61082 | |||
| a1bf13cac3 | |||
| 616bf76bda | |||
| 539bceee7d | |||
| 69b9ea3527 | |||
| 27f4615cd1 | |||
| 01e19d9a8c | |||
| aafc0ebdd7 | |||
| 9de0b1b985 | |||
| 4c12d74789 | |||
| f06df58a8a | |||
| 30004d59c6 | |||
| 4c8cde8857 | |||
| 994c52faf0 | |||
| 5e65381377 | |||
| ff66d55153 | |||
| 50983dbb19 | |||
| 189edd73b1 | |||
| 27670f2408 | |||
| b301a54fba | |||
| 05e29aab0d | |||
| b883feb825 | |||
| 5059444d26 | |||
| be3be96987 | |||
| 682424074f | |||
| 9d0ec3eba4 | |||
| bf87217b9a | |||
| e4638232d3 | |||
| fb6c3ab091 | |||
| a59657a93b | |||
| 30ea1f810a | |||
| fe72625266 | |||
| d2030b7d74 | |||
| 73a283a545 | |||
| 623cfffb6a | |||
| 3669fdfad2 | |||
| f39fab04ce | |||
| 12ff0ceb37 | |||
| 99c62a8dca | |||
| ce5c80a10e | |||
| 46ef4e1db9 | |||
| 14743f7f9b | |||
| a461c2da64 | |||
| 99c9c41528 | |||
| 0e260cf8e4 | |||
| 02e58493f5 | |||
| a46ec3575c | |||
| 2d55643dd9 | |||
| 1ac0647d46 | |||
| a07a412c72 | |||
| e04e918328 | |||
| 0bb949a1e2 | |||
| cf6611087a | |||
| b1a69189d3 | |||
| ad76773111 | |||
| ec46f74c4e | |||
| 3fb225676f | |||
| 0e86459122 | |||
| 77ebb76838 | |||
| 85806ab035 | |||
| 9d92ecb202 | |||
| 5fa625160e | |||
| 403ad72ddb | |||
| 6446681719 | |||
| d50534e270 | |||
| 8a2dfb7b5b | |||
| 0f4f52cb8b | |||
| cd8bb2df8c | |||
| fa5b7a27d5 | |||
| 21f0fc79c1 | |||
| bebe2a02a0 | |||
| 7b0b2404b2 | |||
| 724daf5eda | |||
| c262e612e1 | |||
| 257d91a432 | |||
| 42cf9bd028 | |||
| 7c34c5385a |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -31,6 +31,7 @@ server/docker/containers/
|
|||||||
|
|
||||||
# generic folder to ignore
|
# generic folder to ignore
|
||||||
export/
|
export/
|
||||||
|
exports/
|
||||||
|
|
||||||
# Any testing file
|
# Any testing file
|
||||||
*test
|
*test
|
||||||
|
|||||||
@@ -15,7 +15,6 @@
|
|||||||
|--------------|-----------------------------------------|
|
|--------------|-----------------------------------------|
|
||||||
| Copyright | Copyright (C) 2006-2024 John MacFarlane |
|
| Copyright | Copyright (C) 2006-2024 John MacFarlane |
|
||||||
| License | GNU GPL, version 2 or above |
|
| License | GNU GPL, version 2 or above |
|
||||||
| Maintainer | John MacFarlane \<jgm@berkeley.edu\> |
|
|
||||||
| Stability | alpha |
|
| Stability | alpha |
|
||||||
| Portability | portable |
|
| Portability | portable |
|
||||||
| Safe Haskell | Safe-Inferred |
|
| Safe Haskell | Safe-Inferred |
|
||||||
|
|||||||
66
Bindings/Haskell/flake.lock
generated
66
Bindings/Haskell/flake.lock
generated
@@ -18,23 +18,41 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"flake-utils_2": {
|
||||||
|
"inputs": {
|
||||||
|
"systems": "systems_2"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1731533236,
|
||||||
|
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"gomod2nix": {
|
"gomod2nix": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-utils": [
|
"flake-utils": [
|
||||||
"p2prc",
|
"p2prc-main",
|
||||||
"flake-utils"
|
"flake-utils"
|
||||||
],
|
],
|
||||||
"nixpkgs": [
|
"nixpkgs": [
|
||||||
"p2prc",
|
"p2prc-main",
|
||||||
"nixpkgs"
|
"nixpkgs"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1733668782,
|
"lastModified": 1745875161,
|
||||||
"narHash": "sha256-tPsqU00FhgdFr0JiQUiBMgPVbl1jbPCY5gbFiJycL3I=",
|
"narHash": "sha256-0YkWCS13jpoo3+sX/3kcgdxBNt1VZTmvF+FhZb4rFKI=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "gomod2nix",
|
"repo": "gomod2nix",
|
||||||
"rev": "514283ec89c39ad0079ff2f3b1437404e4cba608",
|
"rev": "2cbd7fdd6eeab65c494cc426e18f4e4d2a5e35c0",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -57,11 +75,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs_2": {
|
"nixpkgs_2": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1735834308,
|
"lastModified": 1748026106,
|
||||||
"narHash": "sha256-dklw3AXr3OGO4/XT1Tu3Xz9n/we8GctZZ75ZWVqAVhk=",
|
"narHash": "sha256-6m1Y3/4pVw1RWTsrkAK2VMYSzG4MMIj7sqUy7o8th1o=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "6df24922a1400241dae323af55f30e4318a6ca65",
|
"rev": "063f43f2dbdef86376cc29ad646c45c46e93234c",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -71,28 +89,28 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"p2prc": {
|
"p2prc-main": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-utils": "flake-utils",
|
"flake-utils": "flake-utils_2",
|
||||||
"gomod2nix": "gomod2nix",
|
"gomod2nix": "gomod2nix",
|
||||||
"nixpkgs": "nixpkgs_2"
|
"nixpkgs": "nixpkgs_2"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 0,
|
"lastModified": 0,
|
||||||
"narHash": "sha256-f4e4JcQzBS+R+8HqJbQVeecInm2ggInJuSSymj6gtQo=",
|
"narHash": "sha256-5qbaxawuLsg8iu9076zlAbLtTFSNJaTz7WERS5rWRxU=",
|
||||||
"path": "/nix/store/hmk8v0lxifsscll054qsdnzxqfql1998-source",
|
"path": "/nix/store/lg694r23fzc6v5ai3qqcszq1fp44djg2-source",
|
||||||
"type": "path"
|
"type": "path"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"path": "/nix/store/hmk8v0lxifsscll054qsdnzxqfql1998-source",
|
"path": "/nix/store/lg694r23fzc6v5ai3qqcszq1fp44djg2-source",
|
||||||
"type": "path"
|
"type": "path"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
|
"flake-utils": "flake-utils",
|
||||||
"nixpkgs": "nixpkgs",
|
"nixpkgs": "nixpkgs",
|
||||||
"p2prc": "p2prc",
|
"p2prc-main": "p2prc-main"
|
||||||
"utils": "utils"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"systems": {
|
"systems": {
|
||||||
@@ -124,24 +142,6 @@
|
|||||||
"repo": "default",
|
"repo": "default",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"utils": {
|
|
||||||
"inputs": {
|
|
||||||
"systems": "systems_2"
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1731533236,
|
|
||||||
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": "root",
|
"root": "root",
|
||||||
|
|||||||
@@ -1,22 +1,26 @@
|
|||||||
{
|
{
|
||||||
description = "Nix flake for P2PRC Haskell library";
|
description = "Nix flake for P2PRC Haskell library";
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
p2prc.url = "../../";
|
flake-utils.url = "github:numtide/flake-utils";
|
||||||
utils.url = "github:numtide/flake-utils";
|
p2prc-main.url = "../../";
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { self, nixpkgs, utils, p2prc }: utils.lib.eachDefaultSystem (system:
|
outputs = { nixpkgs, flake-utils, p2prc-main, ... }:
|
||||||
|
flake-utils.lib.eachDefaultSystem (system:
|
||||||
let
|
let
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
|
||||||
|
packages.default = pkgs.haskellPackages.callPackage ./project.nix {};
|
||||||
|
|
||||||
devShell = pkgs.mkShell {
|
devShell = pkgs.mkShell {
|
||||||
buildInputs = with pkgs; [
|
buildInputs = with pkgs; [
|
||||||
|
cabal2nix
|
||||||
cabal-install
|
cabal-install
|
||||||
haskell.compiler.ghc96
|
ghc
|
||||||
zlib.dev
|
zlib.dev
|
||||||
p2prc.outputs.packages.${system}.default
|
p2prc-main.packages.${system}.default
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ module API
|
|||||||
( P2PRCapi(..)
|
( P2PRCapi(..)
|
||||||
, MapPortRequest(..)
|
, MapPortRequest(..)
|
||||||
, p2prcAPI
|
, p2prcAPI
|
||||||
|
, P2PRCommands(..)
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
|
|
||||||
@@ -13,6 +14,7 @@ import System.Process ( ProcessHandle )
|
|||||||
|
|
||||||
import Data.Aeson ( FromJSON )
|
import Data.Aeson ( FromJSON )
|
||||||
|
|
||||||
|
|
||||||
import Error
|
import Error
|
||||||
( IOEitherError
|
( IOEitherError
|
||||||
)
|
)
|
||||||
@@ -49,15 +51,26 @@ data P2PRCapi
|
|||||||
-- ^ List servers in network
|
-- ^ List servers in network
|
||||||
, execMapPort :: MapPortRequest -> IOEitherError MapPortResponse
|
, execMapPort :: MapPortRequest -> IOEitherError MapPortResponse
|
||||||
-- ^ Exposes and associates a local TCP port with a remote DNS address
|
-- ^ Exposes and associates a local TCP port with a remote DNS address
|
||||||
|
, execMaybeMapPortAndAddCustomInformation :: Maybe MapPortRequest -> PassCustomInformation -> IOEitherError String
|
||||||
|
, execAddCustomInformation :: PassCustomInformation -> IOEitherError String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- | This defines the request required to create an association between a TCP socket port and a DNS server in the network. If successful, it makes a resource available in the network.
|
-- | This defines the request required to create an association between a TCP socket port and a DNS server in the network. If successful, it makes a resource available in the network.
|
||||||
data MapPortRequest =
|
data MapPortRequest =
|
||||||
MkMapPortRequest -- ^ P2PRC's port allocation request value
|
MkMapPortRequest -- ^ P2PRC's port allocation request value
|
||||||
Int -- ^ TCP socket number
|
Int -- ^ TCP socket number
|
||||||
String -- ^ Network domain name
|
String -- ^ Network domain name
|
||||||
|
|
||||||
|
-- | This defined the custom information required to be passed through.
|
||||||
|
newtype PassCustomInformation =
|
||||||
|
MkAddCustomInformation
|
||||||
|
String
|
||||||
|
|
||||||
|
data P2PRCommands
|
||||||
|
= MapPort MapPortRequest
|
||||||
|
| CustomInformation PassCustomInformation
|
||||||
|
|
||||||
{-|
|
{-|
|
||||||
This function intiates a pure P2PRC runtime state and builds up a 'P2PRCapi' API instance. It allows a developer to create computing orchestration algorithms using the API primitives.
|
This function intiates a pure P2PRC runtime state and builds up a 'P2PRCapi' API instance. It allows a developer to create computing orchestration algorithms using the API primitives.
|
||||||
@@ -94,9 +107,15 @@ main =
|
|||||||
|
|
||||||
{-# WARNING p2prcAPI "This function is currently unstable because the configuration reading is dependent on the following issue: https://github.com/Akilan1999/p2p-rendering-computation/issues/120" #-}
|
{-# WARNING p2prcAPI "This function is currently unstable because the configuration reading is dependent on the following issue: https://github.com/Akilan1999/p2p-rendering-computation/issues/120" #-}
|
||||||
p2prcAPI :: P2PRCapi
|
p2prcAPI :: P2PRCapi
|
||||||
p2prcAPI =
|
p2prcAPI = let
|
||||||
|
|
||||||
|
execTemp :: Maybe MapPortRequest -> PassCustomInformation -> IOEitherError String
|
||||||
|
execTemp mp ci = undefined
|
||||||
|
|
||||||
|
|
||||||
|
in
|
||||||
MkP2PRCapi
|
MkP2PRCapi
|
||||||
{ startServer = spawnProcP2PRC p2prcCmdName [ MkOptAtomic "--s" ]
|
{ startServer = spawnProcP2PRC p2prcCmdName [ MkOptAtomic "-s" ]
|
||||||
|
|
||||||
, execListServers =
|
, execListServers =
|
||||||
execProcP2PRCParser [ MkOptAtomic "--ls" ] MkEmptyStdInput
|
execProcP2PRCParser [ MkOptAtomic "--ls" ] MkEmptyStdInput
|
||||||
@@ -115,6 +134,9 @@ p2prcAPI =
|
|||||||
]
|
]
|
||||||
MkEmptyStdInput
|
MkEmptyStdInput
|
||||||
|
|
||||||
|
, execMaybeMapPortAndAddCustomInformation = execTemp
|
||||||
|
, execAddCustomInformation = execTemp Nothing
|
||||||
|
|
||||||
-- , execInitConfig = do
|
-- , execInitConfig = do
|
||||||
|
|
||||||
-- confInitRes <- execProcP2PRC [ MkOptAtomic "--dc" ] MkEmptyStdInput
|
-- confInitRes <- execProcP2PRC [ MkOptAtomic "--dc" ] MkEmptyStdInput
|
||||||
|
|||||||
@@ -116,5 +116,5 @@ eitherErrorDecode esa =
|
|||||||
-- assumes the program is ran inside the haskell module in p2prc's repo
|
-- assumes the program is ran inside the haskell module in p2prc's repo
|
||||||
-- assumes that last path segment is "haskell" and that p2prc binary's name is "p2p-rendering-computation"
|
-- assumes that last path segment is "haskell" and that p2prc binary's name is "p2p-rendering-computation"
|
||||||
p2prcCmdName :: String
|
p2prcCmdName :: String
|
||||||
p2prcCmdName = "p2prc"
|
p2prcCmdName = "p2p-rendering-computation"
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
module Engine
|
module Engine
|
||||||
( runP2PRC
|
( runP2PRC
|
||||||
|
, fn
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
|
|
||||||
@@ -18,7 +19,7 @@ import System.Process ( terminateProcess )
|
|||||||
import API
|
import API
|
||||||
( P2PRCapi(..)
|
( P2PRCapi(..)
|
||||||
, MapPortRequest(..)
|
, MapPortRequest(..)
|
||||||
, p2prcAPI
|
, p2prcAPI, P2PRCommands
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -58,14 +59,10 @@ import API
|
|||||||
@
|
@
|
||||||
-}
|
-}
|
||||||
runP2PRC
|
runP2PRC
|
||||||
:: MapPortRequest -- ^ TCP Port Request
|
:: [P2PRCommands] -- ^ TCP Port Request
|
||||||
-> IO ()
|
-> IO ()
|
||||||
runP2PRC
|
runP2PRC [] = putStrLn ""
|
||||||
( MkMapPortRequest
|
runP2PRC nonEmpty@(_:_) =
|
||||||
portNumber
|
|
||||||
domainName
|
|
||||||
)
|
|
||||||
=
|
|
||||||
let
|
let
|
||||||
|
|
||||||
--
|
--
|
||||||
@@ -98,6 +95,7 @@ runP2PRC
|
|||||||
-- , execInitConfig = execInitConfig
|
-- , execInitConfig = execInitConfig
|
||||||
, execListServers = execListServers
|
, execListServers = execListServers
|
||||||
, execMapPort = execMapPort
|
, execMapPort = execMapPort
|
||||||
|
, execAddCustomInformation = _
|
||||||
}
|
}
|
||||||
) = p2prcAPI
|
) = p2prcAPI
|
||||||
|
|
||||||
@@ -116,7 +114,8 @@ runP2PRC
|
|||||||
|
|
||||||
|
|
||||||
case eitherStartProcessHandle of
|
case eitherStartProcessHandle of
|
||||||
(Right startProcessHandle) -> do
|
(Right startProcessHandle) ->
|
||||||
|
do
|
||||||
|
|
||||||
let sleepNSecs i = threadDelay (i * 1000000)
|
let sleepNSecs i = threadDelay (i * 1000000)
|
||||||
|
|
||||||
@@ -125,7 +124,8 @@ runP2PRC
|
|||||||
outputStr <- execListServers
|
outputStr <- execListServers
|
||||||
print outputStr
|
print outputStr
|
||||||
|
|
||||||
mapPortOut <- execMapPort $ MkMapPortRequest portNumber domainName
|
-- mapPortOut <- execMapPort $ MkMapPortRequest portNumber domainName
|
||||||
|
mapPortOut <- execMapPort $ MkMapPortRequest undefined undefined
|
||||||
|
|
||||||
case mapPortOut of
|
case mapPortOut of
|
||||||
(Right v) -> print v
|
(Right v) -> print v
|
||||||
@@ -159,3 +159,7 @@ runP2PRC
|
|||||||
when (toLower c /= 'q') $ exitOnQ exitF
|
when (toLower c /= 'q') $ exitOnQ exitF
|
||||||
exitF
|
exitF
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
fn :: undefined
|
||||||
|
fn = undefined
|
||||||
@@ -52,6 +52,7 @@ module P2PRC
|
|||||||
, P2PRCConfig(..)
|
, P2PRCConfig(..)
|
||||||
, MapPortRequest(..)
|
, MapPortRequest(..)
|
||||||
, MapPortResponse(..)
|
, MapPortResponse(..)
|
||||||
|
, P2PRCommands(..)
|
||||||
|
|
||||||
-- ** Primitive data types
|
-- ** Primitive data types
|
||||||
-- | These types represent the core data that is communicated between requests and the runtime.
|
-- | These types represent the core data that is communicated between requests and the runtime.
|
||||||
@@ -83,6 +84,7 @@ import API
|
|||||||
( MapPortRequest(..)
|
( MapPortRequest(..)
|
||||||
, P2PRCapi(..)
|
, P2PRCapi(..)
|
||||||
, p2prcAPI
|
, p2prcAPI
|
||||||
|
, P2PRCommands(..)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
13
Bindings/Haskell/project.nix
Normal file
13
Bindings/Haskell/project.nix
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
{ mkDerivation, aeson, base, bytestring, directory, lib, process
|
||||||
|
, text
|
||||||
|
}:
|
||||||
|
mkDerivation {
|
||||||
|
pname = "p2prc";
|
||||||
|
version = "0.1.0.0";
|
||||||
|
src = ./.;
|
||||||
|
libraryHaskellDepends = [
|
||||||
|
aeson base bytestring directory process text
|
||||||
|
];
|
||||||
|
description = "P2PRC haskell library";
|
||||||
|
license = "unknown";
|
||||||
|
}
|
||||||
@@ -3,10 +3,14 @@ module Main where
|
|||||||
import P2PRC
|
import P2PRC
|
||||||
( runP2PRC
|
( runP2PRC
|
||||||
, MapPortRequest(MkMapPortRequest)
|
, MapPortRequest(MkMapPortRequest)
|
||||||
|
, P2PRCommands(MapPort)
|
||||||
)
|
)
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main =
|
main =let
|
||||||
|
in
|
||||||
runP2PRC
|
runP2PRC
|
||||||
( MkMapPortRequest 8080 "jose.akilan.io"
|
[
|
||||||
)
|
( MapPort $ MkMapPortRequest 8080 "jose.akilan.io")
|
||||||
|
]
|
||||||
|
|
||||||
|
|||||||
603
Docs/index.html
603
Docs/index.html
File diff suppressed because it is too large
Load Diff
177
Docs/index.org
177
Docs/index.org
@@ -182,6 +182,110 @@ GLOBAL OPTIONS:
|
|||||||
|
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
|
* Nix Flake
|
||||||
|
|
||||||
|
Nix is a growing ecosystem that allows flexibility on how you develop, build and package software and configurations. It brings all programming languages (and all other tooling) to an equal footing, despite deep design differences. More importantly, integrates all the "packaging" into the context of a "pure" function.
|
||||||
|
|
||||||
|
|
||||||
|
P2PRC aims to become a utility that can be used in various flexible manners and having Nix support is a good alternative to accomplish this goal.
|
||||||
|
|
||||||
|
|
||||||
|
Nix Flake is a format, within the Nix ecosystem, intentionally designed to encourage a standard in packaging distribution. The current packaging assumes that you have "nix flake" installed because it is currently an experimental feature of Nix.
|
||||||
|
|
||||||
|
|
||||||
|
** P2PRC core Go language repo
|
||||||
|
|
||||||
|
In case you want to develop, build or integrate using nix, you just need to run either "nix develop" or "nix run" from the command line locally in a cloned git repository or by running "nix run github:akilan1999/p2p-rendering-computation -- --help"
|
||||||
|
|
||||||
|
|
||||||
|
P2PRC library also is ready to be imported into other nix flakes. To accomplish that please make sure to override the target nixpkgs environment in the following manner;
|
||||||
|
|
||||||
|
#+begin_example
|
||||||
|
pkgs = import nixpkgs {
|
||||||
|
inherit system;
|
||||||
|
overlays = [
|
||||||
|
p2prc-flake.overlays.default
|
||||||
|
];
|
||||||
|
};
|
||||||
|
#+end_example
|
||||||
|
|
||||||
|
|
||||||
|
This will make the p2prc executable available in the environment of any application you use.
|
||||||
|
|
||||||
|
** P2PRC Haskell library
|
||||||
|
|
||||||
|
*** Nix:
|
||||||
|
The project is structured to provide language bindings to any programming language. The first one being supported in this manner is the Haskell programming language. It provides a bootstrapping script for a new Cabal project with p2prc binary available in the environment and, more relevantly, the Haskell library bindings available in the virtual environment cabal environment.
|
||||||
|
|
||||||
|
#+begin_example
|
||||||
|
nix run git+https://github.com/akilan1999/p2p-rendering-computation#initHaskellProject -- <PROJECT_NAME>
|
||||||
|
#+end_example
|
||||||
|
|
||||||
|
|
||||||
|
This will generate a new haskell project setup to automatically work with the p2prc development and running environment.
|
||||||
|
|
||||||
|
|
||||||
|
Once completed, you should go into the project directory and copy the nix flake template, necessary to define the project's environment.
|
||||||
|
|
||||||
|
#+begin_example
|
||||||
|
nix flake init -t github:akilan1999/p2p-rendering-computation#haskell
|
||||||
|
#+end_example
|
||||||
|
|
||||||
|
The previous command sets up the flake environment and its dependencies. It will look like the following
|
||||||
|
|
||||||
|
#+begin_example
|
||||||
|
{
|
||||||
|
description = "Start of Haskell P2PRC flake";
|
||||||
|
|
||||||
|
inputs =
|
||||||
|
{
|
||||||
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
|
|
||||||
|
flake-util.url = "github:numtide/flake-utils";
|
||||||
|
|
||||||
|
p2prc-flake.url = "github:akilan1999/p2p-rendering-computation";
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = { nixpkgs, p2prc-flake, flake-utils, ... }:
|
||||||
|
(flake-utils.lib.eachDefaultSystem (system:
|
||||||
|
let
|
||||||
|
|
||||||
|
pkgs = import nixpkgs {
|
||||||
|
inherit system;
|
||||||
|
overlays = [
|
||||||
|
p2prc-flake.overlays.default
|
||||||
|
p2prc-flake.overlays.bindings
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
in {
|
||||||
|
|
||||||
|
packages.default = pkgs.haskellPackages.callPackage ./cabal.nix { };
|
||||||
|
|
||||||
|
devShells.default = pkgs.haskellPackages.shellFor {
|
||||||
|
|
||||||
|
packages = p: [
|
||||||
|
(p.callPackage ./cabal.nix { })
|
||||||
|
];
|
||||||
|
|
||||||
|
buildInputs = with pkgs; [
|
||||||
|
p2prc-flake.packages.${system}.default
|
||||||
|
ghc
|
||||||
|
cabal2nix
|
||||||
|
cabal-install
|
||||||
|
];
|
||||||
|
|
||||||
|
shellHook = ''
|
||||||
|
cabal2nix . > ./cabal.nix
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
||||||
|
));
|
||||||
|
}
|
||||||
|
#+end_example
|
||||||
|
|
||||||
|
The template uses Cabal2Nix which manages the Haskell virtual environment automatically. It applies the system overlays, sets up the shell environment for the project (updating the Cabal2Nix configuration) and packages the main executable.
|
||||||
|
|
||||||
* Using basic commands
|
* Using basic commands
|
||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
:CUSTOM_ID: using-basic-commands
|
:CUSTOM_ID: using-basic-commands
|
||||||
@@ -668,7 +772,24 @@ called from other programming languages.
|
|||||||
P2PRC officially supports Haskell bindings and will further support
|
P2PRC officially supports Haskell bindings and will further support
|
||||||
project using Haskell to build orchestrators on top of P2PRC.
|
project using Haskell to build orchestrators on top of P2PRC.
|
||||||
|
|
||||||
[[https://p2prc.akilan.io/Docs/haskell][Read more...]]
|
**** Local machine without Nix
|
||||||
|
On the local machine we just create a folder as exports which copies the p2prc haskell bindings
|
||||||
|
and the latest build of the p2prc binary. After the binary is copied it runs the --dc in p2prc to setup the
|
||||||
|
basic p2prc configurations. To do the following just do:
|
||||||
|
#+begin_example
|
||||||
|
make haskell
|
||||||
|
#+end_example
|
||||||
|
**** Directory to enter into
|
||||||
|
#+begin_example
|
||||||
|
cd Bindings/Haskell/exports
|
||||||
|
#+end_example
|
||||||
|
**** Run
|
||||||
|
#+begin_example
|
||||||
|
- cabal build
|
||||||
|
- cabal run
|
||||||
|
#+end_example
|
||||||
|
|
||||||
|
[[https://p2prc.akilan.io/haskell][Read more...]]
|
||||||
|
|
||||||
* Config Implementation
|
* Config Implementation
|
||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
@@ -690,18 +811,28 @@ configuration file was generated using JSON format.
|
|||||||
|
|
||||||
#+begin_src json
|
#+begin_src json
|
||||||
{
|
{
|
||||||
"MachineName": "pc-74-120.customer.ask4.lan",
|
"MachineName": "Akilans-MacBook-Pro.local-975261X",
|
||||||
"IPTable": "/Users/akilan/Documents/p2p-rendering-computation/p2p/iptable/ip_table.json",
|
"IPTable": "/Users/akilan/Documents/p2p-rendering-computation/p2p/iptable/ip_table.json",
|
||||||
"DockerContainers": "/Users/akilan/Documents/p2p-rendering-computation/server/docker/containers/",
|
"DockerContainers": "/Users/akilan/Documents/p2p-rendering-computation/server/docker/containers/",
|
||||||
"DefaultDockerFile": "/Users/akilan/Documents/p2p-rendering-computation/server/docker/containers/docker-ubuntu-sshd/",
|
"DefaultDockerFile": "/Users/akilan/Documents/p2p-rendering-computation/server/docker/containers/docker-ubuntu-sshd/",
|
||||||
|
"DockerRunLogs": "/tmp/",
|
||||||
"SpeedTestFile": "/Users/akilan/Documents/p2p-rendering-computation/p2p/50.bin",
|
"SpeedTestFile": "/Users/akilan/Documents/p2p-rendering-computation/p2p/50.bin",
|
||||||
"IPV6Address": "",
|
"IPV6Address": "",
|
||||||
"PluginPath": "/Users/akilan/Documents/p2p-rendering-computation/plugin/deploy",
|
"PluginPath": "/Users/akilan/Documents/p2p-rendering-computation/plugin/deploy",
|
||||||
"TrackContainersPath": "/Users/akilan/Documents/p2p-rendering-computation/client/trackcontainers/trackcontainers.json",
|
"TrackContainersPath": "/Users/akilan/Documents/p2p-rendering-computation/client/trackcontainers/trackcontainers.json",
|
||||||
"ServerPort": "8088",
|
"ServerPort": "8088",
|
||||||
|
"ProxyPort": "",
|
||||||
"GroupTrackContainersPath": "/Users/akilan/Documents/p2p-rendering-computation/client/trackcontainers/grouptrackcontainers.json",
|
"GroupTrackContainersPath": "/Users/akilan/Documents/p2p-rendering-computation/client/trackcontainers/grouptrackcontainers.json",
|
||||||
"FRPServerPort": "True",
|
"FRPServerPort": true,
|
||||||
"BehindNAT": "True",
|
"BehindNAT": true,
|
||||||
|
"IPTableKey": "QH3yQrGRe2X4",
|
||||||
|
"PublicKeyFile": "/Users/akilan/Documents/p2p-rendering-computation/p2prc.publicKey",
|
||||||
|
"PrivateKeyFile": "/Users/akilan/Documents/p2p-rendering-computation/p2prc.privateKey",
|
||||||
|
"PemFile": "/Users/akilan/Documents/p2p-rendering-computation/cert.pem",
|
||||||
|
"KeyFile": "/Users/akilan/Documents/p2p-rendering-computation/key.pem",
|
||||||
|
"BareMetal": false,
|
||||||
|
"UnsafeMode": false,
|
||||||
|
"Test": false,
|
||||||
"CustomConfig": null
|
"CustomConfig": null
|
||||||
}
|
}
|
||||||
#+end_src
|
#+end_src
|
||||||
@@ -783,10 +914,48 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#+end_src
|
#+end_src
|
||||||
|
* Simulation
|
||||||
|
The simulation library is a really simple library to locally
|
||||||
|
run serveral instances of P2PRC to test the functionality
|
||||||
|
of sending information through the network and particularly
|
||||||
|
the Node discovery mechanism. There are current 5 commands
|
||||||
|
which can be used as shown below:
|
||||||
|
|
||||||
|
** Command
|
||||||
|
- ***P2PRC instances "number of instances"*** : Starts p2prc processes
|
||||||
|
based on the number of number instances provided. This includes
|
||||||
|
creating temporary folders with independent IPTables.
|
||||||
|
- ***Start all instances "number of instances"***: Starts the P2PRC instances
|
||||||
|
created. This function enters into the instance directory and runs
|
||||||
|
```p2prc -s &``` with a delay for approximately 3 seconds. This allows
|
||||||
|
each independent created node to learn about each other.
|
||||||
|
- ***IP Tables after Started number of instances"***: Prints the IPTable of
|
||||||
|
each independant node.
|
||||||
|
- ***Remove all test files***: Removes all test files created which needed for
|
||||||
|
testing the generated P2PRC instances.
|
||||||
|
- ***Kill all instances***: Kills all the background P2PRC instances created.
|
||||||
|
|
||||||
|
** Sample bash instructions
|
||||||
|
#+begin_src bash
|
||||||
|
# Unset default P2PRC env path
|
||||||
|
unset P2PRC
|
||||||
|
|
||||||
|
# Run with 2 nodes
|
||||||
|
P2PRC_instances 3
|
||||||
|
|
||||||
|
# Start instances
|
||||||
|
Start_all_instances 3
|
||||||
|
|
||||||
|
# List ip tables of nodes started
|
||||||
|
IP_Tables_after_Started 3
|
||||||
|
|
||||||
|
# Remove test files created
|
||||||
|
Remove_all_test_files
|
||||||
|
|
||||||
|
# Kill all instances
|
||||||
|
Kill_all_instances
|
||||||
|
#+end_src
|
||||||
|
Source code: https://github.com/Akilan1999/p2p-rendering-computation/blob/master/Simulation/simulation.sh
|
||||||
* Blog posts
|
* Blog posts
|
||||||
** Self host within 5 minutes any program
|
** Self host within 5 minutes any program
|
||||||
|
|
||||||
|
|||||||
3
Makefile
3
Makefile
@@ -14,6 +14,9 @@ sharedObjects:
|
|||||||
python:
|
python:
|
||||||
sh build-python-package.sh
|
sh build-python-package.sh
|
||||||
|
|
||||||
|
haskell:
|
||||||
|
sh build-haskell.sh
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
go clean -modcache
|
go clean -modcache
|
||||||
rm -fr .go-build vendor result*
|
rm -fr .go-build vendor result*
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
> [!TIP]
|
> [!TIP]
|
||||||
> Haskell bindings supported!: [Bindings documentaton](https://p2prc.akilan.io/Docs/haskell/P2PRC.html)
|
> Haskell bindings supported!: [Bindings documentaton](https://p2prc.akilan.io/haskell/P2PRC.html)
|
||||||
|
|
||||||
> [!NOTE]
|
> [!NOTE]
|
||||||
> Fixing documentation to latest changes. If you have any questions setting up P2PRC either [create an issue](https://github.com/Akilan1999/p2p-rendering-computation/issues/new/choose) or send me an email (me AT akilan dot io).
|
> Fixing documentation to latest changes. If you have any questions setting up P2PRC either [create an issue](https://github.com/Akilan1999/p2p-rendering-computation/issues/new/choose) or send me an email (me AT akilan dot io).
|
||||||
@@ -57,7 +57,7 @@ alias p2prc='env P2PRC=<path you want the configs to exist in> nix run github:ak
|
|||||||
```bash
|
```bash
|
||||||
p2prc -h
|
p2prc -h
|
||||||
```
|
```
|
||||||
Read more on command usage: https://p2prc.akilan.io/Docs/#using-basic-commands
|
Read more on command usage: https://p2prc.akilan.io/#using-basic-commands
|
||||||
|
|
||||||
## Latest tutorial
|
## Latest tutorial
|
||||||
[](https://www.youtube.com/watch?v=OMwCpedu5cs")
|
[](https://www.youtube.com/watch?v=OMwCpedu5cs")
|
||||||
@@ -66,7 +66,7 @@ Read more on command usage: https://p2prc.akilan.io/Docs/#using-basic-commands
|
|||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
### We have documented to our best effort the basics of p2prc: [Link](https://p2prc.akilan.io/Docs/)
|
### We have documented to our best effort the basics of p2prc: [Link](https://p2prc.akilan.io/)
|
||||||
|
|
||||||
<!-- ## Table of contents in the current README -->
|
<!-- ## Table of contents in the current README -->
|
||||||
<!-- 1. [Introduction](#Introduction)
|
<!-- 1. [Introduction](#Introduction)
|
||||||
|
|||||||
132
Simulation/simulation.sh
Normal file
132
Simulation/simulation.sh
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
# Unset P2PRC
|
||||||
|
unset P2PRC
|
||||||
|
|
||||||
|
# Create P2PRC instances
|
||||||
|
# Parameters:
|
||||||
|
# 1. Number of nodes
|
||||||
|
P2PRC_instances() {
|
||||||
|
local rootPort=""
|
||||||
|
for (( counter=0; counter<$1; counter++ )); do
|
||||||
|
mkdir test-$counter/
|
||||||
|
cd test-$counter/
|
||||||
|
|
||||||
|
# Generate a new random port
|
||||||
|
NEW_PORT=$(shuf -i 2000-65000 -n 1)
|
||||||
|
|
||||||
|
# Initialize node
|
||||||
|
p2prc --dc
|
||||||
|
|
||||||
|
# Save rootPort from the first node
|
||||||
|
if [[ $counter -eq 0 ]]; then
|
||||||
|
rootPort=$NEW_PORT
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Root port: $rootPort"
|
||||||
|
echo "This node's port: $NEW_PORT"
|
||||||
|
|
||||||
|
# Set root port
|
||||||
|
p2prc --arn --ip 0.0.0.0 -p "$rootPort"
|
||||||
|
|
||||||
|
# add current node
|
||||||
|
p2prc --as 0.0.0.0 -p "$NEW_PORT"
|
||||||
|
|
||||||
|
# Replace the ServerPort in config
|
||||||
|
# test-$counter
|
||||||
|
sed -i.bak "s/\"ServerPort\": \"[0-9]*\"/\"ServerPort\": \"$NEW_PORT\"/" "./config.json"
|
||||||
|
sed -i.bak "s/\"Test\": false/\"Test\": true/" "./config.json"
|
||||||
|
sed -i.bak "s/\"BehindNAT\": true/\"BehindNAT\": false/" "./config.json"
|
||||||
|
# sed -i.bak "s/\"MachineName\": "Akilans-MacBook-Pro.local-J2UbbkF"/\"MachineName\": \"test-$counter\"/" "./config.json"
|
||||||
|
|
||||||
|
cat config.json
|
||||||
|
|
||||||
|
# List services
|
||||||
|
p2prc --ls
|
||||||
|
|
||||||
|
cd ..
|
||||||
|
done
|
||||||
|
|
||||||
|
# remove all instances after testing (optional — might want to comment this during testing)
|
||||||
|
# rm -rf test-*
|
||||||
|
}
|
||||||
|
|
||||||
|
# Arrays of process IDs
|
||||||
|
pids=()
|
||||||
|
|
||||||
|
# Calls all the P2PRC instances created for testing
|
||||||
|
Start_all_instances() {
|
||||||
|
for (( counter=0; counter<$1; counter++ )); do
|
||||||
|
cd test-$counter/
|
||||||
|
# Start P2PRC as background process
|
||||||
|
p2prc -s &
|
||||||
|
pids+=($!)
|
||||||
|
sleep 3
|
||||||
|
cd ..
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Kills all P2PRC instances
|
||||||
|
Kill_all_instances() {
|
||||||
|
for pid in "${pids[@]}"; do
|
||||||
|
kill "$pid"
|
||||||
|
echo "Killed process $pid"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Removes all test files created
|
||||||
|
Remove_all_test_files() {
|
||||||
|
rm -rf test-*
|
||||||
|
}
|
||||||
|
|
||||||
|
# List ip tables of all nodes started
|
||||||
|
IP_Tables_after_Started() {
|
||||||
|
for (( counter=0; counter<$1; counter++ )); do
|
||||||
|
cd test-$counter/
|
||||||
|
p2prc --ls
|
||||||
|
cd ..
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
Update_All_IP_Tables() {
|
||||||
|
for (( counter=0; counter<$1; counter++ )); do
|
||||||
|
cd test-$counter/
|
||||||
|
p2prc --us
|
||||||
|
cd ..
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Test function for the root to custom information
|
||||||
|
# through the network
|
||||||
|
Send_Information() {
|
||||||
|
ls
|
||||||
|
cd test-2/
|
||||||
|
p2prc --amd "test message"
|
||||||
|
cd ..
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------- Work flow test ---------------
|
||||||
|
|
||||||
|
# Unset default P2PRC env path
|
||||||
|
unset P2PRC
|
||||||
|
|
||||||
|
# Run with 2 nodes
|
||||||
|
P2PRC_instances 3
|
||||||
|
|
||||||
|
## Start instances
|
||||||
|
Start_all_instances 3
|
||||||
|
|
||||||
|
|
||||||
|
# Send test information from node 1
|
||||||
|
sleep 10
|
||||||
|
Send_Information
|
||||||
|
|
||||||
|
sleep 10
|
||||||
|
## List ip tables of nodes started
|
||||||
|
IP_Tables_after_Started 3
|
||||||
|
#
|
||||||
|
## Remove test files created
|
||||||
|
Remove_all_test_files
|
||||||
|
|
||||||
|
## Kill all instances
|
||||||
|
Kill_all_instances
|
||||||
|
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
package abstractions
|
package abstractions
|
||||||
|
|
||||||
import "C"
|
|
||||||
import (
|
import (
|
||||||
"github.com/Akilan1999/p2p-rendering-computation/client"
|
"github.com/Akilan1999/p2p-rendering-computation/client"
|
||||||
"github.com/Akilan1999/p2p-rendering-computation/client/clientIPTable"
|
"github.com/Akilan1999/p2p-rendering-computation/client/clientIPTable"
|
||||||
|
|||||||
BIN
artwork/.DS_Store
vendored
BIN
artwork/.DS_Store
vendored
Binary file not shown.
BIN
artwork/p2prc-logos/.DS_Store
vendored
BIN
artwork/p2prc-logos/.DS_Store
vendored
Binary file not shown.
BIN
artwork/p2prc-logos/P2PRCHaskell.png
Normal file
BIN
artwork/p2prc-logos/P2PRCHaskell.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 922 KiB |
31
build-haskell.sh
Normal file
31
build-haskell.sh
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
# This bash script consists of the manaul build script of haskell
|
||||||
|
go build .
|
||||||
|
|
||||||
|
# Unset p2prc path
|
||||||
|
unset p2prc
|
||||||
|
|
||||||
|
# Enter the haskell project
|
||||||
|
cd Bindings/haskell
|
||||||
|
# Remove exsisting export build
|
||||||
|
rm -rf exports
|
||||||
|
# Create exports directory
|
||||||
|
mkdir exports
|
||||||
|
# Copy current haskell project into the folder
|
||||||
|
cp -rf . exports/
|
||||||
|
# Copy p2prc binary inside haskell folder
|
||||||
|
cp ../../p2p-rendering-computation exports/
|
||||||
|
|
||||||
|
cd exports
|
||||||
|
# remove exports directory copied inside exports
|
||||||
|
rm -rf exports/
|
||||||
|
|
||||||
|
# Set p2prc variable
|
||||||
|
echo export P2PRC=$PWD
|
||||||
|
|
||||||
|
export P2PRC=$PWD
|
||||||
|
|
||||||
|
./p2p-rendering-computation --dc
|
||||||
|
|
||||||
|
echo "Run the following commands in the directory: ${PWD}"
|
||||||
|
echo "To build: cabal build"
|
||||||
|
echo "To run sample program: cabal run"
|
||||||
@@ -31,7 +31,7 @@ func AddCustomInformationToIPTable(text string) error {
|
|||||||
if found {
|
if found {
|
||||||
table.WriteIpTable()
|
table.WriteIpTable()
|
||||||
// update IPTable after modified entry
|
// update IPTable after modified entry
|
||||||
go UpdateIpTableListClient()
|
UpdateIpTableListClient()
|
||||||
} else {
|
} else {
|
||||||
return errors.New("start server with p2prc -s as the server is currently not running")
|
return errors.New("start server with p2prc -s as the server is currently not running")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ func UpdateIpTableListClient() error {
|
|||||||
|
|
||||||
Exists := false
|
Exists := false
|
||||||
// If the address is local then add to the local list
|
// If the address is local then add to the local list
|
||||||
if currentIPV4 == Addresses.IpAddress[j].Ipv4 && Addresses.IpAddress[j].ServerPort == Config.ServerPort {
|
if (currentIPV4 == Addresses.IpAddress[j].Ipv4 && !Config.Test) && Addresses.IpAddress[j].ServerPort == Config.ServerPort {
|
||||||
Exists = true
|
Exists = true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,11 +136,12 @@ func UpdateIpTableListClient() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
w.Add(1)
|
w.Add(1)
|
||||||
if Addresses.IpAddress[j].Ipv6 != "" {
|
//if Addresses.IpAddress[j].Ipv6 != "" {
|
||||||
go UpdateIpTable(Addresses.IpAddress[j].Ipv6, Addresses.IpAddress[j].ServerPort, &w)
|
// go UpdateIpTable(Addresses.IpAddress[j].Ipv6, Addresses.IpAddress[j].ServerPort, &w)
|
||||||
} else if Addresses.IpAddress[j].Ipv4 != currentIPV4 {
|
//} else if Addresses.IpAddress[j].Ipv4 != currentIPV4 {
|
||||||
|
// //go UpdateIpTable(Addresses.IpAddress[j].Ipv4, Addresses.IpAddress[j].ServerPort, &w)
|
||||||
|
//}
|
||||||
go UpdateIpTable(Addresses.IpAddress[j].Ipv4, Addresses.IpAddress[j].ServerPort, &w)
|
go UpdateIpTable(Addresses.IpAddress[j].Ipv4, Addresses.IpAddress[j].ServerPort, &w)
|
||||||
}
|
|
||||||
w.Wait()
|
w.Wait()
|
||||||
|
|
||||||
//Appends server1 IP address to variable DoNotRead
|
//Appends server1 IP address to variable DoNotRead
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"github.com/Akilan1999/p2p-rendering-computation/abstractions"
|
"github.com/Akilan1999/p2p-rendering-computation/abstractions"
|
||||||
"github.com/Akilan1999/p2p-rendering-computation/client"
|
"github.com/Akilan1999/p2p-rendering-computation/client"
|
||||||
"github.com/Akilan1999/p2p-rendering-computation/client/clientIPTable"
|
"github.com/Akilan1999/p2p-rendering-computation/client/clientIPTable"
|
||||||
|
Config "github.com/Akilan1999/p2p-rendering-computation/config"
|
||||||
"github.com/Akilan1999/p2p-rendering-computation/config/generate"
|
"github.com/Akilan1999/p2p-rendering-computation/config/generate"
|
||||||
"github.com/Akilan1999/p2p-rendering-computation/p2p"
|
"github.com/Akilan1999/p2p-rendering-computation/p2p"
|
||||||
"github.com/Akilan1999/p2p-rendering-computation/plugin"
|
"github.com/Akilan1999/p2p-rendering-computation/plugin"
|
||||||
@@ -232,6 +233,12 @@ var CliAction = func(ctx *cli.Context) error {
|
|||||||
standardOutput(err, nil)
|
standardOutput(err, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// display configuration
|
||||||
|
if ViewConfig {
|
||||||
|
config, err := Config.ConfigInit(nil, nil)
|
||||||
|
standardOutput(err, config)
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ var (
|
|||||||
AddMetaData string
|
AddMetaData string
|
||||||
AddRootNode bool
|
AddRootNode bool
|
||||||
IP string
|
IP string
|
||||||
|
ViewConfig bool
|
||||||
)
|
)
|
||||||
|
|
||||||
var AppConfigFlags = []cli.Flag{
|
var AppConfigFlags = []cli.Flag{
|
||||||
@@ -288,4 +289,11 @@ var AppConfigFlags = []cli.Flag{
|
|||||||
EnvVars: []string{"IP"},
|
EnvVars: []string{"IP"},
|
||||||
Destination: &IP,
|
Destination: &IP,
|
||||||
},
|
},
|
||||||
|
&cli.BoolFlag{
|
||||||
|
Name: "ViewConfig",
|
||||||
|
Aliases: []string{"vc"},
|
||||||
|
Usage: "View config file",
|
||||||
|
EnvVars: []string{"VC"},
|
||||||
|
Destination: &ViewConfig,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,9 @@ type Config struct {
|
|||||||
KeyFile string
|
KeyFile string
|
||||||
BareMetal bool
|
BareMetal bool
|
||||||
UnsafeMode bool
|
UnsafeMode bool
|
||||||
|
Test bool
|
||||||
CustomConfig interface{}
|
CustomConfig interface{}
|
||||||
|
ConfigPath string
|
||||||
//NetworkInterface string
|
//NetworkInterface string
|
||||||
//NetworkInterfaceIPV6Index int
|
//NetworkInterfaceIPV6Index int
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,6 +95,8 @@ func SetDefaults(envName string, forceDefault bool, CustomConfig interface{}, No
|
|||||||
Defaults.PrivateKeyFile = defaultPath + "p2prc.privateKey"
|
Defaults.PrivateKeyFile = defaultPath + "p2prc.privateKey"
|
||||||
Defaults.BareMetal = false
|
Defaults.BareMetal = false
|
||||||
Defaults.UnsafeMode = false
|
Defaults.UnsafeMode = false
|
||||||
|
Defaults.Test = false
|
||||||
|
Defaults.ConfigPath = defaultPath + "config.json"
|
||||||
|
|
||||||
// Generate certificate files for SSL
|
// Generate certificate files for SSL
|
||||||
err = GenerateCertificate()
|
err = GenerateCertificate()
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import (
|
|||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"crypto/x509/pkix"
|
"crypto/x509/pkix"
|
||||||
"encoding/pem"
|
"encoding/pem"
|
||||||
"github.com/Akilan1999/p2p-rendering-computation/p2p"
|
|
||||||
"log"
|
"log"
|
||||||
"math/big"
|
"math/big"
|
||||||
"net"
|
"net"
|
||||||
@@ -54,7 +53,8 @@ func GenerateCertificate() error {
|
|||||||
|
|
||||||
//flag.Parse()
|
//flag.Parse()
|
||||||
|
|
||||||
host, err = p2p.CurrentPublicIP()
|
//host, err = p2p.CurrentPublicIP()
|
||||||
|
host = "0.0.0.0"
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
12
flake.lock
generated
12
flake.lock
generated
@@ -28,11 +28,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1733668782,
|
"lastModified": 1745875161,
|
||||||
"narHash": "sha256-tPsqU00FhgdFr0JiQUiBMgPVbl1jbPCY5gbFiJycL3I=",
|
"narHash": "sha256-0YkWCS13jpoo3+sX/3kcgdxBNt1VZTmvF+FhZb4rFKI=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "gomod2nix",
|
"repo": "gomod2nix",
|
||||||
"rev": "514283ec89c39ad0079ff2f3b1437404e4cba608",
|
"rev": "2cbd7fdd6eeab65c494cc426e18f4e4d2a5e35c0",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -43,11 +43,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1735834308,
|
"lastModified": 1748460289,
|
||||||
"narHash": "sha256-dklw3AXr3OGO4/XT1Tu3Xz9n/we8GctZZ75ZWVqAVhk=",
|
"narHash": "sha256-7doLyJBzCllvqX4gszYtmZUToxKvMUrg45EUWaUYmBg=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "6df24922a1400241dae323af55f30e4318a6ca65",
|
"rev": "96ec055edbe5ee227f28cdbc3f1ddf1df5965102",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|||||||
122
flake.nix
122
flake.nix
@@ -1,30 +1,58 @@
|
|||||||
{
|
{
|
||||||
description = "P2PRC nix flake";
|
description = "P2PRC nix flake";
|
||||||
|
|
||||||
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
inputs = {
|
||||||
inputs.flake-utils.url = "github:numtide/flake-utils";
|
|
||||||
inputs.gomod2nix.url = "github:nix-community/gomod2nix";
|
|
||||||
inputs.gomod2nix.inputs.nixpkgs.follows = "nixpkgs";
|
|
||||||
inputs.gomod2nix.inputs.flake-utils.follows = "flake-utils";
|
|
||||||
|
|
||||||
outputs = { self, nixpkgs, flake-utils, gomod2nix }:
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
(flake-utils.lib.eachDefaultSystem
|
|
||||||
(system:
|
flake-utils = {
|
||||||
let
|
url = "github:numtide/flake-utils";
|
||||||
pkgs = import nixpkgs {
|
|
||||||
inherit system;
|
|
||||||
overlays = [ gomod2nix.overlays.default ];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
# pkgs = nixpkgs.legacyPackages.${system};
|
gomod2nix = {
|
||||||
|
url = "github:nix-community/gomod2nix";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
inputs.flake-utils.follows = "flake-utils";
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs =
|
||||||
|
{
|
||||||
|
nixpkgs,
|
||||||
|
flake-utils,
|
||||||
|
gomod2nix,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
|
||||||
|
bindingsOverlay = import ./nix/overlays/bindings.nix;
|
||||||
|
coreOverlay = (final: prev: {
|
||||||
|
p2prc = final.callPackage ./. { };
|
||||||
|
});
|
||||||
|
|
||||||
|
in
|
||||||
|
(flake-utils.lib.eachDefaultSystem (system:
|
||||||
|
let
|
||||||
|
|
||||||
|
pkgs = import nixpkgs {
|
||||||
|
inherit system;
|
||||||
|
overlays = [
|
||||||
|
gomod2nix.overlays.default
|
||||||
|
coreOverlay
|
||||||
|
bindingsOverlay
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
# The current default sdk for macOS fails to compile go projects, so we use a newer one for now.
|
# The current default sdk for macOS fails to compile go projects, so we use a newer one for now.
|
||||||
# This has no effect on other platforms.
|
# This has no effect on other platforms.
|
||||||
callPackage = pkgs.darwin.apple_sdk_11_0.callPackage or pkgs.callPackage;
|
callPackage = pkgs.darwin.apple_sdk_11_0.callPackage or pkgs.callPackage;
|
||||||
|
|
||||||
|
p2prcDefault = callPackage ./. { };
|
||||||
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
packages.default = p2prcDefault;
|
||||||
packages.default = callPackage ./. { };
|
|
||||||
|
|
||||||
devShells.default = pkgs.mkShell {
|
devShells.default = pkgs.mkShell {
|
||||||
buildInputs = with pkgs; [
|
buildInputs = with pkgs; [
|
||||||
@@ -36,6 +64,66 @@
|
|||||||
sqlite-interactive
|
sqlite-interactive
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
})
|
|
||||||
);
|
packages.initHaskellProject = pkgs.writeShellApplication {
|
||||||
|
name = "initHaskellProject";
|
||||||
|
runtimeInputs = with pkgs; [
|
||||||
|
ghc
|
||||||
|
cabal2nix
|
||||||
|
cabal-install
|
||||||
|
git
|
||||||
|
p2prcDefault
|
||||||
|
];
|
||||||
|
text =
|
||||||
|
''
|
||||||
|
clear
|
||||||
|
|
||||||
|
if [ "$#" -eq 0 ]; then
|
||||||
|
echo "No arguments provided."
|
||||||
|
echo "Please provide the name of your project"
|
||||||
|
echo "nix run git+https://github:akilan1999/p2p-rendering-computation#initHaskellProject -- <NAME-PROJECT>"
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
PROJECT_DIR="$1"
|
||||||
|
|
||||||
|
mkdir "$PROJECT_DIR"
|
||||||
|
|
||||||
|
cd "$PROJECT_DIR"
|
||||||
|
|
||||||
|
git init .
|
||||||
|
clear
|
||||||
|
|
||||||
|
cabal init --exe --simple
|
||||||
|
|
||||||
|
sed -i 's/base.*$/base, p2prc/' "$PROJECT_DIR".cabal
|
||||||
|
|
||||||
|
cabal2nix . > ./cabal.nix;
|
||||||
|
|
||||||
|
git add .
|
||||||
|
|
||||||
|
clear
|
||||||
|
|
||||||
|
echo -e "run the following commands to finish nix development and production environment:\n\n"
|
||||||
|
|
||||||
|
echo -e "cd $PROJECT_DIR"
|
||||||
|
echo -e "nix flake init -t github:akilan1999/p2p-rendering-computation#haskell"
|
||||||
|
echo -e "nix develop"
|
||||||
|
echo -e "nix run"
|
||||||
|
echo -e "\n\n"
|
||||||
|
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
||||||
|
)) //
|
||||||
|
{
|
||||||
|
overlays = {
|
||||||
|
default = coreOverlay;
|
||||||
|
bindings = bindingsOverlay;
|
||||||
|
};
|
||||||
|
templates.haskell = {
|
||||||
|
path = ./nix/templates/haskell;
|
||||||
|
description = "Haskell Bindings to p2prc protocol";
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
909
index.org~
909
index.org~
@@ -1,909 +0,0 @@
|
|||||||
#+SETUPFILE: https://fniessen.github.io/org-html-themes/org/theme-readtheorg.setup
|
|
||||||
|
|
||||||
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="https://fniessen.github.io/org-html-themes/src/readtheorg_theme/css/search.css"/>
|
|
||||||
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="style.css"/>
|
|
||||||
|
|
||||||
#+attr_html: :width 300px :align center
|
|
||||||
[[./artwork/p2prc-logos/Colored-On-Light-Image.png]]
|
|
||||||
|
|
||||||
* Guide through video
|
|
||||||
*** The video below shows the setup and usage of P2PRC.
|
|
||||||
#+attr_html: :class video
|
|
||||||
[[https://www.youtube.com/watch?v=OMwCpedu5cs][https://i3.ytimg.com/vi/OMwCpedu5cs/maxresdefault.jpg]]
|
|
||||||
|
|
||||||
* Introduction
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: chapter1-introduction
|
|
||||||
:END:
|
|
||||||
This project focuses on creating a framework for running heavy computational tasks that a regular
|
|
||||||
computer cannot handle easily. These tasks may include graphically demanding video games, rendering
|
|
||||||
3D animations, and performing complex protein folding simulations. The major focus of this project
|
|
||||||
is not on financial incentives but rather on building a robust and efficient peer-to-peer (P2P)
|
|
||||||
network to decentralise task execution and increase the computational bandwidth available for
|
|
||||||
such tasks.
|
|
||||||
|
|
||||||
The P2PRC framework serves as a foundation for decentralised rendering and computation,
|
|
||||||
providing insights into how tasks can be distributed efficiently across a network of peers.
|
|
||||||
Leveraging the P2PRC approach, this project extends its capabilities to handle a
|
|
||||||
wider range of computationally intensive tasks.
|
|
||||||
|
|
||||||
** Motivation
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: motivation
|
|
||||||
:END:
|
|
||||||
Many of the users rely on our PC / Laptop or servers that belong to a
|
|
||||||
server farm to run heavy tasks and with the demand of high creativity
|
|
||||||
requires higher computing power. Buying a powerful computer every few
|
|
||||||
years to run a bunch of heavy tasks which are not executed as frequently
|
|
||||||
to reap the benefits can be inefficient utilization of hardware. On the
|
|
||||||
other end, renting servers to run these heavy tasks can be really
|
|
||||||
useful. Ethically speaking this is leading to monopolisation of
|
|
||||||
computing power similar to what is happening in the web server area. By
|
|
||||||
using peer to peer principles it is possible to remove the
|
|
||||||
monopolisation factor and increase the bandwidth between the client and
|
|
||||||
server.
|
|
||||||
|
|
||||||
* Installation
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: installation
|
|
||||||
:END:
|
|
||||||
|
|
||||||
Over here we will cover the basic steps to get the server and client
|
|
||||||
side running.
|
|
||||||
|
|
||||||
** Latest release install
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: latest-release-install
|
|
||||||
:END:
|
|
||||||
https://github.com/Akilan1999/p2p-rendering-computation/releases
|
|
||||||
|
|
||||||
** Install from Github master branch
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: install-from-github-master-branch
|
|
||||||
:END:
|
|
||||||
*** Install Go lang
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: install-go-lang
|
|
||||||
:END:
|
|
||||||
The entire the implementation of this project is done using Go lang.
|
|
||||||
Thus, we need go lang to compile to code to a binary file.
|
|
||||||
[[https://golang.org/doc/install][Instructions to install Go lang]]
|
|
||||||
|
|
||||||
*** Install Docker
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: install-docker
|
|
||||||
:END:
|
|
||||||
In this project the choice of virtualization is Docker due to it's wide
|
|
||||||
usage in the developer community. In the server module we use the Docker
|
|
||||||
Go API to create and interact with the containers.
|
|
||||||
|
|
||||||
[[https://docs.docker.com/get-docker/][Instructions to install docker]]
|
|
||||||
|
|
||||||
[[https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html#docker][Instructions
|
|
||||||
to install docker GPU]]
|
|
||||||
|
|
||||||
#+begin_example
|
|
||||||
// Do ensure that the docker command does not need sudo to run
|
|
||||||
sudo chmod 666 /var/run/docker.sock
|
|
||||||
#+end_example
|
|
||||||
|
|
||||||
*** Build Project and install project
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: build-project-and-install-project
|
|
||||||
:END:
|
|
||||||
To set up the internal dependencies and build the entire go code into a
|
|
||||||
single binary
|
|
||||||
|
|
||||||
#+begin_example
|
|
||||||
make
|
|
||||||
#+end_example
|
|
||||||
|
|
||||||
**** For Windows
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: for-windows
|
|
||||||
:END:
|
|
||||||
To set up P2PRC on Windows, simply run this batch file. *Make sure you
|
|
||||||
are not in admin mode when running this.*
|
|
||||||
|
|
||||||
#+begin_example
|
|
||||||
.\install.bat
|
|
||||||
#+end_example
|
|
||||||
|
|
||||||
*** Add appropriate paths to =.bashrc=
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: add-appropriate-paths-to-.bashrc
|
|
||||||
:END:
|
|
||||||
#+begin_example
|
|
||||||
export P2PRC=/<PATH>/p2p-rendering-computation
|
|
||||||
export PATH=/<PATH>/p2p-rendering-computation:${PATH}
|
|
||||||
#+end_example
|
|
||||||
|
|
||||||
*** Test if binary works
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: test-if-binary-works
|
|
||||||
:END:
|
|
||||||
#+begin_example
|
|
||||||
p2prc --help
|
|
||||||
#+end_example
|
|
||||||
|
|
||||||
**** Output:
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: output
|
|
||||||
:END:
|
|
||||||
#+begin_example
|
|
||||||
NAME:
|
|
||||||
p2p-rendering-computation - p2p cli application to create and access VMs in other servers
|
|
||||||
|
|
||||||
USAGE:
|
|
||||||
p2prc [global options] command [command options] [arguments...]
|
|
||||||
|
|
||||||
VERSION:
|
|
||||||
2.0.0
|
|
||||||
|
|
||||||
COMMANDS:
|
|
||||||
help, h Shows a list of commands or help for one command
|
|
||||||
|
|
||||||
GLOBAL OPTIONS:
|
|
||||||
--Server, -s Starts server (default: false) [$SERVER]
|
|
||||||
--UpdateServerList, --us Update List of Server available based on servers iptables (default: false) [$UPDATE_SERVER_LIST]
|
|
||||||
--ListServers, --ls List servers which can render tasks (default: false) [$LIST_SERVERS]
|
|
||||||
--AddServer value, --as value Adds server IP address to iptables [$ADD_SERVER]
|
|
||||||
--ViewImages value, --vi value View images available on the server IP address [$VIEW_IMAGES]
|
|
||||||
--CreateVM value, --touch value Creates Docker container on the selected server [$CREATE_VM]
|
|
||||||
--ContainerName value, --cn value Specifying the container run on the server side [$CONTAINER_NAME]
|
|
||||||
--BaseImage value, --bi value Specifying the docker base image to template the dockerfile [$CONTAINER_NAME]
|
|
||||||
--RemoveVM value, --rm value Stop and Remove Docker container (IP:port) accompanied by container ID via --ID or --id [$REMOVE_VM]
|
|
||||||
--ID value, --id value Docker Container ID [$ID]
|
|
||||||
--Ports value, -p value Number of ports to open for the Docker Container [$NUM_PORTS]
|
|
||||||
--GPU, --gpu Create Docker Containers to access GPU (default: false) [$USE_GPU]
|
|
||||||
--Specification value, --specs value Specs of the server node [$SPECS]
|
|
||||||
--SetDefaultConfig, --dc Sets a default configuration file (default: false) [$SET_DEFAULT_CONFIG]
|
|
||||||
--NetworkInterfaces, --ni Shows the network interface in your computer (default: false) [$NETWORK_INTERFACE]
|
|
||||||
--ViewPlugins, --vp Shows plugins available to be executed (default: false) [$VIEW_PLUGIN]
|
|
||||||
--TrackedContainers, --tc View (currently running) containers which have been created from the client side (default: false) [$TRACKED_CONTAINERS]
|
|
||||||
--ExecutePlugin value, --plugin value Plugin which needs to be executed [$EXECUTE_PLUGIN]
|
|
||||||
--CreateGroup, --cgroup Creates a new group (default: false) [$CREATE_GROUP]
|
|
||||||
--Group value, --group value group flag with argument group ID [$GROUP]
|
|
||||||
--Groups, --groups View all groups (default: false) [$GROUPS]
|
|
||||||
--RemoveContainerGroup, --rmcgroup Remove specific container in the group (default: false) [$REMOVE_CONTAINER_GROUP]
|
|
||||||
--RemoveGroup value, --rmgroup value Removes the entire group [$REMOVE_GROUP]
|
|
||||||
--MAPPort value, --mp value Maps port for a specific port provided as the parameter [$MAPPORT]
|
|
||||||
--DomainName value, --dn value While mapping ports allows to set a domain name to create a mapping in the proxy server [$DOMAINNAME]
|
|
||||||
--Generate value, --gen value Generates a new copy of P2PRC which can be modified based on your needs [$GENERATE]
|
|
||||||
--ModuleName value, --mod value New go project module name [$MODULENAME]
|
|
||||||
--PullPlugin value, --pp value Pulls plugin from git repos [$PULLPLUGIN]
|
|
||||||
--RemovePlugin value, --rp value Removes plugin [$REMOVEPLUGIN]
|
|
||||||
--AddMetaData value, --amd value Adds metadata about the current node in the p2p network which is then propagated through the network [$ADDMETADATA]
|
|
||||||
--help, -h show help (default: false)
|
|
||||||
--version, -v print the version (default: false)
|
|
||||||
#+end_example
|
|
||||||
|
|
||||||
--------------
|
|
||||||
|
|
||||||
* Using basic commands
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: using-basic-commands
|
|
||||||
:END:
|
|
||||||
*** Start as a server
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: start-as-a-server
|
|
||||||
:END:
|
|
||||||
|
|
||||||
#+begin_example
|
|
||||||
p2prc -s
|
|
||||||
#+end_example
|
|
||||||
|
|
||||||
*** View server Specification
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: view-server-specification
|
|
||||||
:END:
|
|
||||||
#+begin_example
|
|
||||||
p2prc --specs=<ip address>
|
|
||||||
#+end_example
|
|
||||||
|
|
||||||
*** Run container
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: run-container
|
|
||||||
:END:
|
|
||||||
use the =--gpu= if you know the other machine has a gpu.
|
|
||||||
|
|
||||||
#+begin_example
|
|
||||||
p2prc --touch=<server ip address> -p <number of ports> --gpu
|
|
||||||
#+end_example
|
|
||||||
|
|
||||||
*** Remove container
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: remove-container
|
|
||||||
:END:
|
|
||||||
The docker id is present in the output where you create a container
|
|
||||||
|
|
||||||
#+begin_example
|
|
||||||
p2prc --rm=<server ip address> --id=<docker container id>
|
|
||||||
#+end_example
|
|
||||||
|
|
||||||
*** Adding servers to ip table
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: adding-servers-to-ip-table
|
|
||||||
:END:
|
|
||||||
#+begin_example
|
|
||||||
p2prc --as=<server ip address you want to add>
|
|
||||||
#+end_example
|
|
||||||
|
|
||||||
*** Update ip table
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: update-ip-table
|
|
||||||
:END:
|
|
||||||
#+begin_example
|
|
||||||
p2prc --us
|
|
||||||
#+end_example
|
|
||||||
|
|
||||||
*** List Servers
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: list-servers
|
|
||||||
:END:
|
|
||||||
#+begin_example
|
|
||||||
p2prc --ls
|
|
||||||
#+end_example
|
|
||||||
|
|
||||||
*** View Network interfaces
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: view-network-interfaces
|
|
||||||
:END:
|
|
||||||
#+begin_example
|
|
||||||
p2prc --ni
|
|
||||||
#+end_example
|
|
||||||
|
|
||||||
*** Viewing Containers created Client side
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: viewing-containers-created-client-side
|
|
||||||
:END:
|
|
||||||
#+begin_example
|
|
||||||
p2prc --tc
|
|
||||||
#+end_example
|
|
||||||
|
|
||||||
*** Running plugin
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: running-plugin
|
|
||||||
:END:
|
|
||||||
#+begin_example
|
|
||||||
p2prc --plugin <plugin name> --id <container id or group id>
|
|
||||||
#+end_example
|
|
||||||
|
|
||||||
*** Create group
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: create-group
|
|
||||||
:END:
|
|
||||||
#+begin_example
|
|
||||||
p2prc --cgroup
|
|
||||||
#+end_example
|
|
||||||
|
|
||||||
*** Add container to group
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: add-container-to-group
|
|
||||||
:END:
|
|
||||||
#+begin_example
|
|
||||||
p2prc --group <group id> --id <container id>
|
|
||||||
#+end_example
|
|
||||||
|
|
||||||
*** View groups
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: view-groups
|
|
||||||
:END:
|
|
||||||
#+begin_example
|
|
||||||
p2prc --groups
|
|
||||||
#+end_example
|
|
||||||
|
|
||||||
*** View specific group
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: view-specific-group
|
|
||||||
:END:
|
|
||||||
#+begin_example
|
|
||||||
p2prc --group <group id>
|
|
||||||
#+end_example
|
|
||||||
|
|
||||||
*** Delete container from group
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: delete-container-from-group
|
|
||||||
:END:
|
|
||||||
#+begin_example
|
|
||||||
p2prc --rmcgroup --group <group id> --id <container id>
|
|
||||||
#+end_example
|
|
||||||
|
|
||||||
*** Delete entire group
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: delete-entire-group
|
|
||||||
:END:
|
|
||||||
#+begin_example
|
|
||||||
p2prc --rmgroup <group id>
|
|
||||||
#+end_example
|
|
||||||
|
|
||||||
*** Pulling plugin from a remote repo
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: pulling-plugin-from-a-remote-repo
|
|
||||||
:END:
|
|
||||||
#+begin_example
|
|
||||||
p2prc --pp <repo link>
|
|
||||||
#+end_example
|
|
||||||
|
|
||||||
*** Deleting plugin from the plugin directory
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: deleting-plugin-from-the-plugin-directory
|
|
||||||
:END:
|
|
||||||
#+begin_example
|
|
||||||
p2prc --rp <plugin name>
|
|
||||||
#+end_example
|
|
||||||
|
|
||||||
*** Added custom metadata about the current node
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: added-custom-metadata-about-the-current-node
|
|
||||||
:END:
|
|
||||||
#+begin_example
|
|
||||||
p2prc --amd "custom metadata"
|
|
||||||
#+end_example
|
|
||||||
|
|
||||||
*** MapPort and link to domain name
|
|
||||||
Allows to expose remote ports from a machine in the P2P network.
|
|
||||||
#+begin_example
|
|
||||||
p2prc --mp <port no to map> --dn <domain name to link Mapped port against>
|
|
||||||
#+end_example
|
|
||||||
**** MapPort in remote machine
|
|
||||||
This is to ensure ports on remote machines on the P2PRC can be easily opened.
|
|
||||||
#+begin_example
|
|
||||||
p2prc --mp <port no to map> --dn <domain name to link Mapped port against> --ra <remote server address>
|
|
||||||
#+end_example
|
|
||||||
|
|
||||||
--------------
|
|
||||||
|
|
||||||
* P2P Module Implementation
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: p2p-module-implementation
|
|
||||||
:END:
|
|
||||||
The P2P module is for managing server information within the network.
|
|
||||||
It maintains and updates the IP table, ensuring accuracy by preventing duplicates and removing
|
|
||||||
entries for unreachable servers. Furthermore, the module conducts speed tests on the listed servers
|
|
||||||
to determine upload and download speeds. This valuable information enables users to identify nearby
|
|
||||||
servers with optimal performance, enhancing their overall network experience.
|
|
||||||
|
|
||||||
#+caption: UML diagram of P2P module
|
|
||||||
[[file:Docs/images/p2pmoduleArch.png]
|
|
||||||
|
|
||||||
The peer to peer implementation was built from scratch. This is because
|
|
||||||
other peer to peer libraries were on the implementation of the
|
|
||||||
Distributed hash table. At the current moment all those heavy features
|
|
||||||
are not needed because the objective is to search and list all possible
|
|
||||||
servers available. The limitation being that to be a part of the network
|
|
||||||
the user has to know at least 1 server. The advantage of building from
|
|
||||||
scratch makes the module super light and possibility for custom
|
|
||||||
functions and structs. The sub topics below will mention the
|
|
||||||
implementations of each functionality in depth.
|
|
||||||
|
|
||||||
** IP Table
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: ip-table
|
|
||||||
:END:
|
|
||||||
The ip table file is a json as the format with a list of servers ip
|
|
||||||
addresses, latencies, downloads and uploads speeds. The functions
|
|
||||||
implemented include read file, write file and remove duplicate IP
|
|
||||||
addresses. The remove duplicate IP address function exists because
|
|
||||||
sometimes servers IP tables can have the same ip addresses as what the
|
|
||||||
client has. The path of the IP table json file is received from the
|
|
||||||
configuration module.
|
|
||||||
|
|
||||||
#+begin_src json
|
|
||||||
{
|
|
||||||
"ip_address": [
|
|
||||||
{
|
|
||||||
"Name": "<hostname of the machine>",
|
|
||||||
"MachineUsername": "<machine username>",
|
|
||||||
"IPV4": "<ipv4 address>",
|
|
||||||
"IPV6": "<ipv6 address (Not used)>",
|
|
||||||
"Latency": <latency to the server>,
|
|
||||||
"Download": <download speed (Not used)>,
|
|
||||||
"Upload": <upload speed (Not used)>,
|
|
||||||
"ServerPort": "<server port no>",
|
|
||||||
"BareMetalSSHPort": "<Baremetal ssh port no>",
|
|
||||||
"NAT": "<boolean representing if the node is behind NAT or not>",
|
|
||||||
"EscapeImplementation": "<NAT traversal implementation>",
|
|
||||||
"ProxyServer": "<If the node listed is acting as a proxy server>",
|
|
||||||
"UnSafeMode": <Unsafe mode if turned on will allow all nodes in the network public keys to be
|
|
||||||
added to that particular node>",
|
|
||||||
"PublicKey": "<Public key of that particular node>",
|
|
||||||
"CustomInformation": "<custom information passed in through all the nodes in the network>"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
*** Latency
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: latency
|
|
||||||
:END:
|
|
||||||
The latency is measured in milliseconds. The route /server_info is
|
|
||||||
called from the server and time it takes to provide a json response is
|
|
||||||
recorded.
|
|
||||||
|
|
||||||
** NAT Traversal
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: nat-traversal
|
|
||||||
:END:
|
|
||||||
P2PRC currently supports TURN for NAT traversal.
|
|
||||||
|
|
||||||
** TURN
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: turn
|
|
||||||
:END:
|
|
||||||
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
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: client-mode
|
|
||||||
:END:
|
|
||||||
- Call =/FRPPort=
|
|
||||||
|
|
||||||
#+begin_example
|
|
||||||
http://<turn server ip>:<server port no>/FRPport
|
|
||||||
#+end_example
|
|
||||||
|
|
||||||
- Call the TURN server in the following manner. The following is a
|
|
||||||
sample code snippet below.
|
|
||||||
|
|
||||||
#+begin_src 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 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, <the port you want to expose externally>)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
* Language Bindings
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: language-bindings
|
|
||||||
:END:
|
|
||||||
[[https://en.wikipedia.org/wiki/Language_binding][Language bindings]]
|
|
||||||
refers to wrappers to bridge 2 programming languages. This is used in
|
|
||||||
P2PRC to extend calling P2PRC functions in other programming languages.
|
|
||||||
Currently this is done by generating =.so= and =.h= from the Go
|
|
||||||
compiler.
|
|
||||||
|
|
||||||
** How to build shared object files
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: how-to-build-shared-object-files
|
|
||||||
:END:
|
|
||||||
**** The easier way
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: the-easier-way
|
|
||||||
:END:
|
|
||||||
#+begin_src sh
|
|
||||||
# Run
|
|
||||||
make sharedObjects
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
**** Or the direct way
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: or-the-direct-way
|
|
||||||
:END:
|
|
||||||
#+begin_src sh
|
|
||||||
# Run
|
|
||||||
cd Bindings && go build -buildmode=c-shared -o p2prc.so
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
**** If successfully built:
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: if-successfully-built
|
|
||||||
:END:
|
|
||||||
#+begin_src sh
|
|
||||||
# Enter into the Bindings directory
|
|
||||||
cd Bindings
|
|
||||||
# List files
|
|
||||||
ls
|
|
||||||
# Find files
|
|
||||||
p2prc.h p2prc.so
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
** Workings under the hood
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: workings-under-the-hood
|
|
||||||
:END:
|
|
||||||
Below are a sample set of commands to open the bindings implementation.
|
|
||||||
|
|
||||||
#+begin_example
|
|
||||||
# run
|
|
||||||
cd Bindings/
|
|
||||||
# list files
|
|
||||||
ls
|
|
||||||
# search for file
|
|
||||||
Client.go
|
|
||||||
#+end_example
|
|
||||||
|
|
||||||
*** In Client go
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: in-client-go
|
|
||||||
:END:
|
|
||||||
There a few things to notice which are different from your standard Go
|
|
||||||
programs:
|
|
||||||
|
|
||||||
**** 1. We import "C" which means [[https://pkg.go.dev/cmd/cgo][Cgo]] is required.
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: we-import-c-which-means-cgo-is-required.
|
|
||||||
:END:
|
|
||||||
#+begin_src go
|
|
||||||
import "C"
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
**** 2. All functions which are required to be called from other programming languages have comment such as.
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: all-functions-which-are-required-to-be-called-from-other-programming-languages-have-comment-such-as.
|
|
||||||
:END:
|
|
||||||
#+begin_src go
|
|
||||||
//export <function name>
|
|
||||||
|
|
||||||
// ------------ Example ----------------
|
|
||||||
// The function below allows to externally
|
|
||||||
// to call the P2PRC function to start containers
|
|
||||||
// in a specific node in the know list of nodes
|
|
||||||
// in the p2p network.
|
|
||||||
// Note: the comment "//export StartContainer".
|
|
||||||
|
|
||||||
//export StartContainer
|
|
||||||
func StartContainer(IP string) (output *C.char) {
|
|
||||||
container, err := client.StartContainer(IP, 0, false, "", "")
|
|
||||||
if err != nil {
|
|
||||||
return C.CString(err.Error())
|
|
||||||
}
|
|
||||||
return ConvertStructToJSONString(container)
|
|
||||||
}
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
**** 3. While looking through the file (If 2 files are compared it is pretty trivial to notice a common structure).
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: while-looking-through-the-file-if-2-files-are-compared-it-is-pretty-trivial-to-notice-a-common-structure.
|
|
||||||
:END:
|
|
||||||
#+begin_src go
|
|
||||||
// --------- Example ------------
|
|
||||||
|
|
||||||
//export StartContainer
|
|
||||||
func StartContainer(IP string) (output *C.char) {
|
|
||||||
container, err := client.StartContainer(IP, 0, false, "", "")
|
|
||||||
if err != nil {
|
|
||||||
return C.CString(err.Error())
|
|
||||||
}
|
|
||||||
return ConvertStructToJSONString(container)
|
|
||||||
}
|
|
||||||
|
|
||||||
//export ViewPlugin
|
|
||||||
func ViewPlugin() (output *C.char) {
|
|
||||||
plugins, err := plugin.DetectPlugins()
|
|
||||||
if err != nil {
|
|
||||||
return C.CString(err.Error())
|
|
||||||
}
|
|
||||||
return ConvertStructToJSONString(plugins)
|
|
||||||
}
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
**** It is easy to notice that:
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: it-is-easy-to-notice-that
|
|
||||||
:END:
|
|
||||||
- =ConvertStructToJSONString(<go object>)=: This is a helper function
|
|
||||||
that convert a go object to JSON string initially and converts it to
|
|
||||||
=CString=.
|
|
||||||
- =(output *C.char)=: This is the return type for most of the functions.
|
|
||||||
|
|
||||||
**** A Pseudo code to refer to the common function implementation shape could be represented as:
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: a-pseudo-code-to-refer-to-the-common-function-implementation-shape-could-be-represented-as
|
|
||||||
:END:
|
|
||||||
#+begin_example
|
|
||||||
func <Function name> (output *C.char) {
|
|
||||||
<response>,<error> := <P2PRC function name>(<parameters if needed>)
|
|
||||||
if <error> != nil {
|
|
||||||
return C.CString(<error>.Error())
|
|
||||||
}
|
|
||||||
return ConvertStructToJSONString(<response>)
|
|
||||||
}
|
|
||||||
#+end_example
|
|
||||||
|
|
||||||
** Current languages supported
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: current-languages-supported
|
|
||||||
:END:
|
|
||||||
*** Python
|
|
||||||
|
|
||||||
**** Build sample python program
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: build-sample-python-program
|
|
||||||
:END:
|
|
||||||
The easier way
|
|
||||||
|
|
||||||
#+begin_src sh
|
|
||||||
# Run
|
|
||||||
make python
|
|
||||||
# Expected ouput
|
|
||||||
Output is in the Directory Bindings/python/export/
|
|
||||||
# Run
|
|
||||||
cd Bindings/python/export/
|
|
||||||
# list files
|
|
||||||
ls
|
|
||||||
# Expected output
|
|
||||||
SharedObjects/ library.py requirements.txt
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
Above shows a generated folder which consists of a folder called
|
|
||||||
"SharedObjects/" which consists of =p2prc.so= and =p2prc.h= files.
|
|
||||||
=p2prc.py= refers to a sample python script calling P2PRC go functions.
|
|
||||||
To start an any project to extend P2PRC with python, This generated
|
|
||||||
folder can copied and created as a new git repo for P2PRC extensions
|
|
||||||
scripted or used a reference point as proof of concept that P2PRC can be
|
|
||||||
called from other programming languages.
|
|
||||||
|
|
||||||
*** Haskell
|
|
||||||
P2PRC officially supports Haskell bindings and will further support
|
|
||||||
project using Haskell to build orchestrators on top of P2PRC.
|
|
||||||
|
|
||||||
[[https://p2prc.akilan.io/Docs/haskell][Read more...]]
|
|
||||||
|
|
||||||
* Config Implementation
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: config-implementation
|
|
||||||
:END:
|
|
||||||
The configuration module is responsible to store basic information of
|
|
||||||
absolute paths of files being called in the Go code. In a full-fledged
|
|
||||||
Cli the configuration file can be found in the directory /etc/ and from
|
|
||||||
there points to location such as where the IP table file is located. In
|
|
||||||
the future implementation the config file will have information such as
|
|
||||||
number of hops and other parameters to tweak and to improve the
|
|
||||||
effectiveness of the peer to peer network. The configuration module was
|
|
||||||
implemented using the library Viper. The Viper library automates
|
|
||||||
features such as searching in default paths to find out if the
|
|
||||||
configuration file is present. If the configuration file is not present
|
|
||||||
in the default paths then it auto generates the configuration file. The
|
|
||||||
configurations file can be in any format. In this project the
|
|
||||||
configuration file was generated using JSON format.
|
|
||||||
|
|
||||||
#+begin_src json
|
|
||||||
{
|
|
||||||
"MachineName": "pc-74-120.customer.ask4.lan",
|
|
||||||
"IPTable": "/Users/akilan/Documents/p2p-rendering-computation/p2p/iptable/ip_table.json",
|
|
||||||
"DockerContainers": "/Users/akilan/Documents/p2p-rendering-computation/server/docker/containers/",
|
|
||||||
"DefaultDockerFile": "/Users/akilan/Documents/p2p-rendering-computation/server/docker/containers/docker-ubuntu-sshd/",
|
|
||||||
"SpeedTestFile": "/Users/akilan/Documents/p2p-rendering-computation/p2p/50.bin",
|
|
||||||
"IPV6Address": "",
|
|
||||||
"PluginPath": "/Users/akilan/Documents/p2p-rendering-computation/plugin/deploy",
|
|
||||||
"TrackContainersPath": "/Users/akilan/Documents/p2p-rendering-computation/client/trackcontainers/trackcontainers.json",
|
|
||||||
"ServerPort": "8088",
|
|
||||||
"GroupTrackContainersPath": "/Users/akilan/Documents/p2p-rendering-computation/client/trackcontainers/grouptrackcontainers.json",
|
|
||||||
"FRPServerPort": "True",
|
|
||||||
"BehindNAT": "True",
|
|
||||||
"CustomConfig": null
|
|
||||||
}
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
* Abstractions
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: abstractions
|
|
||||||
:END:
|
|
||||||
|
|
||||||
The Abstractions package consists of black-boxed functions for P2PRC.
|
|
||||||
|
|
||||||
** Functions
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: functions
|
|
||||||
:END:
|
|
||||||
- =Init(<Project name>)=: Initializes P2PRC with all the needed
|
|
||||||
configurations.
|
|
||||||
- =Start()=: Starts p2prc as a server and makes it possible to extend by
|
|
||||||
adding other routes and functionality to P2PRC.
|
|
||||||
- =MapPort(<port no>)=: On the local machine the port you want to export
|
|
||||||
to world.
|
|
||||||
- =StartContainer(<ip address>)=: The machine on the p2p network where
|
|
||||||
you want to spin up a docker container.
|
|
||||||
- =RemoveContainer(<ip address>,<container id>)=: Terminate container
|
|
||||||
based on the IP address and container name.
|
|
||||||
- =GetSpecs(<ip address>)=: Get specs of a machine on the network based
|
|
||||||
on the IP address.
|
|
||||||
- =ViewIPTable()=: View the IP table which about nodes in the network.
|
|
||||||
- =UpdateIPTable()=: Force update IP table to learn about new nodes
|
|
||||||
faster.
|
|
||||||
|
|
||||||
* NAT Traversal
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: nat-traversal
|
|
||||||
:END:
|
|
||||||
P2PRC currently supports TURN for NAT traversal.
|
|
||||||
|
|
||||||
** TURN
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: turn
|
|
||||||
:END:
|
|
||||||
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
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: client-mode
|
|
||||||
:END:
|
|
||||||
- Call =/FRPPort=
|
|
||||||
|
|
||||||
#+begin_example
|
|
||||||
http://<turn server ip>:<server port no>/FRPport
|
|
||||||
#+end_example
|
|
||||||
|
|
||||||
- Call the TURN server in the following manner. The following is a
|
|
||||||
sample code snippet below.
|
|
||||||
|
|
||||||
#+begin_src 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 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, <the port you want to expose externally>)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
* Blog posts
|
|
||||||
** Self host within 5 minutes any program
|
|
||||||
|
|
||||||
- Author: [[http://akilan.io/][Akilan Selvacoumar]]
|
|
||||||
- Date: 28-01-2025
|
|
||||||
|
|
||||||
|
|
||||||
- Video tutorial:
|
|
||||||
[[https://youtu.be/rN4SiVowg5E][https://i3.ytimg.com/vi/rN4SiVowg5E/maxresdefault.jpg]]
|
|
||||||
|
|
||||||
This is a fun expirement for anyone to try to quickly run a server and
|
|
||||||
quickly do a map port and domain name mapping in a single command.
|
|
||||||
|
|
||||||
*** 1. Find a program you want to run
|
|
||||||
Let's try to setup a really easy program (Let's do with Linkwarden
|
|
||||||
with docker compose :) ). This is under the assumption you have docker
|
|
||||||
compose installed on your local machine.
|
|
||||||
|
|
||||||
**** Let's run Linkwarden using docker compose and P2PRC
|
|
||||||
[[https://docs.linkwarden.app/self-hosting/installation][Installation instructions]]:
|
|
||||||
#+BEGIN_SRC
|
|
||||||
mkdir linkwarden && cd linkwarden
|
|
||||||
curl -O https://raw.githubusercontent.com/linkwarden/linkwarden/refs/heads/main/docker-compose.yml
|
|
||||||
curl -L https://raw.githubusercontent.com/linkwarden/linkwarden/refs/heads/main/.env.sample -o ".env"
|
|
||||||
#+END_SRC
|
|
||||||
|
|
||||||
Environment configuration
|
|
||||||
#+BEGIN_SRC
|
|
||||||
vim .env
|
|
||||||
|
|
||||||
# Change values
|
|
||||||
NEXTAUTH_URL=https://<DOMAIN NAME>/api/v1/auth
|
|
||||||
NEXTAUTH_SECRET=VERY_SENSITIVE_SECRET
|
|
||||||
POSTGRES_PASSWORD=CUSTOM_POSTGRES_PASSWORD
|
|
||||||
#+END_SRC
|
|
||||||
Run linkwarden!
|
|
||||||
#+BEGIN_SRC
|
|
||||||
docker compose up
|
|
||||||
#+END_SRC
|
|
||||||
|
|
||||||
If setup correctly linkwarden should
|
|
||||||
be running.
|
|
||||||
Local link: http://localhost:3000
|
|
||||||
|
|
||||||
Time to setup P2PRC
|
|
||||||
[[https://p2prc.akilan.io/Docs/#build-project-and-install-project][Installation Instructions]]
|
|
||||||
|
|
||||||
Run p2prc as a background
|
|
||||||
#+BEGIN_SRC
|
|
||||||
p2prc -s &
|
|
||||||
#+END_SRC
|
|
||||||
|
|
||||||
Run map port and domain mapping
|
|
||||||
#+BEGIN_SRC
|
|
||||||
p2prc --mp 3000 --dn <DOMAIN NAME>
|
|
||||||
#+END_SRC
|
|
||||||
|
|
||||||
Sample response
|
|
||||||
#+BEGIN_SRC
|
|
||||||
{
|
|
||||||
"IPAddress": "217.76.63.222",
|
|
||||||
"PortNo": "61582",
|
|
||||||
"EntireAddress": "217.76.63.222:61582"
|
|
||||||
}
|
|
||||||
#+END_SRC
|
|
||||||
|
|
||||||
Add DNS entry
|
|
||||||
#+BEGIN_SRC
|
|
||||||
A entry 217.76.63.222
|
|
||||||
#+END_SRC
|
|
||||||
|
|
||||||
Your done now just head to the DOMAIN NAME you added.
|
|
||||||
ex: https://linkwarden.akilan.io
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
* Ideas for future potencial features
|
|
||||||
Consists of personal loideas for the future of P2PRC.
|
|
||||||
At moment only has main contributors writiing to this.
|
|
||||||
|
|
||||||
** To support hetrogenous set of Nodes that cannot run P2PRC
|
|
||||||
This stems from a personal issue I have when doing research
|
|
||||||
on [[https://github.com/CTSRD-CHERI/cheribsd][CheriBSD]] kernel. For my research I am using the ARM morello
|
|
||||||
which is a 128bit ARMv8 processor. At the moment Go programs
|
|
||||||
can cannot compile and run inside the CPU. This means I cannot
|
|
||||||
run P2PRC at the moment inside the ARM morello to remotely access
|
|
||||||
it when it's behind NAT using P2PRC. This would indeed be a common
|
|
||||||
problem when running against various Architectures that do not
|
|
||||||
support running P2PRC. As you will see soon this also creates
|
|
||||||
oppurtunity space to scale faster to nodes in a local network
|
|
||||||
and would introduce a new layer fault tolerance within a local
|
|
||||||
network nodes.
|
|
||||||
|
|
||||||
*** Assumptions:
|
|
||||||
- I have a Morello board that cannot run P2PRC
|
|
||||||
- The Morello has a local IP address (ex: 192.168.0.10)
|
|
||||||
- I have 2 laptops running P2PRC in that local network.
|
|
||||||
- This means I have 2 ways to access the Morello board: Which is to SSH
|
|
||||||
into either 2 laptops and then SSH into 192.168.0.10 to gain access
|
|
||||||
to the board. Wouldn't it be great to automate this whole layer and
|
|
||||||
as well look into custom tasks into the hetrogenous hardware.
|
|
||||||
*** Set of interesting possible:
|
|
||||||
We build a cool set possibilities before and use this to build up the implementation
|
|
||||||
plan.
|
|
||||||
- We can use P2PRC access the morello board remotely in a single command.
|
|
||||||
- We can use the P2PRC protocol to run servers inside the morello board via traversed
|
|
||||||
node locally which can access that Node.
|
|
||||||
- Spin servers on node not running P2PRC using the P2PRC standard abstractions.
|
|
||||||
- Auto-setup P2PRC nodes with just SSH access via potencially a DSL.
|
|
||||||
- A neat use case for CHERI for instance would be use the architecture to run light
|
|
||||||
weight hypervisors.
|
|
||||||
*** Implementation
|
|
||||||
- To use implementations similar to [[https://linux.die.net/man/1/socat][socat]] to ensure we can bind address of local
|
|
||||||
nodes to a node running P2PRC and the node running P2PRC can do a local map port.
|
|
||||||
- We are working on hardening the implementation of the --mp (Map port) to even
|
|
||||||
map ports to machines which remotely running P2PRC. This means of instance I
|
|
||||||
can issue a command to the Morello board without the morello board being in
|
|
||||||
my local network.
|
|
||||||
- We would want to implement the exsisting P2PRC public key mechanism as well so that
|
|
||||||
other nodes can access the Morello board who have permission access.
|
|
||||||
|
|
||||||
#+CAPTION: Implementation idea (To be improved upon)
|
|
||||||
[[./Docs/images/P2PRCRemoteNodes.png]]
|
|
||||||
7
nix/overlays/bindings.nix
Normal file
7
nix/overlays/bindings.nix
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
final: prev: {
|
||||||
|
haskellPackages = prev.haskellPackages.override {
|
||||||
|
overrides = hfinal: hprev: {
|
||||||
|
p2prc = hfinal.callPackage ../../Bindings/Haskell/project.nix { };
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
190
nix/templates/haskell/flake.lock
generated
Normal file
190
nix/templates/haskell/flake.lock
generated
Normal file
@@ -0,0 +1,190 @@
|
|||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"flake-util": {
|
||||||
|
"inputs": {
|
||||||
|
"systems": "systems"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1731533236,
|
||||||
|
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"flake-utils": {
|
||||||
|
"inputs": {
|
||||||
|
"systems": "systems_2"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1731533236,
|
||||||
|
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"id": "flake-utils",
|
||||||
|
"type": "indirect"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"flake-utils_2": {
|
||||||
|
"inputs": {
|
||||||
|
"systems": "systems_3"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1731533236,
|
||||||
|
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"gomod2nix": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-utils": [
|
||||||
|
"p2prc-flake",
|
||||||
|
"flake-utils"
|
||||||
|
],
|
||||||
|
"nixpkgs": [
|
||||||
|
"p2prc-flake",
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1745875161,
|
||||||
|
"narHash": "sha256-0YkWCS13jpoo3+sX/3kcgdxBNt1VZTmvF+FhZb4rFKI=",
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "gomod2nix",
|
||||||
|
"rev": "2cbd7fdd6eeab65c494cc426e18f4e4d2a5e35c0",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "gomod2nix",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1748460289,
|
||||||
|
"narHash": "sha256-7doLyJBzCllvqX4gszYtmZUToxKvMUrg45EUWaUYmBg=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "96ec055edbe5ee227f28cdbc3f1ddf1df5965102",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixos-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs_2": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1748370509,
|
||||||
|
"narHash": "sha256-QlL8slIgc16W5UaI3w7xHQEP+Qmv/6vSNTpoZrrSlbk=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "4faa5f5321320e49a78ae7848582f684d64783e9",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixos-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"p2prc-flake": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-utils": "flake-utils_2",
|
||||||
|
"gomod2nix": "gomod2nix",
|
||||||
|
"nixpkgs": "nixpkgs_2"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1748646470,
|
||||||
|
"narHash": "sha256-7aZQQ+jHdlxUzFPXzEEYfH1oU3isSZlZnMC7HWUDHCk=",
|
||||||
|
"owner": "xecarlox94",
|
||||||
|
"repo": "p2p-rendering-computation",
|
||||||
|
"rev": "73a283a545d61754a0fe821287541c2cd412bc0e",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "xecarlox94",
|
||||||
|
"ref": "nix",
|
||||||
|
"repo": "p2p-rendering-computation",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-util": "flake-util",
|
||||||
|
"flake-utils": "flake-utils",
|
||||||
|
"nixpkgs": "nixpkgs",
|
||||||
|
"p2prc-flake": "p2prc-flake"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"systems": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1681028828,
|
||||||
|
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"systems_2": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1681028828,
|
||||||
|
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"systems_3": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1681028828,
|
||||||
|
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
||||||
48
nix/templates/haskell/flake.nix
Normal file
48
nix/templates/haskell/flake.nix
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
{
|
||||||
|
description = "Start of Haskell P2PRC flake";
|
||||||
|
|
||||||
|
inputs =
|
||||||
|
{
|
||||||
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
|
|
||||||
|
flake-util.url = "github:numtide/flake-utils";
|
||||||
|
|
||||||
|
p2prc-flake.url = "github:akilan1999/p2p-rendering-computation";
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = { nixpkgs, p2prc-flake, flake-utils, ... }:
|
||||||
|
(flake-utils.lib.eachDefaultSystem (system:
|
||||||
|
let
|
||||||
|
|
||||||
|
pkgs = import nixpkgs {
|
||||||
|
inherit system;
|
||||||
|
overlays = [
|
||||||
|
p2prc-flake.overlays.default
|
||||||
|
p2prc-flake.overlays.bindings
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
in {
|
||||||
|
|
||||||
|
packages.default = pkgs.haskellPackages.callPackage ./cabal.nix { };
|
||||||
|
|
||||||
|
devShells.default = pkgs.haskellPackages.shellFor {
|
||||||
|
|
||||||
|
packages = p: [
|
||||||
|
(p.callPackage ./cabal.nix { })
|
||||||
|
];
|
||||||
|
|
||||||
|
buildInputs = with pkgs; [
|
||||||
|
p2prc-flake.packages.${system}.default
|
||||||
|
ghc
|
||||||
|
cabal2nix
|
||||||
|
cabal-install
|
||||||
|
];
|
||||||
|
|
||||||
|
shellHook = ''
|
||||||
|
cabal2nix . > ./cabal.nix
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
||||||
|
));
|
||||||
|
}
|
||||||
@@ -42,6 +42,8 @@ type IP struct {
|
|||||||
Query string
|
Query string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var Test = false
|
||||||
|
|
||||||
// ReadIpTable Read data from Ip tables from json file
|
// ReadIpTable Read data from Ip tables from json file
|
||||||
func ReadIpTable() (*IpAddresses, error) {
|
func ReadIpTable() (*IpAddresses, error) {
|
||||||
// Get Path from config
|
// Get Path from config
|
||||||
@@ -178,6 +180,16 @@ func (table *IpAddresses) RemoveDuplicates() error {
|
|||||||
|
|
||||||
// CurrentPublicIP Get Current Public IP address
|
// CurrentPublicIP Get Current Public IP address
|
||||||
func CurrentPublicIP() (string, error) {
|
func CurrentPublicIP() (string, error) {
|
||||||
|
// Get configs
|
||||||
|
Config, err := config.ConfigInit(nil, nil)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
// If test mode is on then return local address
|
||||||
|
if Config.Test {
|
||||||
|
return "0.0.0.0", nil
|
||||||
|
}
|
||||||
|
|
||||||
req, err := http.Get("http://ip-api.com/json/")
|
req, err := http.Get("http://ip-api.com/json/")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
@@ -193,6 +205,7 @@ func CurrentPublicIP() (string, error) {
|
|||||||
json.Unmarshal(body, &ip)
|
json.Unmarshal(body, &ip)
|
||||||
|
|
||||||
return ip.Query, nil
|
return ip.Query, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetCurrentIPV6 gets the current IPV6 address based on the interface
|
// GetCurrentIPV6 gets the current IPV6 address based on the interface
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ func (ip *IpAddresses) SpeedTestUpdatedIPTable() error {
|
|||||||
// and look upon later on.
|
// and look upon later on.
|
||||||
AddAuthorisationKey(ip.IpAddress[k].PublicKey)
|
AddAuthorisationKey(ip.IpAddress[k].PublicKey)
|
||||||
}
|
}
|
||||||
|
targets.IpAddress[i].CustomInformation = ip.IpAddress[k].CustomInformation
|
||||||
// Checks if both the IPV4 addresses are the same or the IPV6 address is not
|
// Checks if both the IPV4 addresses are the same or the IPV6 address is not
|
||||||
// an empty string and IPV6 address are the same
|
// an empty string and IPV6 address are the same
|
||||||
if (ip.IpAddress[k].Ipv4 == targets.IpAddress[i].Ipv4 && targets.IpAddress[i].NAT) || (targets.IpAddress[i].Ipv6 != "" && ip.IpAddress[k].Ipv6 == targets.IpAddress[i].Ipv6) {
|
if (ip.IpAddress[k].Ipv4 == targets.IpAddress[i].Ipv4 && targets.IpAddress[i].NAT) || (targets.IpAddress[i].Ipv6 != "" && ip.IpAddress[k].Ipv6 == targets.IpAddress[i].Ipv6) {
|
||||||
|
|||||||
@@ -141,8 +141,6 @@ func Server() (*gin.Engine, error) {
|
|||||||
// Convert Get Request value to int
|
// Convert Get Request value to int
|
||||||
fmt.Sscanf(Ports, "%d", &PortsInt)
|
fmt.Sscanf(Ports, "%d", &PortsInt)
|
||||||
|
|
||||||
fmt.Println(string(PublicKeyDecoded[:]))
|
|
||||||
|
|
||||||
// Creates container and returns-back result to
|
// Creates container and returns-back result to
|
||||||
// access container
|
// access container
|
||||||
resp, err := docker.BuildRunContainer(PortsInt, GPU, ContainerName, BaseImage, string(PublicKeyDecoded[:]))
|
resp, err := docker.BuildRunContainer(PortsInt, GPU, ContainerName, BaseImage, string(PublicKeyDecoded[:]))
|
||||||
@@ -312,6 +310,7 @@ func Server() (*gin.Engine, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
ProxyIpAddr.ServerPort = config.ServerPort
|
ProxyIpAddr.ServerPort = config.ServerPort
|
||||||
ProxyIpAddr.Name = config.MachineName
|
ProxyIpAddr.Name = config.MachineName
|
||||||
ProxyIpAddr.NAT = false
|
ProxyIpAddr.NAT = false
|
||||||
|
|||||||
BIN
wasm/p2prc.wasm
Executable file
BIN
wasm/p2prc.wasm
Executable file
Binary file not shown.
Reference in New Issue
Block a user