Compare commits
16 Commits
v1.0.0-alp
...
v1.0.0-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
68228a6013 | ||
| ae2500ed4b | |||
|
|
5be8778652 | ||
| 6dde485de1 | |||
| c0f70e87f4 | |||
|
|
6df72c4abb | ||
|
|
26e6fd4ec2 | ||
| aabac388ba | |||
|
|
655c5de4ec | ||
| 3e8a99b435 | |||
|
|
5e7f540802 | ||
| 28620b61ad | |||
|
|
6f6072f598 | ||
| f7bae1100a | |||
| a0b63fa2ec | |||
|
|
5b90bf3168 |
5
.gitignore
vendored
5
.gitignore
vendored
@@ -7,4 +7,7 @@ server/docker/__pycache__
|
||||
p2p-rendering-computation
|
||||
p2prc
|
||||
config.json
|
||||
.vscode/
|
||||
.vscode/
|
||||
|
||||
#ignore generated iptables
|
||||
p2p/iptable/
|
||||
@@ -2,6 +2,11 @@
|
||||
|
||||
Over here we will cover the basic steps to get the server and client side running.
|
||||
|
||||
## Alpha release install
|
||||
https://github.com/Akilan1999/p2p-rendering-computation/releases/tag/v1.0.0-alpha
|
||||
|
||||
## Install from Github master branch
|
||||
|
||||
### Install Go lang
|
||||
The entire the implementation of this project is done using Go lang.
|
||||
Thus, we need go lang to compile to code to a binary file.
|
||||
@@ -27,6 +32,19 @@ into a single binary
|
||||
make install
|
||||
```
|
||||
|
||||
### Add appropriate paths to .bashrc
|
||||
```
|
||||
export P2PRC=/<PATH>/p2p-rendering-computation
|
||||
export PATH=/<PATH>/p2p-rendering-computation:${PATH}
|
||||
```
|
||||
|
||||
### Set up configuration file
|
||||
```
|
||||
make configfile
|
||||
```
|
||||
Open the config file ```config.json``` and add the IPv6 address
|
||||
if you have one.
|
||||
|
||||
### Test if binary works
|
||||
```
|
||||
p2prc --help
|
||||
@@ -37,7 +55,7 @@ NAME:
|
||||
p2p-rendering-computation - p2p cli application to create and access VMs in other servers
|
||||
|
||||
USAGE:
|
||||
p2p-rendering-computation [global options] command [command options] [arguments...]
|
||||
p2prc [global options] command [command options] [arguments...]
|
||||
|
||||
VERSION:
|
||||
1.0.0
|
||||
@@ -46,22 +64,72 @@ COMMANDS:
|
||||
help, h Shows a list of commands or help for one command
|
||||
|
||||
GLOBAL OPTIONS:
|
||||
--Mode value Specifies mode of running (default: "client") [$P2P_MODE]
|
||||
--UpdateServerList Update List of Server available based on servers iptables (default: false) [$UPDATE_SERVER_LIST]
|
||||
--ListServers List servers which can render tasks (default: false) [$LIST_SERVERS]
|
||||
--CreateVM value Creates Docker container on the selected server [$CREATE_VM]
|
||||
--RemoveVM value Stop and Remove Docker container [$REMOVE_VM]
|
||||
--ID value Docker Container ID [$ID]
|
||||
--Ports value Number of ports to open for the Docker Container [$NUM_PORTS]
|
||||
--GPU Create Docker Containers to access GPU (default: false) [$USE_GPU]
|
||||
--Specs value Specs of the server node [$SPECS]
|
||||
--SetDefaultConfig Sets a default configuration file (default: false) [$SET_DEFAULT_CONFIG]
|
||||
--help, -h show help (default: false)
|
||||
--version, -v print the version (default: false)
|
||||
|
||||
|
||||
--Server, -s Starts server (default: false) [$SERVER]
|
||||
--UpdateServerList, --us Update List of Server available based on servers iptables (default: false) [$UPDATE_SERVER_LIST]
|
||||
--ListServers, --ls List servers which can render tasks (default: false) [$LIST_SERVERS]
|
||||
--AddServer value, --as value Adds server IP address to iptables [$ADD_SERVER]
|
||||
--ViewImages value, --vi value View images available on the server IP address [$VIEW_IMAGES]
|
||||
--CreateVM value, --touch value Creates Docker container on the selected server [$CREATE_VM]
|
||||
--ContainerName value, --cn value Specifying the container run on the server side [$CONTAINER_NAME]
|
||||
--RemoveVM value, --rm value Stop and Remove Docker container [$REMOVE_VM]
|
||||
--ID value, --id value Docker Container ID [$ID]
|
||||
--Ports value, -p value Number of ports to open for the Docker Container [$NUM_PORTS]
|
||||
--GPU, --gpu Create Docker Containers to access GPU (default: false) [$USE_GPU]
|
||||
--Specification value, --specs value Specs of the server node [$SPECS]
|
||||
--SetDefaultConfig, --dc Sets a default configuration file (default: false) [$SET_DEFAULT_CONFIG]
|
||||
--NetworkInterfaces, --ni Shows the network interface in your computer (default: false) [$NETWORK_INTERFACE]
|
||||
--help, -h show help (default: false)
|
||||
--version, -v print the version (default: false)
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
--------------
|
||||
|
||||
<br>
|
||||
|
||||
# Using the Cli commands
|
||||
|
||||
### Start as a server
|
||||
Do ensure you have docker installed for this
|
||||
```
|
||||
p2prc -s
|
||||
```
|
||||
|
||||
### View server Speciafication
|
||||
```
|
||||
p2prc --specs=<ip address>
|
||||
```
|
||||
|
||||
### Run container
|
||||
use the ```--gpu``` if you know the other machine has a gpu.
|
||||
```
|
||||
p2prc --touch=<server ip address> -p <number of ports> --gpu
|
||||
```
|
||||
|
||||
### Remove container
|
||||
The docker id is present in the output where you create a container
|
||||
```
|
||||
p2prc --rm=<server ip address> --id=<docker container id>
|
||||
```
|
||||
|
||||
### Adding servers to ip table
|
||||
```
|
||||
p2prc --as=<server ip address you want to add>
|
||||
```
|
||||
|
||||
### Update ip table
|
||||
```
|
||||
p2prc --us
|
||||
```
|
||||
|
||||
### List Servers
|
||||
```
|
||||
p2prc --ls
|
||||
```
|
||||
|
||||
### View Network interfaces
|
||||
```
|
||||
p2prc --ni
|
||||
```
|
||||
|
||||
#### Note: The steps on how to use the commands will be added later.
|
||||
|
||||
@@ -41,12 +41,18 @@ var CliAction = func(ctx *cli.Context) error {
|
||||
//Create variable of type IpAddress and set IP address
|
||||
// to it
|
||||
var IpAddr p2p.IpAddress
|
||||
IpAddr.Ipv4 = AddServer
|
||||
|
||||
//Checking if the address is a ipv4
|
||||
// or ipv6 address
|
||||
ip4Orip6 := p2p.Ip4or6(AddServer)
|
||||
if ip4Orip6 == "version 6" {
|
||||
IpAddr.Ipv6 = AddServer
|
||||
} else {
|
||||
IpAddr.Ipv4 = AddServer
|
||||
}
|
||||
// Append IP address to variable result which
|
||||
// is a list
|
||||
res.IpAddress = append(res.IpAddress, IpAddr)
|
||||
|
||||
// Adds the new server IP to the iptable
|
||||
res.WriteIpTable()
|
||||
|
||||
|
||||
@@ -108,7 +108,6 @@ var AppConfigFlags = []cli.Flag{
|
||||
EnvVars: []string{"SPECS"},
|
||||
Destination: &Specs,
|
||||
},
|
||||
|
||||
&cli.BoolFlag{
|
||||
Name: "SetDefaultConfig",
|
||||
Aliases: []string{"dc"},
|
||||
|
||||
@@ -2,6 +2,7 @@ package config
|
||||
|
||||
import (
|
||||
"github.com/spf13/viper"
|
||||
"io"
|
||||
"os"
|
||||
)
|
||||
|
||||
@@ -12,8 +13,6 @@ var (
|
||||
"DockerContainers": "/home/akilan/Documents/p2prendering/p2p-redering-computation/server/docker/containers/",
|
||||
"DefaultDockerFile": "/home/akilan/Documents/p2prendering/p2p-redering-computation/server/docker/containers/docker-ubuntu-sshd/",
|
||||
"SpeedTestFile":"/etc/p2p-rendering/50.bin",
|
||||
"NetworkInterface": "wlp0s20f3",
|
||||
"NetworkInterfaceIPV6Index": "1",
|
||||
}
|
||||
configName = "config"
|
||||
configType = "json"
|
||||
@@ -26,8 +25,9 @@ type Config struct {
|
||||
DockerContainers string
|
||||
DefaultDockerFile string
|
||||
SpeedTestFile string
|
||||
NetworkInterface string
|
||||
NetworkInterfaceIPV6Index int
|
||||
IPV6Address string
|
||||
//NetworkInterface string
|
||||
//NetworkInterfaceIPV6Index int
|
||||
}
|
||||
|
||||
// Exists reports whether the named file or directory exists.
|
||||
@@ -40,6 +40,30 @@ func fileExists(name string) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// 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
|
||||
func Copy(src, dst string) error {
|
||||
in, err := os.Open(src)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer in.Close()
|
||||
|
||||
out, err := os.Create(dst)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer out.Close()
|
||||
|
||||
_, err = io.Copy(out, in)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return out.Close()
|
||||
}
|
||||
|
||||
|
||||
// SetDefaults This function to be called only during a
|
||||
// make install
|
||||
func SetDefaults() error {
|
||||
@@ -49,13 +73,21 @@ func SetDefaults() error {
|
||||
//Setting current directory to default path
|
||||
defaultPath = curDir + "/"
|
||||
|
||||
//Create ip_table.json in the json directory
|
||||
err := Copy("p2p/ip_table.json","p2p/iptable/ip_table.json")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
//Setting default paths for the config file
|
||||
defaults["IPTable"] = defaultPath + "p2p/ip_table.json"
|
||||
defaults["IPTable"] = defaultPath + "p2p/iptable/ip_table.json"
|
||||
defaults["DefaultDockerFile"] = defaultPath + "server/docker/containers/docker-ubuntu-sshd/"
|
||||
defaults["DockerContainers"] = defaultPath + "server/docker/containers/"
|
||||
defaults["SpeedTestFile"] = defaultPath + "p2p/50.bin"
|
||||
defaults["NetworkInterface"] = "wlp0s20f3"
|
||||
defaults["NetworkInterfaceIPV6Index"] = "2"
|
||||
defaults["IPV6Address"] = ""
|
||||
//defaults["NetworkInterface"] = "wlp0s20f3"
|
||||
//defaults["NetworkInterfaceIPV6Index"] = "2"
|
||||
|
||||
//Paths to search for config file
|
||||
configPaths = append(configPaths, defaultPath)
|
||||
@@ -68,7 +100,7 @@ func SetDefaults() error {
|
||||
}
|
||||
|
||||
//Calling configuration file
|
||||
_, err := ConfigInit()
|
||||
_, err = ConfigInit()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
47
index.html
Normal file
47
index.html
Normal file
@@ -0,0 +1,47 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>P2PRC</title>
|
||||
<style>
|
||||
body { font-family: sans-serif; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<img src="Docs/images/p2prclogo.png" alt="P2PRC">
|
||||
<h1>P2PRC</h1>
|
||||
<b>A peer to peer network designed for computation</b>
|
||||
|
||||
<p>P2PRC is peer to peer to network designed for computation reasons.</p>
|
||||
<p>This project was developed during my 4th year dissertation at Heriot-Watt university and We are getting the
|
||||
project to a usable state. </p>
|
||||
<p> It's purpose is for people to use each others computers rather than servers such as AWS and Azure. </p>
|
||||
|
||||
<p><b>Project:</b></p>
|
||||
<ul>
|
||||
<li><a href="https://github.com/Akilan1999/p2p-rendering-computation">P2PRC on GitHub</a></li>
|
||||
<li><a href="https://discord.gg/b4nRGTjYqy">P2PRC Discord Server</a> <font color="red">(join here to chat!)</font></li>
|
||||
</ul>
|
||||
|
||||
<p><b>Community Server to download public network</b></p>
|
||||
<ul>
|
||||
<li>
|
||||
<b>IP Address: 172.104.44.195</a></b>
|
||||
<p>Use this server to only download part of the p2p network</p>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<p><b>Main developer:</b></p>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<b><a href="https://akilan.io">Akilan Selvacoumar</a></b>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<p><b>Other links:</b></p>
|
||||
<ul>
|
||||
<li><a href="https://www.youtube.com/channel/UChy18QB1hBzZ7MniIW_FJvQ">Akilan Selvacoumar on YouTube</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
</body></html>
|
||||
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"ip_address": [
|
||||
{
|
||||
"ipv4": "",
|
||||
"ipv6": "2001:8f8:172d:ee93:7588:ad57:c351:3309",
|
||||
"latency": 1213198,
|
||||
"ipv4": "172.104.44.195",
|
||||
"ipv6": "",
|
||||
"latency": 0,
|
||||
"download": 0,
|
||||
"upload": 0
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package p2p
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"git.sr.ht/~akilan1999/p2p-rendering-computation/config"
|
||||
"io/ioutil"
|
||||
@@ -132,12 +131,11 @@ func (table *IpAddresses)RemoveDuplicates() error {
|
||||
for i, _:= range table.IpAddress {
|
||||
Exists := false
|
||||
for k := range NoDuplicates.IpAddress {
|
||||
if NoDuplicates.IpAddress[k].Ipv4 == table.IpAddress[i].Ipv4 || (NoDuplicates.IpAddress[k].Ipv6 != "" && NoDuplicates.IpAddress[k].Ipv6 == table.IpAddress[i].Ipv6){
|
||||
if (NoDuplicates.IpAddress[k].Ipv4 != "" && NoDuplicates.IpAddress[k].Ipv4 == table.IpAddress[i].Ipv4) || (NoDuplicates.IpAddress[k].Ipv6 != "" && NoDuplicates.IpAddress[k].Ipv6 == table.IpAddress[i].Ipv6) {
|
||||
Exists = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if Exists {
|
||||
continue
|
||||
}
|
||||
@@ -175,23 +173,25 @@ func GetCurrentIPV6()(string,error){
|
||||
if err != nil {
|
||||
return "",err
|
||||
}
|
||||
byNameInterface, err := net.InterfaceByName(Config.NetworkInterface)
|
||||
if err != nil {
|
||||
return "",err
|
||||
}
|
||||
addresses, err := byNameInterface.Addrs()
|
||||
if err != nil {
|
||||
return "",err
|
||||
}
|
||||
if addresses[1].String() == "" {
|
||||
return "",errors.New("IPV6 address not detected")
|
||||
}
|
||||
IP,_,err := net.ParseCIDR(addresses[Config.NetworkInterfaceIPV6Index].String())
|
||||
if err != nil {
|
||||
return "",err
|
||||
}
|
||||
|
||||
return IP.String(), nil
|
||||
// Fix in future release
|
||||
//byNameInterface, err := net.InterfaceByName(Config.NetworkInterface)
|
||||
//if err != nil {
|
||||
// return "",err
|
||||
//}
|
||||
//addresses, err := byNameInterface.Addrs()
|
||||
//if err != nil {
|
||||
// return "",err
|
||||
//}
|
||||
//if addresses[1].String() == "" {
|
||||
// return "",errors.New("IPV6 address not detected")
|
||||
//}
|
||||
//IP,_,err := net.ParseCIDR(addresses[Config.NetworkInterfaceIPV6Index].String())
|
||||
//if err != nil {
|
||||
// return "",err
|
||||
//}
|
||||
|
||||
return Config.IPV6Address, nil
|
||||
}
|
||||
|
||||
// ViewNetworkInterface This function is created to view the network interfaces available
|
||||
@@ -230,6 +230,6 @@ func Ip4or6(s string) string {
|
||||
return "version 6"
|
||||
}
|
||||
}
|
||||
return "unknown"
|
||||
return "version 6"
|
||||
|
||||
}
|
||||
0
p2p/iptable/.gitkeep
Normal file
0
p2p/iptable/.gitkeep
Normal file
@@ -65,3 +65,13 @@ func TestViewNetworkInterface(t *testing.T) {
|
||||
t.Error()
|
||||
}
|
||||
}
|
||||
|
||||
func TestIp4or6(t *testing.T) {
|
||||
// This test ensures that the ipv6 address gets detected
|
||||
test := "2001:8f8:172d:7e27:4f23:ae4:bce5:e037"
|
||||
res := Ip4or6(test)
|
||||
if res != "version 6" {
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/showwin/speedtest-go/speedtest"
|
||||
)
|
||||
|
||||
func main() {
|
||||
user, _ := speedtest.FetchUserInfo()
|
||||
|
||||
serverList, _ := speedtest.FetchServerList(user)
|
||||
targets, _ := serverList.FindServer([]int{})
|
||||
|
||||
for _, s := range targets {
|
||||
s.PingTest()
|
||||
s.DownloadTest(false)
|
||||
s.UploadTest(false)
|
||||
|
||||
fmt.Printf("Latency: %s, Download: %f, Upload: %f\n", s.Latency, s.DLSpeed, s.ULSpeed)
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestDocker(t *testing.T) {
|
||||
func TestDockerUbuntuSSHDProvided(t *testing.T) {
|
||||
// Testing by providing default container name
|
||||
_,err := BuildRunContainer(2,"false","docker-ubuntu-sshd")
|
||||
|
||||
@@ -12,13 +12,15 @@ func TestDocker(t *testing.T) {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
// Testing if no container name is provided if default is used
|
||||
_,err = BuildRunContainer(2,"false","")
|
||||
}
|
||||
|
||||
func TestDockerDefaultContainer(t *testing.T) {
|
||||
// Testing by providing without providing default container name
|
||||
_,err := BuildRunContainer(2,"false","")
|
||||
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestContainerHorovod(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user