Merge pull request #127 from Akilan1999/add-root-node
Added feature to add root node
This commit is contained in:
@@ -2,11 +2,11 @@ package main
|
||||
|
||||
import "C"
|
||||
import (
|
||||
"encoding/json"
|
||||
"time"
|
||||
"encoding/json"
|
||||
"time"
|
||||
|
||||
"github.com/Akilan1999/p2p-rendering-computation/abstractions"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/p2p/frp"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/abstractions"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/p2p/frp"
|
||||
)
|
||||
|
||||
// The Client package where data-types
|
||||
@@ -18,20 +18,20 @@ import (
|
||||
|
||||
//export StartContainer
|
||||
func StartContainer(IP string) (output *C.char) {
|
||||
container, err := abstractions.StartContainer(IP)
|
||||
if err != nil {
|
||||
return C.CString(err.Error())
|
||||
}
|
||||
return ConvertStructToJSONString(container)
|
||||
container, err := abstractions.StartContainer(IP)
|
||||
if err != nil {
|
||||
return C.CString(err.Error())
|
||||
}
|
||||
return ConvertStructToJSONString(container)
|
||||
}
|
||||
|
||||
//export RemoveContainer
|
||||
func RemoveContainer(IP string, ID string) (output *C.char) {
|
||||
err := abstractions.RemoveContainer(IP, ID)
|
||||
if err != nil {
|
||||
return C.CString(err.Error())
|
||||
}
|
||||
return C.CString("Success")
|
||||
err := abstractions.RemoveContainer(IP, ID)
|
||||
if err != nil {
|
||||
return C.CString(err.Error())
|
||||
}
|
||||
return C.CString("Success")
|
||||
}
|
||||
|
||||
// --------------------------------- Plugin Control ----------------------------------------
|
||||
@@ -77,20 +77,20 @@ func RemoveContainer(IP string, ID string) (output *C.char) {
|
||||
|
||||
//export GetSpecs
|
||||
func GetSpecs(IP string) (output *C.char) {
|
||||
specs, err := abstractions.GetSpecs(IP)
|
||||
if err != nil {
|
||||
return C.CString(err.Error())
|
||||
}
|
||||
return ConvertStructToJSONString(specs)
|
||||
specs, err := abstractions.GetSpecs(IP)
|
||||
if err != nil {
|
||||
return C.CString(err.Error())
|
||||
}
|
||||
return ConvertStructToJSONString(specs)
|
||||
}
|
||||
|
||||
//export Init
|
||||
func Init(customConfig string) (output *C.char) {
|
||||
init, err := abstractions.Init(customConfig)
|
||||
if err != nil {
|
||||
return C.CString(err.Error())
|
||||
}
|
||||
return ConvertStructToJSONString(init)
|
||||
init, err := abstractions.Init(customConfig)
|
||||
if err != nil {
|
||||
return C.CString(err.Error())
|
||||
}
|
||||
return ConvertStructToJSONString(init)
|
||||
|
||||
}
|
||||
|
||||
@@ -98,81 +98,90 @@ func Init(customConfig string) (output *C.char) {
|
||||
|
||||
//export ViewIPTable
|
||||
func ViewIPTable() (output *C.char) {
|
||||
table, err := abstractions.ViewIPTable()
|
||||
if err != nil {
|
||||
return C.CString(err.Error())
|
||||
}
|
||||
return ConvertStructToJSONString(table)
|
||||
table, err := abstractions.ViewIPTable()
|
||||
if err != nil {
|
||||
return C.CString(err.Error())
|
||||
}
|
||||
return ConvertStructToJSONString(table)
|
||||
}
|
||||
|
||||
//export UpdateIPTable
|
||||
func UpdateIPTable() (output *C.char) {
|
||||
err := abstractions.UpdateIPTable()
|
||||
if err != nil {
|
||||
return C.CString(err.Error())
|
||||
}
|
||||
return C.CString("Success")
|
||||
err := abstractions.UpdateIPTable()
|
||||
if err != nil {
|
||||
return C.CString(err.Error())
|
||||
}
|
||||
return C.CString("Success")
|
||||
}
|
||||
|
||||
//export EscapeFirewall
|
||||
func EscapeFirewall(HostOutsideNATIP string, HostOutsideNATPort string, internalPort string) (output *C.char) {
|
||||
// Get free port from P2PRC server node
|
||||
serverPort, err := frp.GetFRPServerPort("http://" + HostOutsideNATIP + ":" + HostOutsideNATPort)
|
||||
// Get free port from P2PRC server node
|
||||
serverPort, err := frp.GetFRPServerPort("http://" + HostOutsideNATIP + ":" + HostOutsideNATPort)
|
||||
|
||||
if err != nil {
|
||||
return C.CString(err.Error())
|
||||
}
|
||||
if err != nil {
|
||||
return C.CString(err.Error())
|
||||
}
|
||||
|
||||
time.Sleep(5 * time.Second)
|
||||
time.Sleep(5 * time.Second)
|
||||
|
||||
ExposedPort, err := frp.StartFRPClientForServer(HostOutsideNATIP+":"+HostOutsideNATPort, serverPort, internalPort, "")
|
||||
if err != nil {
|
||||
return C.CString(err.Error())
|
||||
}
|
||||
ExposedPort, err := frp.StartFRPClientForServer(HostOutsideNATIP+":"+HostOutsideNATPort, serverPort, internalPort, "")
|
||||
if err != nil {
|
||||
return C.CString(err.Error())
|
||||
}
|
||||
|
||||
return C.CString(ExposedPort)
|
||||
return C.CString(ExposedPort)
|
||||
}
|
||||
|
||||
//export MapPort
|
||||
func MapPort(Port string, DomainName string, ServerAddress string) *C.char {
|
||||
Address, err := abstractions.MapPort(Port, DomainName, ServerAddress)
|
||||
if err != nil {
|
||||
return C.CString(err.Error())
|
||||
}
|
||||
return C.CString(Address.EntireAddress)
|
||||
Address, err := abstractions.MapPort(Port, DomainName, ServerAddress)
|
||||
if err != nil {
|
||||
return C.CString(err.Error())
|
||||
}
|
||||
return C.CString(Address.EntireAddress)
|
||||
}
|
||||
|
||||
//export CustomInformation
|
||||
func CustomInformation(CustomInformation string) *C.char {
|
||||
err := abstractions.AddCustomInformation(CustomInformation)
|
||||
if err != nil {
|
||||
return C.CString(err.Error())
|
||||
}
|
||||
return C.CString("Success")
|
||||
err := abstractions.AddCustomInformation(CustomInformation)
|
||||
if err != nil {
|
||||
return C.CString(err.Error())
|
||||
}
|
||||
return C.CString("Success")
|
||||
}
|
||||
|
||||
//export AddRootNode
|
||||
func AddRootNode(IP string, Port string) *C.char {
|
||||
err := abstractions.AddRootNode(IP, Port)
|
||||
if err != nil {
|
||||
return C.CString(err.Error())
|
||||
}
|
||||
return C.CString("Success")
|
||||
}
|
||||
|
||||
// --------------------------------- Controlling Server ----------------------------------------
|
||||
|
||||
//export Server
|
||||
func Server() (output *C.char) {
|
||||
_, err := abstractions.Start()
|
||||
if err != nil {
|
||||
return C.CString(err.Error())
|
||||
}
|
||||
_, err := abstractions.Start()
|
||||
if err != nil {
|
||||
return C.CString(err.Error())
|
||||
}
|
||||
|
||||
return ConvertStructToJSONString("")
|
||||
return ConvertStructToJSONString("")
|
||||
}
|
||||
|
||||
// --------------------------------- Helper Functions ----------------------------------------
|
||||
|
||||
func ConvertStructToJSONString(Struct interface{}) *C.char {
|
||||
jsonBytes, err := json.Marshal(Struct)
|
||||
if err != nil {
|
||||
return C.CString(err.Error())
|
||||
}
|
||||
jsonBytes, err := json.Marshal(Struct)
|
||||
if err != nil {
|
||||
return C.CString(err.Error())
|
||||
}
|
||||
|
||||
// Convert the JSON bytes to a string
|
||||
return C.CString(string(jsonBytes))
|
||||
// Convert the JSON bytes to a string
|
||||
return C.CString(string(jsonBytes))
|
||||
}
|
||||
|
||||
func main() {}
|
||||
|
||||
@@ -44,9 +44,9 @@ class Node:
|
||||
Upload: int
|
||||
ServerPort: str
|
||||
BareMetalSSHPort: str
|
||||
NAT: str
|
||||
NAT: bool
|
||||
EscapeImplementation: str
|
||||
ProxyServer: str
|
||||
ProxyServer: bool
|
||||
UnSafeMode: bool
|
||||
PublicKey: str
|
||||
CustomInformation: str
|
||||
@@ -98,6 +98,21 @@ def ListNodes():
|
||||
dat: IPAddress = dacite.from_dict(IPAddress,ipTableObject)
|
||||
return dat
|
||||
|
||||
# Add a root node to P2RRC and overwrites all other nodes.
|
||||
# To be only added before the network started and with
|
||||
# the intention of a fresh protocol.
|
||||
def AddRootNode(ip="", port="") -> bool:
|
||||
ip = go_string(c_char_p(ip.encode('utf-8')), len(ip))
|
||||
port = go_string(c_char_p(port.encode('utf-8')), len(port))
|
||||
|
||||
p2prc.AddRootNode.restype = c_char_p
|
||||
res = p2prc.AddRootNode(ip, port)
|
||||
if str(res).strip("b'") == "Success":
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
|
||||
# python function to pass-through custom
|
||||
# information to interpret which can be
|
||||
# interpreted as a DSL.
|
||||
|
||||
@@ -9,3 +9,6 @@ if __name__ == "__main__":
|
||||
# Add custom information to the network
|
||||
if AddCustomInformation("Test"):
|
||||
print("It worked")
|
||||
|
||||
if AddRootNode("0.0.0.0", "8081"):
|
||||
print("It worked for adding root node")
|
||||
|
||||
BIN
Docs/Colored-On-Light-Image.png
Normal file
BIN
Docs/Colored-On-Light-Image.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 276 KiB |
178
Docs/index.html
178
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-25 Fri 23:17 -->
|
||||
<!-- 2025-04-28 Mon 23:14 -->
|
||||
<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="#org9c37a3a">1. Guide through video</a>
|
||||
<li><a href="#org3cfeea9">1. Guide through video</a>
|
||||
<ul>
|
||||
<li>
|
||||
<ul>
|
||||
<li><a href="#org73ac1f8">1.0.1. The video below shows the setup and usage of P2PRC.</a></li>
|
||||
<li><a href="#orgf3f19a6">1.0.2. Source code: https://github.com/Akilan1999/p2p-rendering-computation</a></li>
|
||||
<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>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -78,7 +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="#org8aff015">4.0.20. MapPort and link to domain name</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>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -108,8 +109,8 @@
|
||||
</li>
|
||||
<li><a href="#current-languages-supported">6.3. Current languages supported</a>
|
||||
<ul>
|
||||
<li><a href="#orga857f83">6.3.1. Python</a></li>
|
||||
<li><a href="#orgf0d5243">6.3.2. Haskell</a></li>
|
||||
<li><a href="#org92a1e8c">6.3.1. Python</a></li>
|
||||
<li><a href="#org780e43b">6.3.2. Haskell</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -126,22 +127,22 @@
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#client-mode">10. Client mode</a></li>
|
||||
<li><a href="#orgefbf5e1">11. Blog posts</a>
|
||||
<li><a href="#org1b92827">11. Blog posts</a>
|
||||
<ul>
|
||||
<li><a href="#org0aff8a2">11.1. Self host within 5 minutes any program</a>
|
||||
<li><a href="#orgec8979c">11.1. Self host within 5 minutes any program</a>
|
||||
<ul>
|
||||
<li><a href="#orgc1cd454">11.1.1. 1. Find a program you want to run</a></li>
|
||||
<li><a href="#orgd03815a">11.1.1. 1. Find a program you want to run</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#org6a05ac1">12. Ideas for future potencial features</a>
|
||||
<li><a href="#orgb32e475">12. Ideas for future potencial features</a>
|
||||
<ul>
|
||||
<li><a href="#org2136819">12.1. To support hetrogenous set of Nodes that cannot run P2PRC</a>
|
||||
<li><a href="#org2666d00">12.1. To support hetrogenous set of Nodes that cannot run P2PRC</a>
|
||||
<ul>
|
||||
<li><a href="#org8f98161">12.1.1. Assumptions:</a></li>
|
||||
<li><a href="#org806bc11">12.1.2. Set of interesting possible:</a></li>
|
||||
<li><a href="#org2df764e">12.1.3. Implementation</a></li>
|
||||
<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>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -150,26 +151,26 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="org93c8684" class="figure">
|
||||
<p><img src="../artwork/p2prc-logos/Colored-On-Light-Image.png" alt="Colored-On-Light-Image.png" width="300px" />
|
||||
<div id="orgefb6d6c" class="figure">
|
||||
<p><img src="./Colored-On-Light-Image.png" alt="Colored-On-Light-Image.png" width="300px" />
|
||||
</p>
|
||||
</div>
|
||||
<div id="outline-container-org9c37a3a" class="outline-2">
|
||||
<h2 id="org9c37a3a"><span class="section-number-2">1.</span> Guide through video</h2>
|
||||
<div id="outline-container-org3cfeea9" class="outline-2">
|
||||
<h2 id="org3cfeea9"><span class="section-number-2">1.</span> Guide through video</h2>
|
||||
<div class="outline-text-2" id="text-1">
|
||||
</div>
|
||||
<div id="outline-container-org73ac1f8" class="outline-4">
|
||||
<h4 id="org73ac1f8"><span class="section-number-4">1.0.1.</span> The video below shows the setup and usage of P2PRC.</h4>
|
||||
<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 class="outline-text-4" id="text-1-0-1">
|
||||
|
||||
<div id="org1f2f6d2" class="figure">
|
||||
<div id="org863dfc7" 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-orgf3f19a6" class="outline-4">
|
||||
<h4 id="orgf3f19a6"><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-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>
|
||||
</div>
|
||||
<div id="outline-container-chapter1-introduction" class="outline-2">
|
||||
@@ -258,7 +259,7 @@ Go API to create and interact with the containers.
|
||||
to install docker GPU</a>
|
||||
</p>
|
||||
|
||||
<pre class="example" id="orgd9620d4">
|
||||
<pre class="example" id="orgfc326ea">
|
||||
// Do ensure that the docker command does not need sudo to run
|
||||
sudo chmod 666 /var/run/docker.sock
|
||||
</pre>
|
||||
@@ -272,7 +273,7 @@ To set up the internal dependencies and build the entire go code into a
|
||||
single binary
|
||||
</p>
|
||||
|
||||
<pre class="example" id="org1a7a29f">
|
||||
<pre class="example" id="org9abf859">
|
||||
make
|
||||
</pre>
|
||||
</div>
|
||||
@@ -284,7 +285,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="org0bf0b81">
|
||||
<pre class="example" id="org754bc46">
|
||||
.\install.bat
|
||||
</pre>
|
||||
</div>
|
||||
@@ -294,7 +295,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="orgabf26a3">
|
||||
<pre class="example" id="org06344db">
|
||||
export P2PRC=/<PATH>/p2p-rendering-computation
|
||||
export PATH=/<PATH>/p2p-rendering-computation:${PATH}
|
||||
</pre>
|
||||
@@ -303,14 +304,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="org2685522">
|
||||
<pre class="example" id="org189a0e9">
|
||||
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="orgac10245">
|
||||
<pre class="example" id="org705fb25">
|
||||
NAME:
|
||||
p2p-rendering-computation - p2p cli application to create and access VMs in other servers
|
||||
|
||||
@@ -372,7 +373,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="org282e2af">
|
||||
<pre class="example" id="org1be9ce7">
|
||||
p2prc -s
|
||||
</pre>
|
||||
</div>
|
||||
@@ -380,7 +381,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="org985433e">
|
||||
<pre class="example" id="org7c6080c">
|
||||
p2prc --specs=<ip address>
|
||||
</pre>
|
||||
</div>
|
||||
@@ -392,7 +393,7 @@ p2prc --specs=<ip address>
|
||||
use the <code>--gpu</code> if you know the other machine has a gpu.
|
||||
</p>
|
||||
|
||||
<pre class="example" id="org9d5f05e">
|
||||
<pre class="example" id="org96ebc97">
|
||||
p2prc --touch=<server ip address> -p <number of ports> --gpu
|
||||
</pre>
|
||||
</div>
|
||||
@@ -404,7 +405,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="org9e5bd7e">
|
||||
<pre class="example" id="org3a50a5b">
|
||||
p2prc --rm=<server ip address> --id=<docker container id>
|
||||
</pre>
|
||||
</div>
|
||||
@@ -412,7 +413,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="orgb1d5224">
|
||||
<pre class="example" id="orgd0b12dc">
|
||||
p2prc --as=<server ip address you want to add>
|
||||
</pre>
|
||||
</div>
|
||||
@@ -420,7 +421,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="org671a527">
|
||||
<pre class="example" id="org2b52762">
|
||||
p2prc --us
|
||||
</pre>
|
||||
</div>
|
||||
@@ -428,7 +429,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="org18aa560">
|
||||
<pre class="example" id="org9a40c4a">
|
||||
p2prc --ls
|
||||
</pre>
|
||||
</div>
|
||||
@@ -436,7 +437,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="orge4afb87">
|
||||
<pre class="example" id="orge766dd3">
|
||||
p2prc --ni
|
||||
</pre>
|
||||
</div>
|
||||
@@ -444,7 +445,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="orgb9767d1">
|
||||
<pre class="example" id="org9787c64">
|
||||
p2prc --tc
|
||||
</pre>
|
||||
</div>
|
||||
@@ -452,7 +453,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="orgc805e30">
|
||||
<pre class="example" id="org94b7a90">
|
||||
p2prc --plugin <plugin name> --id <container id or group id>
|
||||
</pre>
|
||||
</div>
|
||||
@@ -460,7 +461,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="orgaa0084e">
|
||||
<pre class="example" id="orge008a6c">
|
||||
p2prc --cgroup
|
||||
</pre>
|
||||
</div>
|
||||
@@ -468,7 +469,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="org25f0283">
|
||||
<pre class="example" id="org8598b18">
|
||||
p2prc --group <group id> --id <container id>
|
||||
</pre>
|
||||
</div>
|
||||
@@ -476,7 +477,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="org8abb354">
|
||||
<pre class="example" id="org5425a07">
|
||||
p2prc --groups
|
||||
</pre>
|
||||
</div>
|
||||
@@ -484,7 +485,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="org3a73cfe">
|
||||
<pre class="example" id="org187af36">
|
||||
p2prc --group <group id>
|
||||
</pre>
|
||||
</div>
|
||||
@@ -492,7 +493,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="orge983347">
|
||||
<pre class="example" id="orga4687ab">
|
||||
p2prc --rmcgroup --group <group id> --id <container id>
|
||||
</pre>
|
||||
</div>
|
||||
@@ -500,7 +501,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="org1a2d4d9">
|
||||
<pre class="example" id="orgf60b3a8">
|
||||
p2prc --rmgroup <group id>
|
||||
</pre>
|
||||
</div>
|
||||
@@ -508,7 +509,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="orgee7b538">
|
||||
<pre class="example" id="orgb9bee77">
|
||||
p2prc --pp <repo link>
|
||||
</pre>
|
||||
</div>
|
||||
@@ -516,7 +517,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="org380741b">
|
||||
<pre class="example" id="org2979ba1">
|
||||
p2prc --rp <plugin name>
|
||||
</pre>
|
||||
</div>
|
||||
@@ -524,28 +525,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="org3da0b46">
|
||||
<pre class="example" id="org3c1dba9">
|
||||
p2prc --amd "custom metadata"
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-org8aff015" class="outline-4">
|
||||
<h4 id="org8aff015"><span class="section-number-4">4.0.20.</span> MapPort and link to domain name</h4>
|
||||
<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 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="org971ad93">
|
||||
<pre class="example" id="org9d628c6">
|
||||
p2prc --mp <port no to map> --dn <domain name to link Mapped port against>
|
||||
</pre>
|
||||
</div>
|
||||
<ol class="org-ol">
|
||||
<li><a id="org0e256de"></a>MapPort in remote machine<br />
|
||||
<li><a id="org29021b1"></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="orgdc964c0">
|
||||
<pre class="example" id="orga1ff65e">
|
||||
p2prc --mp <port no to map> --dn <domain name to link Mapped port against> --ra <remote server address>
|
||||
</pre>
|
||||
|
||||
@@ -554,6 +555,19 @@ 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 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">
|
||||
p2prc --arn --ip <root node ip address> -p <root node port no>
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-p2p-module-implementation" class="outline-2">
|
||||
<h2 id="p2p-module-implementation"><span class="section-number-2">5.</span> P2P Module Implementation</h2>
|
||||
@@ -660,7 +674,7 @@ from the TURN server. The flow below describes the workflow.
|
||||
<li>Call <code>/FRPPort</code></li>
|
||||
</ul>
|
||||
|
||||
<pre class="example" id="org1216e2d">
|
||||
<pre class="example" id="org90a2001">
|
||||
http://<turn server ip>:<server port no>/FRPport
|
||||
</pre>
|
||||
|
||||
@@ -749,7 +763,7 @@ p2prc.h p2prc.so
|
||||
Below are a sample set of commands to open the bindings implementation.
|
||||
</p>
|
||||
|
||||
<pre class="example" id="org43e18ca">
|
||||
<pre class="example" id="orgb8690e2">
|
||||
# run
|
||||
cd Bindings/
|
||||
# list files
|
||||
@@ -837,7 +851,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="orgfc7fe39">
|
||||
<pre class="example" id="orgd0da451">
|
||||
func <Function name> (output *C.char) {
|
||||
<response>,<error> := <P2PRC function name>(<parameters if needed>)
|
||||
if <error> != nil {
|
||||
@@ -855,8 +869,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-orga857f83" class="outline-4">
|
||||
<h4 id="orga857f83"><span class="section-number-4">6.3.1.</span> Python</h4>
|
||||
<div id="outline-container-org92a1e8c" class="outline-4">
|
||||
<h4 id="org92a1e8c"><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">
|
||||
@@ -893,8 +907,8 @@ called from other programming languages.
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
<div id="outline-container-orgf0d5243" class="outline-4">
|
||||
<h4 id="orgf0d5243"><span class="section-number-4">6.3.2.</span> Haskell</h4>
|
||||
<div id="outline-container-org780e43b" class="outline-4">
|
||||
<h4 id="org780e43b"><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
|
||||
@@ -1006,7 +1020,7 @@ from the TURN server. The flow below describes the workflow.
|
||||
<li>Call <code>/FRPPort</code></li>
|
||||
</ul>
|
||||
|
||||
<pre class="example" id="org19abd64">
|
||||
<pre class="example" id="org910dfb2">
|
||||
http://<turn server ip>:<server port no>/FRPport
|
||||
</pre>
|
||||
|
||||
@@ -1037,12 +1051,12 @@ func main() {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-orgefbf5e1" class="outline-2">
|
||||
<h2 id="orgefbf5e1"><span class="section-number-2">11.</span> Blog posts</h2>
|
||||
<div id="outline-container-org1b92827" class="outline-2">
|
||||
<h2 id="org1b92827"><span class="section-number-2">11.</span> Blog posts</h2>
|
||||
<div class="outline-text-2" id="text-11">
|
||||
</div>
|
||||
<div id="outline-container-org0aff8a2" class="outline-3">
|
||||
<h3 id="org0aff8a2"><span class="section-number-3">11.1.</span> Self host within 5 minutes any program</h3>
|
||||
<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 class="outline-text-3" id="text-11-1">
|
||||
<ul class="org-ul">
|
||||
<li>Author: <a href="http://akilan.io/">Akilan Selvacoumar</a></li>
|
||||
@@ -1054,7 +1068,7 @@ func main() {
|
||||
<li>Video tutorial:</li>
|
||||
</ul>
|
||||
|
||||
<div id="org96fc14a" class="figure">
|
||||
<div id="org756aa28" 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>
|
||||
@@ -1064,8 +1078,8 @@ 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-orgc1cd454" class="outline-4">
|
||||
<h4 id="orgc1cd454"><span class="section-number-4">11.1.1.</span> 1. Find a program you want to run</h4>
|
||||
<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">
|
||||
<p>
|
||||
Let's try to setup a really easy program (Let's do with Linkwarden
|
||||
@@ -1074,7 +1088,7 @@ compose installed on your local machine.
|
||||
</p>
|
||||
</div>
|
||||
<ol class="org-ol">
|
||||
<li><a id="org29864ce"></a>Let's run Linkwarden using docker compose and P2PRC<br />
|
||||
<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">
|
||||
<p>
|
||||
<a href="https://docs.linkwarden.app/self-hosting/installation">Installation instructions</a>:
|
||||
@@ -1163,16 +1177,16 @@ ex: <a href="https://linkwarden.akilan.io">https://linkwarden.akilan.io</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-org6a05ac1" class="outline-2">
|
||||
<h2 id="org6a05ac1"><span class="section-number-2">12.</span> Ideas for future potencial features</h2>
|
||||
<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">
|
||||
<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-org2136819" class="outline-3">
|
||||
<h3 id="org2136819"><span class="section-number-3">12.1.</span> To support hetrogenous set of Nodes that cannot run P2PRC</h3>
|
||||
<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">
|
||||
<p>
|
||||
This stems from a personal issue I have when doing research
|
||||
@@ -1188,8 +1202,8 @@ and would introduce a new layer fault tolerance within a local
|
||||
network nodes.
|
||||
</p>
|
||||
</div>
|
||||
<div id="outline-container-org8f98161" class="outline-4">
|
||||
<h4 id="org8f98161"><span class="section-number-4">12.1.1.</span> Assumptions:</h4>
|
||||
<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">
|
||||
<ul class="org-ul">
|
||||
<li>I have a Morello board that cannot run P2PRC</li>
|
||||
@@ -1202,8 +1216,8 @@ as well look into custom tasks into the hetrogenous hardware.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-org806bc11" class="outline-4">
|
||||
<h4 id="org806bc11"><span class="section-number-4">12.1.2.</span> Set of interesting possible:</h4>
|
||||
<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">
|
||||
<p>
|
||||
We build a cool set possibilities before and use this to build up the implementation
|
||||
@@ -1220,8 +1234,8 @@ weight hypervisors.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-org2df764e" class="outline-4">
|
||||
<h4 id="org2df764e"><span class="section-number-4">12.1.3.</span> Implementation</h4>
|
||||
<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">
|
||||
<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
|
||||
@@ -1235,7 +1249,7 @@ other nodes can access the Morello board who have permission access.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<div id="orga7ceb3b" class="figure">
|
||||
<div id="orgf818690" 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>
|
||||
@@ -1247,7 +1261,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-25 Fri 23:17</p>
|
||||
<p class="date">Created: 2025-04-28 Mon 23:14</p>
|
||||
<p class="validation"><a href="https://validator.w3.org/check?uri=referer">Validate</a></p>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="style.css"/>
|
||||
|
||||
#+attr_html: :width 300px
|
||||
[[../artwork/p2prc-logos/Colored-On-Light-Image.png]]
|
||||
[[./Colored-On-Light-Image.png]]
|
||||
|
||||
* Guide through video
|
||||
*** The video below shows the setup and usage of P2PRC.
|
||||
@@ -356,6 +356,14 @@ p2prc --mp <port no to map> --dn <domain name to link Mapped port against> --ra
|
||||
|
||||
--------------
|
||||
|
||||
*** Add root node
|
||||
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.
|
||||
#+begin_example
|
||||
p2prc --arn --ip <root node ip address> -p <root node port no>
|
||||
#+end_example
|
||||
|
||||
* P2P Module Implementation
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: p2p-module-implementation
|
||||
|
||||
@@ -2,94 +2,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
|
||||
|
||||
rootNode = append(rootNode, p2p.IpAddress{
|
||||
Name: "",
|
||||
Ipv4: rootIP,
|
||||
ServerPort: portNo,
|
||||
NAT: false,
|
||||
})
|
||||
return generate.GenerateIPTableFile(rootNode)
|
||||
}
|
||||
|
||||
130
cmd/action.go
130
cmd/action.go
@@ -2,6 +2,7 @@ package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/abstractions"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/client"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/client/clientIPTable"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/config/generate"
|
||||
@@ -87,11 +88,7 @@ var CliAction = func(ctx *cli.Context) error {
|
||||
// Displays all images available on the server side
|
||||
if ViewImages != "" {
|
||||
imageRes, err := client.ViewContainers(ViewImages)
|
||||
|
||||
if err != nil {
|
||||
fmt.Print(err)
|
||||
}
|
||||
client.PrettyPrint(imageRes)
|
||||
standardOutput(err, imageRes)
|
||||
}
|
||||
|
||||
// Function called to stop and remove server from Docker
|
||||
@@ -100,9 +97,7 @@ var CliAction = func(ctx *cli.Context) error {
|
||||
fmt.Println("provide container ID via --ID or --id")
|
||||
} else {
|
||||
err := client.RemoveContianer(RemoveVM, ID)
|
||||
if err != nil {
|
||||
fmt.Print(err)
|
||||
}
|
||||
standardOutput(err, nil)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,58 +114,40 @@ var CliAction = func(ctx *cli.Context) error {
|
||||
// Calls function to do Api call to start the container on the server side
|
||||
imageRes, err := client.StartContainer(CreateVM, PortsInt, GPU, ContainerName, BaseImage)
|
||||
|
||||
if err != nil {
|
||||
fmt.Print(err)
|
||||
}
|
||||
client.PrettyPrint(imageRes)
|
||||
standardOutput(err, imageRes)
|
||||
}
|
||||
|
||||
//Call if specs flag is called
|
||||
if Specs != "" {
|
||||
specs, err := client.GetSpecs(Specs)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Pretty print
|
||||
client.PrettyPrint(specs)
|
||||
standardOutput(err, specs)
|
||||
}
|
||||
|
||||
//Sets default paths to the config file
|
||||
if SetDefaultConfig {
|
||||
_, err := generate.SetDefaults("P2PRC", false, nil, false)
|
||||
if err != nil {
|
||||
fmt.Print(err)
|
||||
}
|
||||
standardOutput(err, nil)
|
||||
}
|
||||
|
||||
//If the network interface flag is called
|
||||
// Then all the network interfaces are displayed
|
||||
if NetworkInterface {
|
||||
err := p2p.ViewNetworkInterface()
|
||||
if err != nil {
|
||||
fmt.Print(err)
|
||||
}
|
||||
standardOutput(err, nil)
|
||||
}
|
||||
|
||||
// If the view plugin flag is called then display all
|
||||
// plugins available
|
||||
if ViewPlugin {
|
||||
plugins, err := plugin.DetectPlugins()
|
||||
if err != nil {
|
||||
fmt.Print(err)
|
||||
}
|
||||
client.PrettyPrint(plugins)
|
||||
standardOutput(err, plugins)
|
||||
}
|
||||
|
||||
// If the flag Tracked Container is called or the flag
|
||||
// --tc
|
||||
if TrackedContainers {
|
||||
err, trackedContainers := client.ViewTrackedContainers()
|
||||
if err != nil {
|
||||
fmt.Print(err)
|
||||
}
|
||||
client.PrettyPrint(trackedContainers)
|
||||
standardOutput(err, trackedContainers)
|
||||
}
|
||||
|
||||
//Executing plugin when the plugin flag is called
|
||||
@@ -179,14 +156,11 @@ var CliAction = func(ctx *cli.Context) error {
|
||||
// To execute plugin requires the container ID or group ID provided when being executed
|
||||
if ID != "" {
|
||||
err := plugin.CheckRunPlugin(ExecutePlugin, ID)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
} else {
|
||||
fmt.Println("Success")
|
||||
}
|
||||
} else {
|
||||
fmt.Println("provide container ID via --ID or --id")
|
||||
standardOutput(err, nil)
|
||||
}
|
||||
//else {
|
||||
// fmt.Println("provide container ID via --ID or --id")
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
@@ -194,10 +168,7 @@ var CliAction = func(ctx *cli.Context) error {
|
||||
// Creates new group and outputs JSON file
|
||||
if CreateGroup {
|
||||
group, err := client.CreateGroup()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
client.PrettyPrint(group)
|
||||
standardOutput(err, group)
|
||||
}
|
||||
|
||||
// Actions to be performed when the
|
||||
@@ -208,26 +179,14 @@ var CliAction = func(ctx *cli.Context) error {
|
||||
// --rmcgroup --id <contianer id>
|
||||
if RemoveContainerGroup && ID != "" {
|
||||
group, err := client.RemoveContainerGroup(ID, Group)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
} else {
|
||||
client.PrettyPrint(group)
|
||||
}
|
||||
standardOutput(err, group)
|
||||
} else if ID != "" { // Add container to group based on group ID provided
|
||||
// --id <Container ID>
|
||||
group, err := client.AddContainerToGroup(ID, Group)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
} else {
|
||||
client.PrettyPrint(group)
|
||||
}
|
||||
standardOutput(err, group)
|
||||
} else { // View all information about current group
|
||||
group, err := client.GetGroup(Group)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
} else {
|
||||
client.PrettyPrint(group)
|
||||
}
|
||||
standardOutput(err, group)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,63 +195,52 @@ var CliAction = func(ctx *cli.Context) error {
|
||||
// --rmgroup
|
||||
if RemoveGroup != "" {
|
||||
err := client.RemoveGroup(RemoveGroup)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
} else {
|
||||
fmt.Println("Group Removed")
|
||||
}
|
||||
standardOutput(err, nil)
|
||||
}
|
||||
|
||||
// Execute Function to view all groups
|
||||
if Groups {
|
||||
groups, err := client.ReadGroup()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
} else {
|
||||
client.PrettyPrint(groups)
|
||||
}
|
||||
standardOutput(err, groups)
|
||||
}
|
||||
|
||||
//--------------------------------
|
||||
|
||||
if PullPlugin != "" {
|
||||
err := plugin.DownloadPlugin(PullPlugin)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
} else {
|
||||
fmt.Println("Success")
|
||||
}
|
||||
standardOutput(err, nil)
|
||||
}
|
||||
|
||||
if RemovePlugin != "" {
|
||||
err := plugin.DeletePlugin(RemovePlugin)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
} else {
|
||||
fmt.Println("Success")
|
||||
}
|
||||
standardOutput(err, nil)
|
||||
}
|
||||
|
||||
if AddMetaData != "" {
|
||||
err := clientIPTable.AddCustomInformationToIPTable(AddMetaData)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
} else {
|
||||
fmt.Println("Success")
|
||||
}
|
||||
standardOutput(err, nil)
|
||||
}
|
||||
|
||||
if MAPPort != "" {
|
||||
address, err := client.MAPPort(MAPPort, DomainName, RemoteAddress)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
} else {
|
||||
client.PrettyPrint(address)
|
||||
}
|
||||
standardOutput(err, address)
|
||||
}
|
||||
|
||||
// Action called to add root node to network
|
||||
if AddRootNode && IP != "" && Ports != "" {
|
||||
err := abstractions.AddRootNode(IP, Ports)
|
||||
standardOutput(err, nil)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func standardOutput(err error, i interface{}) {
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
} else if i == nil {
|
||||
fmt.Println("Success")
|
||||
} else {
|
||||
client.PrettyPrint(i)
|
||||
}
|
||||
}
|
||||
|
||||
16
cmd/flags.go
16
cmd/flags.go
@@ -41,6 +41,8 @@ var (
|
||||
PullPlugin string
|
||||
RemovePlugin string
|
||||
AddMetaData string
|
||||
AddRootNode bool
|
||||
IP string
|
||||
)
|
||||
|
||||
var AppConfigFlags = []cli.Flag{
|
||||
@@ -272,4 +274,18 @@ var AppConfigFlags = []cli.Flag{
|
||||
EnvVars: []string{"ADDMETADATA"},
|
||||
Destination: &AddMetaData,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "AddRootNode",
|
||||
Aliases: []string{"arn"},
|
||||
Usage: "Adds initial root node to talk to",
|
||||
EnvVars: []string{"ADDROOTNODE"},
|
||||
Destination: &AddRootNode,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "IPAddress",
|
||||
Aliases: []string{"ip"},
|
||||
Usage: "IP address",
|
||||
EnvVars: []string{"IP"},
|
||||
Destination: &IP,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -29,8 +29,8 @@ type Config struct {
|
||||
ServerPort string
|
||||
ProxyPort string
|
||||
GroupTrackContainersPath string
|
||||
FRPServerPort string
|
||||
BehindNAT string
|
||||
FRPServerPort bool
|
||||
BehindNAT bool
|
||||
IPTableKey string
|
||||
PublicKeyFile string
|
||||
PrivateKeyFile string
|
||||
|
||||
@@ -78,9 +78,9 @@ func SetDefaults(envName string, forceDefault bool, CustomConfig interface{}, No
|
||||
Defaults.GroupTrackContainersPath = defaultPath + "client/trackcontainers/grouptrackcontainers.json"
|
||||
Defaults.ServerPort = "8088"
|
||||
Defaults.ProxyPort = ""
|
||||
Defaults.FRPServerPort = "True"
|
||||
Defaults.FRPServerPort = true
|
||||
Defaults.CustomConfig = CustomConfig
|
||||
Defaults.BehindNAT = "True"
|
||||
Defaults.BehindNAT = true
|
||||
Defaults.DockerRunLogs = "/tmp/"
|
||||
// Generate a random key to be added to IPTable
|
||||
Defaults.IPTableKey = String(12)
|
||||
|
||||
@@ -45,9 +45,9 @@ func GenerateIPTableFile(rootNodes []p2p.IpAddress) (err error) {
|
||||
if len(rootNodes) <= 0 {
|
||||
rootnode.Name = "Node1"
|
||||
rootnode.ServerPort = "8078"
|
||||
rootnode.NAT = "False"
|
||||
rootnode.NAT = false
|
||||
rootnode.Ipv4 = "217.76.63.222"
|
||||
rootnode.ProxyServer = "True"
|
||||
rootnode.ProxyServer = true
|
||||
|
||||
rootnodes.IpAddress = append(rootnodes.IpAddress, rootnode)
|
||||
} else {
|
||||
|
||||
@@ -29,9 +29,9 @@ type IpAddress struct {
|
||||
Upload float64 `json:"Upload"`
|
||||
ServerPort string `json:"ServerPort"`
|
||||
BareMetalSSHPort string `json:"BareMetalSSHPort"`
|
||||
NAT string `json:"NAT"`
|
||||
NAT bool `json:"NAT"`
|
||||
EscapeImplementation string `json:"EscapeImplementation"`
|
||||
ProxyServer string `json:"ProxyServer"`
|
||||
ProxyServer bool `json:"ProxyServer"`
|
||||
UnSafeMode bool `json:"UnSafeMode"`
|
||||
PublicKey string `json:"PublicKey"`
|
||||
CustomInformation string `json:"CustomInformation"`
|
||||
@@ -161,7 +161,7 @@ func (table *IpAddresses) RemoveDuplicates() error {
|
||||
}
|
||||
}
|
||||
|
||||
if table.IpAddress[i].NAT == "True" && table.IpAddress[i].EscapeImplementation == "None" {
|
||||
if table.IpAddress[i].NAT && table.IpAddress[i].EscapeImplementation == "None" {
|
||||
Exists = true
|
||||
}
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ func (ip *IpAddresses) SpeedTestUpdatedIPTable() error {
|
||||
}
|
||||
// Checks if both the IPV4 addresses are the same or the IPV6 address is not
|
||||
// an empty string and IPV6 address are the same
|
||||
if (ip.IpAddress[k].Ipv4 == targets.IpAddress[i].Ipv4 && targets.IpAddress[i].NAT == "True") || (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) {
|
||||
Exists = true
|
||||
break
|
||||
}
|
||||
|
||||
@@ -255,7 +255,7 @@ func Server() (*gin.Engine, error) {
|
||||
// TODO check if IPV6 or Proxy port is specified
|
||||
// if not update current entry as proxy address
|
||||
// with appropriate port on IP Table
|
||||
if config.BehindNAT == "True" {
|
||||
if config.BehindNAT {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -267,7 +267,7 @@ func Server() (*gin.Engine, error) {
|
||||
for i, _ := range table.IpAddress {
|
||||
// Checks if the ping is the lowest and if the following node is acting as a proxy
|
||||
//if table.IpAddress[i].Latency.Milliseconds() < lowestLatency && table.IpAddress[i].ProxyPort != "" {
|
||||
if table.IpAddress[i].Latency.Milliseconds() < lowestLatency && table.IpAddress[i].NAT != "" {
|
||||
if table.IpAddress[i].Latency.Milliseconds() < lowestLatency && !table.IpAddress[i].NAT {
|
||||
lowestLatency = table.IpAddress[i].Latency.Milliseconds()
|
||||
lowestLatencyIpAddress = table.IpAddress[i]
|
||||
}
|
||||
@@ -291,8 +291,8 @@ func Server() (*gin.Engine, error) {
|
||||
ProxyIpAddr.Ipv4 = lowestLatencyIpAddress.Ipv4
|
||||
ProxyIpAddr.ServerPort = proxyPort
|
||||
ProxyIpAddr.Name = config.MachineName
|
||||
ProxyIpAddr.NAT = "False"
|
||||
ProxyIpAddr.ProxyServer = "False"
|
||||
ProxyIpAddr.NAT = false
|
||||
ProxyIpAddr.ProxyServer = false
|
||||
ProxyIpAddr.EscapeImplementation = "FRP"
|
||||
|
||||
if config.BareMetal {
|
||||
@@ -314,9 +314,9 @@ func Server() (*gin.Engine, error) {
|
||||
}
|
||||
ProxyIpAddr.ServerPort = config.ServerPort
|
||||
ProxyIpAddr.Name = config.MachineName
|
||||
ProxyIpAddr.NAT = "False"
|
||||
ProxyIpAddr.NAT = false
|
||||
if config.ProxyPort != "" {
|
||||
ProxyIpAddr.ProxyServer = "True"
|
||||
ProxyIpAddr.ProxyServer = true
|
||||
}
|
||||
ProxyIpAddr.EscapeImplementation = ""
|
||||
if config.BareMetal {
|
||||
@@ -425,9 +425,9 @@ func MapPort(port string, domainName string) (string, string, error) {
|
||||
for i, _ := range table.IpAddress {
|
||||
// Checks if the ping is the lowest and if the following node is acting as a proxy
|
||||
//if table.IpAddress[i].Latency.Milliseconds() < lowestLatency && table.IpAddress[i].ProxyPort != "" {
|
||||
if table.IpAddress[i].Latency.Milliseconds() < lowestLatency && table.IpAddress[i].NAT != "" {
|
||||
if table.IpAddress[i].Latency.Milliseconds() < lowestLatency && !table.IpAddress[i].NAT {
|
||||
// Filter based on nodes with proxy enabled
|
||||
if domainName != "" && table.IpAddress[i].ProxyServer == "True" {
|
||||
if domainName != "" && table.IpAddress[i].ProxyServer {
|
||||
lowestLatency = table.IpAddress[i].Latency.Milliseconds()
|
||||
lowestLatencyIpAddress = table.IpAddress[i]
|
||||
continue
|
||||
@@ -466,7 +466,7 @@ func MapPort(port string, domainName string) (string, string, error) {
|
||||
ProxyIpAddr.Ipv4 = lowestLatencyIpAddress.Ipv4
|
||||
ProxyIpAddr.ServerPort = proxyPort
|
||||
ProxyIpAddr.Name = config.MachineName
|
||||
ProxyIpAddr.NAT = "False"
|
||||
ProxyIpAddr.NAT = false
|
||||
ProxyIpAddr.EscapeImplementation = "FRP"
|
||||
|
||||
//ProxyIpAddr.CustomInformationKey = p2p.GenerateHashSHA256(config.IPTableKey)
|
||||
|
||||
Reference in New Issue
Block a user