20 Commits

Author SHA1 Message Date
5f8407a37f added comment 2025-04-24 23:28:19 +01:00
a6939ec35e added python function call add custom information 2025-04-24 23:15:02 +01:00
Akilan Selvacoumar
c445ac88c4 Merge pull request #124 from Akilan1999/python-bindings
Python bindings (Base function calls)
2025-04-24 22:17:02 +01:00
9075ab5967 added python bindings 2025-04-24 15:51:47 +01:00
125d113ade added base python bindings 2025-04-07 20:25:25 +01:00
e7e0641f31 removed syscall kill 2025-04-07 18:52:18 +01:00
05655e2da1 modified README 2025-02-27 17:21:21 +00:00
ed8d2be205 added version 3 2025-02-27 17:19:56 +00:00
Akilan Selvacoumar
30cd9c1901 Update README.md 2025-01-29 17:17:02 +00:00
d9d5ebe475 Merge branch 'master' of github.com:Akilan1999/p2p-rendering-computation 2025-01-29 17:12:00 +00:00
23abbc8f90 added base tutorial for running nix 2025-01-29 17:11:43 +00:00
Akilan Selvacoumar
5c0bcfd4cf Update README.md 2025-01-28 16:17:36 +00:00
9b255265c4 added docs changes 2025-01-28 16:15:42 +00:00
075d1850f6 Merge branch 'master' of github.com:Akilan1999/p2p-rendering-computation 2025-01-27 22:41:12 +00:00
38bef975d5 added initial blog post 2025-01-27 22:41:03 +00:00
Akilan Selvacoumar
5cbc9842b4 Update README.md 2025-01-27 21:26:44 +00:00
4479a79912 pushed commit for remote map port 2025-01-24 22:35:50 +00:00
88a4e02e30 added index.html 2025-01-21 21:25:58 +00:00
ddd6864741 latest git ignore changes 2025-01-21 21:25:21 +00:00
Akilan Selvacoumar
3735ab87e0 Merge pull request #122 from Akilan1999/p2prc-docs
P2PRC docs
2025-01-21 21:14:36 +00:00
28 changed files with 1762 additions and 581 deletions

BIN
.DS_Store vendored

Binary file not shown.

3
.gitignore vendored
View File

@@ -43,6 +43,9 @@ p2prc.PublicKeyBareMetal
# Ignore pem files # Ignore pem files
*.pem *.pem
# ignore virtual env file
venv
# Nix and Nix flake files # Nix and Nix flake files
result result
result-* result-*

View File

@@ -2,11 +2,11 @@ package main
import "C" import "C"
import ( import (
"encoding/json" "encoding/json"
"time" "time"
"github.com/Akilan1999/p2p-rendering-computation/abstractions" "github.com/Akilan1999/p2p-rendering-computation/abstractions"
"github.com/Akilan1999/p2p-rendering-computation/p2p/frp" "github.com/Akilan1999/p2p-rendering-computation/p2p/frp"
) )
// The Client package where data-types // The Client package where data-types
@@ -18,20 +18,20 @@ import (
//export StartContainer //export StartContainer
func StartContainer(IP string) (output *C.char) { func StartContainer(IP string) (output *C.char) {
container, err := abstractions.StartContainer(IP) container, err := abstractions.StartContainer(IP)
if err != nil { if err != nil {
return C.CString(err.Error()) return C.CString(err.Error())
} }
return ConvertStructToJSONString(container) return ConvertStructToJSONString(container)
} }
//export RemoveContainer //export RemoveContainer
func RemoveContainer(IP string, ID string) (output *C.char) { func RemoveContainer(IP string, ID string) (output *C.char) {
err := abstractions.RemoveContainer(IP, ID) err := abstractions.RemoveContainer(IP, ID)
if err != nil { if err != nil {
return C.CString(err.Error()) return C.CString(err.Error())
} }
return C.CString("Success") return C.CString("Success")
} }
// --------------------------------- Plugin Control ---------------------------------------- // --------------------------------- Plugin Control ----------------------------------------
@@ -77,20 +77,20 @@ func RemoveContainer(IP string, ID string) (output *C.char) {
//export GetSpecs //export GetSpecs
func GetSpecs(IP string) (output *C.char) { func GetSpecs(IP string) (output *C.char) {
specs, err := abstractions.GetSpecs(IP) specs, err := abstractions.GetSpecs(IP)
if err != nil { if err != nil {
return C.CString(err.Error()) return C.CString(err.Error())
} }
return ConvertStructToJSONString(specs) return ConvertStructToJSONString(specs)
} }
//export Init //export Init
func Init(customConfig string) (output *C.char) { func Init(customConfig string) (output *C.char) {
init, err := abstractions.Init(customConfig) init, err := abstractions.Init(customConfig)
if err != nil { if err != nil {
return C.CString(err.Error()) return C.CString(err.Error())
} }
return ConvertStructToJSONString(init) return ConvertStructToJSONString(init)
} }
@@ -98,72 +98,81 @@ func Init(customConfig string) (output *C.char) {
//export ViewIPTable //export ViewIPTable
func ViewIPTable() (output *C.char) { func ViewIPTable() (output *C.char) {
table, err := abstractions.ViewIPTable() table, err := abstractions.ViewIPTable()
if err != nil { if err != nil {
return C.CString(err.Error()) return C.CString(err.Error())
} }
return ConvertStructToJSONString(table) return ConvertStructToJSONString(table)
} }
//export UpdateIPTable //export UpdateIPTable
func UpdateIPTable() (output *C.char) { func UpdateIPTable() (output *C.char) {
err := abstractions.UpdateIPTable() err := abstractions.UpdateIPTable()
if err != nil { if err != nil {
return C.CString(err.Error()) return C.CString(err.Error())
} }
return C.CString("Success") return C.CString("Success")
} }
//export EscapeFirewall //export EscapeFirewall
func EscapeFirewall(HostOutsideNATIP string, HostOutsideNATPort string, internalPort string) (output *C.char) { func EscapeFirewall(HostOutsideNATIP string, HostOutsideNATPort string, internalPort string) (output *C.char) {
// Get free port from P2PRC server node // Get free port from P2PRC server node
serverPort, err := frp.GetFRPServerPort("http://" + HostOutsideNATIP + ":" + HostOutsideNATPort) serverPort, err := frp.GetFRPServerPort("http://" + HostOutsideNATIP + ":" + HostOutsideNATPort)
if err != nil { if err != nil {
return C.CString(err.Error()) return C.CString(err.Error())
} }
time.Sleep(5 * time.Second) time.Sleep(5 * time.Second)
ExposedPort, err := frp.StartFRPClientForServer(HostOutsideNATIP+":"+HostOutsideNATPort, serverPort, internalPort, "") ExposedPort, err := frp.StartFRPClientForServer(HostOutsideNATIP+":"+HostOutsideNATPort, serverPort, internalPort, "")
if err != nil { if err != nil {
return C.CString(err.Error()) return C.CString(err.Error())
} }
return C.CString(ExposedPort) return C.CString(ExposedPort)
} }
//export MapPort //export MapPort
func MapPort(Port string, DomainName string, ServerAddress string) *C.char { func MapPort(Port string, DomainName string, ServerAddress string) *C.char {
entireAddress, _, err := abstractions.MapPort(Port, DomainName, ServerAddress) Address, err := abstractions.MapPort(Port, DomainName, ServerAddress)
if err != nil { if err != nil {
return C.CString(err.Error()) return C.CString(err.Error())
} }
return C.CString(entireAddress) 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")
} }
// --------------------------------- Controlling Server ---------------------------------------- // --------------------------------- Controlling Server ----------------------------------------
//export Server //export Server
func Server() (output *C.char) { func Server() (output *C.char) {
_, err := abstractions.Start() _, err := abstractions.Start()
if err != nil { if err != nil {
return C.CString(err.Error()) return C.CString(err.Error())
} }
return ConvertStructToJSONString("") return ConvertStructToJSONString("")
} }
// --------------------------------- Helper Functions ---------------------------------------- // --------------------------------- Helper Functions ----------------------------------------
func ConvertStructToJSONString(Struct interface{}) *C.char { func ConvertStructToJSONString(Struct interface{}) *C.char {
jsonBytes, err := json.Marshal(Struct) jsonBytes, err := json.Marshal(Struct)
if err != nil { if err != nil {
return C.CString(err.Error()) return C.CString(err.Error())
} }
// Convert the JSON bytes to a string // Convert the JSON bytes to a string
return C.CString(string(jsonBytes)) return C.CString(string(jsonBytes))
} }
func main() {} func main() {}

2
Bindings/Haskell/.mhsi Normal file
View File

@@ -0,0 +1,2 @@
exit
Exit

View File

@@ -0,0 +1,4 @@
module Paths_p2prc where
import Data.Version
version :: Version; version = makeVersion [0,1,0,0]
getDataDir :: IO FilePath; getDataDir = return "/Users/akilan/.mcabal/mhs-0.12.3.0/packages/p2prc-0.1.0.0/data"

View File

@@ -0,0 +1 @@
z

Binary file not shown.

114
Bindings/python/library.py Normal file
View File

@@ -0,0 +1,114 @@
import ctypes
from ctypes import Structure, c_char_p, c_int, cdll
from dataclasses import dataclass, astuple
import time
import json
from urllib.parse import urlparse
from typing import List
import subprocess
import uuid
import dacite
import os
import sqlalchemy
import dataclasses
from typing import Union
import schedule
import threading
import requests
p2prc = ctypes.CDLL("SharedObjects/p2prc.so")
p2prc.Init("")
# Start running schedule
schedule.run_pending()
# # Create Sqlite database to track processes
# engine=sqlalchemy.create_engine(f'sqlite:///homeserver.db')
# Global variable
# A global variable will be populated on runtime.
# It is read from P2PRC directly or from a local
# database.
# Node information
# Generated using: https://jsonformatter.org/json-to-python
@dataclass
class Node:
Name: str
MachineUsername: str
IPV4: str
IPV6: str
Latency: int
Download: int
Upload: int
ServerPort: str
BareMetalSSHPort: str
NAT: str
EscapeImplementation: str
ProxyServer: str
UnSafeMode: bool
PublicKey: str
CustomInformation: str
@dataclass
class IPAddress:
ip_address: List[Node]
# ----------------------------------------------------------------------------
# ----------------------------- Helper functions -----------------------------
# ----------------------------------------------------------------------------
def StartServer():
# Starting P2PRC as a server mode
p2prc.Server()
# Class to create string to pass as string function
# parameter to shared object file
class go_string(Structure):
_fields_ = [
("p", c_char_p),
("n", c_int)]
# Ensuring local port can escape NAT and responds
# with the public ip and port no.
# If the domain name is specified then the public IP
# can be used as an A name entry.
def P2PRCMapPort(port="",domainname="",serveraddress=""):
port = go_string(c_char_p(port.encode('utf-8')), len(port))
domainname = go_string(c_char_p(domainname.encode('utf-8')), len(domainname))
serveraddress = go_string(c_char_p(serveraddress.encode('utf-8')), len(serveraddress))
# Defining the response type of the GoLang function
# function
p2prc.MapPort.restype = c_char_p
# Calling the Go function
address = p2prc.MapPort(port,domainname,serveraddress)
res = str(address).strip("b'")
return res
# Lists all avaliable nodes in the network
def ListNodes():
# View IP Table information
p2prc.ViewIPTable.restype = c_char_p
ipTable = p2prc.ViewIPTable()
# View IP Table as
ipTableObject = json.loads((str(ipTable).strip("b'")))
dat: IPAddress = dacite.from_dict(IPAddress,ipTableObject)
return dat
# python function to pass-through custom
# information to interpret which can be
# interpreted as a DSL.
def AddCustomInformation(message="") -> bool:
message = go_string(c_char_p(message.encode('utf-8')), len(message))
p2prc.CustomInformation.restype = c_char_p
status = p2prc.CustomInformation(message)
if str(status).strip("b'") == "Success":
return True
return False

View File

@@ -1,11 +0,0 @@
import ctypes
p2prc = ctypes.CDLL("SharedOBjects/p2prc.so")
p2prc.Init("")
def StartServer():
# Starting P2PRC as a server mode
p2prc.Server()
for _ in iter(int, 1):
pass

View File

@@ -0,0 +1,4 @@
dacite
schedule
sqlalchemy
requests

11
Bindings/python/test.py Normal file
View File

@@ -0,0 +1,11 @@
from library import *
if __name__ == "__main__":
P2PRCNodes = ListNodes()
# Print nodes in the network
print(P2PRCNodes)
# Add custom information to the network
if AddCustomInformation("Test"):
print("It worked")

View File

@@ -1,93 +0,0 @@
* Contributing
:PROPERTIES:
:CUSTOM_ID: contributing
:END:
When contributing to this repository, please first discuss the change
you wish to make via issue, email, or any other method with the owners
of this repository before making a change.
Please note we have a code of conduct, please follow it in all your
interactions with the project.
** Pull Request Process
:PROPERTIES:
:CUSTOM_ID: pull-request-process
:END:
1. Ensure any install or build dependencies are removed before the end
of the layer when doing a build.
2. Update the appropriate docs before stating the changes you did.
3. You may merge the Pull Request in once you have the approval of
CODEOWNER, or if you do not have permission to do that, you may
request the second reviewer to merge it for you.
** Code of conduct
:PROPERTIES:
:CUSTOM_ID: code-of-conduct
:END:
All projects(including mailing lists) at HWTechClub is required to
follow [[https://lunduke.com/pages/codeofconduct/][The Lunduke Code of
Conduct]].
*** The Lunduke Code of Conduct
:PROPERTIES:
:CUSTOM_ID: the-lunduke-code-of-conduct
:END:
#+begin_quote
**** "Be Excellent to Each Other."
:PROPERTIES:
:CUSTOM_ID: be-excellent-to-each-other.
:END:
#+end_quote
***** FAQ
:PROPERTIES:
:CUSTOM_ID: faq
:END:
*Q*: Wait. That's it?
A: Yup.
*Q*: But... but... it's only 5 words!
A: It is? Cool!
*Q*: Isn't that too short to be a viable Code of Conduct?
A: Nah.
*Q*: It's too vague! How would you enforce this?!?
A: By being excellent to each other.
*Q*: What if someone violates this Code of Conduct?
A: I trust you to figure it out.
*Q*: What if someone talks about politics I disagree with?!?!!?
A: I know a guy who votes for Papa Smurf in every Presidential election.
He's a pretty cool dude.
*Q*: I'm super angry about something! And a person likes the thing
making me angry! What do I do?
A: I dunno. Try /hugs/?
*Q*: Are virtual hugs (such as /"hugs"/ and animated .GIFs of teddy
bears hugging) excellent?
A: Most excellent.
*Q*: Huh. Seems so simple!
A: I know, right?
*Q*: I like you!
A: I like you, too!
/The Lunduke Code of Conduct is free for you to use however you like./
*Source*: [[https://lunduke.com/pages/codeofconduct/][The Lunduke Code
of Conduct]]

BIN
Docs/.DS_Store vendored

Binary file not shown.

1
Docs/.gitignore vendored
View File

@@ -13,7 +13,6 @@
*.elc *.elc
*.fn *.fn
*.fns *.fns
*.html
*.info *.info
*.ky *.ky
*.kys *.kys

1299
Docs/index.html Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -93,7 +93,7 @@ To set up the internal dependencies and build the entire go code into a
single binary single binary
#+begin_example #+begin_example
make install make
#+end_example #+end_example
**** For Windows **** For Windows
@@ -116,17 +116,6 @@ export P2PRC=/<PATH>/p2p-rendering-computation
export PATH=/<PATH>/p2p-rendering-computation:${PATH} export PATH=/<PATH>/p2p-rendering-computation:${PATH}
#+end_example #+end_example
*** Set up configuration file
:PROPERTIES:
:CUSTOM_ID: set-up-configuration-file
:END:
#+begin_example
make configfile
#+end_example
Open the config file =config.json= and add the IPv6 address if you have
one.
*** Test if binary works *** Test if binary works
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: test-if-binary-works :CUSTOM_ID: test-if-binary-works
@@ -351,9 +340,15 @@ p2prc --amd "custom metadata"
#+end_example #+end_example
*** MapPort and link to domain name *** MapPort and link to domain name
Allows to expose remote ports from a machine in the P2P network.
#+begin_example #+begin_example
p2prc --mp <port no to map> --dn <domain name to link Mapped port against> p2prc --mp <port no to map> --dn <domain name to link Mapped port against>
#+end_example #+end_example
**** MapPort in remote machine
This is to ensure ports on remote machines on the P2PRC can be easily opened.
#+begin_example
p2prc --mp <port no to map> --dn <domain name to link Mapped port against> --ra <remote server address>
#+end_example
-------------- --------------
@@ -628,9 +623,9 @@ func <Function name> (output *C.char) {
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: current-languages-supported :CUSTOM_ID: current-languages-supported
:END: :END:
- Python *** Python
*** Build sample python program **** Build sample python program
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: build-sample-python-program :CUSTOM_ID: build-sample-python-program
:END: :END:
@@ -646,7 +641,7 @@ cd Bindings/python/export/
# list files # list files
ls ls
# Expected output # Expected output
SharedObjects/ p2prc.py SharedObjects/ library.py requirements.txt
#+end_src #+end_src
Above shows a generated folder which consists of a folder called Above shows a generated folder which consists of a folder called
@@ -657,6 +652,11 @@ folder can copied and created as a new git repo for P2PRC extensions
scripted or used a reference point as proof of concept that P2PRC can be scripted or used a reference point as proof of concept that P2PRC can be
called from other programming languages. called from other programming languages.
*** Haskell
P2PRC officially supports Haskell bindings and will further support
project using Haskell to build orchestrators on top of P2PRC.
[[https://p2prc.akilan.io/Docs/haskell][Read more...]]
* Config Implementation * Config Implementation
:PROPERTIES: :PROPERTIES:
@@ -775,6 +775,88 @@ func main() {
* Blog posts
** Self host within 5 minutes any program
- Author: [[http://akilan.io/][Akilan Selvacoumar]]
- Date: 28-01-2025
- Video tutorial:
[[https://youtu.be/rN4SiVowg5E][https://i3.ytimg.com/vi/rN4SiVowg5E/maxresdefault.jpg]]
This is a fun expirement for anyone to try to quickly run a server and
quickly do a map port and domain name mapping in a single command.
*** 1. Find a program you want to run
Let's try to setup a really easy program (Let's do with Linkwarden
with docker compose :) ). This is under the assumption you have docker
compose installed on your local machine.
**** Let's run Linkwarden using docker compose and P2PRC
[[https://docs.linkwarden.app/self-hosting/installation][Installation instructions]]:
#+BEGIN_SRC
mkdir linkwarden && cd linkwarden
curl -O https://raw.githubusercontent.com/linkwarden/linkwarden/refs/heads/main/docker-compose.yml
curl -L https://raw.githubusercontent.com/linkwarden/linkwarden/refs/heads/main/.env.sample -o ".env"
#+END_SRC
Environment configuration
#+BEGIN_SRC
vim .env
# Change values
NEXTAUTH_URL=https://<DOMAIN NAME>/api/v1/auth
NEXTAUTH_SECRET=VERY_SENSITIVE_SECRET
POSTGRES_PASSWORD=CUSTOM_POSTGRES_PASSWORD
#+END_SRC
Run linkwarden!
#+BEGIN_SRC
docker compose up
#+END_SRC
If setup correctly linkwarden should
be running.
Local link: http://localhost:3000
Time to setup P2PRC
[[https://p2prc.akilan.io/Docs/#build-project-and-install-project][Installation Instructions]]
Run p2prc as a background
#+BEGIN_SRC
p2prc -s &
#+END_SRC
Run map port and domain mapping
#+BEGIN_SRC
p2prc --mp 3000 --dn <DOMAIN NAME>
#+END_SRC
Sample response
#+BEGIN_SRC
{
"IPAddress": "217.76.63.222",
"PortNo": "61582",
"EntireAddress": "217.76.63.222:61582"
}
#+END_SRC
Add DNS entry
#+BEGIN_SRC
A entry 217.76.63.222
#+END_SRC
Your done now just head to the DOMAIN NAME you added.
ex: https://linkwarden.akilan.io
* Ideas for future potencial features * Ideas for future potencial features
Consists of personal loideas for the future of P2PRC. Consists of personal loideas for the future of P2PRC.

View File

@@ -47,11 +47,27 @@ Networking details are completely abstracted, enabling users to focus on develop
### Flexible Task Distribution ### Flexible Task Distribution
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. 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.
## Setup with Nix
- Ensure you have the nix package manager installed.
- Add the following to your .bashrc file.
```bash
alias p2prc='env P2PRC=<path you want the configs to exist in> nix run github:akilan1999/p2p-rendering-computation --'
```
- Check if it's successful
```bash
p2prc -h
```
Read more on command usage: https://p2prc.akilan.io/Docs/#using-basic-commands
## Latest tutorial ## Latest tutorial
[![IMAGE ALT TEXT](https://i.ytimg.com/vi/OMwCpedu5cs/hqdefault.jpg)](https://www.youtube.com/watch?v=OMwCpedu5cs") [![IMAGE ALT TEXT](https://i.ytimg.com/vi/OMwCpedu5cs/hqdefault.jpg)](https://www.youtube.com/watch?v=OMwCpedu5cs")
<br> <br>
## Documentation
### We have documented to our best effort the basics of p2prc: [Link](https://p2prc.akilan.io/Docs/)
<!-- ## Table of contents in the current README --> <!-- ## Table of contents in the current README -->
<!-- 1. [Introduction](#Introduction) <!-- 1. [Introduction](#Introduction)
2. [Installation](#extend-your-application-with-p2prc) 2. [Installation](#extend-your-application-with-p2prc)
@@ -98,7 +114,7 @@ This project aims to create a peer to peer (p2p) network, where a user can use t
<!-- <br> --> <!-- <br> -->
## Extend your application with P2PRC <!-- ## Extend your application with P2PRC
```go ```go
package main package main
@@ -127,7 +143,7 @@ func main() {
} }
} }
``` ``` -->
<!-- ### Export once this is added export P2PRC as environment paths <!-- ### Export once this is added export P2PRC as environment paths
``` ```
@@ -190,4 +206,4 @@ The programming language used for this project was Golang. The reason Go lang wa
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 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. 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.
[![Star History Chart](https://api.star-history.com/svg?repos=Akilan1999/p2p-rendering-computation&type=Date)](https://github.com/Gaurav-Gosain) <!-- [![Star History Chart](https://api.star-history.com/svg?repos=Akilan1999/p2p-rendering-computation&type=Date)](https://github.com/Gaurav-Gosain) -->

View File

@@ -1,252 +0,0 @@
#+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]]]]

View File

@@ -2,87 +2,94 @@ package abstractions
import "C" import "C"
import ( import (
"github.com/Akilan1999/p2p-rendering-computation/client" "github.com/Akilan1999/p2p-rendering-computation/client"
"github.com/Akilan1999/p2p-rendering-computation/client/clientIPTable" "github.com/Akilan1999/p2p-rendering-computation/client/clientIPTable"
Config "github.com/Akilan1999/p2p-rendering-computation/config" Config "github.com/Akilan1999/p2p-rendering-computation/config"
"github.com/Akilan1999/p2p-rendering-computation/config/generate" "github.com/Akilan1999/p2p-rendering-computation/config/generate"
"github.com/Akilan1999/p2p-rendering-computation/p2p" "github.com/Akilan1999/p2p-rendering-computation/p2p"
"github.com/Akilan1999/p2p-rendering-computation/server" "github.com/Akilan1999/p2p-rendering-computation/server"
"github.com/Akilan1999/p2p-rendering-computation/server/docker" "github.com/Akilan1999/p2p-rendering-computation/server/docker"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"os" "os"
) )
// Init Initialises p2prc // Init Initialises p2prc
func Init(customConfig interface{}) (config *Config.Config, err error) { func Init(customConfig interface{}) (config *Config.Config, err error) {
// Get config file path // Get config file path
// Checks P2PRC path initially // Checks P2PRC path initially
// - Get PATH if environment varaible // - Get PATH if environment varaible
path, err := Config.GetPathP2PRC("P2PRC") path, err := Config.GetPathP2PRC("P2PRC")
if err != nil { if err != nil {
return return
} }
// check if the config file exists // check if the config file exists
if _, err = os.Stat(path + "config.json"); err != nil { if _, err = os.Stat(path + "config.json"); err != nil {
// Initialize with base p2prc config files // Initialize with base p2prc config files
// set the config file with default paths // set the config file with default paths
config, err = generate.SetDefaults("P2PRC", false, customConfig, false) config, err = generate.SetDefaults("P2PRC", false, customConfig, false)
if err != nil { if err != nil {
return return
} }
} else { } else {
// If the configs are available then use them over generating new ones. // If the configs are available then use them over generating new ones.
config, err = Config.ConfigInit(nil, nil) config, err = Config.ConfigInit(nil, nil)
if err != nil { if err != nil {
return return
} }
} }
return return
} }
// Start p2prc in a server mode // Start p2prc in a server mode
func Start() (*gin.Engine, error) { func Start() (*gin.Engine, error) {
engine, err := server.Server() engine, err := server.Server()
if err != nil { if err != nil {
return nil, err return nil, err
} }
return engine, nil return engine, nil
} }
// MapPort Creates a reverse proxy connection and maps the appropriate port // MapPort Creates a reverse proxy connection and maps the appropriate port
func MapPort(port string, domainName string, serverAddress string) (entireAddress string, mapPort string, err error) { func MapPort(port string, domainName string, serverAddress string) (response *client.ResponseMAPPort, err error) {
entireAddress, mapPort, err = server.MapPort(port, domainName, serverAddress) response, err = client.MAPPort(port, domainName, serverAddress)
return return
} }
// StartContainer Starts docker container on the remote machine // StartContainer Starts docker container on the remote machine
func StartContainer(IP string) (container *docker.DockerVM, err error) { func StartContainer(IP string) (container *docker.DockerVM, err error) {
container, err = client.StartContainer(IP, 0, false, "", "") container, err = client.StartContainer(IP, 0, false, "", "")
return return
} }
// RemoveContainer Removes docker container based on the IP address and ID // RemoveContainer Removes docker container based on the IP address and ID
// provided // provided
func RemoveContainer(IP string, ID string) error { 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 // GetSpecs Get spec information about the remote server
func GetSpecs(IP string) (specs *server.SysInfo, err error) { func GetSpecs(IP string) (specs *server.SysInfo, err error) {
specs, err = client.GetSpecs(IP) specs, err = client.GetSpecs(IP)
return return
} }
// ViewIPTable View information of nodes in the network // ViewIPTable View information of nodes in the network
func ViewIPTable() (table *p2p.IpAddresses, err error) { func ViewIPTable() (table *p2p.IpAddresses, err error) {
table, err = p2p.ReadIpTable() table, err = p2p.ReadIpTable()
return return
} }
// UpdateIPTable Force updates IP tables based on new // UpdateIPTable Force updates IP tables based on new
// new nodes discovered in the network // new nodes discovered in the network
func UpdateIPTable() (err error) { 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)
} }

View File

@@ -6,12 +6,19 @@ mkdir Bindings/python/export
# Creating SharedObjects directory for python # Creating SharedObjects directory for python
mkdir Bindings/python/export/SharedObjects mkdir Bindings/python/export/SharedObjects
# Builds p2prc.h and p2prc.so file
# as apart of Go FFI to interacted
# with later on.
sh build-bindings.sh sh build-bindings.sh
# Copy the shared object files as well to ensure
# that python can interact with the latest snapshot
# of P2PRC
cp Bindings/p2prc.h Bindings/python/export/SharedObjects/ cp Bindings/p2prc.h Bindings/python/export/SharedObjects/
cp Bindings/p2prc.so Bindings/python/export/SharedObjects/ cp Bindings/p2prc.so Bindings/python/export/SharedObjects/
cp Bindings/python/p2prc.py Bindings/python/export/ # Copy python library and tests as export as well
cp Bindings/python/* Bindings/python/export/
echo "Output is in the Directory Bindings/python/export/" echo "Output is in the Directory Bindings/python/export/"

View File

@@ -3,21 +3,30 @@ package client
import ( import (
"github.com/Akilan1999/p2p-rendering-computation/config" "github.com/Akilan1999/p2p-rendering-computation/config"
"io/ioutil" "io/ioutil"
"net"
"net/http" "net/http"
) )
type ResponseMAPPort struct { type ResponseMAPPort struct {
IPAddress string IPAddress string
PortNo string
EntireAddress string
} }
func MAPPort(port string, domainName string) (*ResponseMAPPort, error) { func MAPPort(port string, domainName string, ServerAddress string) (*ResponseMAPPort, error) {
Config, err := config.ConfigInit(nil, nil) Config, err := config.ConfigInit(nil, nil)
if err != nil { if err != nil {
return nil, err return nil, err
} }
URL := "http://0.0.0.0:" + Config.ServerPort
if ServerAddress != "" {
URL = "http://" + ServerAddress
}
//if version == "version 6" { //if version == "version 6" {
URL := "http://0.0.0.0:" + Config.ServerPort + "/MAPPort?port=" + port + "&domain_name=" + domainName URL = URL + "/MAPPort?port=" + port + "&domain_name=" + domainName
//} else { //} else {
// URL = "http://" + IP + ":" + serverPort + "/server_info" // URL = "http://" + IP + ":" + serverPort + "/server_info"
//} //}
@@ -32,8 +41,15 @@ func MAPPort(port string, domainName string) (*ResponseMAPPort, error) {
return nil, err return nil, err
} }
host, Exposedport, err := net.SplitHostPort(string(byteValue))
if err != nil {
return nil, err
}
var response ResponseMAPPort var response ResponseMAPPort
response.IPAddress = string(byteValue) response.IPAddress = host
response.PortNo = Exposedport
response.EntireAddress = string(byteValue)
return &response, nil return &response, nil
} }

View File

@@ -283,7 +283,7 @@ var CliAction = func(ctx *cli.Context) error {
} }
if MAPPort != "" { if MAPPort != "" {
address, err := client.MAPPort(MAPPort, DomainName) address, err := client.MAPPort(MAPPort, DomainName, RemoteAddress)
if err != nil { if err != nil {
return err return err
} }

View File

@@ -30,6 +30,7 @@ var (
RemoveContainerGroup bool RemoveContainerGroup bool
RemoveGroup string RemoveGroup string
MAPPort string MAPPort string
RemoteAddress string
DomainName string DomainName string
//FRPProxy bool //FRPProxy bool
// Generate only allowed in dev release // Generate only allowed in dev release
@@ -43,7 +44,6 @@ var (
) )
var AppConfigFlags = []cli.Flag{ var AppConfigFlags = []cli.Flag{
// Deprecated to be implemented using GRPC
&cli.BoolFlag{ &cli.BoolFlag{
Name: "Server", Name: "Server",
Aliases: []string{"s"}, Aliases: []string{"s"},
@@ -213,6 +213,13 @@ var AppConfigFlags = []cli.Flag{
EnvVars: []string{"MAPPORT"}, EnvVars: []string{"MAPPORT"},
Destination: &MAPPort, Destination: &MAPPort,
}, },
&cli.StringFlag{
Name: "RemoteAddress",
Aliases: []string{"ra"},
Usage: "Parameter for Map port for a remote address",
EnvVars: []string{"REMOTEADDRESS"},
Destination: &RemoteAddress,
},
&cli.StringFlag{ &cli.StringFlag{
Name: "DomainName", Name: "DomainName",
Aliases: []string{"dn"}, Aliases: []string{"dn"},

11
go.mod
View File

@@ -11,7 +11,7 @@ require (
github.com/google/uuid v1.3.0 github.com/google/uuid v1.3.0
github.com/lithammer/shortuuid v3.0.0+incompatible github.com/lithammer/shortuuid v3.0.0+incompatible
github.com/otiai10/copy v1.6.0 github.com/otiai10/copy v1.6.0
github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2 github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5
github.com/shirou/gopsutil/v3 v3.22.10 github.com/shirou/gopsutil/v3 v3.22.10
github.com/urfave/cli/v2 v2.3.0 github.com/urfave/cli/v2 v2.3.0
gitlab.com/NebulousLabs/go-upnp v0.0.0-20181011194642-3a71999ed0d3 gitlab.com/NebulousLabs/go-upnp v0.0.0-20181011194642-3a71999ed0d3
@@ -31,7 +31,7 @@ require (
github.com/cespare/xxhash/v2 v2.1.2 // indirect github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/containerd/containerd v1.5.0-beta.1 // indirect github.com/containerd/containerd v1.5.0-beta.1 // indirect
github.com/coreos/go-oidc v2.2.1+incompatible // indirect github.com/coreos/go-oidc v2.2.1+incompatible // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
github.com/docker/distribution v2.7.1+incompatible // indirect github.com/docker/distribution v2.7.1+incompatible // indirect
github.com/docker/go-connections v0.4.0 // indirect github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.4.0 // indirect github.com/docker/go-units v0.4.0 // indirect
@@ -76,10 +76,9 @@ require (
github.com/prometheus/client_model v0.2.0 // indirect github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.37.0 // indirect github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect github.com/prometheus/procfs v0.8.0 // indirect
github.com/russross/blackfriday/v2 v2.0.1 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/sergi/go-diff v1.1.0 // indirect github.com/sergi/go-diff v1.1.0 // indirect
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect github.com/sirupsen/logrus v1.9.3 // indirect
github.com/sirupsen/logrus v1.7.0 // indirect
github.com/templexxx/cpufeat v0.0.0-20180724012125-cef66df7f161 // indirect github.com/templexxx/cpufeat v0.0.0-20180724012125-cef66df7f161 // indirect
github.com/templexxx/xor v0.0.0-20191217153810-f85b25db303b // indirect github.com/templexxx/xor v0.0.0-20191217153810-f85b25db303b // indirect
github.com/tjfoc/gmsm v1.4.1 // indirect github.com/tjfoc/gmsm v1.4.1 // indirect
@@ -91,7 +90,7 @@ require (
gitlab.com/NebulousLabs/fastrand v0.0.0-20181126182046-603482d69e40 // indirect gitlab.com/NebulousLabs/fastrand v0.0.0-20181126182046-603482d69e40 // indirect
golang.org/x/net v0.10.0 // indirect golang.org/x/net v0.10.0 // indirect
golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b // indirect golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b // indirect
golang.org/x/sys v0.15.0 // indirect golang.org/x/sys v0.29.0 // indirect
golang.org/x/text v0.14.0 // indirect golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect
google.golang.org/appengine v1.6.7 // indirect google.golang.org/appengine v1.6.7 // indirect

19
go.sum
View File

@@ -183,8 +183,9 @@ github.com/coreos/go-systemd/v22 v22.1.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+
github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/cpuguy83/go-md2man/v2 v2.0.0 h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng4PGlyM=
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4=
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
@@ -548,8 +549,8 @@ github.com/otiai10/mint v1.3.2 h1:VYWnrP5fXmz1MXvjuUvcBrXSjGE6xjON+axB/UrpO3E=
github.com/otiai10/mint v1.3.2/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc= github.com/otiai10/mint v1.3.2/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc=
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU=
github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2 h1:JhzVVoYvbOACxoUmOs6V/G4D5nPVUW73rKvXxP4XUJc= github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5 h1:Ii+DKncOVM8Cu1Hc+ETb5K+23HdAMvESYE3ZJ5b5cMI=
github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2/go.mod h1:iIss55rKnNBTvrwdmkUpLnDpZoAHvWaiq5+iMmen4AE= github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5/go.mod h1:iIss55rKnNBTvrwdmkUpLnDpZoAHvWaiq5+iMmen4AE=
github.com/pires/go-proxyproto v0.6.2 h1:KAZ7UteSOt6urjme6ZldyFm4wDe/z0ZUP0Yv0Dos0d8= github.com/pires/go-proxyproto v0.6.2 h1:KAZ7UteSOt6urjme6ZldyFm4wDe/z0ZUP0Yv0Dos0d8=
github.com/pires/go-proxyproto v0.6.2/go.mod h1:Odh9VFOZJCf9G8cLW5o435Xf1J95Jw9Gw5rnCjcwzAY= github.com/pires/go-proxyproto v0.6.2/go.mod h1:Odh9VFOZJCf9G8cLW5o435Xf1J95Jw9Gw5rnCjcwzAY=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
@@ -611,8 +612,9 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8= github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8=
github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/safchain/ethtool v0.0.0-20190326074333-42ed695e3de8/go.mod h1:Z0q5wiBQGYcxhMZ6gUqHn6pYNLypFAvaL3UvgZLR0U4= github.com/safchain/ethtool v0.0.0-20190326074333-42ed695e3de8/go.mod h1:Z0q5wiBQGYcxhMZ6gUqHn6pYNLypFAvaL3UvgZLR0U4=
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
github.com/seccomp/libseccomp-golang v0.9.1/go.mod h1:GbW5+tmTXfcxTToHLXlScSlAvWlF4P2Ca7zGrPiEpWo= github.com/seccomp/libseccomp-golang v0.9.1/go.mod h1:GbW5+tmTXfcxTToHLXlScSlAvWlF4P2Ca7zGrPiEpWo=
@@ -620,7 +622,6 @@ github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/shirou/gopsutil/v3 v3.22.10 h1:4KMHdfBRYXGF9skjDWiL4RA2N+E8dRdodU/bOZpPoVg= github.com/shirou/gopsutil/v3 v3.22.10 h1:4KMHdfBRYXGF9skjDWiL4RA2N+E8dRdodU/bOZpPoVg=
github.com/shirou/gopsutil/v3 v3.22.10/go.mod h1:QNza6r4YQoydyCfo6rH0blGfKahgibh4dQmV5xdFkQk= github.com/shirou/gopsutil/v3 v3.22.10/go.mod h1:QNza6r4YQoydyCfo6rH0blGfKahgibh4dQmV5xdFkQk=
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/sirupsen/logrus v1.0.4-0.20170822132746-89742aefa4b2/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc= github.com/sirupsen/logrus v1.0.4-0.20170822132746-89742aefa4b2/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc=
github.com/sirupsen/logrus v1.0.6/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc= github.com/sirupsen/logrus v1.0.6/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc=
@@ -628,8 +629,9 @@ github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPx
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
github.com/sirupsen/logrus v1.7.0 h1:ShrD1U9pZB12TX0cVy0DtePoCH97K8EtX+mg7ZARUtM=
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
@@ -917,8 +919,9 @@ golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4= golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4=

View File

@@ -11,7 +11,7 @@ import (
) )
// VERSION specifies the version of the platform // VERSION specifies the version of the platform
var VERSION = "2.0.0" var VERSION = "3.0.0"
var mode string var mode string
// Varaibles if mode is client // Varaibles if mode is client
@@ -34,10 +34,6 @@ func getFireSignalsChannel() chan os.Signal {
} }
func exit() {
syscall.Kill(syscall.Getpid(), syscall.SIGTERM)
}
func main() { func main() {
app := cli.NewApp() app := cli.NewApp()
app.Name = "p2p-rendering-computation" app.Name = "p2p-rendering-computation"

View File

@@ -1,40 +0,0 @@
#+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]]

View File

@@ -11,9 +11,7 @@ import (
"github.com/Akilan1999/p2p-rendering-computation/p2p/frp" "github.com/Akilan1999/p2p-rendering-computation/p2p/frp"
"github.com/Akilan1999/p2p-rendering-computation/server/docker" "github.com/Akilan1999/p2p-rendering-computation/server/docker"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"io"
"io/ioutil" "io/ioutil"
"net"
"net/http" "net/http"
"os/user" "os/user"
"strconv" "strconv"
@@ -195,7 +193,7 @@ func Server() (*gin.Engine, error) {
r.GET("/MAPPort", func(c *gin.Context) { r.GET("/MAPPort", func(c *gin.Context) {
Ports := c.DefaultQuery("port", "0") Ports := c.DefaultQuery("port", "0")
DomainName := c.DefaultQuery("domain_name", "") DomainName := c.DefaultQuery("domain_name", "")
url, _, err := MapPort(Ports, DomainName, "") url, _, err := MapPort(Ports, DomainName)
if err != nil { if err != nil {
c.String(http.StatusInternalServerError, fmt.Sprintf("error: %s", err)) c.String(http.StatusInternalServerError, fmt.Sprintf("error: %s", err))
} }
@@ -298,7 +296,7 @@ func Server() (*gin.Engine, error) {
ProxyIpAddr.EscapeImplementation = "FRP" ProxyIpAddr.EscapeImplementation = "FRP"
if config.BareMetal { if config.BareMetal {
_, SSHPort, err := MapPort("22", "", "") _, SSHPort, err := MapPort("22", "")
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -375,33 +373,33 @@ func Server() (*gin.Engine, error) {
return r, nil return r, nil
} }
func MapPort(port string, domainName string, serverAddress string) (string, string, error) { func MapPort(port string, domainName string) (string, string, error) {
// if server address is provided to do call RESTAPI to remotely open port. // if server address is provided to do call RESTAPI to remotely open port.
if serverAddress != "" { //if serverAddress != "" {
requestURL := fmt.Sprintf("http://%v/MAPPort?port=%v&domain_name=%v", serverAddress, port, domainName) // requestURL := fmt.Sprintf("http://%v/MAPPort?port=%v&domain_name=%v", serverAddress, port, domainName)
req, err := http.NewRequest(http.MethodGet, requestURL, nil) // req, err := http.NewRequest(http.MethodGet, requestURL, nil)
if err != nil { // if err != nil {
return "", "", err // return "", "", err
} // }
//
res, err := http.DefaultClient.Do(req) // res, err := http.DefaultClient.Do(req)
if err != nil { // if err != nil {
return "", "", err // return "", "", err
} // }
//
resBody, err := io.ReadAll(res.Body) // resBody, err := io.ReadAll(res.Body)
if err != nil { // if err != nil {
return "", "", err // return "", "", err
} // }
//
_, Exposedport, err := net.SplitHostPort(string(resBody)) // _, Exposedport, err := net.SplitHostPort(string(resBody))
if err != nil { // if err != nil {
return "", "", err // return "", "", err
} // }
//
return string(resBody), Exposedport, nil // return string(resBody), Exposedport, nil
} //}
//Get Server port based on the config file //Get Server port based on the config file
config, err := config.ConfigInit(nil, nil) config, err := config.ConfigInit(nil, nil)