pushed final docs for initial merge

This commit is contained in:
2025-01-21 21:08:22 +00:00
parent 1bd3a35992
commit a07f9588fb
17 changed files with 2774 additions and 6 deletions

BIN
.DS_Store vendored

Binary file not shown.

113
Bindings/docs.md Normal file
View File

@@ -0,0 +1,113 @@
<!-- Code generated by gomarkdoc. DO NOT EDIT -->
# Bindings
```go
import "github.com/Akilan1999/p2p-rendering-computation/Bindings"
```
## Index
- [func ConvertStructToJSONString\(Struct interface\{\}\) \*C.char](<#ConvertStructToJSONString>)
- [func EscapeFirewall\(HostOutsideNATIP string, HostOutsideNATPort string, internalPort string\) \(output \*C.char\)](<#EscapeFirewall>)
- [func GetSpecs\(IP string\) \(output \*C.char\)](<#GetSpecs>)
- [func Init\(customConfig string\) \(output \*C.char\)](<#Init>)
- [func MapPort\(Port string, DomainName string, ServerAddress string\) \*C.char](<#MapPort>)
- [func RemoveContainer\(IP string, ID string\) \(output \*C.char\)](<#RemoveContainer>)
- [func Server\(\) \(output \*C.char\)](<#Server>)
- [func StartContainer\(IP string\) \(output \*C.char\)](<#StartContainer>)
- [func UpdateIPTable\(\) \(output \*C.char\)](<#UpdateIPTable>)
- [func ViewIPTable\(\) \(output \*C.char\)](<#ViewIPTable>)
<a name="ConvertStructToJSONString"></a>
## func [ConvertStructToJSONString](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/Bindings/Client.go#L159>)
```go
func ConvertStructToJSONString(Struct interface{}) *C.char
```
<a name="EscapeFirewall"></a>
## func [EscapeFirewall](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/Bindings/Client.go#L118>)
```go
func EscapeFirewall(HostOutsideNATIP string, HostOutsideNATPort string, internalPort string) (output *C.char)
```
<a name="GetSpecs"></a>
## func [GetSpecs](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/Bindings/Client.go#L79>)
```go
func GetSpecs(IP string) (output *C.char)
```
<a name="Init"></a>
## func [Init](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/Bindings/Client.go#L88>)
```go
func Init(customConfig string) (output *C.char)
```
<a name="MapPort"></a>
## func [MapPort](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/Bindings/Client.go#L137>)
```go
func MapPort(Port string, DomainName string, ServerAddress string) *C.char
```
<a name="RemoveContainer"></a>
## func [RemoveContainer](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/Bindings/Client.go#L29>)
```go
func RemoveContainer(IP string, ID string) (output *C.char)
```
<a name="Server"></a>
## func [Server](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/Bindings/Client.go#L148>)
```go
func Server() (output *C.char)
```
<a name="StartContainer"></a>
## func [StartContainer](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/Bindings/Client.go#L20>)
```go
func StartContainer(IP string) (output *C.char)
```
<a name="UpdateIPTable"></a>
## func [UpdateIPTable](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/Bindings/Client.go#L109>)
```go
func UpdateIPTable() (output *C.char)
```
<a name="ViewIPTable"></a>
## func [ViewIPTable](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/Bindings/Client.go#L100>)
```go
func ViewIPTable() (output *C.char)
```
Generated by [gomarkdoc](<https://github.com/princjef/gomarkdoc>)

View File

@@ -4,12 +4,6 @@
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="style.css"/>
#+ATTR_HTML: :align right
#+ATTR_ORG: :align center
#+ATTR_ORG: :width
[[../artwork/p2prc-logos/Colored-On-Light-Image.png]]
* Introduction
:PROPERTIES:
:CUSTOM_ID: chapter1-introduction

252
README.md.org Normal file
View File

@@ -0,0 +1,252 @@
#+begin_quote
[!TIP] Haskell bindings supported!:
[[https://p2prc.akilan.io/Docs/haskell/P2PRC.html][Bindings
documentaton]]
#+end_quote
#+begin_quote
[!NOTE] Fixing documentation to latest changes. If you have any
questions setting up P2PRC either
[[https://github.com/Akilan1999/p2p-rendering-computation/issues/new/choose][create
an issue]] or send me an email (me AT akilan dot io). Currently HEAD is
always intended to stay on a working state. It is recommended to always
use HEAD in your go.mod file.
#+end_quote
#+begin_html
<h1 align="center">
#+end_html
#+begin_html
</h1>
#+end_html
#+begin_html
<!-- seperator -->
#+end_html
#+begin_html
<!-- The main aim of this project was to create a custom peer to peer network. The user acting as the
client has total flexibility on how to batch the tasks and the user acting as the server has complete
flexibility on tracking the container's usages and killing the containers at any point of time. -->
#+end_html
#+begin_html
<!-- The objective is to allow users to self host servers in easier
and abstracted manner. The main aim of this project was to create a custom peer to peer network for distributed computing. The user acting as the client has total flexibility on how to batch the tasks to any of nodes in networks. These nodes can anywhere from personal
computers behind NAT to custom hardware for running custom workload. The aim to provide
access to Heterogeneous set of nodes as a singular global list and abstract away the networking details giving the user focus on designing a custom orchestrator based
on the requirements of a user. -->
#+end_html
This project aims to simplify self-hosting servers and streamline the
creation of distributed systems. The primary focus is to enable users to
design custom peer-to-peer networks for distributed computing, offering
full flexibility and control while abstracting away the complexities of
networking.
** Key Features
:PROPERTIES:
:CUSTOM_ID: key-features
:END:
Simplified Self-Hosting Empower users to easily host nodes, whether on
personal computers behind NAT, custom hardware, or cloud-based
infrastructure.
*** Custom Peer-to-Peer Networks
:PROPERTIES:
:CUSTOM_ID: custom-peer-to-peer-networks
:END:
Build a decentralised network tailored to user requirements, enabling
distributed task execution without the need for in-depth networking
knowledge.
*** Heterogeneous Node Support
:PROPERTIES:
:CUSTOM_ID: heterogeneous-node-support
:END:
Harness a diverse array of nodes from personal computers to specialised
hardware---seamlessly integrated into a global node list.
*** Abstracted Networking Layer
:PROPERTIES:
:CUSTOM_ID: abstracted-networking-layer
:END:
Networking details are completely abstracted, enabling users to focus on
developing bespoke task orchestration systems. No more manual
configuration of IPs, ports, or connection logic.
*** Flexible Task Distribution
:PROPERTIES:
:CUSTOM_ID: flexible-task-distribution
:END:
Users acting as clients retain full control over how tasks are batched
and assigned to nodes, creating endless possibilities for optimising
performance based on specific use cases.
** Latest tutorial
:PROPERTIES:
:CUSTOM_ID: latest-tutorial
:END:
[[https://www.youtube.com/watch?v=OMwCpedu5cs%22][[[https://i.ytimg.com/vi/OMwCpedu5cs/hqdefault.jpg]]]]
#+begin_html
<!-- ## Table of contents in the current README -->
#+end_html
#+begin_html
<!-- 1. [Introduction](#Introduction)
2. [Installation](#extend-your-application-with-p2prc)
3. [Design Architecture](#Design-Architecture)
4. [Implementation](#Implementation)
5. [Find out more](#Find-out-more) -->
#+end_html
#+begin_html
<!-- # Table of contents in the Docs folder
1. [Introduction](Docs/Introduction.md)
2. [Installation](Docs/Installation.md)
3. [Abstractions](Docs/Abstractions.md)
3. [Design Architecture](DesignArchtectureIntro.md)
1. [Client Module](ClientArchitecture.md)
2. [P2P Module](P2PArchitecture.md)
3. [Server Module](ServerArchitecture.md)
4. [Implementation](Docs/Implementation.md)
1. [Client Module](Docs/ClientImplementation.md)
2. [P2P Module](Docs/P2PImplementation.md)
3. [Server Module](Docs/ServerImplementation.md)
4. [Config Module](Docs/ConfigImplementation.md)
5. [Cli Module](Docs/CliImplementation.md)
6. [Plugin Module](Docs/PluginImplementation.md)
7. [Language bindings](Docs/Bindings.md)
8. [Domain name mappings](Docs/Bindings.md)
5. Language bindings
1. [Haskell](Docs/haskell/)
5. [Problems](https://github.com/Akilan1999/p2p-rendering-computation/issues) -->
#+end_html
#+begin_html
<!--
## Introduction
This project aims to create a peer to peer (p2p) network, where a user can use the p2p network to act as a client (i.e sending tasks) or the server (i.e executing the tasks). A prototype application will be developed, which comes bundled with a p2p module and possible to execute docker containers or virtual environments across selected nodes.
### Objectives
- Background review on peer to peer network, virtual environments, decentralized rendering tools and tools to batch any sort of tasks.
- Creating p2p network
- Server to create a containerised environment
- The client node to run tasks on Server containerised node -->
#+end_html
#+begin_html
<!-- [Read more on the introduction](Docs/Introduction.md) -->
#+end_html
#+begin_html
<!-- <br> -->
#+end_html
** Extend your application with P2PRC
:PROPERTIES:
:CUSTOM_ID: extend-your-application-with-p2prc
:END:
#+begin_src go
package main
import (
"fmt"
"github.com/Akilan1999/p2p-rendering-computation/abstractions"
)
func main() {
_, err := abstractions.Init(nil)
if err != nil {
fmt.Println(err)
return
}
// start p2prc
_, err = abstractions.Start()
if err != nil {
fmt.Println(err)
return
}
// Run server till termination
for {
}
}
#+end_src
#+begin_html
<!-- ### Export once this is added export P2PRC as environment paths
```
export P2PRC=<PROJECT PATH>
export PATH=<PROJECT PATH>:${PATH}
```
[Read more](Docs/Abstractions.md) ...
## Installation from source
1. Ensure the Go compiler is installed
```
go version
```
3. Ensure docker is installed (Should run without sudo)
```
docker ps
```
3. Clone this repository
```
git clone https://github.com/Akilan1999/p2p-rendering-computation
```
4. Install and build the project
```
make install
```
- If you look closely you will get outputs such as:
```
// Add them to your .bashrc file
export P2PRC=/<path>/p2p-rendering-computation
export PATH=/<path>/p2p-rendering-computation:${PATH}
```
5. Test if it works
```
p2prc -h
```
or
```
./p2prc -h
```
[Read more on the installation and usage](Docs/Installation.md)
<br>
## Design Architecture
The design architecture was inspired and based on the linux kernel design. The project is segmented into various modules. Each module is responsible for certain tasks in the project. The modules are highly dependent on each other hence the entire codebase can be considered as a huge monolithic chuck which acts as its own library
[Read more on the Design Architecture](Docs/DesignArchtectureIntro.md)
<br>
## Implementation
The programming language used for this project was Golang. The reason Go lang was chosen was because it is a compiled language. The entire codebase is just a single binary file. When distributing to other linux distributing the only requirement would be the binary file to run the code. It is easy to write independant modules and be monolithic at the sametime using Go. Using Go.mod makes it very easy to handle external libraries and modularise code. The go.mod name for the project is git.sr.ht/~akilan1999/p2p-rendering-computation.
[Read more on the Implementation](Docs/Implementation.md)
<br> -->
#+end_html
** Find out more
:PROPERTIES:
:CUSTOM_ID: find-out-more
:END:
As we are working on the open source project p2prc (i.e p2p network
designed for computation).If you are interested in participating as a
contributor or just providing feedback on new features to build or even
just curious about new features added to the project do file an Issue or
send an email to me@akilan.io.
[[https://github.com/Gaurav-Gosain][[[https://api.star-history.com/svg?repos=Akilan1999/p2p-rendering-computation&type=Date]]]]

93
abstractions/docs.md Normal file
View File

@@ -0,0 +1,93 @@
<!-- Code generated by gomarkdoc. DO NOT EDIT -->
# abstractions
```go
import "github.com/Akilan1999/p2p-rendering-computation/abstractions"
```
## Index
- [func GetSpecs\(IP string\) \(specs \*server.SysInfo, err error\)](<#GetSpecs>)
- [func Init\(customConfig interface\{\}\) \(config \*Config.Config, err error\)](<#Init>)
- [func MapPort\(port string, domainName string, serverAddress string\) \(entireAddress string, mapPort string, err error\)](<#MapPort>)
- [func RemoveContainer\(IP string, ID string\) error](<#RemoveContainer>)
- [func Start\(\) \(\*gin.Engine, error\)](<#Start>)
- [func StartContainer\(IP string\) \(container \*docker.DockerVM, err error\)](<#StartContainer>)
- [func UpdateIPTable\(\) \(err error\)](<#UpdateIPTable>)
- [func ViewIPTable\(\) \(table \*p2p.IpAddresses, err error\)](<#ViewIPTable>)
<a name="GetSpecs"></a>
## func [GetSpecs](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/abstractions/base.go#L73>)
```go
func GetSpecs(IP string) (specs *server.SysInfo, err error)
```
GetSpecs Get spec information about the remote server
<a name="Init"></a>
## func [Init](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/abstractions/base.go#L17>)
```go
func Init(customConfig interface{}) (config *Config.Config, err error)
```
Init Initialises p2prc
<a name="MapPort"></a>
## func [MapPort](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/abstractions/base.go#L55>)
```go
func MapPort(port string, domainName string, serverAddress string) (entireAddress string, mapPort string, err error)
```
MapPort Creates a reverse proxy connection and maps the appropriate port
<a name="RemoveContainer"></a>
## func [RemoveContainer](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/abstractions/base.go#L68>)
```go
func RemoveContainer(IP string, ID string) error
```
RemoveContainer Removes docker container based on the IP address and ID provided
<a name="Start"></a>
## func [Start](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/abstractions/base.go#L46>)
```go
func Start() (*gin.Engine, error)
```
Start p2prc in a server mode
<a name="StartContainer"></a>
## func [StartContainer](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/abstractions/base.go#L61>)
```go
func StartContainer(IP string) (container *docker.DockerVM, err error)
```
StartContainer Starts docker container on the remote machine
<a name="UpdateIPTable"></a>
## func [UpdateIPTable](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/abstractions/base.go#L86>)
```go
func UpdateIPTable() (err error)
```
UpdateIPTable Force updates IP tables based on new new nodes discovered in the network
<a name="ViewIPTable"></a>
## func [ViewIPTable](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/abstractions/base.go#L79>)
```go
func ViewIPTable() (table *p2p.IpAddresses, err error)
```
ViewIPTable View information of nodes in the network
Generated by [gomarkdoc](<https://github.com/princjef/gomarkdoc>)

View File

@@ -0,0 +1,63 @@
<!-- Code generated by gomarkdoc. DO NOT EDIT -->
# clientIPTable
```go
import "github.com/Akilan1999/p2p-rendering-computation/client/clientIPTable"
```
## Index
- [func AddCustomInformationToIPTable\(text string\) error](<#AddCustomInformationToIPTable>)
- [func RemoveOfflineNodes\(\) error](<#RemoveOfflineNodes>)
- [func UpdateIpTable\(IpAddress string, serverPort string, wg \*sync.WaitGroup\) error](<#UpdateIpTable>)
- [func UpdateIpTableListClient\(\) error](<#UpdateIpTableListClient>)
- [func UploadMultipartFile\(client http.Client, uri, key, path string\) \(\[\]byte, error\)](<#UploadMultipartFile>)
<a name="AddCustomInformationToIPTable"></a>
## func [AddCustomInformationToIPTable](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/client/clientIPTable/AddCustomInformationToIPTable.go#L9>)
```go
func AddCustomInformationToIPTable(text string) error
```
<a name="RemoveOfflineNodes"></a>
## func [RemoveOfflineNodes](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/client/clientIPTable/Iptable.go#L154>)
```go
func RemoveOfflineNodes() error
```
<a name="UpdateIpTable"></a>
## func [UpdateIpTable](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/client/clientIPTable/Iptable.go#L19>)
```go
func UpdateIpTable(IpAddress string, serverPort string, wg *sync.WaitGroup) error
```
UpdateIpTable Does the following to update it's IP table
<a name="UpdateIpTableListClient"></a>
## func [UpdateIpTableListClient](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/client/clientIPTable/Iptable.go#L80>)
```go
func UpdateIpTableListClient() error
```
UpdateIpTableListClient updates IP tables \(Default 3 hops\) based on server information available on the ip tables
<a name="UploadMultipartFile"></a>
## func [UploadMultipartFile](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/client/clientIPTable/Iptable.go#L209>)
```go
func UploadMultipartFile(client http.Client, uri, key, path string) ([]byte, error)
```
Generated by [gomarkdoc](<https://github.com/princjef/gomarkdoc>)

357
client/docs.md Normal file
View File

@@ -0,0 +1,357 @@
<!-- Code generated by gomarkdoc. DO NOT EDIT -->
# client
```go
import "github.com/Akilan1999/p2p-rendering-computation/client"
```
## Index
- [func AddTrackContainer\(d \*docker.DockerVM, ipAddress string\) error](<#AddTrackContainer>)
- [func CheckID\(ID string\) \(string, error\)](<#CheckID>)
- [func GetServerPort\(IpAddress string\) \(string, error\)](<#GetServerPort>)
- [func GetSpecs\(IP string\) \(\*server.SysInfo, error\)](<#GetSpecs>)
- [func PrettyPrint\(data interface\{\}\)](<#PrettyPrint>)
- [func RemoveContainerGroups\(ContainerID string\) error](<#RemoveContainerGroups>)
- [func RemoveContianer\(IP string, ID string\) error](<#RemoveContianer>)
- [func RemoveGroup\(GroupID string\) error](<#RemoveGroup>)
- [func RemoveTrackedContainer\(id string\) error](<#RemoveTrackedContainer>)
- [func StartContainer\(IP string, NumPorts int, GPU bool, ContainerName string, baseImage string\) \(\*docker.DockerVM, error\)](<#StartContainer>)
- [func ViewContainers\(IP string\) \(\*docker.DockerContainers, error\)](<#ViewContainers>)
- [type Group](<#Group>)
- [func AddContainerToGroup\(ContainerID string, GroupID string\) \(\*Group, error\)](<#AddContainerToGroup>)
- [func CreateGroup\(\) \(\*Group, error\)](<#CreateGroup>)
- [func GetGroup\(GroupID string\) \(\*Group, error\)](<#GetGroup>)
- [func RemoveContainerGroup\(ContainerID string, GroupID string\) \(\*Group, error\)](<#RemoveContainerGroup>)
- [func \(grp \*Group\) AddContainer\(Container \*TrackContainer\) error](<#Group.AddContainer>)
- [func \(grp \*Group\) AddGroupToFile\(\) error](<#Group.AddGroupToFile>)
- [func \(grp \*Group\) RemoveContainerGroup\(Container \*TrackContainer\) error](<#Group.RemoveContainerGroup>)
- [type Groups](<#Groups>)
- [func ReadGroup\(\) \(\*Groups, error\)](<#ReadGroup>)
- [func \(grp \*Groups\) RemoveContainerGroups\(Container \*TrackContainer\) error](<#Groups.RemoveContainerGroups>)
- [func \(grp \*Groups\) WriteGroup\(\) error](<#Groups.WriteGroup>)
- [type ResponseMAPPort](<#ResponseMAPPort>)
- [func MAPPort\(port string, domainName string\) \(\*ResponseMAPPort, error\)](<#MAPPort>)
- [type TrackContainer](<#TrackContainer>)
- [func GetContainerInformation\(ID string\) \(\*TrackContainer, error\)](<#GetContainerInformation>)
- [func \(TC \*TrackContainer\) ModifyContainerGroups\(\) error](<#TrackContainer.ModifyContainerGroups>)
- [func \(TC \*TrackContainer\) ModifyContainerInformation\(\) error](<#TrackContainer.ModifyContainerInformation>)
- [type TrackContainers](<#TrackContainers>)
- [func ReadTrackContainers\(filename string\) \(\*TrackContainers, error\)](<#ReadTrackContainers>)
- [func ViewTrackedContainers\(\) \(error, \*TrackContainers\)](<#ViewTrackedContainers>)
- [func \(TC \*TrackContainers\) WriteContainers\(\) error](<#TrackContainers.WriteContainers>)
<a name="AddTrackContainer"></a>
## func [AddTrackContainer](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/client/TrackContainers.go#L26>)
```go
func AddTrackContainer(d *docker.DockerVM, ipAddress string) error
```
AddTrackContainer Adds new container which has been added to the track container
<a name="CheckID"></a>
## func [CheckID](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/client/TrackContainers.go#L212>)
```go
func CheckID(ID string) (string, error)
```
CheckID Checks if the ID belongs to a group or a single container
<a name="GetServerPort"></a>
## func [GetServerPort](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/client/container.go#L170>)
```go
func GetServerPort(IpAddress string) (string, error)
```
GetServerPort Helper function to do find out server port information
<a name="GetSpecs"></a>
## func [GetSpecs](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/client/ServerSpecs.go#L14>)
```go
func GetSpecs(IP string) (*server.SysInfo, error)
```
GetSpecs Gets Specs from the server such CPU, GPU usage and other basic information which helps set a cluster of computer
<a name="PrettyPrint"></a>
## func [PrettyPrint](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/client/ServerSpecs.go#L54>)
```go
func PrettyPrint(data interface{})
```
PrettyPrint print the contents of the obj \( Reference: https://stackoverflow.com/questions/24512112/how-to-print-struct-variables-in-console
<a name="RemoveContainerGroups"></a>
## func [RemoveContainerGroups](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/client/GroupTrackContainer.go#L139>)
```go
func RemoveContainerGroups(ContainerID string) error
```
RemoveContainerGroups Remove Container from groups \(i.e which ever groups has information about that container\). This is mostly called when a container is deleted or removed from the tracked container list
<a name="RemoveContianer"></a>
## func [RemoveContianer](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/client/container.go#L84>)
```go
func RemoveContianer(IP string, ID string) error
```
RemoveContianer Stops and removes container from the server
<a name="RemoveGroup"></a>
## func [RemoveGroup](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/client/GroupTrackContainer.go#L47>)
```go
func RemoveGroup(GroupID string) error
```
RemoveGroup Removes group based on the group ID provided
<a name="RemoveTrackedContainer"></a>
## func [RemoveTrackedContainer](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/client/TrackContainers.go#L82>)
```go
func RemoveTrackedContainer(id string) error
```
RemoveTrackedContainer This function removos tracked container from the trackcontainer JSON file
<a name="StartContainer"></a>
## func [StartContainer](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/client/container.go#L24>)
```go
func StartContainer(IP string, NumPorts int, GPU bool, ContainerName string, baseImage string) (*docker.DockerVM, error)
```
StartContainer Start container using REST api Implementation From the selected server IP address TODO: Test cases for this function Calls URL ex: http://0.0.0.0:8088/startcontainer?ports=0&GPU=false&ContainerName=docker-ubuntu-sshd
<a name="ViewContainers"></a>
## func [ViewContainers](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/client/container.go#L130>)
```go
func ViewContainers(IP string) (*docker.DockerContainers, error)
```
ViewContainers This function displays all containers available on server side
<a name="Group"></a>
## type [Group](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/client/GroupTrackContainer.go#L18-L24>)
Group Information about a single group
```go
type Group struct {
ID string `json:"ID"`
TrackContainerList []*TrackContainer `json:"TrackContainer"`
// contains filtered or unexported fields
}
```
<a name="AddContainerToGroup"></a>
### func [AddContainerToGroup](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/client/GroupTrackContainer.go#L73>)
```go
func AddContainerToGroup(ContainerID string, GroupID string) (*Group, error)
```
AddContainerToGroup Adds container information to the Group based on the Group ID
<a name="CreateGroup"></a>
### func [CreateGroup](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/client/GroupTrackContainer.go#L27>)
```go
func CreateGroup() (*Group, error)
```
CreateGroup Creates a new group to add a set of track containers
<a name="GetGroup"></a>
### func [GetGroup](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/client/GroupTrackContainer.go#L166>)
```go
func GetGroup(GroupID string) (*Group, error)
```
GetGroup Gets group information based on group id provided
<a name="RemoveContainerGroup"></a>
### func [RemoveContainerGroup](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/client/GroupTrackContainer.go#L104>)
```go
func RemoveContainerGroup(ContainerID string, GroupID string) (*Group, error)
```
RemoveContainerGroup Remove Container from the group ID specified
<a name="Group.AddContainer"></a>
### func \(\*Group\) [AddContainer](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/client/GroupTrackContainer.go#L250>)
```go
func (grp *Group) AddContainer(Container *TrackContainer) error
```
AddContainer Adds a container to the Tracked container list of the group
<a name="Group.AddGroupToFile"></a>
### func \(\*Group\) [AddGroupToFile](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/client/GroupTrackContainer.go#L186>)
```go
func (grp *Group) AddGroupToFile() error
```
AddGroupToFile Adds Group struct to the GroupTrackContainer File
<a name="Group.RemoveContainerGroup"></a>
### func \(\*Group\) [RemoveContainerGroup](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/client/GroupTrackContainer.go#L256>)
```go
func (grp *Group) RemoveContainerGroup(Container *TrackContainer) error
```
RemoveContainerGroup Removes container information from the group
<a name="Groups"></a>
## type [Groups](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/client/GroupTrackContainer.go#L13-L15>)
Groups Data Structure type
```go
type Groups struct {
GroupList []*Group `json:"Groups"`
}
```
<a name="ReadGroup"></a>
### func [ReadGroup](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/client/GroupTrackContainer.go#L207>)
```go
func ReadGroup() (*Groups, error)
```
ReadGroup Function reads grouptrackcontainers.json and converts result to Groups
<a name="Groups.RemoveContainerGroups"></a>
### func \(\*Groups\) [RemoveContainerGroups](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/client/GroupTrackContainer.go#L268>)
```go
func (grp *Groups) RemoveContainerGroups(Container *TrackContainer) error
```
RemoveContainerGroups removes container found in all groups
<a name="Groups.WriteGroup"></a>
### func \(\*Groups\) [WriteGroup](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/client/GroupTrackContainer.go#L231>)
```go
func (grp *Groups) WriteGroup() error
```
WriteGroup Function to write type Groups to the grouptrackcontainers.json file
<a name="ResponseMAPPort"></a>
## type [ResponseMAPPort](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/client/MAPPort.go#L9-L11>)
```go
type ResponseMAPPort struct {
IPAddress string
}
```
<a name="MAPPort"></a>
### func [MAPPort](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/client/MAPPort.go#L13>)
```go
func MAPPort(port string, domainName string) (*ResponseMAPPort, error)
```
<a name="TrackContainer"></a>
## type [TrackContainer](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/client/TrackContainers.go#L19-L23>)
TrackContainer Stores information of current containers
```go
type TrackContainer struct {
Id string `json:"ID"`
Container *docker.DockerVM `json:"Container"`
IpAddress string `json:"IpAddress"`
}
```
<a name="GetContainerInformation"></a>
### func [GetContainerInformation](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/client/TrackContainers.go#L153>)
```go
func GetContainerInformation(ID string) (*TrackContainer, error)
```
GetContainerInformation gets information about container based on container ID provided
<a name="TrackContainer.ModifyContainerGroups"></a>
### func \(\*TrackContainer\) [ModifyContainerGroups](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/client/GroupTrackContainer.go#L285>)
```go
func (TC *TrackContainer) ModifyContainerGroups() error
```
ModifyContainerGroups Modifies container information is all groups available
<a name="TrackContainer.ModifyContainerInformation"></a>
### func \(\*TrackContainer\) [ModifyContainerInformation](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/client/TrackContainers.go#L170>)
```go
func (TC *TrackContainer) ModifyContainerInformation() error
```
ModifyContainerInformation Modifies information inside the container
<a name="TrackContainers"></a>
## type [TrackContainers](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/client/TrackContainers.go#L14-L16>)
TrackContainers This struct stores arrays of current containers running
```go
type TrackContainers struct {
TrackContainerList []TrackContainer `json:"TrackContainer"`
}
```
<a name="ReadTrackContainers"></a>
### func [ReadTrackContainers](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/client/TrackContainers.go#L134>)
```go
func ReadTrackContainers(filename string) (*TrackContainers, error)
```
ReadTrackContainers Reads containers which are currently tracked
<a name="ViewTrackedContainers"></a>
### func [ViewTrackedContainers](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/client/TrackContainers.go#L120>)
```go
func ViewTrackedContainers() (error, *TrackContainers)
```
ViewTrackedContainers View Containers currently tracked
<a name="TrackContainers.WriteContainers"></a>
### func \(\*TrackContainers\) [WriteContainers](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/client/TrackContainers.go#L195>)
```go
func (TC *TrackContainers) WriteContainers() error
```
WriteContainers Write information back to the config file
Generated by [gomarkdoc](<https://github.com/princjef/gomarkdoc>)

523
cmd/docs.md Normal file
View File

@@ -0,0 +1,523 @@
<!-- Code generated by gomarkdoc. DO NOT EDIT -->
# cmd
```go
import "github.com/Akilan1999/p2p-rendering-computation/cmd"
```
## Index
- [Variables](<#variables>)
## Variables
<a name="AddServer"></a>Variables declared for CLI
```go
var (
AddServer string
ViewImages string
CreateVM string
ContainerName string
BaseImage string
Ports string
Server bool
RemoveVM string
ID string
Specs string
GPU bool
UpdateServerList bool
ServerList bool
SetDefaultConfig bool
NetworkInterface bool
ViewPlugin bool
TrackedContainers bool
ExecutePlugin string
CreateGroup bool
Group string
Groups bool
RemoveContainerGroup bool
RemoveGroup string
MAPPort string
DomainName string
//FRPProxy bool
// Generate only allowed in dev release
// -- REMOVE ON REGULAR RELEASE --
Generate string
Modulename string
//--------------------------------
PullPlugin string
RemovePlugin string
AddMetaData string
)
```
<a name="AppConfigFlags"></a>
```go
var AppConfigFlags = []cli.Flag{
&cli.BoolFlag{
Name: "Server",
Aliases: []string{"s"},
Usage: "Starts server",
EnvVars: []string{"SERVER"},
Destination: &Server,
},
&cli.BoolFlag{
Name: "UpdateServerList",
Aliases: []string{"us"},
Usage: "Update List of Server available based on servers iptables",
EnvVars: []string{"UPDATE_SERVER_LIST"},
Destination: &UpdateServerList,
},
&cli.BoolFlag{
Name: "ListServers",
Aliases: []string{"ls"},
Usage: "List servers which can render tasks",
EnvVars: []string{"LIST_SERVERS"},
Destination: &ServerList,
},
&cli.StringFlag{
Name: "AddServer",
Aliases: []string{"as"},
Usage: "Adds server IP address to iptables",
EnvVars: []string{"ADD_SERVER"},
Destination: &AddServer,
},
&cli.StringFlag{
Name: "ViewImages",
Aliases: []string{"vi"},
Usage: "View images available on the server IP address",
EnvVars: []string{"VIEW_IMAGES"},
Destination: &ViewImages,
},
&cli.StringFlag{
Name: "CreateVM",
Aliases: []string{"touch"},
Usage: "Creates Docker container on the selected server",
EnvVars: []string{"CREATE_VM"},
Destination: &CreateVM,
},
&cli.StringFlag{
Name: "ContainerName",
Aliases: []string{"cn"},
Usage: "Specifying the container run on the server side",
EnvVars: []string{"CONTAINER_NAME"},
Destination: &ContainerName,
},
&cli.StringFlag{
Name: "BaseImage",
Aliases: []string{"bi"},
Usage: "Specifying the docker base image to template the dockerfile",
EnvVars: []string{"CONTAINER_NAME"},
Destination: &BaseImage,
},
&cli.StringFlag{
Name: "RemoveVM",
Aliases: []string{"rm"},
Usage: "Stop and Remove Docker container (IP:port) accompanied by container ID via --ID or --id",
EnvVars: []string{"REMOVE_VM"},
Destination: &RemoveVM,
},
&cli.StringFlag{
Name: "ID",
Aliases: []string{"id"},
Usage: "Docker Container ID",
EnvVars: []string{"ID"},
Destination: &ID,
},
&cli.StringFlag{
Name: "Ports",
Aliases: []string{"p"},
Usage: "Number of ports to open for the Docker Container",
EnvVars: []string{"NUM_PORTS"},
Destination: &Ports,
},
&cli.BoolFlag{
Name: "GPU",
Aliases: []string{"gpu"},
Usage: "Create Docker Containers to access GPU",
EnvVars: []string{"USE_GPU"},
Destination: &GPU,
},
&cli.StringFlag{
Name: "Specification",
Aliases: []string{"specs"},
Usage: "Specs of the server node",
EnvVars: []string{"SPECS"},
Destination: &Specs,
},
&cli.BoolFlag{
Name: "SetDefaultConfig",
Aliases: []string{"dc"},
Usage: "Sets a default configuration file",
EnvVars: []string{"SET_DEFAULT_CONFIG"},
Destination: &SetDefaultConfig,
},
&cli.BoolFlag{
Name: "NetworkInterfaces",
Aliases: []string{"ni"},
Usage: "Shows the network interface in your computer",
EnvVars: []string{"NETWORK_INTERFACE"},
Destination: &NetworkInterface,
},
&cli.BoolFlag{
Name: "ViewPlugins",
Aliases: []string{"vp"},
Usage: "Shows plugins available to be executed",
EnvVars: []string{"VIEW_PLUGIN"},
Destination: &ViewPlugin,
},
&cli.BoolFlag{
Name: "TrackedContainers",
Aliases: []string{"tc"},
Usage: "View (currently running) containers which have " +
"been created from the client side ",
EnvVars: []string{"TRACKED_CONTAINERS"},
Destination: &TrackedContainers,
},
&cli.StringFlag{
Name: "ExecutePlugin",
Aliases: []string{"plugin"},
Usage: "Plugin which needs to be executed",
EnvVars: []string{"EXECUTE_PLUGIN"},
Destination: &ExecutePlugin,
},
&cli.BoolFlag{
Name: "CreateGroup",
Aliases: []string{"cgroup"},
Usage: "Creates a new group",
EnvVars: []string{"CREATE_GROUP"},
Destination: &CreateGroup,
},
&cli.StringFlag{
Name: "Group",
Aliases: []string{"group"},
Usage: "group flag with argument group ID",
EnvVars: []string{"GROUP"},
Destination: &Group,
},
&cli.BoolFlag{
Name: "Groups",
Aliases: []string{"groups"},
Usage: "View all groups",
EnvVars: []string{"GROUPS"},
Destination: &Groups,
},
&cli.BoolFlag{
Name: "RemoveContainerGroup",
Aliases: []string{"rmcgroup"},
Usage: "Remove specific container in the group",
EnvVars: []string{"REMOVE_CONTAINER_GROUP"},
Destination: &RemoveContainerGroup,
},
&cli.StringFlag{
Name: "RemoveGroup",
Aliases: []string{"rmgroup"},
Usage: "Removes the entire group",
EnvVars: []string{"REMOVE_GROUP"},
Destination: &RemoveGroup,
},
&cli.StringFlag{
Name: "MAPPort",
Aliases: []string{"mp"},
Usage: "Maps port for a specific port provided as the parameter",
EnvVars: []string{"MAPPORT"},
Destination: &MAPPort,
},
&cli.StringFlag{
Name: "DomainName",
Aliases: []string{"dn"},
Usage: "While mapping ports allows to set a domain name to create a mapping in the proxy server",
EnvVars: []string{"DOMAINNAME"},
Destination: &DomainName,
},
&cli.StringFlag{
Name: "Generate",
Aliases: []string{"gen"},
Usage: "Generates a new copy of P2PRC which can be modified based on your needs",
EnvVars: []string{"GENERATE"},
Destination: &Generate,
},
&cli.StringFlag{
Name: "ModuleName",
Aliases: []string{"mod"},
Usage: "New go project module name",
EnvVars: []string{"MODULENAME"},
Destination: &Modulename,
},
&cli.StringFlag{
Name: "PullPlugin",
Aliases: []string{"pp"},
Usage: "Pulls plugin from git repos",
EnvVars: []string{"PULLPLUGIN"},
Destination: &PullPlugin,
},
&cli.StringFlag{
Name: "RemovePlugin",
Aliases: []string{"rp"},
Usage: "Removes plugin",
EnvVars: []string{"REMOVEPLUGIN"},
Destination: &RemovePlugin,
},
&cli.StringFlag{
Name: "AddMetaData",
Aliases: []string{"amd"},
Usage: "Adds metadata about the current node in the p2p network which is then propagated through the network",
EnvVars: []string{"ADDMETADATA"},
Destination: &AddMetaData,
},
}
```
<a name="CliAction"></a>
```go
var CliAction = func(ctx *cli.Context) error {
if Server {
_, err := server.Server()
if err != nil {
fmt.Print(err)
}
for {
}
}
if UpdateServerList {
err := clientIPTable.UpdateIpTableListClient()
if err != nil {
fmt.Print(err)
}
p2p.PrintIpTable()
}
if ServerList {
p2p.PrintIpTable()
}
if AddServer != "" {
res, err := p2p.ReadIpTable()
if err != nil {
fmt.Println(err)
}
//Create variable of type IpAddress and set IP address
// to it
var IpAddr p2p.IpAddress
ip4Orip6 := p2p.Ip4or6(AddServer)
if ip4Orip6 == "version 6" {
IpAddr.Ipv6 = AddServer
} else {
IpAddr.Ipv4 = AddServer
}
if Ports != "" {
IpAddr.ServerPort = Ports
} else {
IpAddr.ServerPort = "8088"
}
res.IpAddress = append(res.IpAddress, IpAddr)
res.WriteIpTable()
}
if ViewImages != "" {
imageRes, err := client.ViewContainers(ViewImages)
if err != nil {
fmt.Print(err)
}
client.PrettyPrint(imageRes)
}
if RemoveVM != "" {
if ID == "" {
fmt.Println("provide container ID via --ID or --id")
} else {
err := client.RemoveContianer(RemoveVM, ID)
if err != nil {
fmt.Print(err)
}
}
}
if CreateVM != "" {
var PortsInt int
if Ports != "" {
fmt.Sscanf(Ports, "%d", &PortsInt)
}
imageRes, err := client.StartContainer(CreateVM, PortsInt, GPU, ContainerName, BaseImage)
if err != nil {
fmt.Print(err)
}
client.PrettyPrint(imageRes)
}
if Specs != "" {
specs, err := client.GetSpecs(Specs)
if err != nil {
return err
}
client.PrettyPrint(specs)
}
if SetDefaultConfig {
_, err := generate.SetDefaults("P2PRC", false, nil, false)
if err != nil {
fmt.Print(err)
}
}
if NetworkInterface {
err := p2p.ViewNetworkInterface()
if err != nil {
fmt.Print(err)
}
}
if ViewPlugin {
plugins, err := plugin.DetectPlugins()
if err != nil {
fmt.Print(err)
}
client.PrettyPrint(plugins)
}
if TrackedContainers {
err, trackedContainers := client.ViewTrackedContainers()
if err != nil {
fmt.Print(err)
}
client.PrettyPrint(trackedContainers)
}
if ExecutePlugin != "" {
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")
}
}
if CreateGroup {
group, err := client.CreateGroup()
if err != nil {
return err
}
client.PrettyPrint(group)
}
if Group != "" {
if RemoveContainerGroup && ID != "" {
group, err := client.RemoveContainerGroup(ID, Group)
if err != nil {
fmt.Println(err)
} else {
client.PrettyPrint(group)
}
} else if ID != "" {
group, err := client.AddContainerToGroup(ID, Group)
if err != nil {
fmt.Println(err)
} else {
client.PrettyPrint(group)
}
} else {
group, err := client.GetGroup(Group)
if err != nil {
fmt.Println(err)
} else {
client.PrettyPrint(group)
}
}
}
if RemoveGroup != "" {
err := client.RemoveGroup(RemoveGroup)
if err != nil {
fmt.Println(err)
} else {
fmt.Println("Group Removed")
}
}
if Groups {
groups, err := client.ReadGroup()
if err != nil {
fmt.Println(err)
} else {
client.PrettyPrint(groups)
}
}
if PullPlugin != "" {
err := plugin.DownloadPlugin(PullPlugin)
if err != nil {
fmt.Println(err)
} else {
fmt.Println("Success")
}
}
if RemovePlugin != "" {
err := plugin.DeletePlugin(RemovePlugin)
if err != nil {
fmt.Println(err)
} else {
fmt.Println("Success")
}
}
if AddMetaData != "" {
err := clientIPTable.AddCustomInformationToIPTable(AddMetaData)
if err != nil {
fmt.Println(err)
} else {
fmt.Println("Success")
}
}
if MAPPort != "" {
address, err := client.MAPPort(MAPPort, DomainName)
if err != nil {
return err
}
if err != nil {
fmt.Println(err)
} else {
client.PrettyPrint(address)
}
}
return nil
}
```
Generated by [gomarkdoc](<https://github.com/princjef/gomarkdoc>)

116
config/docs.md Normal file
View File

@@ -0,0 +1,116 @@
<!-- Code generated by gomarkdoc. DO NOT EDIT -->
# config
```go
import "github.com/Akilan1999/p2p-rendering-computation/config"
```
## Index
- [func GetCurrentPath\(\) \(string, error\)](<#GetCurrentPath>)
- [func GetEnvName\(\) string](<#GetEnvName>)
- [func GetPathP2PRC\(Envname string\) \(string, error\)](<#GetPathP2PRC>)
- [func SetEnvName\(EnvName string\) error](<#SetEnvName>)
- [type Config](<#Config>)
- [func ConfigInit\(defaultsParameter map\[string\]interface\{\}, CustomConfig interface\{\}, envNameOptional ...string\) \(\*Config, error\)](<#ConfigInit>)
- [func \(c \*Config\) GetPublicKey\(\) \(string, error\)](<#Config.GetPublicKey>)
- [func \(c \*Config\) WriteConfig\(\) error](<#Config.WriteConfig>)
<a name="GetCurrentPath"></a>
## func [GetCurrentPath](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/config/config.go#L47>)
```go
func GetCurrentPath() (string, error)
```
GetCurrentPath Getting P2PRC Directory from environment variable
<a name="GetEnvName"></a>
## func [GetEnvName](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/config/config.go#L80>)
```go
func GetEnvName() string
```
<a name="GetPathP2PRC"></a>
## func [GetPathP2PRC](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/config/config.go#L53>)
```go
func GetPathP2PRC(Envname string) (string, error)
```
GetPathP2PRC Getting P2PRC Directory from environment variable
<a name="SetEnvName"></a>
## func [SetEnvName](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/config/config.go#L74>)
```go
func SetEnvName(EnvName string) error
```
SetEnvName Sets the environment name This is to ensure that the Path of your project is detected from your environment variable This is useful when extending the use case of P2PRC
<a name="Config"></a>
## type [Config](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/config/config.go#L19-L44>)
```go
type Config struct {
MachineName string
IPTable string
DockerContainers string
DefaultDockerFile string
DockerRunLogs string
SpeedTestFile string
IPV6Address string
PluginPath string
TrackContainersPath string
ServerPort string
ProxyPort string
GroupTrackContainersPath string
FRPServerPort string
BehindNAT string
IPTableKey string
PublicKeyFile string
PrivateKeyFile string
PemFile string
KeyFile string
BareMetal bool
UnsafeMode bool
CustomConfig interface{}
}
```
<a name="ConfigInit"></a>
### func [ConfigInit](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/config/config.go#L85>)
```go
func ConfigInit(defaultsParameter map[string]interface{}, CustomConfig interface{}, envNameOptional ...string) (*Config, error)
```
ConfigInit Pass environment name as an optional parameter
<a name="Config.GetPublicKey"></a>
### func \(\*Config\) [GetPublicKey](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/config/config.go#L179>)
```go
func (c *Config) GetPublicKey() (string, error)
```
GetPublicKey Gets public key of the current machine based on the path provided on the config file
<a name="Config.WriteConfig"></a>
### func \(\*Config\) [WriteConfig](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/config/config.go#L161>)
```go
func (c *Config) WriteConfig() error
```
Generated by [gomarkdoc](<https://github.com/princjef/gomarkdoc>)

176
config/generate/docs.md Normal file
View File

@@ -0,0 +1,176 @@
<!-- Code generated by gomarkdoc. DO NOT EDIT -->
# generate
```go
import "github.com/Akilan1999/p2p-rendering-computation/config/generate"
```
## Index
- [func Copy\(src, dst string\) error](<#Copy>)
- [func CreateIPTableFolderStructure\(\) \(err error\)](<#CreateIPTableFolderStructure>)
- [func FileExists\(path string\) \(bool, error\)](<#FileExists>)
- [func GenerateCertificate\(\) error](<#GenerateCertificate>)
- [func GenerateClientTrackContainers\(\) \(err error\)](<#GenerateClientTrackContainers>)
- [func GenerateDockerFiles\(\) \(err error\)](<#GenerateDockerFiles>)
- [func GenerateFiles\(rootNodes ...p2p.IpAddress\) \(err error\)](<#GenerateFiles>)
- [func GenerateIPTableFile\(rootNodes \[\]p2p.IpAddress\) \(err error\)](<#GenerateIPTableFile>)
- [func GeneratePluginDirectory\(\) \(err error\)](<#GeneratePluginDirectory>)
- [func GetPathP2PRC\(\) \(string, error\)](<#GetPathP2PRC>)
- [func MakeSSHKeyPair\(pubKeyPath, privateKeyPath string\) error](<#MakeSSHKeyPair>)
- [func SetDefaults\(envName string, forceDefault bool, CustomConfig interface\{\}, NoBoilerPlate bool, ConfigUpdate ...\*config.Config\) \(\*config.Config, error\)](<#SetDefaults>)
- [func SetEnvName\(EnvName string\) error](<#SetEnvName>)
- [func String\(length int\) string](<#String>)
- [func StringWithCharset\(length int, charset string\) string](<#StringWithCharset>)
- [type AuthorizedKey](<#AuthorizedKey>)
<a name="Copy"></a>
## func [Copy](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/config/generate/helperFunctions.go#L21>)
```go
func Copy(src, dst string) error
```
Copy the src file to dst. Any existing file will be overwritten and will not copy file attributes. Source: https://stackoverflow.com/questions/21060945/simple-way-to-copy-a-file
<a name="CreateIPTableFolderStructure"></a>
## func [CreateIPTableFolderStructure](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/config/generate/generateFiles.go#L65>)
```go
func CreateIPTableFolderStructure() (err error)
```
CreateIPTableFolderStructure Create folder structure for IPTable
<a name="FileExists"></a>
## func [FileExists](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/config/generate/generateFiles.go#L218>)
```go
func FileExists(path string) (bool, error)
```
FileExists exists returns whether the given file or directory exists source: https://stackoverflow.com/questions/10510691/how-to-check-whether-a-file-or-directory-exists
<a name="GenerateCertificate"></a>
## func [GenerateCertificate](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/config/generate/generateCertificate.go#L51>)
```go
func GenerateCertificate() error
```
<a name="GenerateClientTrackContainers"></a>
## func [GenerateClientTrackContainers](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/config/generate/generateFiles.go#L154>)
```go
func GenerateClientTrackContainers() (err error)
```
<a name="GenerateDockerFiles"></a>
## func [GenerateDockerFiles](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/config/generate/generateFiles.go#L91>)
```go
func GenerateDockerFiles() (err error)
```
GenerateDockerFiles Generate default docker files
<a name="GenerateFiles"></a>
## func [GenerateFiles](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/config/generate/generateFiles.go#L17>)
```go
func GenerateFiles(rootNodes ...p2p.IpAddress) (err error)
```
GenerateFiles Generates all the files needed to setup P2PRC
<a name="GenerateIPTableFile"></a>
## func [GenerateIPTableFile](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/config/generate/generateFiles.go#L35>)
```go
func GenerateIPTableFile(rootNodes []p2p.IpAddress) (err error)
```
GenerateIPTableFile Generates the IPTable file with the appropirate root node
<a name="GeneratePluginDirectory"></a>
## func [GeneratePluginDirectory](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/config/generate/generateFiles.go#L136>)
```go
func GeneratePluginDirectory() (err error)
```
GeneratePluginDirectory Generates plugin directory structure
<a name="GetPathP2PRC"></a>
## func [GetPathP2PRC](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/config/generate/generate.go#L17>)
```go
func GetPathP2PRC() (string, error)
```
GetPathP2PRC Getting P2PRC Directory from environment variable
<a name="MakeSSHKeyPair"></a>
## func [MakeSSHKeyPair](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/config/generate/generateFiles.go#L186>)
```go
func MakeSSHKeyPair(pubKeyPath, privateKeyPath string) error
```
MakeSSHKeyPair make a pair of public and private keys for SSH access. Public key is encoded in the format for inclusion in an OpenSSH authorized\_keys file. Private Key generated is PEM encoded source: https://gist.github.com/goliatone/e9c13e5f046e34cef6e150d06f20a34c
<a name="SetDefaults"></a>
## func [SetDefaults](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/config/generate/generate.go#L36>)
```go
func SetDefaults(envName string, forceDefault bool, CustomConfig interface{}, NoBoilerPlate bool, ConfigUpdate ...*config.Config) (*config.Config, error)
```
SetDefaults This function to be called only during a make install
<a name="SetEnvName"></a>
## func [SetEnvName](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/config/generate/generate.go#L26>)
```go
func SetEnvName(EnvName string) error
```
SetEnvName Sets the environment name This is to ensure that the Path of your project is detected from your environment variable This is useful when extending the use case of P2PRC
<a name="String"></a>
## func [String](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/config/generate/generate.go#L176>)
```go
func String(length int) string
```
<a name="StringWithCharset"></a>
## func [StringWithCharset](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/config/generate/generate.go#L168>)
```go
func StringWithCharset(length int, charset string) string
```
<a name="AuthorizedKey"></a>
## type [AuthorizedKey](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/config/generate/generateFiles.go#L230-L233>)
AuthorizedKey struct represents the structure of an authorized key
```go
type AuthorizedKey struct {
Username string
Key string
}
```
Generated by [gomarkdoc](<https://github.com/princjef/gomarkdoc>)

View File

40
main.md.org Normal file
View File

@@ -0,0 +1,40 @@
#+begin_html
<!-- Code generated by gomarkdoc. DO NOT EDIT -->
#+end_html
* p2p-rendering-computation
:PROPERTIES:
:CUSTOM_ID: p2p-rendering-computation
:END:
#+begin_src go
import "github.com/Akilan1999/p2p-rendering-computation"
#+end_src
** Index
:PROPERTIES:
:CUSTOM_ID: index
:END:
- [[#variables][Variables]]
** Variables
:PROPERTIES:
:CUSTOM_ID: variables
:END:
#+begin_src go
var List_servers, Ip_table bool
#+end_src
Varaibles if mode is client
#+begin_src go
var OS, Pull_location, Run_script string
#+end_src
VERSION specifies the version of the platform
#+begin_src go
var VERSION = "2.0.0"
#+end_src
Generated by [[https://github.com/princjef/gomarkdoc][gomarkdoc]]

303
p2p/docs.md Normal file
View File

@@ -0,0 +1,303 @@
<!-- Code generated by gomarkdoc. DO NOT EDIT -->
# p2p
```go
import "github.com/Akilan1999/p2p-rendering-computation/p2p"
```
## Index
- [func AddAuthorisationKey\(PublicKey string\) error](<#AddAuthorisationKey>)
- [func AddKeyToAuthorizedKeys\(path, newKey string\) error](<#AddKeyToAuthorizedKeys>)
- [func CurrentPublicIP\(\) \(string, error\)](<#CurrentPublicIP>)
- [func ForwardPort\(port int\) error](<#ForwardPort>)
- [func GenerateHashSHA256\(text string\) \[\]byte](<#GenerateHashSHA256>)
- [func GetAuthorizedKeysPath\(\) \(string, error\)](<#GetAuthorizedKeysPath>)
- [func GetCurrentIPV6\(\) \(string, error\)](<#GetCurrentIPV6>)
- [func Ip4or6\(s string\) string](<#Ip4or6>)
- [func LocalSpeedTestIpTable\(\) error](<#LocalSpeedTestIpTable>)
- [func PrettyPrint\(data interface\{\}\)](<#PrettyPrint>)
- [func PrintIpTable\(\) error](<#PrintIpTable>)
- [func ReadAuthorizedKeys\(path string\) \(map\[string\]bool, error\)](<#ReadAuthorizedKeys>)
- [func RemoveKeyFromAuthorizedKeys\(path, keyToRemove string\) error](<#RemoveKeyFromAuthorizedKeys>)
- [func UnForwardPort\(port int\) error](<#UnForwardPort>)
- [func ValidateHashSHA256\(text string, Hash \[\]byte\) bool](<#ValidateHashSHA256>)
- [func ViewNetworkInterface\(\) error](<#ViewNetworkInterface>)
- [type IP](<#IP>)
- [type IpAddress](<#IpAddress>)
- [func \(s \*IpAddress\) DownloadSpeed\(\) error](<#IpAddress.DownloadSpeed>)
- [func \(s \*IpAddress\) PingTest\(\) error](<#IpAddress.PingTest>)
- [func \(s \*IpAddress\) UploadSpeed\(\) error](<#IpAddress.UploadSpeed>)
- [type IpAddresses](<#IpAddresses>)
- [func ReadIpTable\(\) \(\*IpAddresses, error\)](<#ReadIpTable>)
- [func \(table \*IpAddresses\) RemoveDuplicates\(\) error](<#IpAddresses.RemoveDuplicates>)
- [func \(ip \*IpAddresses\) SpeedTest\(\) error](<#IpAddresses.SpeedTest>)
- [func \(ip \*IpAddresses\) SpeedTestUpdatedIPTable\(\) error](<#IpAddresses.SpeedTestUpdatedIPTable>)
- [func \(i \*IpAddresses\) WriteIpTable\(\) error](<#IpAddresses.WriteIpTable>)
<a name="AddAuthorisationKey"></a>
## func [AddAuthorisationKey](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/ssh_autorisation.go#L105>)
```go
func AddAuthorisationKey(PublicKey string) error
```
AddAuthorisationKey Adds public key provided to the authorization file so that nodes can SSH into the
<a name="AddKeyToAuthorizedKeys"></a>
## func [AddKeyToAuthorizedKeys](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/ssh_autorisation.go#L48>)
```go
func AddKeyToAuthorizedKeys(path, newKey string) error
```
AddKeyToAuthorizedKeys adds a new key to the authorized\_keys file if it doesnt already exist
<a name="CurrentPublicIP"></a>
## func [CurrentPublicIP](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/iptable.go#L180>)
```go
func CurrentPublicIP() (string, error)
```
CurrentPublicIP Get Current Public IP address
<a name="ForwardPort"></a>
## func [ForwardPort](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/upnp.go#L9>)
```go
func ForwardPort(port int) error
```
Port forwarding to the router
<a name="GenerateHashSHA256"></a>
## func [GenerateHashSHA256](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/iptable.go#L277>)
```go
func GenerateHashSHA256(text string) []byte
```
<a name="GetAuthorizedKeysPath"></a>
## func [GetAuthorizedKeysPath](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/ssh_autorisation.go#L16>)
```go
func GetAuthorizedKeysPath() (string, error)
```
GetAuthorizedKeysPath returns the path to the authorized\_keys file
<a name="GetCurrentIPV6"></a>
## func [GetCurrentIPV6](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/iptable.go#L200>)
```go
func GetCurrentIPV6() (string, error)
```
GetCurrentIPV6 gets the current IPV6 address based on the interface specified in the config file
<a name="Ip4or6"></a>
## func [Ip4or6](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/iptable.go#L253>)
```go
func Ip4or6(s string) string
```
Ip4or6 Helper function to check if the IP address is IPV4 or IPV6 \(https://socketloop.com/tutorials/golang-check-if-ip-address-is-version-4-or-6\)
<a name="LocalSpeedTestIpTable"></a>
## func [LocalSpeedTestIpTable](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/speedtest.go#L122>)
```go
func LocalSpeedTestIpTable() error
```
LocalSpeedTestIpTable Runs speed test in iptables locally only
<a name="PrettyPrint"></a>
## func [PrettyPrint](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/iptable.go#L266>)
```go
func PrettyPrint(data interface{})
```
<a name="PrintIpTable"></a>
## func [PrintIpTable](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/iptable.go#L127>)
```go
func PrintIpTable() error
```
PrintIpTable Print Ip table data for Cli
<a name="ReadAuthorizedKeys"></a>
## func [ReadAuthorizedKeys](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/ssh_autorisation.go#L25>)
```go
func ReadAuthorizedKeys(path string) (map[string]bool, error)
```
ReadAuthorizedKeys reads and returns the current contents of the authorized\_keys file as a map
<a name="RemoveKeyFromAuthorizedKeys"></a>
## func [RemoveKeyFromAuthorizedKeys](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/ssh_autorisation.go#L72>)
```go
func RemoveKeyFromAuthorizedKeys(path, keyToRemove string) error
```
<a name="UnForwardPort"></a>
## func [UnForwardPort](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/upnp.go#L42>)
```go
func UnForwardPort(port int) error
```
UnForwardPort from router
<a name="ValidateHashSHA256"></a>
## func [ValidateHashSHA256](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/iptable.go#L289>)
```go
func ValidateHashSHA256(text string, Hash []byte) bool
```
ValidateHashSHA256 CustomInformationKey the text and check if the text and the hash are the same, if they are then return true SHA256 is the current hashing algorthm used.
<a name="ViewNetworkInterface"></a>
## func [ViewNetworkInterface](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/iptable.go#L227>)
```go
func ViewNetworkInterface() error
```
ViewNetworkInterface This function is created to view the network interfaces available
<a name="IP"></a>
## type [IP](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/iptable.go#L41-L43>)
```go
type IP struct {
Query string
}
```
<a name="IpAddress"></a>
## type [IpAddress](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/iptable.go#L22-L39>)
```go
type IpAddress struct {
Name string `json:"Name"`
MachineUsername string `json:"MachineUsername"`
Ipv4 string `json:"IPV4"`
Ipv6 string `json:"IPV6"`
Latency time.Duration `json:"Latency"`
Download float64 `json:"Download"`
Upload float64 `json:"Upload"`
ServerPort string `json:"ServerPort"`
BareMetalSSHPort string `json:"BareMetalSSHPort"`
NAT string `json:"NAT"`
EscapeImplementation string `json:"EscapeImplementation"`
ProxyServer string `json:"ProxyServer"`
UnSafeMode bool `json:"UnSafeMode"`
PublicKey string `json:"PublicKey"`
CustomInformation string `json:"CustomInformation"`
}
```
<a name="IpAddress.DownloadSpeed"></a>
### func \(\*IpAddress\) [DownloadSpeed](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/testingMetrics.go#L82>)
```go
func (s *IpAddress) DownloadSpeed() error
```
Download Speed
<a name="IpAddress.PingTest"></a>
### func \(\*IpAddress\) [PingTest](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/testingMetrics.go#L152>)
```go
func (s *IpAddress) PingTest() error
```
PingTest executes test to measure latency
<a name="IpAddress.UploadSpeed"></a>
### func \(\*IpAddress\) [UploadSpeed](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/testingMetrics.go#L97>)
```go
func (s *IpAddress) UploadSpeed() error
```
<a name="IpAddresses"></a>
## type [IpAddresses](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/iptable.go#L18-L20>)
```go
type IpAddresses struct {
IpAddress []IpAddress `json:"ip_address"`
}
```
<a name="ReadIpTable"></a>
### func [ReadIpTable](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/iptable.go#L46>)
```go
func ReadIpTable() (*IpAddresses, error)
```
ReadIpTable Read data from Ip tables from json file
<a name="IpAddresses.RemoveDuplicates"></a>
### func \(\*IpAddresses\) [RemoveDuplicates](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/iptable.go#L146>)
```go
func (table *IpAddresses) RemoveDuplicates() error
```
RemoveDuplicates This is a temporary fix current functions failing to remove Duplicate IP addresses from local IP table
<a name="IpAddresses.SpeedTest"></a>
### func \(\*IpAddresses\) [SpeedTest](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/speedtest.go#L8>)
```go
func (ip *IpAddresses) SpeedTest() error
```
SpeedTest Runs a speed test and does updates IP tables accordingly
<a name="IpAddresses.SpeedTestUpdatedIPTable"></a>
### func \(\*IpAddresses\) [SpeedTestUpdatedIPTable](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/speedtest.go#L56>)
```go
func (ip *IpAddresses) SpeedTestUpdatedIPTable() error
```
SpeedTestUpdatedIPTable Called when ip tables from httpclient/server is also passed on
<a name="IpAddresses.WriteIpTable"></a>
### func \(\*IpAddresses\) [WriteIpTable](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/iptable.go#L101>)
```go
func (i *IpAddresses) WriteIpTable() error
```
WriteIpTable Write to IP table json file
Generated by [gomarkdoc](<https://github.com/princjef/gomarkdoc>)

113
p2p/frp/docs.md Normal file
View File

@@ -0,0 +1,113 @@
<!-- Code generated by gomarkdoc. DO NOT EDIT -->
# frp
```go
import "github.com/Akilan1999/p2p-rendering-computation/p2p/frp"
```
## Index
- [func GetFRPServerPort\(host string\) \(string, error\)](<#GetFRPServerPort>)
- [func StartFRPCDockerContainer\(ipaddress string, port string, Docker \*docker.DockerVM\) \(\*docker.DockerVM, error\)](<#StartFRPCDockerContainer>)
- [func StartFRPClientForServer\(ipaddress string, port string, localport string, remoteport string\) \(string, error\)](<#StartFRPClientForServer>)
- [func StartFRPProxyFromRandom\(\) \(int, error\)](<#StartFRPProxyFromRandom>)
- [type Client](<#Client>)
- [func \(c \*Client\) StartFRPClient\(\) error](<#Client.StartFRPClient>)
- [type ClientMapping](<#ClientMapping>)
- [type Server](<#Server>)
- [func \(s \*Server\) StartFRPServer\(\) error](<#Server.StartFRPServer>)
<a name="GetFRPServerPort"></a>
## func [GetFRPServerPort](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/frp/server.go#L65>)
```go
func GetFRPServerPort(host string) (string, error)
```
GetFRPServerPort Gets the port no from the FRPServer to establish the FRP connection needed.
<a name="StartFRPCDockerContainer"></a>
## func [StartFRPCDockerContainer](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/frp/client.go#L90>)
```go
func StartFRPCDockerContainer(ipaddress string, port string, Docker *docker.DockerVM) (*docker.DockerVM, error)
```
<a name="StartFRPClientForServer"></a>
## func [StartFRPClientForServer](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/frp/client.go#L35>)
```go
func StartFRPClientForServer(ipaddress string, port string, localport string, remoteport string) (string, error)
```
StartFRPClientForServer Starts Server using FRP server returns back a port remote port is a custom external port a user would want to open. This under the assumption the user knows the exact port available in server doing the TURN connection.
<a name="StartFRPProxyFromRandom"></a>
## func [StartFRPProxyFromRandom](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/frp/server.go#L19>)
```go
func StartFRPProxyFromRandom() (int, error)
```
StartFRPProxyFromRandom starts reverse proxy server based on a random port generated
<a name="Client"></a>
## type [Client](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/frp/client.go#L16-L20>)
Client This struct stores client information with server proxy connected
```go
type Client struct {
Name string
Server *Server
ClientMappings []ClientMapping
}
```
<a name="Client.StartFRPClient"></a>
### func \(\*Client\) [StartFRPClient](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/frp/client.go#L143>)
```go
func (c *Client) StartFRPClient() error
```
StartFRPClient Starts FRP client
<a name="ClientMapping"></a>
## type [ClientMapping](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/frp/client.go#L24-L28>)
ClientMapping Stores client mapping ports to proxy server
```go
type ClientMapping struct {
LocalIP string
LocalPort int
RemotePort int
}
```
<a name="Server"></a>
## type [Server](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/frp/server.go#L11-L14>)
```go
type Server struct {
// contains filtered or unexported fields
}
```
<a name="Server.StartFRPServer"></a>
### func \(\*Server\) [StartFRPServer](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/frp/server.go#L49>)
```go
func (s *Server) StartFRPServer() error
```
StartFRPServer The initial plan is only support reverse proxy for TCP ports This function starts a server that can act as a reverse proxy for nodes behind NAT.
Generated by [gomarkdoc](<https://github.com/princjef/gomarkdoc>)

224
plugin/docs.md Normal file
View File

@@ -0,0 +1,224 @@
<!-- Code generated by gomarkdoc. DO NOT EDIT -->
# plugin
```go
import "github.com/Akilan1999/p2p-rendering-computation/plugin"
```
## Index
- [func CheckRunPlugin\(PluginName string, ID string\) error](<#CheckRunPlugin>)
- [func DeletePlugin\(pluginname string\) error](<#DeletePlugin>)
- [func DownloadPlugin\(pluginurl string\) error](<#DownloadPlugin>)
- [func RunPluginContainer\(PluginName string, ContainerID string\) error](<#RunPluginContainer>)
- [type ExecuteIP](<#ExecuteIP>)
- [func \(e \*ExecuteIP\) ModifyHost\(p \*Plugin\) error](<#ExecuteIP.ModifyHost>)
- [func \(e \*ExecuteIP\) RunAnsible\(p \*Plugin\) error](<#ExecuteIP.RunAnsible>)
- [type Host](<#Host>)
- [func ReadHost\(filename string\) \(\*Host, error\)](<#ReadHost>)
- [type Plugin](<#Plugin>)
- [func RunPlugin\(pluginName string, IPAddresses \[\]\*ExecuteIP\) \(\*Plugin, error\)](<#RunPlugin>)
- [func SearchPlugin\(pluginname string\) \(\*Plugin, error\)](<#SearchPlugin>)
- [func \(p \*Plugin\) AutoSetPorts\(containerID string\) error](<#Plugin.AutoSetPorts>)
- [func \(p \*Plugin\) CopyToTmpPlugin\(\) error](<#Plugin.CopyToTmpPlugin>)
- [func \(p \*Plugin\) ExecutePlugin\(\) error](<#Plugin.ExecutePlugin>)
- [func \(p \*Plugin\) NumPorts\(\) error](<#Plugin.NumPorts>)
- [type Plugins](<#Plugins>)
- [func DetectPlugins\(\) \(\*Plugins, error\)](<#DetectPlugins>)
<a name="CheckRunPlugin"></a>
## func [CheckRunPlugin](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/plugin/plugin.go#L330>)
```go
func CheckRunPlugin(PluginName string, ID string) error
```
CheckRunPlugin Checks if the ID belongs to the group or container calls the plugin function the appropriate amount of times
<a name="DeletePlugin"></a>
## func [DeletePlugin](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/plugin/packageManager.go#L46>)
```go
func DeletePlugin(pluginname string) error
```
DeletePlugin The following function deletes a plugin based on the plugin name provided.
<a name="DownloadPlugin"></a>
## func [DownloadPlugin](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/plugin/packageManager.go#L13>)
```go
func DownloadPlugin(pluginurl string) error
```
DownloadPlugin This functions downloads package from a git repo.
<a name="RunPluginContainer"></a>
## func [RunPluginContainer](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/plugin/plugin.go#L284>)
```go
func RunPluginContainer(PluginName string, ContainerID string) error
```
RunPluginContainer Runs ansible plugin based on plugin name and container name which is derived from the tracked containers file We pass in the group ID as a parameter because when we modify the ports taken
<a name="ExecuteIP"></a>
## type [ExecuteIP](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/plugin/plugin.go#L40-L45>)
ExecuteIP IP Address to execute Ansible instruction
```go
type ExecuteIP struct {
ContainerID string
IPAddress string
SSHPortNo string
Success bool
}
```
<a name="ExecuteIP.ModifyHost"></a>
### func \(\*ExecuteIP\) [ModifyHost](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/plugin/plugin.go#L234>)
```go
func (e *ExecuteIP) ModifyHost(p *Plugin) error
```
ModifyHost adds IP address , port no to the config file
<a name="ExecuteIP.RunAnsible"></a>
### func \(\*ExecuteIP\) [RunAnsible](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/plugin/plugin.go#L199>)
```go
func (e *ExecuteIP) RunAnsible(p *Plugin) error
```
RunAnsible Executes based on credentials on the struct
<a name="Host"></a>
## type [Host](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/plugin/plugin.go#L49-L66>)
Host Struct for ansible host Generated from https://zhwt.github.io/yaml-to-go/
```go
type Host struct {
All struct {
Vars struct {
AnsiblePythonInterpreter string `yaml:"ansible_python_interpreter"`
} `yaml:"vars"`
} `yaml:"all"`
Main struct {
Hosts struct {
Host1 struct {
AnsibleHost string `yaml:"ansible_host"`
AnsiblePort int `yaml:"ansible_port"`
AnsibleUser string `yaml:"ansible_user"`
AnsibleSSHPass string `yaml:"ansible_ssh_pass"`
AnsibleSudoPass string `yaml:"ansible_sudo_pass"`
} `yaml:"host1"`
} `yaml:"hosts"`
} `yaml:"main"`
}
```
<a name="ReadHost"></a>
### func [ReadHost](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/plugin/plugin.go#L266>)
```go
func ReadHost(filename string) (*Host, error)
```
ReadHost Reads host file and adds
<a name="Plugin"></a>
## type [Plugin](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/plugin/plugin.go#L31-L37>)
Plugin Information about the plugins available
```go
type Plugin struct {
FolderName string
PluginDescription string
Execute []*ExecuteIP
NumOfPorts int
// contains filtered or unexported fields
}
```
<a name="RunPlugin"></a>
### func [RunPlugin](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/plugin/plugin.go#L131>)
```go
func RunPlugin(pluginName string, IPAddresses []*ExecuteIP) (*Plugin, error)
```
RunPlugin Executes plugins based on the plugin name provided
<a name="SearchPlugin"></a>
### func [SearchPlugin](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/plugin/plugin.go#L114>)
```go
func SearchPlugin(pluginname string) (*Plugin, error)
```
SearchPlugin Detects plugin information based on the name provided on the parameter
<a name="Plugin.AutoSetPorts"></a>
### func \(\*Plugin\) [AutoSetPorts](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/plugin/plugin.go#L383>)
```go
func (p *Plugin) AutoSetPorts(containerID string) error
```
AutoSetPorts Automatically maps free ports to site.yml file
<a name="Plugin.CopyToTmpPlugin"></a>
### func \(\*Plugin\) [CopyToTmpPlugin](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/plugin/plugin.go#L366>)
```go
func (p *Plugin) CopyToTmpPlugin() error
```
CopyToTmpPlugin This function would ensure that we create a copy of the plugin in the tmp directory, and it would be executed from there. This due to the reason of automating port allocation when running plugins
<a name="Plugin.ExecutePlugin"></a>
### func \(\*Plugin\) [ExecutePlugin](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/plugin/plugin.go#L174>)
```go
func (p *Plugin) ExecutePlugin() error
```
ExecutePlugin Function to execute plugins that are called
<a name="Plugin.NumPorts"></a>
### func \(\*Plugin\) [NumPorts](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/plugin/plugin.go#L446>)
```go
func (p *Plugin) NumPorts() error
```
NumPorts Gets the Number the ports the plugin requires
<a name="Plugins"></a>
## type [Plugins](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/plugin/plugin.go#L26-L28>)
Plugins Array of all plugins detected
```go
type Plugins struct {
PluginsDetected []*Plugin
}
```
<a name="DetectPlugins"></a>
### func [DetectPlugins](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/plugin/plugin.go#L69>)
```go
func DetectPlugins() (*Plugins, error)
```
DetectPlugins Detects all the plugins available
Generated by [gomarkdoc](<https://github.com/princjef/gomarkdoc>)

174
server/docker/docs.md Normal file
View File

@@ -0,0 +1,174 @@
<!-- Code generated by gomarkdoc. DO NOT EDIT -->
# docker
```go
import "github.com/Akilan1999/p2p-rendering-computation/server/docker"
```
## Index
- [func StopAndRemoveContainer\(containername string\) error](<#StopAndRemoveContainer>)
- [type DockerContainer](<#DockerContainer>)
- [type DockerContainers](<#DockerContainers>)
- [func ViewAllContainers\(\) \(\*DockerContainers, error\)](<#ViewAllContainers>)
- [type DockerVM](<#DockerVM>)
- [func BuildRunContainer\(NumPorts int, GPU string, ContainerName string, baseImage string, publicKey string\) \(\*DockerVM, error\)](<#BuildRunContainer>)
- [func \(d \*DockerVM\) CopyToTmpContainer\(\) error](<#DockerVM.CopyToTmpContainer>)
- [func \(d \*DockerVM\) TemplateDockerContainer\(\) error](<#DockerVM.TemplateDockerContainer>)
- [type ErrorDetail](<#ErrorDetail>)
- [type ErrorLine](<#ErrorLine>)
- [type Port](<#Port>)
- [type Ports](<#Ports>)
- [func OpenPortsFile\(filename string\) \(\*Ports, error\)](<#OpenPortsFile>)
<a name="StopAndRemoveContainer"></a>
## func [StopAndRemoveContainer](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/server/docker/docker.go#L340>)
```go
func StopAndRemoveContainer(containername string) error
```
StopAndRemoveContainer Stop and remove a container Reference \(https://gist.github.com/frikky/e2efcea6c733ea8d8d015b7fe8a91bf6\)
<a name="DockerContainer"></a>
## type [DockerContainer](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/server/docker/docker.go#L40-L43>)
```go
type DockerContainer struct {
ContainerName string `json:"DockerContainerName"`
ContainerDescription string `json:"ContainerDescription"`
}
```
<a name="DockerContainers"></a>
## type [DockerContainers](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/server/docker/docker.go#L36-L38>)
```go
type DockerContainers struct {
DockerContainer []DockerContainer `json:"DockerContainer"`
}
```
<a name="ViewAllContainers"></a>
### func [ViewAllContainers](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/server/docker/docker.go#L387>)
```go
func ViewAllContainers() (*DockerContainers, error)
```
ViewAllContainers returns all containers runnable and which can be built
<a name="DockerVM"></a>
## type [DockerVM](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/server/docker/docker.go#L22-L34>)
```go
type DockerVM struct {
SSHUsername string `json:"SSHUsername"`
SSHPublcKey string `json:"SSHPublicKey"`
ID string `json:"ID"`
TagName string `json:"TagName"`
ImagePath string `json:"ImagePath"`
Ports Ports `json:"Ports"`
GPU string `json:"GPU"`
TempPath string
BaseImage string
LogsPath string
SSHCommand string `json:"SSHCommand"`
}
```
<a name="BuildRunContainer"></a>
### func [BuildRunContainer](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/server/docker/docker.go#L70>)
```go
func BuildRunContainer(NumPorts int, GPU string, ContainerName string, baseImage string, publicKey string) (*DockerVM, error)
```
BuildRunContainer Function is incharge to invoke building and running contianer and also allocating external ports
<a name="DockerVM.CopyToTmpContainer"></a>
### func \(\*DockerVM\) [CopyToTmpContainer](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/server/docker/docker.go#L493>)
```go
func (d *DockerVM) CopyToTmpContainer() error
```
CopyToTmpContainer Creates a copy of the docker folder
<a name="DockerVM.TemplateDockerContainer"></a>
### func \(\*DockerVM\) [TemplateDockerContainer](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/server/docker/docker.go#L464>)
```go
func (d *DockerVM) TemplateDockerContainer() error
```
TemplateDockerContainer This function templates the docker container with the base docker image to use
<a name="ErrorDetail"></a>
## type [ErrorDetail](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/server/docker/docker.go#L62-L64>)
```go
type ErrorDetail struct {
Message string `json:"message"`
}
```
<a name="ErrorLine"></a>
## type [ErrorLine](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/server/docker/docker.go#L57-L60>)
```go
type ErrorLine struct {
Error string `json:"error"`
ErrorDetail ErrorDetail `json:"errorDetail"`
}
```
<a name="Port"></a>
## type [Port](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/server/docker/docker.go#L48-L55>)
```go
type Port struct {
PortName string `json:"PortName"`
InternalPort int `json:"InternalPort"`
Type string `json:"Type"`
ExternalPort int `json:"ExternalPort"`
IsUsed bool `json:"IsUsed"`
Description string `json:"Description"`
}
```
<a name="Ports"></a>
## type [Ports](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/server/docker/docker.go#L45-L47>)
```go
type Ports struct {
PortSet []Port `json:"Port"`
}
```
<a name="OpenPortsFile"></a>
### func [OpenPortsFile](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/server/docker/docker.go#L447>)
```go
func OpenPortsFile(filename string) (*Ports, error)
```
Generated by [gomarkdoc](<https://github.com/princjef/gomarkdoc>)

227
server/docs.md Normal file
View File

@@ -0,0 +1,227 @@
<!-- Code generated by gomarkdoc. DO NOT EDIT -->
# server
```go
import "github.com/Akilan1999/p2p-rendering-computation/server"
```
source:https://github.com/afoley587/go-rev-proxy/tree/main
## Index
- [Variables](<#variables>)
- [func GetScheme\(c \*gin.Context\) string](<#GetScheme>)
- [func MapPort\(port string, domainName string, serverAddress string\) \(string, string, error\)](<#MapPort>)
- [func Proxy\(c \*gin.Context\)](<#Proxy>)
- [func ProxyRun\(port string\)](<#ProxyRun>)
- [func SaveRegistration\(OutsideHost string, InsideHost string\) error](<#SaveRegistration>)
- [func Server\(\) \(\*gin.Engine, error\)](<#Server>)
- [type Gpu](<#Gpu>)
- [type GpuClock](<#GpuClock>)
- [type GpuTemperature](<#GpuTemperature>)
- [type GpuUtilization](<#GpuUtilization>)
- [type Query](<#Query>)
- [func GPUInfo\(\) \(\*Query, error\)](<#GPUInfo>)
- [type RegistrationRequest](<#RegistrationRequest>)
- [type ReverseProxy](<#ReverseProxy>)
- [type SysInfo](<#SysInfo>)
- [func ServerInfo\(\) \*SysInfo](<#ServerInfo>)
## Variables
<a name="KnownAddresses"></a>
```go
var (
//RunPort = 2002 // The server port to run on
//ReverseServerAddr = fmt.Sprint("0.0.0.0:", RunPort) // this is our reverse server ip address
//InsideProxyHostname = fmt.Sprint("proxy:", RunPort) // Requests from private network
//OutsideProxyHostname = fmt.Sprint("registration.localhost:", RunPort) // Requests from public network
KnownAddresses = map[string]string{} // Known Addresses
)
```
<a name="ReverseProxies"></a>ReverseProxies Reverse to the map such as ReverseProxies\[\<domain nane\>\]ReverseProxy type
```go
var ReverseProxies map[string]ReverseProxy
```
<a name="GetScheme"></a>
## func [GetScheme](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/server/ReverseProxy.go#L29>)
```go
func GetScheme(c *gin.Context) string
```
This function checks if TLS was enabled on the request and translates it to the proper scheme \(http or https\)
<a name="MapPort"></a>
## func [MapPort](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/server/server.go#L378>)
```go
func MapPort(port string, domainName string, serverAddress string) (string, string, error)
```
<a name="Proxy"></a>
## func [Proxy](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/server/ReverseProxy.go#L84>)
```go
func Proxy(c *gin.Context)
```
Proxy runs the actual proxy and will look at the hostnames requested from the received request. It will then translate that to the inside hostname and forward the request
<a name="ProxyRun"></a>
## func [ProxyRun](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/server/ReverseProxy.go#L130>)
```go
func ProxyRun(port string)
```
<a name="SaveRegistration"></a>
## func [SaveRegistration](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/server/ReverseProxy.go#L66>)
```go
func SaveRegistration(OutsideHost string, InsideHost string) error
```
SaveRegistration Creates registration of proxy node
<a name="Server"></a>
## func [Server](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/server/server.go#L31>)
```go
func Server() (*gin.Engine, error)
```
<a name="Gpu"></a>
## type [Gpu](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/server/gpu.go#L13-L20>)
```go
type Gpu struct {
GpuName string `xml:"product_name"`
BiosVersion string `xml:"vbios_version"`
FanSpeed string `xml:"fan_speed"`
Utilization GpuUtilization `xml:"utilization"`
Temperature GpuTemperature `xml:"temperature"`
Clock GpuClock `xml:"clocks"`
}
```
<a name="GpuClock"></a>
## type [GpuClock](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/server/gpu.go#L31-L34>)
```go
type GpuClock struct {
GpuClock string `xml:"graphics_clock"`
GpuMemClock string `xml:"mem_clock"`
}
```
<a name="GpuTemperature"></a>
## type [GpuTemperature](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/server/gpu.go#L27-L29>)
```go
type GpuTemperature struct {
GpuTemp string `xml:"gpu_temp"`
}
```
<a name="GpuUtilization"></a>
## type [GpuUtilization](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/server/gpu.go#L22-L25>)
```go
type GpuUtilization struct {
GpuUsage string `xml:"gpu_util"`
MemoryUsage string `xml:"memory_util"`
}
```
<a name="Query"></a>
## type [Query](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/server/gpu.go#L8-L11>)
```go
type Query struct {
DriveVersion string `xml:"driver_version"`
Gpu Gpu `xml:"gpu"`
}
```
<a name="GPUInfo"></a>
### func [GPUInfo](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/server/gpu.go#L38>)
```go
func GPUInfo() (*Query, error)
```
Gets GPU information by calling nvidia\-smi in XML output
<a name="RegistrationRequest"></a>
## type [RegistrationRequest](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/server/ReverseProxy.go#L22-L25>)
```go
type RegistrationRequest struct {
OutsideHost string // Outside host address. The hostname or IP on the public network. For example foo.bar.com or foo.localhost
InsideHost string // Inside host address. The hostname or IP on the internal network. For example 192.168.10.5
}
```
<a name="ReverseProxy"></a>
## type [ReverseProxy](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/server/server.go#L23-L26>)
```go
type ReverseProxy struct {
IPAddress string
Port string
}
```
<a name="SysInfo"></a>
## type [SysInfo](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/server/gopsutil.go#L11-L18>)
SysInfo saves the basic system information
```go
type SysInfo struct {
Hostname string `bson:hostname`
Platform string `bson:platform`
CPU string `bson:cpu`
RAM uint64 `bson:ram`
Disk uint64 `bson:disk`
GPU *Query `xml: GpuInfo`
}
```
<a name="ServerInfo"></a>
### func [ServerInfo](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/server/gopsutil.go#L20>)
```go
func ServerInfo() *SysInfo
```
Generated by [gomarkdoc](<https://github.com/princjef/gomarkdoc>)