Compare commits
78 Commits
simulation
...
nix
| Author | SHA1 | Date | |
|---|---|---|---|
| ac2c5f8a83 | |||
| 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 |
66
Bindings/Haskell/flake.lock
generated
66
Bindings/Haskell/flake.lock
generated
@@ -18,23 +18,41 @@
|
||||
"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": {
|
||||
"inputs": {
|
||||
"flake-utils": [
|
||||
"p2prc",
|
||||
"p2prc-main",
|
||||
"flake-utils"
|
||||
],
|
||||
"nixpkgs": [
|
||||
"p2prc",
|
||||
"p2prc-main",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1733668782,
|
||||
"narHash": "sha256-tPsqU00FhgdFr0JiQUiBMgPVbl1jbPCY5gbFiJycL3I=",
|
||||
"lastModified": 1745875161,
|
||||
"narHash": "sha256-0YkWCS13jpoo3+sX/3kcgdxBNt1VZTmvF+FhZb4rFKI=",
|
||||
"owner": "nix-community",
|
||||
"repo": "gomod2nix",
|
||||
"rev": "514283ec89c39ad0079ff2f3b1437404e4cba608",
|
||||
"rev": "2cbd7fdd6eeab65c494cc426e18f4e4d2a5e35c0",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -57,11 +75,11 @@
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1735834308,
|
||||
"narHash": "sha256-dklw3AXr3OGO4/XT1Tu3Xz9n/we8GctZZ75ZWVqAVhk=",
|
||||
"lastModified": 1748026106,
|
||||
"narHash": "sha256-6m1Y3/4pVw1RWTsrkAK2VMYSzG4MMIj7sqUy7o8th1o=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "6df24922a1400241dae323af55f30e4318a6ca65",
|
||||
"rev": "063f43f2dbdef86376cc29ad646c45c46e93234c",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -71,28 +89,28 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"p2prc": {
|
||||
"p2prc-main": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"flake-utils": "flake-utils_2",
|
||||
"gomod2nix": "gomod2nix",
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 0,
|
||||
"narHash": "sha256-f4e4JcQzBS+R+8HqJbQVeecInm2ggInJuSSymj6gtQo=",
|
||||
"path": "/nix/store/hmk8v0lxifsscll054qsdnzxqfql1998-source",
|
||||
"narHash": "sha256-5qbaxawuLsg8iu9076zlAbLtTFSNJaTz7WERS5rWRxU=",
|
||||
"path": "/nix/store/lg694r23fzc6v5ai3qqcszq1fp44djg2-source",
|
||||
"type": "path"
|
||||
},
|
||||
"original": {
|
||||
"path": "/nix/store/hmk8v0lxifsscll054qsdnzxqfql1998-source",
|
||||
"path": "/nix/store/lg694r23fzc6v5ai3qqcszq1fp44djg2-source",
|
||||
"type": "path"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"p2prc": "p2prc",
|
||||
"utils": "utils"
|
||||
"p2prc-main": "p2prc-main"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
@@ -124,24 +142,6 @@
|
||||
"repo": "default",
|
||||
"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",
|
||||
|
||||
@@ -1,24 +1,28 @@
|
||||
{
|
||||
description = "Nix flake for P2PRC Haskell library";
|
||||
|
||||
inputs = {
|
||||
p2prc.url = "../../";
|
||||
utils.url = "github:numtide/flake-utils";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
p2prc-main.url = "../../";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, utils, p2prc }: utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
in
|
||||
{
|
||||
devShell = pkgs.mkShell {
|
||||
buildInputs = with pkgs; [
|
||||
cabal-install
|
||||
haskell.compiler.ghc96
|
||||
zlib.dev
|
||||
p2prc.outputs.packages.${system}.default
|
||||
];
|
||||
};
|
||||
}
|
||||
);
|
||||
outputs = { nixpkgs, flake-utils, p2prc-main, ... }:
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
in
|
||||
{
|
||||
|
||||
packages.default = pkgs.haskellPackages.callPackage ./project.nix {};
|
||||
|
||||
devShell = pkgs.mkShell {
|
||||
buildInputs = with pkgs; [
|
||||
cabal2nix
|
||||
cabal-install
|
||||
ghc
|
||||
zlib.dev
|
||||
p2prc-main.packages.${system}.default
|
||||
];
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -116,5 +116,5 @@ eitherErrorDecode esa =
|
||||
-- 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"
|
||||
p2prcCmdName :: String
|
||||
p2prcCmdName = "p2prc"
|
||||
p2prcCmdName = "p2p-rendering-computation"
|
||||
|
||||
|
||||
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";
|
||||
}
|
||||
265
Docs/index.html
265
Docs/index.html
@@ -3,7 +3,7 @@
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
|
||||
<head>
|
||||
<!-- 2025-04-28 Mon 23:14 -->
|
||||
<!-- 2025-05-30 Fri 18:05 -->
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>‎</title>
|
||||
@@ -26,12 +26,12 @@
|
||||
<h2>Table of Contents</h2>
|
||||
<div id="text-table-of-contents" role="doc-toc">
|
||||
<ul>
|
||||
<li><a href="#org3cfeea9">1. Guide through video</a>
|
||||
<li><a href="#orga8d6384">1. Guide through video</a>
|
||||
<ul>
|
||||
<li>
|
||||
<ul>
|
||||
<li><a href="#org4256417">1.0.1. The video below shows the setup and usage of P2PRC.</a></li>
|
||||
<li><a href="#orgecee0c3">1.0.2. Source code: https://github.com/Akilan1999/p2p-rendering-computation</a></li>
|
||||
<li><a href="#org1df53fe">1.0.1. The video below shows the setup and usage of P2PRC.</a></li>
|
||||
<li><a href="#orgd08f572">1.0.2. Source code: https://github.com/Akilan1999/p2p-rendering-computation</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -78,8 +78,8 @@
|
||||
<li><a href="#pulling-plugin-from-a-remote-repo">4.0.17. Pulling plugin from a remote repo</a></li>
|
||||
<li><a href="#deleting-plugin-from-the-plugin-directory">4.0.18. Deleting plugin from the plugin directory</a></li>
|
||||
<li><a href="#added-custom-metadata-about-the-current-node">4.0.19. Added custom metadata about the current node</a></li>
|
||||
<li><a href="#org899f210">4.0.20. MapPort and link to domain name</a></li>
|
||||
<li><a href="#orge681470">4.0.21. Add root node</a></li>
|
||||
<li><a href="#org966244c">4.0.20. MapPort and link to domain name</a></li>
|
||||
<li><a href="#org2f19c06">4.0.21. Add root node</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -109,8 +109,8 @@
|
||||
</li>
|
||||
<li><a href="#current-languages-supported">6.3. Current languages supported</a>
|
||||
<ul>
|
||||
<li><a href="#org92a1e8c">6.3.1. Python</a></li>
|
||||
<li><a href="#org780e43b">6.3.2. Haskell</a></li>
|
||||
<li><a href="#orgf65d6f6">6.3.1. Python</a></li>
|
||||
<li><a href="#org40fe543">6.3.2. Haskell</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -127,22 +127,28 @@
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#client-mode">10. Client mode</a></li>
|
||||
<li><a href="#org1b92827">11. Blog posts</a>
|
||||
<li><a href="#orgfe7fc3c">11. Simulation</a>
|
||||
<ul>
|
||||
<li><a href="#orgec8979c">11.1. Self host within 5 minutes any program</a>
|
||||
<li><a href="#org22226ea">11.1. Command</a></li>
|
||||
<li><a href="#orga514f52">11.2. Sample bash instructions</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#orga046d58">12. Blog posts</a>
|
||||
<ul>
|
||||
<li><a href="#orgd03815a">11.1.1. 1. Find a program you want to run</a></li>
|
||||
<li><a href="#orgec88f20">12.1. Self host within 5 minutes any program</a>
|
||||
<ul>
|
||||
<li><a href="#org07ee6bd">12.1.1. 1. Find a program you want to run</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#orgb32e475">12. Ideas for future potencial features</a>
|
||||
<li><a href="#orgf31160d">13. Ideas for future potencial features</a>
|
||||
<ul>
|
||||
<li><a href="#org2666d00">12.1. To support hetrogenous set of Nodes that cannot run P2PRC</a>
|
||||
<li><a href="#org1a8a88e">13.1. To support hetrogenous set of Nodes that cannot run P2PRC</a>
|
||||
<ul>
|
||||
<li><a href="#org332fcc8">12.1.1. Assumptions:</a></li>
|
||||
<li><a href="#org21a29ac">12.1.2. Set of interesting possible:</a></li>
|
||||
<li><a href="#org4947494">12.1.3. Implementation</a></li>
|
||||
<li><a href="#org5d2c045">13.1.1. Assumptions:</a></li>
|
||||
<li><a href="#orgb55e814">13.1.2. Set of interesting possible:</a></li>
|
||||
<li><a href="#org7855189">13.1.3. Implementation</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -151,26 +157,26 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="orgefb6d6c" class="figure">
|
||||
<div id="org628b85a" class="figure">
|
||||
<p><img src="./Colored-On-Light-Image.png" alt="Colored-On-Light-Image.png" width="300px" />
|
||||
</p>
|
||||
</div>
|
||||
<div id="outline-container-org3cfeea9" class="outline-2">
|
||||
<h2 id="org3cfeea9"><span class="section-number-2">1.</span> Guide through video</h2>
|
||||
<div id="outline-container-orga8d6384" class="outline-2">
|
||||
<h2 id="orga8d6384"><span class="section-number-2">1.</span> Guide through video</h2>
|
||||
<div class="outline-text-2" id="text-1">
|
||||
</div>
|
||||
<div id="outline-container-org4256417" class="outline-4">
|
||||
<h4 id="org4256417"><span class="section-number-4">1.0.1.</span> The video below shows the setup and usage of P2PRC.</h4>
|
||||
<div id="outline-container-org1df53fe" class="outline-4">
|
||||
<h4 id="org1df53fe"><span class="section-number-4">1.0.1.</span> The video below shows the setup and usage of P2PRC.</h4>
|
||||
<div class="outline-text-4" id="text-1-0-1">
|
||||
|
||||
<div id="org863dfc7" class="figure">
|
||||
<div id="orgaf620b9" class="figure">
|
||||
<p><a href="https://www.youtube.com/watch?v=OMwCpedu5cs" class="video"><img src="https://i3.ytimg.com/vi/OMwCpedu5cs/maxresdefault.jpg" alt="maxresdefault.jpg" class="video" /></a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-orgecee0c3" class="outline-4">
|
||||
<h4 id="orgecee0c3"><span class="section-number-4">1.0.2.</span> Source code: <a href="https://github.com/Akilan1999/p2p-rendering-computation">https://github.com/Akilan1999/p2p-rendering-computation</a></h4>
|
||||
<div id="outline-container-orgd08f572" class="outline-4">
|
||||
<h4 id="orgd08f572"><span class="section-number-4">1.0.2.</span> Source code: <a href="https://github.com/Akilan1999/p2p-rendering-computation">https://github.com/Akilan1999/p2p-rendering-computation</a></h4>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-chapter1-introduction" class="outline-2">
|
||||
@@ -259,7 +265,7 @@ Go API to create and interact with the containers.
|
||||
to install docker GPU</a>
|
||||
</p>
|
||||
|
||||
<pre class="example" id="orgfc326ea">
|
||||
<pre class="example" id="orge229820">
|
||||
// Do ensure that the docker command does not need sudo to run
|
||||
sudo chmod 666 /var/run/docker.sock
|
||||
</pre>
|
||||
@@ -273,7 +279,7 @@ To set up the internal dependencies and build the entire go code into a
|
||||
single binary
|
||||
</p>
|
||||
|
||||
<pre class="example" id="org9abf859">
|
||||
<pre class="example" id="orge6efab3">
|
||||
make
|
||||
</pre>
|
||||
</div>
|
||||
@@ -285,7 +291,7 @@ To set up P2PRC on Windows, simply run this batch file. <b>Make sure you
|
||||
are not in admin mode when running this.</b>
|
||||
</p>
|
||||
|
||||
<pre class="example" id="org754bc46">
|
||||
<pre class="example" id="org503a4ba">
|
||||
.\install.bat
|
||||
</pre>
|
||||
</div>
|
||||
@@ -295,7 +301,7 @@ are not in admin mode when running this.</b>
|
||||
<div id="outline-container-add-appropriate-paths-to-.bashrc" class="outline-4">
|
||||
<h4 id="add-appropriate-paths-to-.bashrc"><span class="section-number-4">3.2.4.</span> Add appropriate paths to <code>.bashrc</code></h4>
|
||||
<div class="outline-text-4" id="text-add-appropriate-paths-to-.bashrc">
|
||||
<pre class="example" id="org06344db">
|
||||
<pre class="example" id="org3da98df">
|
||||
export P2PRC=/<PATH>/p2p-rendering-computation
|
||||
export PATH=/<PATH>/p2p-rendering-computation:${PATH}
|
||||
</pre>
|
||||
@@ -304,14 +310,14 @@ export PATH=/<PATH>/p2p-rendering-computation:${PATH}
|
||||
<div id="outline-container-test-if-binary-works" class="outline-4">
|
||||
<h4 id="test-if-binary-works"><span class="section-number-4">3.2.5.</span> Test if binary works</h4>
|
||||
<div class="outline-text-4" id="text-test-if-binary-works">
|
||||
<pre class="example" id="org189a0e9">
|
||||
<pre class="example" id="org842f745">
|
||||
p2prc --help
|
||||
</pre>
|
||||
</div>
|
||||
<ol class="org-ol">
|
||||
<li><a id="output"></a>Output:<br />
|
||||
<div class="outline-text-5" id="text-output">
|
||||
<pre class="example" id="org705fb25">
|
||||
<pre class="example" id="org2d62e91">
|
||||
NAME:
|
||||
p2p-rendering-computation - p2p cli application to create and access VMs in other servers
|
||||
|
||||
@@ -373,7 +379,7 @@ GLOBAL OPTIONS:
|
||||
<div id="outline-container-start-as-a-server" class="outline-4">
|
||||
<h4 id="start-as-a-server"><span class="section-number-4">4.0.1.</span> Start as a server</h4>
|
||||
<div class="outline-text-4" id="text-start-as-a-server">
|
||||
<pre class="example" id="org1be9ce7">
|
||||
<pre class="example" id="org41f3e1c">
|
||||
p2prc -s
|
||||
</pre>
|
||||
</div>
|
||||
@@ -381,7 +387,7 @@ p2prc -s
|
||||
<div id="outline-container-view-server-specification" class="outline-4">
|
||||
<h4 id="view-server-specification"><span class="section-number-4">4.0.2.</span> View server Specification</h4>
|
||||
<div class="outline-text-4" id="text-view-server-specification">
|
||||
<pre class="example" id="org7c6080c">
|
||||
<pre class="example" id="orgc305043">
|
||||
p2prc --specs=<ip address>
|
||||
</pre>
|
||||
</div>
|
||||
@@ -393,7 +399,7 @@ p2prc --specs=<ip address>
|
||||
use the <code>--gpu</code> if you know the other machine has a gpu.
|
||||
</p>
|
||||
|
||||
<pre class="example" id="org96ebc97">
|
||||
<pre class="example" id="orgc7648f7">
|
||||
p2prc --touch=<server ip address> -p <number of ports> --gpu
|
||||
</pre>
|
||||
</div>
|
||||
@@ -405,7 +411,7 @@ p2prc --touch=<server ip address> -p <number of ports> --gpu
|
||||
The docker id is present in the output where you create a container
|
||||
</p>
|
||||
|
||||
<pre class="example" id="org3a50a5b">
|
||||
<pre class="example" id="org9aca1f2">
|
||||
p2prc --rm=<server ip address> --id=<docker container id>
|
||||
</pre>
|
||||
</div>
|
||||
@@ -413,7 +419,7 @@ p2prc --rm=<server ip address> --id=<docker container id>
|
||||
<div id="outline-container-adding-servers-to-ip-table" class="outline-4">
|
||||
<h4 id="adding-servers-to-ip-table"><span class="section-number-4">4.0.5.</span> Adding servers to ip table</h4>
|
||||
<div class="outline-text-4" id="text-adding-servers-to-ip-table">
|
||||
<pre class="example" id="orgd0b12dc">
|
||||
<pre class="example" id="orgb518ed0">
|
||||
p2prc --as=<server ip address you want to add>
|
||||
</pre>
|
||||
</div>
|
||||
@@ -421,7 +427,7 @@ p2prc --as=<server ip address you want to add>
|
||||
<div id="outline-container-update-ip-table" class="outline-4">
|
||||
<h4 id="update-ip-table"><span class="section-number-4">4.0.6.</span> Update ip table</h4>
|
||||
<div class="outline-text-4" id="text-update-ip-table">
|
||||
<pre class="example" id="org2b52762">
|
||||
<pre class="example" id="org26ead4a">
|
||||
p2prc --us
|
||||
</pre>
|
||||
</div>
|
||||
@@ -429,7 +435,7 @@ p2prc --us
|
||||
<div id="outline-container-list-servers" class="outline-4">
|
||||
<h4 id="list-servers"><span class="section-number-4">4.0.7.</span> List Servers</h4>
|
||||
<div class="outline-text-4" id="text-list-servers">
|
||||
<pre class="example" id="org9a40c4a">
|
||||
<pre class="example" id="orgc098d33">
|
||||
p2prc --ls
|
||||
</pre>
|
||||
</div>
|
||||
@@ -437,7 +443,7 @@ p2prc --ls
|
||||
<div id="outline-container-view-network-interfaces" class="outline-4">
|
||||
<h4 id="view-network-interfaces"><span class="section-number-4">4.0.8.</span> View Network interfaces</h4>
|
||||
<div class="outline-text-4" id="text-view-network-interfaces">
|
||||
<pre class="example" id="orge766dd3">
|
||||
<pre class="example" id="org68a2716">
|
||||
p2prc --ni
|
||||
</pre>
|
||||
</div>
|
||||
@@ -445,7 +451,7 @@ p2prc --ni
|
||||
<div id="outline-container-viewing-containers-created-client-side" class="outline-4">
|
||||
<h4 id="viewing-containers-created-client-side"><span class="section-number-4">4.0.9.</span> Viewing Containers created Client side</h4>
|
||||
<div class="outline-text-4" id="text-viewing-containers-created-client-side">
|
||||
<pre class="example" id="org9787c64">
|
||||
<pre class="example" id="orgc3b9a5e">
|
||||
p2prc --tc
|
||||
</pre>
|
||||
</div>
|
||||
@@ -453,7 +459,7 @@ p2prc --tc
|
||||
<div id="outline-container-running-plugin" class="outline-4">
|
||||
<h4 id="running-plugin"><span class="section-number-4">4.0.10.</span> Running plugin</h4>
|
||||
<div class="outline-text-4" id="text-running-plugin">
|
||||
<pre class="example" id="org94b7a90">
|
||||
<pre class="example" id="org0f205e5">
|
||||
p2prc --plugin <plugin name> --id <container id or group id>
|
||||
</pre>
|
||||
</div>
|
||||
@@ -461,7 +467,7 @@ p2prc --plugin <plugin name> --id <container id or group id>
|
||||
<div id="outline-container-create-group" class="outline-4">
|
||||
<h4 id="create-group"><span class="section-number-4">4.0.11.</span> Create group</h4>
|
||||
<div class="outline-text-4" id="text-create-group">
|
||||
<pre class="example" id="orge008a6c">
|
||||
<pre class="example" id="org3dc07ae">
|
||||
p2prc --cgroup
|
||||
</pre>
|
||||
</div>
|
||||
@@ -469,7 +475,7 @@ p2prc --cgroup
|
||||
<div id="outline-container-add-container-to-group" class="outline-4">
|
||||
<h4 id="add-container-to-group"><span class="section-number-4">4.0.12.</span> Add container to group</h4>
|
||||
<div class="outline-text-4" id="text-add-container-to-group">
|
||||
<pre class="example" id="org8598b18">
|
||||
<pre class="example" id="orgc7ac7ea">
|
||||
p2prc --group <group id> --id <container id>
|
||||
</pre>
|
||||
</div>
|
||||
@@ -477,7 +483,7 @@ p2prc --group <group id> --id <container id>
|
||||
<div id="outline-container-view-groups" class="outline-4">
|
||||
<h4 id="view-groups"><span class="section-number-4">4.0.13.</span> View groups</h4>
|
||||
<div class="outline-text-4" id="text-view-groups">
|
||||
<pre class="example" id="org5425a07">
|
||||
<pre class="example" id="org147a736">
|
||||
p2prc --groups
|
||||
</pre>
|
||||
</div>
|
||||
@@ -485,7 +491,7 @@ p2prc --groups
|
||||
<div id="outline-container-view-specific-group" class="outline-4">
|
||||
<h4 id="view-specific-group"><span class="section-number-4">4.0.14.</span> View specific group</h4>
|
||||
<div class="outline-text-4" id="text-view-specific-group">
|
||||
<pre class="example" id="org187af36">
|
||||
<pre class="example" id="orgd045744">
|
||||
p2prc --group <group id>
|
||||
</pre>
|
||||
</div>
|
||||
@@ -493,7 +499,7 @@ p2prc --group <group id>
|
||||
<div id="outline-container-delete-container-from-group" class="outline-4">
|
||||
<h4 id="delete-container-from-group"><span class="section-number-4">4.0.15.</span> Delete container from group</h4>
|
||||
<div class="outline-text-4" id="text-delete-container-from-group">
|
||||
<pre class="example" id="orga4687ab">
|
||||
<pre class="example" id="org9fc6938">
|
||||
p2prc --rmcgroup --group <group id> --id <container id>
|
||||
</pre>
|
||||
</div>
|
||||
@@ -501,7 +507,7 @@ p2prc --rmcgroup --group <group id> --id <container id>
|
||||
<div id="outline-container-delete-entire-group" class="outline-4">
|
||||
<h4 id="delete-entire-group"><span class="section-number-4">4.0.16.</span> Delete entire group</h4>
|
||||
<div class="outline-text-4" id="text-delete-entire-group">
|
||||
<pre class="example" id="orgf60b3a8">
|
||||
<pre class="example" id="org752e829">
|
||||
p2prc --rmgroup <group id>
|
||||
</pre>
|
||||
</div>
|
||||
@@ -509,7 +515,7 @@ p2prc --rmgroup <group id>
|
||||
<div id="outline-container-pulling-plugin-from-a-remote-repo" class="outline-4">
|
||||
<h4 id="pulling-plugin-from-a-remote-repo"><span class="section-number-4">4.0.17.</span> Pulling plugin from a remote repo</h4>
|
||||
<div class="outline-text-4" id="text-pulling-plugin-from-a-remote-repo">
|
||||
<pre class="example" id="orgb9bee77">
|
||||
<pre class="example" id="orga6511bc">
|
||||
p2prc --pp <repo link>
|
||||
</pre>
|
||||
</div>
|
||||
@@ -517,7 +523,7 @@ p2prc --pp <repo link>
|
||||
<div id="outline-container-deleting-plugin-from-the-plugin-directory" class="outline-4">
|
||||
<h4 id="deleting-plugin-from-the-plugin-directory"><span class="section-number-4">4.0.18.</span> Deleting plugin from the plugin directory</h4>
|
||||
<div class="outline-text-4" id="text-deleting-plugin-from-the-plugin-directory">
|
||||
<pre class="example" id="org2979ba1">
|
||||
<pre class="example" id="orgbff120f">
|
||||
p2prc --rp <plugin name>
|
||||
</pre>
|
||||
</div>
|
||||
@@ -525,28 +531,28 @@ p2prc --rp <plugin name>
|
||||
<div id="outline-container-added-custom-metadata-about-the-current-node" class="outline-4">
|
||||
<h4 id="added-custom-metadata-about-the-current-node"><span class="section-number-4">4.0.19.</span> Added custom metadata about the current node</h4>
|
||||
<div class="outline-text-4" id="text-added-custom-metadata-about-the-current-node">
|
||||
<pre class="example" id="org3c1dba9">
|
||||
<pre class="example" id="org93cf0f5">
|
||||
p2prc --amd "custom metadata"
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-org899f210" class="outline-4">
|
||||
<h4 id="org899f210"><span class="section-number-4">4.0.20.</span> MapPort and link to domain name</h4>
|
||||
<div id="outline-container-org966244c" class="outline-4">
|
||||
<h4 id="org966244c"><span class="section-number-4">4.0.20.</span> MapPort and link to domain name</h4>
|
||||
<div class="outline-text-4" id="text-4-0-20">
|
||||
<p>
|
||||
Allows to expose remote ports from a machine in the P2P network.
|
||||
</p>
|
||||
<pre class="example" id="org9d628c6">
|
||||
<pre class="example" id="org583d4c1">
|
||||
p2prc --mp <port no to map> --dn <domain name to link Mapped port against>
|
||||
</pre>
|
||||
</div>
|
||||
<ol class="org-ol">
|
||||
<li><a id="org29021b1"></a>MapPort in remote machine<br />
|
||||
<li><a id="orgf707bff"></a>MapPort in remote machine<br />
|
||||
<div class="outline-text-5" id="text-4-0-20-1">
|
||||
<p>
|
||||
This is to ensure ports on remote machines on the P2PRC can be easily opened.
|
||||
</p>
|
||||
<pre class="example" id="orga1ff65e">
|
||||
<pre class="example" id="org72eef4d">
|
||||
p2prc --mp <port no to map> --dn <domain name to link Mapped port against> --ra <remote server address>
|
||||
</pre>
|
||||
|
||||
@@ -555,15 +561,15 @@ p2prc --mp <port no to map> --dn <domain name to link Mapped port again
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
<div id="outline-container-orge681470" class="outline-4">
|
||||
<h4 id="orge681470"><span class="section-number-4">4.0.21.</span> Add root node</h4>
|
||||
<div id="outline-container-org2f19c06" class="outline-4">
|
||||
<h4 id="org2f19c06"><span class="section-number-4">4.0.21.</span> Add root node</h4>
|
||||
<div class="outline-text-4" id="text-4-0-21">
|
||||
<p>
|
||||
Adds a root node to P2RRC and overwrites all other nodes in the ip table.
|
||||
To be only added before the network is started and with
|
||||
the intention of a fresh instance.
|
||||
</p>
|
||||
<pre class="example" id="org79b869e">
|
||||
<pre class="example" id="org202dc68">
|
||||
p2prc --arn --ip <root node ip address> -p <root node port no>
|
||||
</pre>
|
||||
</div>
|
||||
@@ -674,7 +680,7 @@ from the TURN server. The flow below describes the workflow.
|
||||
<li>Call <code>/FRPPort</code></li>
|
||||
</ul>
|
||||
|
||||
<pre class="example" id="org90a2001">
|
||||
<pre class="example" id="org2bea991">
|
||||
http://<turn server ip>:<server port no>/FRPport
|
||||
</pre>
|
||||
|
||||
@@ -763,7 +769,7 @@ p2prc.h p2prc.so
|
||||
Below are a sample set of commands to open the bindings implementation.
|
||||
</p>
|
||||
|
||||
<pre class="example" id="orgb8690e2">
|
||||
<pre class="example" id="orgdd81071">
|
||||
# run
|
||||
cd Bindings/
|
||||
# list files
|
||||
@@ -851,7 +857,7 @@ that convert a go object to JSON string initially and converts it to
|
||||
</li>
|
||||
<li><a id="a-pseudo-code-to-refer-to-the-common-function-implementation-shape-could-be-represented-as"></a>A Pseudo code to refer to the common function implementation shape could be represented as:<br />
|
||||
<div class="outline-text-5" id="text-a-pseudo-code-to-refer-to-the-common-function-implementation-shape-could-be-represented-as">
|
||||
<pre class="example" id="orgd0da451">
|
||||
<pre class="example" id="orge44168c">
|
||||
func <Function name> (output *C.char) {
|
||||
<response>,<error> := <P2PRC function name>(<parameters if needed>)
|
||||
if <error> != nil {
|
||||
@@ -869,8 +875,8 @@ func <Function name> (output *C.char) {
|
||||
<h3 id="current-languages-supported"><span class="section-number-3">6.3.</span> Current languages supported</h3>
|
||||
<div class="outline-text-3" id="text-current-languages-supported">
|
||||
</div>
|
||||
<div id="outline-container-org92a1e8c" class="outline-4">
|
||||
<h4 id="org92a1e8c"><span class="section-number-4">6.3.1.</span> Python</h4>
|
||||
<div id="outline-container-orgf65d6f6" class="outline-4">
|
||||
<h4 id="orgf65d6f6"><span class="section-number-4">6.3.1.</span> Python</h4>
|
||||
<div class="outline-text-4" id="text-6-3-1">
|
||||
</div>
|
||||
<ol class="org-ol">
|
||||
@@ -907,8 +913,8 @@ called from other programming languages.
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
<div id="outline-container-org780e43b" class="outline-4">
|
||||
<h4 id="org780e43b"><span class="section-number-4">6.3.2.</span> Haskell</h4>
|
||||
<div id="outline-container-org40fe543" class="outline-4">
|
||||
<h4 id="org40fe543"><span class="section-number-4">6.3.2.</span> Haskell</h4>
|
||||
<div class="outline-text-4" id="text-6-3-2">
|
||||
<p>
|
||||
P2PRC officially supports Haskell bindings and will further support
|
||||
@@ -943,18 +949,28 @@ configuration file was generated using JSON format.
|
||||
|
||||
<div class="org-src-container">
|
||||
<pre class="src 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",
|
||||
"DockerContainers": "/Users/akilan/Documents/p2p-rendering-computation/server/docker/containers/",
|
||||
"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",
|
||||
"IPV6Address": "",
|
||||
"PluginPath": "/Users/akilan/Documents/p2p-rendering-computation/plugin/deploy",
|
||||
"TrackContainersPath": "/Users/akilan/Documents/p2p-rendering-computation/client/trackcontainers/trackcontainers.json",
|
||||
"ServerPort": "8088",
|
||||
"ProxyPort": "",
|
||||
"GroupTrackContainersPath": "/Users/akilan/Documents/p2p-rendering-computation/client/trackcontainers/grouptrackcontainers.json",
|
||||
"FRPServerPort": "True",
|
||||
"BehindNAT": "True",
|
||||
"FRPServerPort": 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
|
||||
}
|
||||
</pre>
|
||||
@@ -1020,7 +1036,7 @@ from the TURN server. The flow below describes the workflow.
|
||||
<li>Call <code>/FRPPort</code></li>
|
||||
</ul>
|
||||
|
||||
<pre class="example" id="org910dfb2">
|
||||
<pre class="example" id="org60a83ac">
|
||||
http://<turn server ip>:<server port no>/FRPport
|
||||
</pre>
|
||||
|
||||
@@ -1051,14 +1067,73 @@ func main() {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-org1b92827" class="outline-2">
|
||||
<h2 id="org1b92827"><span class="section-number-2">11.</span> Blog posts</h2>
|
||||
<div id="outline-container-orgfe7fc3c" class="outline-2">
|
||||
<h2 id="orgfe7fc3c"><span class="section-number-2">11.</span> Simulation</h2>
|
||||
<div class="outline-text-2" id="text-11">
|
||||
<p>
|
||||
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:
|
||||
</p>
|
||||
</div>
|
||||
<div id="outline-container-orgec8979c" class="outline-3">
|
||||
<h3 id="orgec8979c"><span class="section-number-3">11.1.</span> Self host within 5 minutes any program</h3>
|
||||
<div id="outline-container-org22226ea" class="outline-3">
|
||||
<h3 id="org22226ea"><span class="section-number-3">11.1.</span> Command</h3>
|
||||
<div class="outline-text-3" id="text-11-1">
|
||||
<ul class="org-ul">
|
||||
<li><b><b><b>P2PRC instances "number of instances"</b></b></b> : Starts p2prc processes
|
||||
based on the number of number instances provided. This includes
|
||||
creating temporary folders with independent IPTables.</li>
|
||||
<li><b><b><b>Start all instances "number of instances"</b></b></b>: 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.</li>
|
||||
<li><b><b><b>IP Tables after Started number of instances"</b></b></b>: Prints the IPTable of
|
||||
each independant node.</li>
|
||||
<li><b><b><b>Remove all test files</b></b></b>: Removes all test files created which needed for
|
||||
testing the generated P2PRC instances.</li>
|
||||
<li><b><b><b>Kill all instances</b></b></b>: Kills all the background P2PRC instances created.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-orga514f52" class="outline-3">
|
||||
<h3 id="orga514f52"><span class="section-number-3">11.2.</span> Sample bash instructions</h3>
|
||||
<div class="outline-text-3" id="text-11-2">
|
||||
<div class="org-src-container">
|
||||
<pre class="src 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
|
||||
</pre>
|
||||
</div>
|
||||
<p>
|
||||
Source code: <a href="https://github.com/Akilan1999/p2p-rendering-computation/blob/master/Simulation/simulation.sh">https://github.com/Akilan1999/p2p-rendering-computation/blob/master/Simulation/simulation.sh</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-orga046d58" class="outline-2">
|
||||
<h2 id="orga046d58"><span class="section-number-2">12.</span> Blog posts</h2>
|
||||
<div class="outline-text-2" id="text-12">
|
||||
</div>
|
||||
<div id="outline-container-orgec88f20" class="outline-3">
|
||||
<h3 id="orgec88f20"><span class="section-number-3">12.1.</span> Self host within 5 minutes any program</h3>
|
||||
<div class="outline-text-3" id="text-12-1">
|
||||
<ul class="org-ul">
|
||||
<li>Author: <a href="http://akilan.io/">Akilan Selvacoumar</a></li>
|
||||
<li>Date: 28-01-2025</li>
|
||||
</ul>
|
||||
@@ -1068,7 +1143,7 @@ func main() {
|
||||
<li>Video tutorial:</li>
|
||||
</ul>
|
||||
|
||||
<div id="org756aa28" class="figure">
|
||||
<div id="org01fbebe" class="figure">
|
||||
<p><a href="https://youtu.be/rN4SiVowg5E" class="video"><img src="https://i3.ytimg.com/vi/rN4SiVowg5E/maxresdefault.jpg" alt="maxresdefault.jpg" class="video" /></a>
|
||||
</p>
|
||||
</div>
|
||||
@@ -1078,9 +1153,9 @@ 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.
|
||||
</p>
|
||||
</div>
|
||||
<div id="outline-container-orgd03815a" class="outline-4">
|
||||
<h4 id="orgd03815a"><span class="section-number-4">11.1.1.</span> 1. Find a program you want to run</h4>
|
||||
<div class="outline-text-4" id="text-11-1-1">
|
||||
<div id="outline-container-org07ee6bd" class="outline-4">
|
||||
<h4 id="org07ee6bd"><span class="section-number-4">12.1.1.</span> 1. Find a program you want to run</h4>
|
||||
<div class="outline-text-4" id="text-12-1-1">
|
||||
<p>
|
||||
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
|
||||
@@ -1088,8 +1163,8 @@ compose installed on your local machine.
|
||||
</p>
|
||||
</div>
|
||||
<ol class="org-ol">
|
||||
<li><a id="orgc05f730"></a>Let's run Linkwarden using docker compose and P2PRC<br />
|
||||
<div class="outline-text-5" id="text-11-1-1-1">
|
||||
<li><a id="org2b6a10c"></a>Let's run Linkwarden using docker compose and P2PRC<br />
|
||||
<div class="outline-text-5" id="text-12-1-1-1">
|
||||
<p>
|
||||
<a href="https://docs.linkwarden.app/self-hosting/installation">Installation instructions</a>:
|
||||
</p>
|
||||
@@ -1177,17 +1252,17 @@ ex: <a href="https://linkwarden.akilan.io">https://linkwarden.akilan.io</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-orgb32e475" class="outline-2">
|
||||
<h2 id="orgb32e475"><span class="section-number-2">12.</span> Ideas for future potencial features</h2>
|
||||
<div class="outline-text-2" id="text-12">
|
||||
<div id="outline-container-orgf31160d" class="outline-2">
|
||||
<h2 id="orgf31160d"><span class="section-number-2">13.</span> Ideas for future potencial features</h2>
|
||||
<div class="outline-text-2" id="text-13">
|
||||
<p>
|
||||
Consists of personal loideas for the future of P2PRC.
|
||||
At moment only has main contributors writiing to this.
|
||||
</p>
|
||||
</div>
|
||||
<div id="outline-container-org2666d00" class="outline-3">
|
||||
<h3 id="org2666d00"><span class="section-number-3">12.1.</span> To support hetrogenous set of Nodes that cannot run P2PRC</h3>
|
||||
<div class="outline-text-3" id="text-12-1">
|
||||
<div id="outline-container-org1a8a88e" class="outline-3">
|
||||
<h3 id="org1a8a88e"><span class="section-number-3">13.1.</span> To support hetrogenous set of Nodes that cannot run P2PRC</h3>
|
||||
<div class="outline-text-3" id="text-13-1">
|
||||
<p>
|
||||
This stems from a personal issue I have when doing research
|
||||
on <a href="https://github.com/CTSRD-CHERI/cheribsd">CheriBSD</a> kernel. For my research I am using the ARM morello
|
||||
@@ -1202,9 +1277,9 @@ and would introduce a new layer fault tolerance within a local
|
||||
network nodes.
|
||||
</p>
|
||||
</div>
|
||||
<div id="outline-container-org332fcc8" class="outline-4">
|
||||
<h4 id="org332fcc8"><span class="section-number-4">12.1.1.</span> Assumptions:</h4>
|
||||
<div class="outline-text-4" id="text-12-1-1">
|
||||
<div id="outline-container-org5d2c045" class="outline-4">
|
||||
<h4 id="org5d2c045"><span class="section-number-4">13.1.1.</span> Assumptions:</h4>
|
||||
<div class="outline-text-4" id="text-13-1-1">
|
||||
<ul class="org-ul">
|
||||
<li>I have a Morello board that cannot run P2PRC</li>
|
||||
<li>The Morello has a local IP address (ex: 192.168.0.10)</li>
|
||||
@@ -1216,9 +1291,9 @@ as well look into custom tasks into the hetrogenous hardware.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-org21a29ac" class="outline-4">
|
||||
<h4 id="org21a29ac"><span class="section-number-4">12.1.2.</span> Set of interesting possible:</h4>
|
||||
<div class="outline-text-4" id="text-12-1-2">
|
||||
<div id="outline-container-orgb55e814" class="outline-4">
|
||||
<h4 id="orgb55e814"><span class="section-number-4">13.1.2.</span> Set of interesting possible:</h4>
|
||||
<div class="outline-text-4" id="text-13-1-2">
|
||||
<p>
|
||||
We build a cool set possibilities before and use this to build up the implementation
|
||||
plan.
|
||||
@@ -1234,9 +1309,9 @@ weight hypervisors.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-org4947494" class="outline-4">
|
||||
<h4 id="org4947494"><span class="section-number-4">12.1.3.</span> Implementation</h4>
|
||||
<div class="outline-text-4" id="text-12-1-3">
|
||||
<div id="outline-container-org7855189" class="outline-4">
|
||||
<h4 id="org7855189"><span class="section-number-4">13.1.3.</span> Implementation</h4>
|
||||
<div class="outline-text-4" id="text-13-1-3">
|
||||
<ul class="org-ul">
|
||||
<li>To use implementations similar to <a href="https://linux.die.net/man/1/socat">socat</a> 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.</li>
|
||||
@@ -1249,7 +1324,7 @@ other nodes can access the Morello board who have permission access.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<div id="orgf818690" class="figure">
|
||||
<div id="orgd955246" class="figure">
|
||||
<p><img src="./images/P2PRCRemoteNodes.png" alt="P2PRCRemoteNodes.png" />
|
||||
</p>
|
||||
<p><span class="figure-number">Figure 1: </span>Implementation idea (To be improved upon)</p>
|
||||
@@ -1261,7 +1336,7 @@ other nodes can access the Morello board who have permission access.</li>
|
||||
</div>
|
||||
<div id="postamble" class="status">
|
||||
<p class="author">Author: Akilan</p>
|
||||
<p class="date">Created: 2025-04-28 Mon 23:14</p>
|
||||
<p class="date">Created: 2025-05-30 Fri 18:05</p>
|
||||
<p class="validation"><a href="https://validator.w3.org/check?uri=referer">Validate</a></p>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
@@ -690,18 +690,28 @@ configuration file was generated using JSON format.
|
||||
|
||||
#+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",
|
||||
"DockerContainers": "/Users/akilan/Documents/p2p-rendering-computation/server/docker/containers/",
|
||||
"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",
|
||||
"IPV6Address": "",
|
||||
"PluginPath": "/Users/akilan/Documents/p2p-rendering-computation/plugin/deploy",
|
||||
"TrackContainersPath": "/Users/akilan/Documents/p2p-rendering-computation/client/trackcontainers/trackcontainers.json",
|
||||
"ServerPort": "8088",
|
||||
"ProxyPort": "",
|
||||
"GroupTrackContainersPath": "/Users/akilan/Documents/p2p-rendering-computation/client/trackcontainers/grouptrackcontainers.json",
|
||||
"FRPServerPort": "True",
|
||||
"BehindNAT": "True",
|
||||
"FRPServerPort": 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
|
||||
}
|
||||
#+end_src
|
||||
@@ -783,10 +793,48 @@ func main() {
|
||||
}
|
||||
}
|
||||
#+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
|
||||
** Self host within 5 minutes any program
|
||||
|
||||
|
||||
114
Simulation/simulation.sh
Normal file
114
Simulation/simulation.sh
Normal file
@@ -0,0 +1,114 @@
|
||||
# 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
|
||||
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"
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
# ---------------- Work flow test ---------------
|
||||
|
||||
# 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
|
||||
@@ -1,109 +1,108 @@
|
||||
package abstractions
|
||||
|
||||
import "C"
|
||||
import (
|
||||
"github.com/Akilan1999/p2p-rendering-computation/client"
|
||||
"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/p2p"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/server"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/server/docker"
|
||||
"github.com/gin-gonic/gin"
|
||||
"os"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/client"
|
||||
"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/p2p"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/server"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/server/docker"
|
||||
"github.com/gin-gonic/gin"
|
||||
"os"
|
||||
)
|
||||
|
||||
// Init Initialises p2prc
|
||||
func Init(customConfig interface{}) (config *Config.Config, err error) {
|
||||
|
||||
// Get config file path
|
||||
// Checks P2PRC path initially
|
||||
// - Get PATH if environment varaible
|
||||
path, err := Config.GetPathP2PRC("P2PRC")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
// check if the config file exists
|
||||
if _, err = os.Stat(path + "config.json"); err != nil {
|
||||
// Initialize with base p2prc config files
|
||||
// set the config file with default paths
|
||||
config, err = generate.SetDefaults("P2PRC", false, customConfig, false)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
// If the configs are available then use them over generating new ones.
|
||||
config, err = Config.ConfigInit(nil, nil)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
// Get config file path
|
||||
// Checks P2PRC path initially
|
||||
// - Get PATH if environment varaible
|
||||
path, err := Config.GetPathP2PRC("P2PRC")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
// check if the config file exists
|
||||
if _, err = os.Stat(path + "config.json"); err != nil {
|
||||
// Initialize with base p2prc config files
|
||||
// set the config file with default paths
|
||||
config, err = generate.SetDefaults("P2PRC", false, customConfig, false)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
// If the configs are available then use them over generating new ones.
|
||||
config, err = Config.ConfigInit(nil, nil)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
return
|
||||
}
|
||||
|
||||
// Start p2prc in a server mode
|
||||
func Start() (*gin.Engine, error) {
|
||||
engine, err := server.Server()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return engine, nil
|
||||
engine, err := server.Server()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return engine, nil
|
||||
}
|
||||
|
||||
// MapPort Creates a reverse proxy connection and maps the appropriate port
|
||||
func MapPort(port string, domainName string, serverAddress string) (response *client.ResponseMAPPort, err error) {
|
||||
response, err = client.MAPPort(port, domainName, serverAddress)
|
||||
return
|
||||
response, err = client.MAPPort(port, domainName, serverAddress)
|
||||
return
|
||||
}
|
||||
|
||||
// StartContainer Starts docker container on the remote machine
|
||||
func StartContainer(IP string) (container *docker.DockerVM, err error) {
|
||||
container, err = client.StartContainer(IP, 0, false, "", "")
|
||||
return
|
||||
container, err = client.StartContainer(IP, 0, false, "", "")
|
||||
return
|
||||
}
|
||||
|
||||
// RemoveContainer Removes docker container based on the IP address and ID
|
||||
// provided
|
||||
func RemoveContainer(IP string, ID string) error {
|
||||
return client.RemoveContianer(IP, ID)
|
||||
return client.RemoveContianer(IP, ID)
|
||||
}
|
||||
|
||||
// GetSpecs Get spec information about the remote server
|
||||
func GetSpecs(IP string) (specs *server.SysInfo, err error) {
|
||||
specs, err = client.GetSpecs(IP)
|
||||
return
|
||||
specs, err = client.GetSpecs(IP)
|
||||
return
|
||||
}
|
||||
|
||||
// ViewIPTable View information of nodes in the network
|
||||
func ViewIPTable() (table *p2p.IpAddresses, err error) {
|
||||
table, err = p2p.ReadIpTable()
|
||||
return
|
||||
table, err = p2p.ReadIpTable()
|
||||
return
|
||||
}
|
||||
|
||||
// UpdateIPTable Force updates IP tables based on new
|
||||
// new nodes discovered in the network
|
||||
func UpdateIPTable() (err error) {
|
||||
return clientIPTable.UpdateIpTableListClient()
|
||||
return clientIPTable.UpdateIpTableListClient()
|
||||
}
|
||||
|
||||
// AddCustomInformation allows to pass custom information
|
||||
// through the network to which can be listened on
|
||||
// all peers in the network to execute a task.
|
||||
func AddCustomInformation(information string) error {
|
||||
return clientIPTable.AddCustomInformationToIPTable(information)
|
||||
return clientIPTable.AddCustomInformationToIPTable(information)
|
||||
}
|
||||
|
||||
// AddRootNode Adds root node to the network by using defaults except for
|
||||
// ip address and port no. Supports only IPV4 as of now.
|
||||
func AddRootNode(rootIP string, portNo string) error {
|
||||
var rootNode []p2p.IpAddress
|
||||
var rootNode []p2p.IpAddress
|
||||
|
||||
rootNode = append(rootNode, p2p.IpAddress{
|
||||
Name: "",
|
||||
Ipv4: rootIP,
|
||||
ServerPort: portNo,
|
||||
NAT: false,
|
||||
})
|
||||
return generate.GenerateIPTableFile(rootNode)
|
||||
rootNode = append(rootNode, p2p.IpAddress{
|
||||
Name: "",
|
||||
Ipv4: rootIP,
|
||||
ServerPort: portNo,
|
||||
NAT: false,
|
||||
})
|
||||
return generate.GenerateIPTableFile(rootNode)
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
package clientIPTable
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/config"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/p2p"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
"os"
|
||||
"sync"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/config"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/p2p"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
"os"
|
||||
"sync"
|
||||
)
|
||||
|
||||
var mu sync.Mutex
|
||||
@@ -18,146 +18,147 @@ var mu sync.Mutex
|
||||
// UpdateIpTable Does the following to update it's IP table
|
||||
func UpdateIpTable(IpAddress string, serverPort string, wg *sync.WaitGroup) error {
|
||||
|
||||
config, err := config.ConfigInit(nil, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
config, err := config.ConfigInit(nil, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
client := http.Client{}
|
||||
client := http.Client{}
|
||||
|
||||
var resp []byte
|
||||
var resp []byte
|
||||
|
||||
version := p2p.Ip4or6(IpAddress)
|
||||
if version == "version 6" {
|
||||
resp, err = UploadMultipartFile(client, "http://["+IpAddress+"]:"+serverPort+"/IpTable", "json", config.IPTable)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
resp, err = UploadMultipartFile(client, "http://"+IpAddress+":"+serverPort+"/IpTable", "json", config.IPTable)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
version := p2p.Ip4or6(IpAddress)
|
||||
if version == "version 6" {
|
||||
resp, err = UploadMultipartFile(client, "http://["+IpAddress+"]:"+serverPort+"/IpTable", "json", config.IPTable)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
resp, err = UploadMultipartFile(client, "http://"+IpAddress+":"+serverPort+"/IpTable", "json", config.IPTable)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if resp == nil {
|
||||
return nil
|
||||
}
|
||||
if resp == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
//resp, err := SendPostRequest("http://"+IpAddress+":8088/IpTable",
|
||||
// config.IPTable,
|
||||
// "json")
|
||||
//
|
||||
//if err != nil {
|
||||
// return err
|
||||
//}
|
||||
//resp, err := SendPostRequest("http://"+IpAddress+":8088/IpTable",
|
||||
// config.IPTable,
|
||||
// "json")
|
||||
//
|
||||
//if err != nil {
|
||||
// return err
|
||||
//}
|
||||
|
||||
var ipStruct p2p.IpAddresses
|
||||
json.Unmarshal(resp, &ipStruct)
|
||||
var ipStruct p2p.IpAddresses
|
||||
json.Unmarshal(resp, &ipStruct)
|
||||
|
||||
// Updates IP table based on information provided
|
||||
// by the server
|
||||
if len(ipStruct.IpAddress) > 0 {
|
||||
err = ipStruct.SpeedTestUpdatedIPTable()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
// Updates IP table based on information provided
|
||||
// by the server
|
||||
if len(ipStruct.IpAddress) > 0 {
|
||||
err = ipStruct.SpeedTestUpdatedIPTable()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// Not required to update IP table as speed test updates the IP Table
|
||||
//err = ipStruct.WriteIpTable()
|
||||
//if err != nil {
|
||||
// return err
|
||||
//}
|
||||
// Not required to update IP table as speed test updates the IP Table
|
||||
//err = ipStruct.WriteIpTable()
|
||||
//if err != nil {
|
||||
// return err
|
||||
//}
|
||||
|
||||
wg.Done()
|
||||
wg.Done()
|
||||
|
||||
return nil
|
||||
return nil
|
||||
}
|
||||
|
||||
// UpdateIpTableListClient updates IP tables (Default 3 hops) based on server information available
|
||||
// on the ip tables
|
||||
func UpdateIpTableListClient() error {
|
||||
// Get config information
|
||||
Config, err := config.ConfigInit(nil, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// Get config information
|
||||
Config, err := config.ConfigInit(nil, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Ensure that the IP Table has Node pingable
|
||||
err = p2p.LocalSpeedTestIpTable()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// Ensure that the IP Table has Node pingable
|
||||
err = p2p.LocalSpeedTestIpTable()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// IP addresses to not append to struct due to
|
||||
// duplication
|
||||
// IP addresses to not append to struct due to
|
||||
// duplication
|
||||
|
||||
Addresses, err := p2p.ReadIpTable()
|
||||
var DoNotRead p2p.IpAddresses
|
||||
Addresses, err := p2p.ReadIpTable()
|
||||
var DoNotRead p2p.IpAddresses
|
||||
|
||||
currentIPV4, err := p2p.CurrentPublicIP()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
currentIPV4, err := p2p.CurrentPublicIP()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var w sync.WaitGroup
|
||||
var w sync.WaitGroup
|
||||
|
||||
// Run loop 2 times
|
||||
for i := 0; i < 2; i++ {
|
||||
// Gets information from IP table
|
||||
Addresses, err = p2p.ReadIpTable()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// Run loop 2 times
|
||||
for i := 0; i < 2; i++ {
|
||||
// Gets information from IP table
|
||||
Addresses, err = p2p.ReadIpTable()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
//DoNotRead.IpAddress = append(DoNotRead.IpAddress, PublicIP)
|
||||
//DoNotRead.IpAddress = append(DoNotRead.IpAddress, PublicIP)
|
||||
|
||||
// Updates IP table based on server IP table
|
||||
for j := range Addresses.IpAddress {
|
||||
// Updates IP table based on server IP table
|
||||
for j := range Addresses.IpAddress {
|
||||
|
||||
Exists := false
|
||||
// If the address is local then add to the local list
|
||||
if currentIPV4 == Addresses.IpAddress[j].Ipv4 && Addresses.IpAddress[j].ServerPort == Config.ServerPort {
|
||||
Exists = true
|
||||
}
|
||||
Exists := false
|
||||
// If the address is local then add to the local list
|
||||
if (currentIPV4 == Addresses.IpAddress[j].Ipv4 && !Config.Test) && Addresses.IpAddress[j].ServerPort == Config.ServerPort {
|
||||
Exists = true
|
||||
}
|
||||
|
||||
// Check if IP addresses is there in the struct DoNotRead
|
||||
for k := range DoNotRead.IpAddress {
|
||||
if (DoNotRead.IpAddress[k].Ipv4 == Addresses.IpAddress[j].Ipv4 && DoNotRead.IpAddress[k].ServerPort == Addresses.IpAddress[j].ServerPort) || (DoNotRead.IpAddress[k].Ipv6 != "" && Addresses.IpAddress[j].Ipv6 == DoNotRead.IpAddress[k].Ipv6) {
|
||||
Exists = true
|
||||
break
|
||||
}
|
||||
}
|
||||
// Check if IP addresses is there in the struct DoNotRead
|
||||
for k := range DoNotRead.IpAddress {
|
||||
if (DoNotRead.IpAddress[k].Ipv4 == Addresses.IpAddress[j].Ipv4 && DoNotRead.IpAddress[k].ServerPort == Addresses.IpAddress[j].ServerPort) || (DoNotRead.IpAddress[k].Ipv6 != "" && Addresses.IpAddress[j].Ipv6 == DoNotRead.IpAddress[k].Ipv6) {
|
||||
Exists = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// If the struct exists then continues
|
||||
if Exists {
|
||||
continue
|
||||
}
|
||||
// If the struct exists then continues
|
||||
if Exists {
|
||||
continue
|
||||
}
|
||||
|
||||
w.Add(1)
|
||||
if Addresses.IpAddress[j].Ipv6 != "" {
|
||||
go UpdateIpTable(Addresses.IpAddress[j].Ipv6, Addresses.IpAddress[j].ServerPort, &w)
|
||||
} else if Addresses.IpAddress[j].Ipv4 != currentIPV4 {
|
||||
go UpdateIpTable(Addresses.IpAddress[j].Ipv4, Addresses.IpAddress[j].ServerPort, &w)
|
||||
}
|
||||
w.Wait()
|
||||
w.Add(1)
|
||||
//if Addresses.IpAddress[j].Ipv6 != "" {
|
||||
// go UpdateIpTable(Addresses.IpAddress[j].Ipv6, Addresses.IpAddress[j].ServerPort, &w)
|
||||
//} 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)
|
||||
w.Wait()
|
||||
|
||||
//Appends server1 IP address to variable DoNotRead
|
||||
DoNotRead.IpAddress = append(DoNotRead.IpAddress, Addresses.IpAddress[j])
|
||||
}
|
||||
}
|
||||
//Appends server1 IP address to variable DoNotRead
|
||||
DoNotRead.IpAddress = append(DoNotRead.IpAddress, Addresses.IpAddress[j])
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
return nil
|
||||
}
|
||||
|
||||
func RemoveOfflineNodes() error {
|
||||
// Ensure that the IP Table has Node pingable
|
||||
err := p2p.LocalSpeedTestIpTable()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
// Ensure that the IP Table has Node pingable
|
||||
err := p2p.LocalSpeedTestIpTable()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// SendPostRequest Sends a file as a
|
||||
@@ -207,58 +208,58 @@ func RemoveOfflineNodes() error {
|
||||
//}
|
||||
|
||||
func UploadMultipartFile(client http.Client, uri, key, path string) ([]byte, error) {
|
||||
body, writer := io.Pipe()
|
||||
body, writer := io.Pipe()
|
||||
|
||||
req, err := http.NewRequest(http.MethodPost, uri, body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req, err := http.NewRequest(http.MethodPost, uri, body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
mwriter := multipart.NewWriter(writer)
|
||||
req.Header.Add("Content-Type", mwriter.FormDataContentType())
|
||||
mwriter := multipart.NewWriter(writer)
|
||||
req.Header.Add("Content-Type", mwriter.FormDataContentType())
|
||||
|
||||
errchan := make(chan error)
|
||||
errchan := make(chan error)
|
||||
|
||||
go func() {
|
||||
defer close(errchan)
|
||||
defer writer.Close()
|
||||
defer mwriter.Close()
|
||||
go func() {
|
||||
defer close(errchan)
|
||||
defer writer.Close()
|
||||
defer mwriter.Close()
|
||||
|
||||
w, err := mwriter.CreateFormFile(key, path)
|
||||
if err != nil {
|
||||
errchan <- err
|
||||
return
|
||||
}
|
||||
w, err := mwriter.CreateFormFile(key, path)
|
||||
if err != nil {
|
||||
errchan <- err
|
||||
return
|
||||
}
|
||||
|
||||
in, err := os.Open(path)
|
||||
if err != nil {
|
||||
errchan <- err
|
||||
return
|
||||
}
|
||||
defer in.Close()
|
||||
in, err := os.Open(path)
|
||||
if err != nil {
|
||||
errchan <- err
|
||||
return
|
||||
}
|
||||
defer in.Close()
|
||||
|
||||
if written, err := io.Copy(w, in); err != nil {
|
||||
errchan <- fmt.Errorf("error copying %s (%d bytes written): %v", path, written, err)
|
||||
return
|
||||
}
|
||||
if written, err := io.Copy(w, in); err != nil {
|
||||
errchan <- fmt.Errorf("error copying %s (%d bytes written): %v", path, written, err)
|
||||
return
|
||||
}
|
||||
|
||||
if err := mwriter.Close(); err != nil {
|
||||
errchan <- err
|
||||
return
|
||||
}
|
||||
}()
|
||||
if err := mwriter.Close(); err != nil {
|
||||
errchan <- err
|
||||
return
|
||||
}
|
||||
}()
|
||||
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
content, err := ioutil.ReadAll(resp.Body)
|
||||
content, err := ioutil.ReadAll(resp.Body)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return content, nil
|
||||
return content, nil
|
||||
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ type Config struct {
|
||||
KeyFile string
|
||||
BareMetal bool
|
||||
UnsafeMode bool
|
||||
Test bool
|
||||
CustomConfig interface{}
|
||||
//NetworkInterface string
|
||||
//NetworkInterfaceIPV6Index int
|
||||
|
||||
@@ -95,6 +95,7 @@ func SetDefaults(envName string, forceDefault bool, CustomConfig interface{}, No
|
||||
Defaults.PrivateKeyFile = defaultPath + "p2prc.privateKey"
|
||||
Defaults.BareMetal = false
|
||||
Defaults.UnsafeMode = false
|
||||
Defaults.Test = false
|
||||
|
||||
// Generate certificate files for SSL
|
||||
err = GenerateCertificate()
|
||||
|
||||
@@ -16,7 +16,6 @@ import (
|
||||
"crypto/x509"
|
||||
"crypto/x509/pkix"
|
||||
"encoding/pem"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/p2p"
|
||||
"log"
|
||||
"math/big"
|
||||
"net"
|
||||
@@ -54,7 +53,8 @@ func GenerateCertificate() error {
|
||||
|
||||
//flag.Parse()
|
||||
|
||||
host, err = p2p.CurrentPublicIP()
|
||||
//host, err = p2p.CurrentPublicIP()
|
||||
host = "0.0.0.0"
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
12
flake.lock
generated
12
flake.lock
generated
@@ -28,11 +28,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1733668782,
|
||||
"narHash": "sha256-tPsqU00FhgdFr0JiQUiBMgPVbl1jbPCY5gbFiJycL3I=",
|
||||
"lastModified": 1745875161,
|
||||
"narHash": "sha256-0YkWCS13jpoo3+sX/3kcgdxBNt1VZTmvF+FhZb4rFKI=",
|
||||
"owner": "nix-community",
|
||||
"repo": "gomod2nix",
|
||||
"rev": "514283ec89c39ad0079ff2f3b1437404e4cba608",
|
||||
"rev": "2cbd7fdd6eeab65c494cc426e18f4e4d2a5e35c0",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -43,11 +43,11 @@
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1735834308,
|
||||
"narHash": "sha256-dklw3AXr3OGO4/XT1Tu3Xz9n/we8GctZZ75ZWVqAVhk=",
|
||||
"lastModified": 1748460289,
|
||||
"narHash": "sha256-7doLyJBzCllvqX4gszYtmZUToxKvMUrg45EUWaUYmBg=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "6df24922a1400241dae323af55f30e4318a6ca65",
|
||||
"rev": "96ec055edbe5ee227f28cdbc3f1ddf1df5965102",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
||||
170
flake.nix
170
flake.nix
@@ -1,41 +1,147 @@
|
||||
{
|
||||
description = "P2PRC nix flake";
|
||||
|
||||
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
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";
|
||||
inputs = {
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils, gomod2nix }:
|
||||
(flake-utils.lib.eachDefaultSystem
|
||||
(system:
|
||||
let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [ gomod2nix.overlays.default ];
|
||||
};
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
|
||||
# pkgs = nixpkgs.legacyPackages.${system};
|
||||
flake-utils = {
|
||||
url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
||||
# 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.
|
||||
callPackage = pkgs.darwin.apple_sdk_11_0.callPackage or pkgs.callPackage;
|
||||
in
|
||||
{
|
||||
gomod2nix = {
|
||||
url = "github:nix-community/gomod2nix";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
inputs.flake-utils.follows = "flake-utils";
|
||||
};
|
||||
|
||||
packages.default = callPackage ./. { };
|
||||
};
|
||||
|
||||
devShells.default = pkgs.mkShell {
|
||||
buildInputs = with pkgs; [
|
||||
go
|
||||
gopls
|
||||
gotools
|
||||
go-tools
|
||||
gomod2nix.packages.${system}.default
|
||||
sqlite-interactive
|
||||
];
|
||||
};
|
||||
})
|
||||
);
|
||||
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.
|
||||
# This has no effect on other platforms.
|
||||
callPackage = pkgs.darwin.apple_sdk_11_0.callPackage or pkgs.callPackage;
|
||||
|
||||
p2prcDefault = callPackage ./. { };
|
||||
|
||||
in
|
||||
{
|
||||
packages.default = p2prcDefault;
|
||||
|
||||
devShells.default = pkgs.mkShell {
|
||||
buildInputs = with pkgs; [
|
||||
go
|
||||
gopls
|
||||
gotools
|
||||
go-tools
|
||||
gomod2nix.packages.${system}.default
|
||||
sqlite-interactive
|
||||
];
|
||||
};
|
||||
|
||||
packages.initHaskellProject = pkgs.writeShellApplication {
|
||||
name = "initHaskellProject";
|
||||
runtimeInputs = with pkgs; [
|
||||
ghc
|
||||
cabal2nix
|
||||
cabal-install
|
||||
git
|
||||
p2prcDefault
|
||||
];
|
||||
text =
|
||||
let
|
||||
# TODO: add the content for the main file
|
||||
# p2prcMainContent = availablePort: availableUrl:
|
||||
# ''
|
||||
# module Main where
|
||||
#
|
||||
# import P2PRC
|
||||
# ( runP2PRC
|
||||
# , MapPortRequest(MkMapPortRequest)
|
||||
# )
|
||||
#
|
||||
# main :: IO ()
|
||||
# main =
|
||||
# runP2PRC
|
||||
# ( MkMapPortRequest ${availablePort} "${availableUrl}.akilan.io"
|
||||
# )
|
||||
# '';
|
||||
#
|
||||
# mainFileContent = p2prcMainContent (builtins.toString 8080) "haskell";
|
||||
in
|
||||
''
|
||||
clear
|
||||
if [ "$#" -eq 0 ]; then
|
||||
echo "No arguments provided."
|
||||
echo "Please provide the name of your project"
|
||||
echo "nix run 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;
|
||||
cabal2nix . --shell > shell.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"
|
||||
|
||||
'';
|
||||
};
|
||||
}
|
||||
)) //
|
||||
{
|
||||
overlays = {
|
||||
default = coreOverlay;
|
||||
bindings = bindingsOverlay;
|
||||
};
|
||||
templates.haskell = {
|
||||
path = ./nix/templates/haskell;
|
||||
description = "Haskell Bindings to p2prc protocol";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
49
nix/templates/haskell/flake.nix
Normal file
49
nix/templates/haskell/flake.nix
Normal file
@@ -0,0 +1,49 @@
|
||||
{
|
||||
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:xecarlox94/p2p-rendering-computation?ref=nix";
|
||||
};
|
||||
|
||||
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
|
||||
];
|
||||
|
||||
# TODO: add cabal2nix shell command
|
||||
# cabal2nix . --shell > ./shell.nix
|
||||
shellHook = ''
|
||||
cabal2nix . > ./cabal.nix
|
||||
'';
|
||||
};
|
||||
}
|
||||
));
|
||||
}
|
||||
@@ -42,6 +42,8 @@ type IP struct {
|
||||
Query string
|
||||
}
|
||||
|
||||
var Test = false
|
||||
|
||||
// ReadIpTable Read data from Ip tables from json file
|
||||
func ReadIpTable() (*IpAddresses, error) {
|
||||
// Get Path from config
|
||||
@@ -178,6 +180,16 @@ func (table *IpAddresses) RemoveDuplicates() error {
|
||||
|
||||
// CurrentPublicIP Get Current Public IP address
|
||||
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/")
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
||||
@@ -312,6 +312,7 @@ func Server() (*gin.Engine, error) {
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
ProxyIpAddr.ServerPort = config.ServerPort
|
||||
ProxyIpAddr.Name = config.MachineName
|
||||
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