Compare commits
11 Commits
v1.0.0-alp
...
sample-run
| Author | SHA1 | Date | |
|---|---|---|---|
| e6bd7ae103 | |||
| 5f76b1272a | |||
| 15b3344238 | |||
| 1324e0394f | |||
| 6c86082f48 | |||
|
|
5a164749b3 | ||
|
|
31b9e7e934 | ||
| 9a72149a52 | |||
| 3e1e6e6928 | |||
| 9809517ebd | |||
| 7742377304 |
7
.gitignore
vendored
7
.gitignore
vendored
@@ -7,4 +7,9 @@ server/docker/__pycache__
|
||||
p2p-rendering-computation
|
||||
p2prc
|
||||
config.json
|
||||
.vscode/
|
||||
*.tgz
|
||||
.vscode/
|
||||
hosts
|
||||
*.retry
|
||||
**/*.swp
|
||||
**/*.retry
|
||||
|
||||
@@ -16,8 +16,7 @@ interact with the containers.
|
||||
|
||||
[Instructions to install docker GPU](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html#docker)
|
||||
````
|
||||
// Do ensure that the docker command does not need sudo to run
|
||||
sudo chmod 666 /var/run/docker.sock
|
||||
Do ensure that the docker command does not need sudo to run
|
||||
````
|
||||
|
||||
### Build Project and install project
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 5.7 KiB |
15
Makefile
15
Makefile
@@ -1,16 +1,19 @@
|
||||
SHELL := /bin/bash
|
||||
/ https://www.youtube.com/channel/UCQdZltW7bh1ta-_nCH7LWYw/playlistSHELL := /bin/bash
|
||||
|
||||
install:
|
||||
go build -o p2prc
|
||||
echo '# Paths for p2p rendering and computation'
|
||||
echo 'export P2PRC=${PWD}'
|
||||
echo 'export PATH=${PWD}:$${PATH}'
|
||||
echo '# Paths for p2p rendering and computation' >> ~/.bashrc
|
||||
echo 'export P2PRC=${PWD}' >> ~/.bashrc
|
||||
echo 'export path=${PWD}:$${PATH}' >> ~/.bashrc
|
||||
source ~/.bashrc
|
||||
./p2prc --SetDefaultConfig
|
||||
|
||||
|
||||
build:
|
||||
go build -o p2prc
|
||||
|
||||
configfile:
|
||||
./p2prc --SetDefaultConfig
|
||||
config:
|
||||
./p2p-rendering-computation --SetDefaultConfig
|
||||
|
||||
run:
|
||||
go run main.go
|
||||
|
||||
84
README.md
84
README.md
@@ -1,87 +1,13 @@
|
||||
<h1 align="center">
|
||||
<br>
|
||||
<a href=""><img src="https://raw.githubusercontent.com/Akilan1999/p2p-rendering-computation/master/Docs/images/p2prclogo.png" alt="p2prc" width="400"></a>
|
||||
<br>
|
||||
</h1>
|
||||
# P2P rendering and computation
|
||||
|
||||
|
||||
[](http://perso.crans.org/besson/LICENSE.html)
|
||||
[](https://GitHub.com/Akilan1999/p2p-rendering-computation/graphs/commit-activity)
|
||||
[](http://golang.org)
|
||||
[](https://pkg.go.dev/git.sr.ht/~akilan1999/p2p-rendering-computation)
|
||||
[](https://www.youtube.com/watch?v=LRv3NR2lu7I "Simple P2P Cli application for creating containers")
|
||||
|
||||
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.
|
||||
|
||||
## Demo
|
||||
[](https://www.youtube.com/watch?v=LRv3NR2lu7I "Simple P2P Cli application for creating containers")
|
||||
|
||||
<br>
|
||||
|
||||
## Table of contents
|
||||
1. [Introduction](#Introduction)
|
||||
2. [Installation](#Installation.md)
|
||||
3. [Design Architecture](#Design-Architecture)
|
||||
4. [Implementation](#Implementation)
|
||||
5. [Find out more](#Find-out-more)
|
||||
|
||||
<br>
|
||||
|
||||
## 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
|
||||
|
||||
[Read more on the introduction](Docs/Introduction.md)
|
||||
|
||||
<br>
|
||||
|
||||
## Installation
|
||||
1. Ensure the Go compiler is installed
|
||||
2. Ensure docker is installed
|
||||
3. Clone this repository
|
||||
```
|
||||
git clone https://github.com/Akilan1999/p2p-rendering-computation
|
||||
```
|
||||
4. Install and build the project
|
||||
```
|
||||
make install
|
||||
```
|
||||
5. Test if it works
|
||||
```
|
||||
p2prc -h
|
||||
```
|
||||
or
|
||||
```
|
||||
./p2prc -h
|
||||
```
|
||||
[Read more on the installation](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>
|
||||
|
||||
## Find out more
|
||||
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. We have decided to create a discord group.
|
||||
Group:
|
||||
https://discord.gg/b4nRGTjYqy
|
||||
1. [Installation](Docs/Installation.md)
|
||||
2. [Documentation](Docs/README.md)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -12,6 +12,10 @@ import (
|
||||
"os"
|
||||
)
|
||||
|
||||
type IP struct {
|
||||
Query string
|
||||
}
|
||||
|
||||
// UpdateIpTable Does the following to update it's IP table
|
||||
func UpdateIpTable(IpAddress string) error {
|
||||
|
||||
@@ -22,23 +26,10 @@ func UpdateIpTable(IpAddress string) error {
|
||||
|
||||
client := http.Client{}
|
||||
|
||||
var resp []byte
|
||||
resp, err := UploadMultipartFile(client,"http://"+IpAddress+":8088/IpTable","json",config.IPTable)
|
||||
|
||||
version := p2p.Ip4or6(IpAddress)
|
||||
if version == "version 6" {
|
||||
resp, err = UploadMultipartFile(client,"http://["+IpAddress+"]:8088/IpTable","json",config.IPTable)
|
||||
if err != nil {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
resp, err = UploadMultipartFile(client,"http://"+IpAddress+":8088/IpTable","json",config.IPTable)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if resp == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
//resp, err := SendPostRequest("http://"+IpAddress+":8088/IpTable",
|
||||
@@ -68,7 +59,6 @@ func UpdateIpTable(IpAddress string) error {
|
||||
// UpdateIpTableListClient updates IP tables (Default 3 hops) based on server information available
|
||||
//on the ip tables
|
||||
func UpdateIpTableListClient() error {
|
||||
|
||||
// Ensure that the IP Table has Node pingable
|
||||
err := p2p.LocalSpeedTestIpTable()
|
||||
if err != nil {
|
||||
@@ -79,55 +69,61 @@ func UpdateIpTableListClient() error {
|
||||
// duplication
|
||||
|
||||
Addresses, err := p2p.ReadIpTable()
|
||||
//var DoNotRead p2p.IpAddresses
|
||||
var DoNotRead p2p.IpAddresses
|
||||
|
||||
// Run loop 3 times
|
||||
for i := 0; i < 3; i++ {
|
||||
// Gets information from IP table
|
||||
//Addresses, err = p2p.ReadIpTable()
|
||||
//if err != nil {
|
||||
// return err
|
||||
//}
|
||||
//
|
||||
//DoNotRead.IpAddress = append(DoNotRead.IpAddress, PublicIP)
|
||||
Addresses, err = p2p.ReadIpTable()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Appending current machine public IP address as should not be there in IP Table
|
||||
var PublicIP p2p.IpAddress
|
||||
ip, err := CurrentPublicIP()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
PublicIP.Ipv4 = ip
|
||||
DoNotRead.IpAddress = append(DoNotRead.IpAddress, PublicIP)
|
||||
|
||||
// Updates IP table based on server IP table
|
||||
for j := range Addresses.IpAddress {
|
||||
|
||||
//Exists := false
|
||||
//
|
||||
//if PublicIP.Ipv4 == Addresses.IpAddress[j].Ipv4 || (PublicIP.Ipv6 != "" && Addresses.IpAddress[j].Ipv6 == PublicIP.Ipv6){
|
||||
// Exists = true
|
||||
//}
|
||||
//
|
||||
//// Check if IP addresses is there in the struct DoNotRead
|
||||
//for k := range DoNotRead.IpAddress {
|
||||
// if DoNotRead.IpAddress[k].Ipv4 == Addresses.IpAddress[j].Ipv4 || (DoNotRead.IpAddress[k].Ipv6 != "" && Addresses.IpAddress[j].Ipv6 == DoNotRead.IpAddress[k].Ipv6) {
|
||||
// Exists = true
|
||||
// break
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//// If the struct exists then continues
|
||||
//if Exists {
|
||||
// continue
|
||||
//}
|
||||
Exists := false
|
||||
|
||||
if Addresses.IpAddress[j].Ipv6 != "" {
|
||||
err = UpdateIpTable(Addresses.IpAddress[j].Ipv6)
|
||||
} else {
|
||||
err = UpdateIpTable(Addresses.IpAddress[j].Ipv4)
|
||||
if PublicIP.Ipv4 == Addresses.IpAddress[j].Ipv4 {
|
||||
Exists = true
|
||||
}
|
||||
|
||||
// Check if IP addresses is there in the struct DoNotRead
|
||||
for k := range DoNotRead.IpAddress {
|
||||
if DoNotRead.IpAddress[k].Ipv4 == Addresses.IpAddress[j].Ipv4 {
|
||||
Exists = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// If the struct exists then continues
|
||||
if Exists {
|
||||
continue
|
||||
}
|
||||
err = UpdateIpTable(Addresses.IpAddress[j].Ipv4)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
//Appends server1 IP address to variable DoNotRead
|
||||
//DoNotRead.IpAddress = append(DoNotRead.IpAddress, Addresses.IpAddress[j])
|
||||
DoNotRead.IpAddress = append(DoNotRead.IpAddress, Addresses.IpAddress[j])
|
||||
}
|
||||
}
|
||||
|
||||
// Removing duplicates in the IP table
|
||||
if err := p2p.RemoveDuplicates(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -220,10 +216,6 @@ func UploadMultipartFile(client http.Client, uri, key, path string) ([]byte, err
|
||||
}()
|
||||
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
content, err := ioutil.ReadAll(resp.Body)
|
||||
|
||||
if err != nil {
|
||||
@@ -234,3 +226,21 @@ func UploadMultipartFile(client http.Client, uri, key, path string) ([]byte, err
|
||||
|
||||
}
|
||||
|
||||
// CurrentPublicIP Get Current Public IP address
|
||||
func CurrentPublicIP() (string,error) {
|
||||
req, err := http.Get("http://ip-api.com/json/")
|
||||
if err != nil {
|
||||
return "",err
|
||||
}
|
||||
defer req.Body.Close()
|
||||
|
||||
body, err := ioutil.ReadAll(req.Body)
|
||||
if err != nil {
|
||||
return "",err
|
||||
}
|
||||
|
||||
var ip IP
|
||||
json.Unmarshal(body, &ip)
|
||||
|
||||
return ip.Query, nil
|
||||
}
|
||||
@@ -3,7 +3,6 @@ package client
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"git.sr.ht/~akilan1999/p2p-rendering-computation/p2p"
|
||||
"git.sr.ht/~akilan1999/p2p-rendering-computation/server"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
@@ -13,13 +12,7 @@ import (
|
||||
// and other basic information which helps set a
|
||||
// cluster of computer
|
||||
func GetSpecs(IP string)(*server.SysInfo,error) {
|
||||
var URL string
|
||||
version := p2p.Ip4or6(IP)
|
||||
if version == "version 6" {
|
||||
URL = "http://[" + IP + "]:" + serverPort + "/server_info"
|
||||
} else {
|
||||
URL = "http://" + IP + ":" + serverPort + "/server_info"
|
||||
}
|
||||
URL := "http://" + IP + ":" + serverPort + "/server_info"
|
||||
resp, err := http.Get(URL)
|
||||
if err != nil {
|
||||
return nil,err
|
||||
|
||||
@@ -3,7 +3,6 @@ package client
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"git.sr.ht/~akilan1999/p2p-rendering-computation/p2p"
|
||||
"git.sr.ht/~akilan1999/p2p-rendering-computation/server/docker"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
@@ -20,17 +19,9 @@ var client = http.Client{}
|
||||
// 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
|
||||
func StartContainer(IP string, NumPorts int, GPU bool, ContainerName string) (*docker.DockerVM ,error) {
|
||||
func StartContainer(IP string, NumPorts int, GPU bool) (*docker.DockerVM ,error) {
|
||||
// Passes URL with number of TCP ports to allocated and to give GPU access to the docker container
|
||||
var URL string
|
||||
version := p2p.Ip4or6(IP)
|
||||
if version == "version 6" {
|
||||
URL = "http://[" + IP + "]:" + serverPort + "/startcontainer?ports=" + fmt.Sprint(NumPorts) + "&GPU=" + strconv.FormatBool(GPU) + "&ContainerName=" + ContainerName
|
||||
} else {
|
||||
URL = "http://" + IP + ":" + serverPort + "/startcontainer?ports=" + fmt.Sprint(NumPorts) + "&GPU=" + strconv.FormatBool(GPU) + "&ContainerName=" + ContainerName
|
||||
}
|
||||
|
||||
URL := "http://" + IP + ":" + serverPort + "/startcontainer?ports=" + fmt.Sprint(NumPorts) + "&GPU=" + strconv.FormatBool(GPU)
|
||||
resp, err := http.Get(URL)
|
||||
if err != nil {
|
||||
return nil,err
|
||||
@@ -56,13 +47,7 @@ func StartContainer(IP string, NumPorts int, GPU bool, ContainerName string) (*d
|
||||
|
||||
// RemoveContianer Stops and removes container from the server
|
||||
func RemoveContianer(IP string,ID string) error {
|
||||
var URL string
|
||||
version := p2p.Ip4or6(IP)
|
||||
if version == "version 6" {
|
||||
URL = "http://[" + IP + "]:" + serverPort + "/RemoveContainer?id=" + ID
|
||||
} else {
|
||||
URL = "http://" + IP + ":" + serverPort + "/RemoveContainer?id=" + ID
|
||||
}
|
||||
URL := "http://" + IP + ":" + serverPort + "/RemoveContainer?id=" + ID
|
||||
resp, err := http.Get(URL)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -80,39 +65,6 @@ func RemoveContianer(IP string,ID string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ViewContainers This function displays all containers available on server side
|
||||
func ViewContainers(IP string)(*docker.DockerContainers, error){
|
||||
// Passes URL with route /ShowImages
|
||||
var URL string
|
||||
version := p2p.Ip4or6(IP)
|
||||
if version == "version 6" {
|
||||
URL = "http://[" + IP + "]:" + serverPort + "/ShowImages"
|
||||
} else {
|
||||
URL = "http://" + IP + ":" + serverPort + "/ShowImages"
|
||||
}
|
||||
resp, err := http.Get(URL)
|
||||
if err != nil {
|
||||
return nil,err
|
||||
}
|
||||
|
||||
// Convert response to byte value
|
||||
byteValue, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil,err
|
||||
}
|
||||
|
||||
// Create variable for result response type
|
||||
var Result docker.DockerContainers
|
||||
|
||||
// Adds byte value to docker.DockerContainers struct
|
||||
json.Unmarshal(byteValue, &Result)
|
||||
if err != nil {
|
||||
return nil,err
|
||||
}
|
||||
|
||||
return &Result, nil
|
||||
}
|
||||
|
||||
// PrintStartContainer Prints results Generated container
|
||||
func PrintStartContainer(d *docker.DockerVM){
|
||||
fmt.Println("ID : " + fmt.Sprint(d.ID))
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
import "testing"
|
||||
|
||||
func TestUpdateIpTableListClient(t *testing.T) {
|
||||
err := UpdateIpTableListClient()
|
||||
@@ -10,5 +8,4 @@ func TestUpdateIpTableListClient(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
var CliAction = func(ctx *cli.Context) error {
|
||||
if Server {
|
||||
if Mode == "server" {
|
||||
// TODO: with RPC calls
|
||||
server.Server()
|
||||
//server.Rpc()
|
||||
@@ -26,43 +26,10 @@ var CliAction = func(ctx *cli.Context) error {
|
||||
p2p.PrintIpTable()
|
||||
}
|
||||
|
||||
// Displays the IP table
|
||||
if ServerList {
|
||||
p2p.PrintIpTable()
|
||||
}
|
||||
|
||||
// Add provided IP to the IP table
|
||||
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
|
||||
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()
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Displays all images available on the server side
|
||||
if ViewImages != "" {
|
||||
imageRes, err := client.ViewContainers(ViewImages)
|
||||
|
||||
if err != nil {
|
||||
fmt.Print(err)
|
||||
}
|
||||
client.PrettyPrint(imageRes)
|
||||
}
|
||||
|
||||
// Function called to stop and remove server from Docker
|
||||
if RemoveVM != "" && ID != "" {
|
||||
err := client.RemoveContianer(RemoveVM,ID)
|
||||
@@ -81,8 +48,7 @@ var CliAction = func(ctx *cli.Context) error {
|
||||
fmt.Sscanf(Ports, "%d", &PortsInt)
|
||||
}
|
||||
|
||||
// Calls function to do Api call to start the container on the server side
|
||||
imageRes, err := client.StartContainer(CreateVM,PortsInt,GPU,ContainerName)
|
||||
imageRes, err := client.StartContainer(CreateVM,PortsInt,GPU)
|
||||
|
||||
if err != nil {
|
||||
fmt.Print(err)
|
||||
@@ -109,15 +75,6 @@ var CliAction = func(ctx *cli.Context) error {
|
||||
}
|
||||
}
|
||||
|
||||
//If the network interface flag is called
|
||||
// Then all the network interfaces are displayed
|
||||
if NetworkInterface {
|
||||
err := p2p.ViewNetworkInterface()
|
||||
if err != nil {
|
||||
fmt.Print(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
58
cmd/flags.go
58
cmd/flags.go
@@ -6,12 +6,9 @@ import (
|
||||
|
||||
// Variables declared for CLI
|
||||
var (
|
||||
AddServer string
|
||||
ViewImages string
|
||||
CreateVM string
|
||||
ContainerName string
|
||||
Ports string
|
||||
Server bool
|
||||
Mode string
|
||||
RemoveVM string
|
||||
ID string
|
||||
Specs string
|
||||
@@ -19,108 +16,69 @@ var (
|
||||
UpdateServerList bool
|
||||
ServerList bool
|
||||
SetDefaultConfig bool
|
||||
NetworkInterface bool
|
||||
)
|
||||
|
||||
var AppConfigFlags = []cli.Flag{
|
||||
// Deprecated to be implemented using GRPC
|
||||
&cli.BoolFlag{
|
||||
Name: "Server",
|
||||
Aliases: []string{"s"},
|
||||
Usage: "Starts server",
|
||||
EnvVars: []string{"SERVER"},
|
||||
Destination: &Server,
|
||||
&cli.StringFlag{
|
||||
Name: "Mode",
|
||||
Value: "client",
|
||||
Usage: "Specifies mode of running",
|
||||
EnvVars: []string{"P2P_MODE"},
|
||||
Destination: &Mode,
|
||||
},
|
||||
&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: "RemoveVM",
|
||||
Aliases: []string{"rm"},
|
||||
Usage: "Stop and Remove Docker container",
|
||||
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"},
|
||||
Name: "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,
|
||||
},
|
||||
}
|
||||
@@ -9,11 +9,8 @@ var (
|
||||
defaultPath string
|
||||
defaults = map[string]interface{}{
|
||||
"IPTable": "/etc/p2p-rendering/ip_table.json",
|
||||
"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/",
|
||||
"DockerFile": "/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"
|
||||
@@ -22,12 +19,9 @@ var (
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
IPTable string
|
||||
DockerContainers string
|
||||
DefaultDockerFile string
|
||||
SpeedTestFile string
|
||||
NetworkInterface string
|
||||
NetworkInterfaceIPV6Index int
|
||||
IPTable string
|
||||
DockerFile string
|
||||
SpeedTestFile string
|
||||
}
|
||||
|
||||
// Exists reports whether the named file or directory exists.
|
||||
@@ -51,11 +45,8 @@ func SetDefaults() error {
|
||||
|
||||
//Setting default paths for the config file
|
||||
defaults["IPTable"] = defaultPath + "p2p/ip_table.json"
|
||||
defaults["DefaultDockerFile"] = defaultPath + "server/docker/containers/docker-ubuntu-sshd/"
|
||||
defaults["DockerContainers"] = defaultPath + "server/docker/containers/"
|
||||
defaults["DockerFile"] = defaultPath + "server/docker/containers/docker-ubuntu-sshd/"
|
||||
defaults["SpeedTestFile"] = defaultPath + "p2p/50.bin"
|
||||
defaults["NetworkInterface"] = "wlp0s20f3"
|
||||
defaults["NetworkInterfaceIPV6Index"] = "2"
|
||||
|
||||
//Paths to search for config file
|
||||
configPaths = append(configPaths, defaultPath)
|
||||
|
||||
@@ -13,5 +13,7 @@ general:
|
||||
- software-properties-common=0.96.24.32.7 # known good with 0.96.24.32.7
|
||||
- git
|
||||
- golang
|
||||
- g++
|
||||
- openjdk-8-jdk
|
||||
pip:
|
||||
- docker>=3.7.0 # known good with 3.7.0
|
||||
|
||||
2
go.mod
2
go.mod
@@ -13,6 +13,7 @@ require (
|
||||
github.com/google/go-cmp v0.5.4 // indirect
|
||||
github.com/google/uuid v1.1.2
|
||||
github.com/gorilla/mux v1.8.0 // indirect
|
||||
github.com/grandcat/zeroconf v1.0.0 // indirect
|
||||
github.com/lithammer/shortuuid v3.0.0+incompatible
|
||||
github.com/moby/sys/mount v0.2.0 // indirect
|
||||
github.com/moby/term v0.0.0-20201110203204-bea5bbe245bf // indirect
|
||||
@@ -28,6 +29,7 @@ require (
|
||||
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4 // indirect
|
||||
golang.org/x/text v0.3.5 // indirect
|
||||
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba // indirect
|
||||
golang.org/x/tools v0.0.0-20210106214847-113979e3529a // indirect
|
||||
google.golang.org/grpc v1.35.0 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
gotest.tools/v3 v3.0.3 // indirect
|
||||
|
||||
28
go.sum
28
go.sum
@@ -35,13 +35,13 @@ github.com/Azure/go-autorest/autorest/mocks v0.4.0/go.mod h1:LTp+uSrOhSkaKrUy935
|
||||
github.com/Azure/go-autorest/autorest/mocks v0.4.1/go.mod h1:LTp+uSrOhSkaKrUy935gNZuuIPPVsHlr9DSOxSayd+k=
|
||||
github.com/Azure/go-autorest/logger v0.2.0/go.mod h1:T9E3cAhj2VqvPOtCYAvby9aBXkZmbF5NWuPV8+WeEW8=
|
||||
github.com/Azure/go-autorest/tracing v0.6.0/go.mod h1:+vhtPC754Xsa23ID7GlGsrdKBpUA79WCAKPPZVC2DeU=
|
||||
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||
github.com/Microsoft/go-winio v0.4.11/go.mod h1:VhR8bwka0BXejwEJY73c50VrPtXAaKcyvVC4A4RozmA=
|
||||
github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA=
|
||||
github.com/Microsoft/go-winio v0.4.15-0.20190919025122-fc70bd9a86b5/go.mod h1:tTuCMEN+UleMWgg9dVx4Hu52b1bJo+59jBh3ajtinzw=
|
||||
github.com/Microsoft/go-winio v0.4.16-0.20201130162521-d1ffc52c7331/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugXOPRXwdLnMv0=
|
||||
github.com/Microsoft/go-winio v0.4.16 h1:FtSW/jqD+l4ba5iPBj9CODVtgfYAD8w2wS923g/cFDk=
|
||||
github.com/Microsoft/go-winio v0.4.16/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugXOPRXwdLnMv0=
|
||||
github.com/Microsoft/go-winio v0.4.17-0.20210211115548-6eac466e5fa3 h1:mw6pDQqv38/WGF1cO/jF5t/jyAJ2yi7CmtFLLO5tGFI=
|
||||
github.com/Microsoft/go-winio v0.4.17-0.20210211115548-6eac466e5fa3/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84=
|
||||
@@ -83,6 +83,8 @@ github.com/buger/jsonparser v0.0.0-20180808090653-f4dd9f5a6b44/go.mod h1:bbYlZJ7
|
||||
github.com/bugsnag/bugsnag-go v0.0.0-20141110184014-b1d153021fcd/go.mod h1:2oa8nejYd4cQ/b0hMIopN0lCRxU0bueqREvZLWFrtK8=
|
||||
github.com/bugsnag/osext v0.0.0-20130617224835-0dd3f918b21b/go.mod h1:obH5gd0BsqsP2LwDJ9aOkm/6J86V6lyAXCoQWGw3K50=
|
||||
github.com/bugsnag/panicwrap v0.0.0-20151223152923-e2c28503fcd0/go.mod h1:D/8v3kj0zr8ZAKg1AQ6crr+5VwKN5eIywRkfhyM/+dE=
|
||||
github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4=
|
||||
github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
|
||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
@@ -160,6 +162,7 @@ github.com/coreos/go-systemd/v22 v22.0.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+
|
||||
github.com/coreos/go-systemd/v22 v22.1.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+1atmu1JpKERPPk=
|
||||
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/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
|
||||
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=
|
||||
@@ -285,6 +288,7 @@ github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrU
|
||||
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
||||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
|
||||
github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0=
|
||||
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/golang/protobuf v1.4.3 h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM=
|
||||
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
@@ -323,6 +327,8 @@ github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB7
|
||||
github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
|
||||
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
|
||||
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/grandcat/zeroconf v1.0.0 h1:uHhahLBKqwWBV6WZUDAT71044vwOTL+McW0mBJvo6kE=
|
||||
github.com/grandcat/zeroconf v1.0.0/go.mod h1:lTKmG1zh86XyCoUeIHSA4FJMBwCJiQmGfcP2PdzytEs=
|
||||
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA=
|
||||
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
|
||||
github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
|
||||
@@ -349,6 +355,7 @@ github.com/jmespath/go-jmespath v0.0.0-20160803190731-bd40a432e4c7/go.mod h1:Nht
|
||||
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
||||
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||
github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/json-iterator/go v1.1.9 h1:9yzud/Ht36ygwatGx56VwCZtlI/2AD15T1X2sjSuGns=
|
||||
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/json-iterator/go v1.1.10 h1:Kz6Cvnvv2wGdaG/V8yMvfkmNiXq9Ya2KUv4rouJJr68=
|
||||
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
@@ -365,10 +372,12 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxv
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
|
||||
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs=
|
||||
github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/pty v1.1.5 h1:hyz3dwM5QLc1Rfoz4FuWJQG5BN7tc6K1MndAUnGpQr4=
|
||||
github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA=
|
||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
@@ -390,6 +399,8 @@ github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzp
|
||||
github.com/mattn/go-shellwords v1.0.3/go.mod h1:3xCvwCdWdlDJUrvuMn7Wuy9eWs4pE8vqg+NOMyg4B2o=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
|
||||
github.com/miekg/dns v1.1.27 h1:aEH/kqUzUxGJ/UHcEKdJY+ugH6WEzsEBBSPa8zuy1aM=
|
||||
github.com/miekg/dns v1.1.27/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM=
|
||||
github.com/mistifyio/go-zfs v2.1.2-0.20190413222219-f784269be439+incompatible/go.mod h1:8AuVvqP/mXw1px98n46wfvcGfQ4ci2FwoAjKYxuo3Z4=
|
||||
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE=
|
||||
@@ -403,9 +414,11 @@ github.com/moby/sys/symlink v0.1.0/go.mod h1:GGDODQmbFOjFsXvfLVn3+ZRxkch54RkSiGq
|
||||
github.com/moby/term v0.0.0-20200312100748-672ec06f55cd/go.mod h1:DdlQx2hp0Ss5/fLikoLlEeIYiATotOjgB//nb973jeo=
|
||||
github.com/moby/term v0.0.0-20201110203204-bea5bbe245bf h1:Un6PNx5oMK6CCwO3QTUyPiK2mtZnPrpDl5UnZ64eCkw=
|
||||
github.com/moby/term v0.0.0-20201110203204-bea5bbe245bf/go.mod h1:FBS0z0QWA44HXygs7VXDUOGoN/1TV3RuWkLO04am3wc=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLDQ0W1YjYsBW+p8U2u7vzgW2SQVmlNazg=
|
||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
|
||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
@@ -439,6 +452,7 @@ github.com/opencontainers/image-spec v1.0.0/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zM
|
||||
github.com/opencontainers/image-spec v1.0.1 h1:JMemWkRwHx4Zj+fVxWoMCFm/8sYGGrUVojFA6h/TRcI=
|
||||
github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0=
|
||||
github.com/opencontainers/runc v0.0.0-20190115041553-12f6a991201f/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U=
|
||||
github.com/opencontainers/runc v0.1.1 h1:GlxAyO6x8rfZYN9Tt0Kti5a/cP41iuiO2yYT0IJGY8Y=
|
||||
github.com/opencontainers/runc v0.1.1/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U=
|
||||
github.com/opencontainers/runc v1.0.0-rc8.0.20190926000215-3e425f80a8c9/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U=
|
||||
github.com/opencontainers/runc v1.0.0-rc9/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U=
|
||||
@@ -544,6 +558,7 @@ github.com/stretchr/testify v0.0.0-20180303142811-b89eecf5ca5d/go.mod h1:a8OnRci
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
|
||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
|
||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
@@ -607,6 +622,7 @@ golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8U
|
||||
golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0 h1:hb9wdF1z5waM+dSIICn1l0DkLVDT3hqhhQsDNUmHPRE=
|
||||
golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
@@ -660,6 +676,7 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL
|
||||
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20191004110552-13f9640d40b9/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
@@ -686,6 +703,7 @@ golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJ
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9 h1:SQFwaSi55rU7vdNs9Yr0Z324VNlrF+0wMqRXT4St8ck=
|
||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a h1:DcqTD9SDLc+1P/r1EmRBwnVsrOwW+kk2vWf9n+1sGhs=
|
||||
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
@@ -712,6 +730,7 @@ golang.org/x/sys v0.0.0-20190801041406-cbf593c0f2f3/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||
golang.org/x/sys v0.0.0-20190812073006-9eafafc0a87e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191022100944-742c48ecaeb7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
@@ -740,6 +759,7 @@ golang.org/x/sys v0.0.0-20200916030750-2334cc1a136f/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||
golang.org/x/sys v0.0.0-20200922070232-aee5d888a860/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201112073958-5cba982894dd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 h1:nxC68pudNYkKU6jWhgrqdreuFiOQWj1Fs7T3VrH4Pjw=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201202213521-69691e467435/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
@@ -751,6 +771,7 @@ golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fq
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.5 h1:i6eZZ+zk0SOf0xgBpEpPD18qWcJda6q1sxt3S0kzyUQ=
|
||||
@@ -787,6 +808,7 @@ golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtn
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191216052735-49a3e744a425/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
@@ -798,6 +820,7 @@ golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapK
|
||||
golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw=
|
||||
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||
golang.org/x/tools v0.0.0-20210106214847-113979e3529a h1:CB3a9Nez8M13wwlr/E2YtwoU+qYHKfC+JrDa45RXXoQ=
|
||||
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
@@ -841,6 +864,7 @@ google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4
|
||||
google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY=
|
||||
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
|
||||
google.golang.org/genproto v0.0.0-20201110150050-8816d57aaa9a h1:pOwg4OoaRYScjmR4LlLgdtnyoHYTSAVhhqe5uPdpII8=
|
||||
google.golang.org/genproto v0.0.0-20201110150050-8816d57aaa9a/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
@@ -874,6 +898,7 @@ gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4
|
||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20141024133853-64131543e789/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
@@ -893,6 +918,7 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||
|
||||
@@ -1,11 +1,3 @@
|
||||
{
|
||||
"ip_address": [
|
||||
{
|
||||
"ipv4": "",
|
||||
"ipv6": "2001:8f8:172d:ee93:7588:ad57:c351:3309",
|
||||
"latency": 1213198,
|
||||
"download": 0,
|
||||
"upload": 0
|
||||
}
|
||||
]
|
||||
"ip_address": null
|
||||
}
|
||||
136
p2p/iptable.go
136
p2p/iptable.go
@@ -2,12 +2,9 @@ package p2p
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"git.sr.ht/~akilan1999/p2p-rendering-computation/config"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
@@ -20,16 +17,11 @@ type IpAddresses struct {
|
||||
|
||||
type IpAddress struct {
|
||||
Ipv4 string `json:"ipv4"`
|
||||
Ipv6 string `json:"ipv6"`
|
||||
Latency time.Duration `json:"latency"`
|
||||
Download float64 `json:"download"`
|
||||
Upload float64 `json:"upload"`
|
||||
}
|
||||
|
||||
type IP struct {
|
||||
Query string
|
||||
}
|
||||
|
||||
// ReadIpTable Read data from Ip tables from json file
|
||||
func ReadIpTable()(*IpAddresses ,error){
|
||||
// Get Path from config
|
||||
@@ -57,38 +49,11 @@ func ReadIpTable()(*IpAddresses ,error){
|
||||
// jsonFile's content into 'users' which we defined above
|
||||
json.Unmarshal(byteValue, &ipAddresses)
|
||||
|
||||
var PublicIP IpAddress
|
||||
|
||||
ipv6, err := GetCurrentIPV6()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ip, err := CurrentPublicIP()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
PublicIP.Ipv4 = ip
|
||||
PublicIP.Ipv6 = ipv6
|
||||
|
||||
// Updates current machine IP address to the IP table
|
||||
ipAddresses.IpAddress = append(ipAddresses.IpAddress, PublicIP)
|
||||
|
||||
//before writing to iptable ensures the duplicates are removed
|
||||
if err = ipAddresses.RemoveDuplicates(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &ipAddresses, nil
|
||||
}
|
||||
|
||||
// WriteIpTable Write to IP table json file
|
||||
func (i *IpAddresses) WriteIpTable() error {
|
||||
//before writing to iptable ensures the duplicates are removed
|
||||
if err := i.RemoveDuplicates(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
file, err := json.MarshalIndent(i, "", " ")
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -117,8 +82,8 @@ func PrintIpTable() error {
|
||||
}
|
||||
|
||||
for i := 0; i < len(table.IpAddress); i++ {
|
||||
fmt.Printf("\nIP Address: %s\nIPV6: %s\nLatency: %s\n-----------" +
|
||||
"-----------------\n",table.IpAddress[i].Ipv4,table.IpAddress[i].Ipv6,
|
||||
fmt.Printf("\nIP Address: %s\nLatency: %s\n-----------" +
|
||||
"-----------------\n",table.IpAddress[i].Ipv4,
|
||||
table.IpAddress[i].Latency)
|
||||
}
|
||||
return nil
|
||||
@@ -126,13 +91,17 @@ func PrintIpTable() error {
|
||||
|
||||
// RemoveDuplicates This is a temporary fix current functions failing to remove
|
||||
// Duplicate IP addresses from local IP table
|
||||
func (table *IpAddresses)RemoveDuplicates() error {
|
||||
func RemoveDuplicates() error {
|
||||
table, err := ReadIpTable()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var NoDuplicates IpAddresses
|
||||
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 == table.IpAddress[i].Ipv4 {
|
||||
Exists = true
|
||||
break
|
||||
}
|
||||
@@ -144,92 +113,9 @@ func (table *IpAddresses)RemoveDuplicates() error {
|
||||
NoDuplicates.IpAddress = append(NoDuplicates.IpAddress, table.IpAddress[i])
|
||||
}
|
||||
|
||||
table.IpAddress = NoDuplicates.IpAddress
|
||||
if err := NoDuplicates.WriteIpTable(); err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// CurrentPublicIP Get Current Public IP address
|
||||
func CurrentPublicIP() (string,error) {
|
||||
req, err := http.Get("http://ip-api.com/json/")
|
||||
if err != nil {
|
||||
return "",err
|
||||
}
|
||||
defer req.Body.Close()
|
||||
|
||||
body, err := ioutil.ReadAll(req.Body)
|
||||
if err != nil {
|
||||
return "",err
|
||||
}
|
||||
|
||||
var ip IP
|
||||
json.Unmarshal(body, &ip)
|
||||
|
||||
return ip.Query, nil
|
||||
}
|
||||
|
||||
// GetCurrentIPV6 gets the current IPV6 address based on the interface
|
||||
// specified in the config file
|
||||
func GetCurrentIPV6()(string,error){
|
||||
Config, err := config.ConfigInit()
|
||||
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
|
||||
}
|
||||
|
||||
// ViewNetworkInterface This function is created to view the network interfaces available
|
||||
func ViewNetworkInterface() error {
|
||||
ifaces, err := net.Interfaces()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, i := range ifaces {
|
||||
addrs, err := i.Addrs()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for index, a := range addrs {
|
||||
switch v := a.(type) {
|
||||
case *net.IPAddr:
|
||||
fmt.Printf("(%v) %v : %s (%s)\n", index, i.Name, v, v.IP.DefaultMask())
|
||||
|
||||
case *net.IPNet:
|
||||
fmt.Printf("(%v) %v : %s \n", index, i.Name, v)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// 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)
|
||||
func Ip4or6(s string) string {
|
||||
for i := 0; i < len(s); i++ {
|
||||
switch s[i] {
|
||||
case '.':
|
||||
return "version 4"
|
||||
case ':':
|
||||
return "version 6"
|
||||
}
|
||||
}
|
||||
return "unknown"
|
||||
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package p2p
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -21,47 +20,3 @@ func TestReadIpTable(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Testing is a IPV6 address is returned
|
||||
func TestGetCurrentIPV6(t *testing.T) {
|
||||
res, err := GetCurrentIPV6()
|
||||
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
fmt.Println(res)
|
||||
}
|
||||
|
||||
// This test ensures that the duplicate function works as intended
|
||||
func TestIpAddresses_RemoveDuplicates(t *testing.T) {
|
||||
var testduplicates IpAddresses
|
||||
var duplicateaddress1 IpAddress
|
||||
var duplicateaddress2 IpAddress
|
||||
|
||||
duplicateaddress1.Ipv6="2001:8f8:172d:ee93:7588:ad57:c351:3309"
|
||||
duplicateaddress1.Ipv4="0.0.0.0"
|
||||
|
||||
duplicateaddress2.Ipv6="2001:8f8:172d:ee93:7588:ad57:c351:3309"
|
||||
duplicateaddress2.Ipv4="0.0.0.0"
|
||||
|
||||
testduplicates.IpAddress = append(testduplicates.IpAddress, duplicateaddress1)
|
||||
testduplicates.IpAddress = append(testduplicates.IpAddress, duplicateaddress2)
|
||||
|
||||
err := testduplicates.RemoveDuplicates()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if len(testduplicates.IpAddress) == 2 {
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestViewNetworkInterface(t *testing.T) {
|
||||
err := ViewNetworkInterface()
|
||||
if err != nil {
|
||||
t.Error()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,13 +2,10 @@ package p2p
|
||||
|
||||
// SpeedTest Runs a speed test and does updates IP tables accordingly
|
||||
func (ip *IpAddresses)SpeedTest() error{
|
||||
|
||||
//temp variable to store elements IP addresses and other information
|
||||
// of IP addresses that are pingable
|
||||
var ActiveIP IpAddresses
|
||||
|
||||
// Index to remove from struct
|
||||
for _, value := range ip.IpAddress {
|
||||
// Index to remove from struct
|
||||
var RemoveIndex []int
|
||||
for i, value := range ip.IpAddress {
|
||||
|
||||
var err error
|
||||
//if len(ip.IpAddress) == 1 {
|
||||
@@ -19,6 +16,10 @@ func (ip *IpAddresses)SpeedTest() error{
|
||||
err = value.PingTest()
|
||||
|
||||
if err != nil {
|
||||
RemoveIndex = append(RemoveIndex, i)
|
||||
// Record index to remove
|
||||
//ip.IpAddress = append(ip.IpAddress[:i], ip.IpAddress[i+1:]...)
|
||||
// Proceed to next element in the array
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -34,12 +35,19 @@ func (ip *IpAddresses)SpeedTest() error{
|
||||
//}
|
||||
|
||||
//Set value to the list
|
||||
|
||||
ActiveIP.IpAddress = append(ActiveIP.IpAddress, value)
|
||||
ip.IpAddress[i] = value
|
||||
|
||||
}
|
||||
|
||||
ip.IpAddress = ActiveIP.IpAddress
|
||||
// Remove element from struct
|
||||
for _, index := range RemoveIndex {
|
||||
// If there is only 1 element and that has to be
|
||||
// removed
|
||||
if len(ip.IpAddress) == 1 {
|
||||
ip.IpAddress = nil
|
||||
break
|
||||
}
|
||||
ip.IpAddress = append(ip.IpAddress[:index], ip.IpAddress[index+1:]...)
|
||||
}
|
||||
|
||||
err := ip.WriteIpTable()
|
||||
if err != nil {
|
||||
@@ -49,7 +57,7 @@ func (ip *IpAddresses)SpeedTest() error{
|
||||
return nil
|
||||
}
|
||||
|
||||
// SpeedTestUpdatedIPTable Called when ip tables from httpclient/server is also passed on
|
||||
// SpeedTestUpdatedIPTable Called when ip tables from client/server is also passed on
|
||||
func (ip *IpAddresses)SpeedTestUpdatedIPTable() error{
|
||||
targets, err := ReadIpTable()
|
||||
if err != nil {
|
||||
@@ -63,20 +71,18 @@ func (ip *IpAddresses)SpeedTestUpdatedIPTable() error{
|
||||
for i, _ := range targets.IpAddress {
|
||||
|
||||
// To ensure that there are no duplicate IP addresses
|
||||
//Exists := false
|
||||
//for k := range ip.IpAddress {
|
||||
// // Checks if both the IPV4 addresses are the same or the IPV6 address is not
|
||||
// // an empty string and IPV6 address are the same
|
||||
// if ip.IpAddress[k].Ipv4 == targets.IpAddress[i].Ipv4 || (targets.IpAddress[i].Ipv6 != "" && ip.IpAddress[k].Ipv6 == targets.IpAddress[i].Ipv6) {
|
||||
// Exists = true
|
||||
// break
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//// If the struct exists then continues
|
||||
//if Exists {
|
||||
// continue
|
||||
//}
|
||||
Exists := false
|
||||
for k := range ip.IpAddress {
|
||||
if ip.IpAddress[k].Ipv4 == targets.IpAddress[i].Ipv4 {
|
||||
Exists = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// If the struct exists then continues
|
||||
if Exists {
|
||||
continue
|
||||
}
|
||||
|
||||
ip.IpAddress = append(ip.IpAddress, targets.IpAddress[i])
|
||||
}
|
||||
@@ -105,7 +111,6 @@ func LocalSpeedTestIpTable() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
// Helper function to remove element from an array of a struct
|
||||
//func remove(s []IpAddress, i int) []IpAddress {
|
||||
// s[len(s)-1], s[i] = s[i], s[len(s)-1]
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
|
||||
//var dlSizes = [...]int{350, 500, 750, 1000, 1500, 2000, 2500, 3000, 3500, 4000}
|
||||
//var ulSizes = [...]int{100, 300, 500, 800, 1000, 1500, 2500, 3000, 3500, 4000} //kB
|
||||
var httpclient = http.Client{}
|
||||
var client = http.Client{}
|
||||
|
||||
// DownloadTest executes the test to measure download speed
|
||||
//func (s *IpAddress) DownloadTest(savingMode bool) error {
|
||||
@@ -80,7 +80,7 @@ var httpclient = http.Client{}
|
||||
// Download Speed
|
||||
func (s *IpAddress)DownloadSpeed() error {
|
||||
start := time.Now()
|
||||
resp, err := httpclient.Get("http://" + s.Ipv4 + ":8088/50")
|
||||
resp, err := client.Get("http://" + s.Ipv4 + ":8088/50")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -150,14 +150,7 @@ func mustOpen(f string) *os.File {
|
||||
// PingTest executes test to measure latency
|
||||
func (s *IpAddress) PingTest() error {
|
||||
//pingURL := strings.Split(s.URL, "/upload")[0] + "/latency.txt"
|
||||
var pingURL string
|
||||
if s.Ipv6 != "" {
|
||||
pingURL = "http://[" + s.Ipv6 + "]:8088/server_info"
|
||||
s.Ipv4 = ""
|
||||
} else {
|
||||
pingURL = "http://" + s.Ipv4 + ":8088/server_info"
|
||||
}
|
||||
|
||||
pingURL := "http://" + s.Ipv4 + ":8088/server_info"
|
||||
l := time.Duration(100000000000) // 10sec
|
||||
for i := 0; i < 3; i++ {
|
||||
sTime := time.Now()
|
||||
|
||||
21
p2p/upnp_test.go
Normal file
21
p2p/upnp_test.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package p2p
|
||||
|
||||
import(
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestAddRemoveUpnp(t *testing.T){
|
||||
|
||||
// forwarding port 23241 via upnp
|
||||
err := ForwardPort(23241)
|
||||
if err != nil {
|
||||
t.Errorf("Error returned: %q", err)
|
||||
}
|
||||
|
||||
// unforwarding port 23241 via upnp
|
||||
err = UnForwardPort(23241)
|
||||
if err != nil {
|
||||
t.Errorf("Error returned: %q", err)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
# 3. handlers - these steps run only in response to specific events. If the event does not occur, the handler does not run.
|
||||
################################################################################
|
||||
---
|
||||
- hosts: test # Alternatively, 'canary', 'blue'|'green', 'all' according to your deployment strategy and your /etc/ansible/hosts file
|
||||
- hosts: gpu # Alternatively, 'canary', 'blue'|'green', 'all' according to your deployment strategy and your /etc/ansible/hosts file
|
||||
become: yes # All commands must run as root
|
||||
strategy: free # Allows all hosts to run to the end of the playbook as fast as they can
|
||||
|
||||
@@ -26,8 +26,8 @@
|
||||
# vars:
|
||||
# users: "{{ secrets.users }}"
|
||||
|
||||
- role: cuda # CUDA Driver Setup
|
||||
tags: [cuda]
|
||||
# - role: cuda # CUDA Driver Setup
|
||||
# tags: [cuda]
|
||||
|
||||
# - role: nvidia # NVIDIA-Docker Runtime Setup
|
||||
# tags: [nvidia]
|
||||
3
sample-run/ML/requirements.yml
Normal file
3
sample-run/ML/requirements.yml
Normal file
@@ -0,0 +1,3 @@
|
||||
---
|
||||
- name: nvidia.nvidia_driver
|
||||
version: 2.0.0
|
||||
@@ -11,5 +11,10 @@ general:
|
||||
- software-properties-common # known good with 0.96.24.32.7
|
||||
- git
|
||||
- golang
|
||||
- apt-utils
|
||||
- libopenmpi-dev
|
||||
- python3-setuptools
|
||||
- python3-dev
|
||||
pip:
|
||||
- docker>=3.7.0 # known good with 3.7.0
|
||||
- tensorflow
|
||||
27
sample-run/run.txt
Normal file
27
sample-run/run.txt
Normal file
@@ -0,0 +1,27 @@
|
||||
Create 3 vm using ./p2prc --CreateVM 0.0.0.0 --Ports=1 --GPU
|
||||
|
||||
then on each run
|
||||
|
||||
sudo apt clean && sudo apt update && sudo apt -y install cmake ccache nano
|
||||
sudo ln -s /usr/local/cuda-11.2 /usr/local/cuda
|
||||
export PATH=${HOME}/.local/bin:$PATH && export PATH=/usr/local/cuda-11.2/bin${PATH:+:${PATH}} && export LD_LIBRARY_PATH=/usr/local/cuda-11.2/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
|
||||
wget -c https://raw.githubusercontent.com/horovod/horovod/master/examples/tensorflow2/tensorflow2_synthetic_benchmark.py
|
||||
|
||||
pip install --no-cache-dir horovod[tensorflow]
|
||||
|
||||
# this will test if its locally install properly
|
||||
horovodrun -np 1 python3 tensorflow2_synthetic_benchmark.py
|
||||
|
||||
then configure machine1 ssh/config file like
|
||||
Host host1
|
||||
HostName 0.0.0.0
|
||||
Port 39751
|
||||
|
||||
Host host2
|
||||
HostName 0.0.0.0
|
||||
Port 34779
|
||||
|
||||
and ensure that the ssh can be connected and ssh keys are copied using ssh-copy-id command
|
||||
|
||||
then run
|
||||
horovodrun -np 2 -H host1:1,host2:1 python3 tensorflow2_synthetic_benchmark.py
|
||||
@@ -1,12 +0,0 @@
|
||||
---
|
||||
all:
|
||||
vars:
|
||||
ansible_python_interpreter: /usr/bin/python3
|
||||
test:
|
||||
hosts:
|
||||
test1:
|
||||
ansible_host: 0.0.0.0 # Replace with your remote IP
|
||||
ansible_port: 44003 # Replace with your remote SSH port
|
||||
ansible_user: master # Replace wtih your username
|
||||
ansible_ssh_pass: password
|
||||
ansible_sudo_pass: password
|
||||
@@ -1,23 +0,0 @@
|
||||
# The `cuda` Role
|
||||
|
||||
The `cuda` role installs the Nvidia CUDA GPU repository and drivers.
|
||||
|
||||
This role may be executed independently by running:
|
||||
|
||||
```bash
|
||||
$ ansible-playbook packages.yml --tags "cuda"
|
||||
```
|
||||
|
||||
On execution, this role installs the following directly to the remote machine's operating system:
|
||||
|
||||
### Apt Repositories (Debian/Ubuntu)
|
||||
|
||||
- Nvidia CUDA
|
||||
|
||||
### Apt GPG Signing Keys (Debian/Ubuntu)
|
||||
|
||||
- cudatools <cudatools@nvidia.com>
|
||||
|
||||
### Operating System Packages (Debian/Ubuntu)
|
||||
|
||||
- cuda v10.x
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,5 +0,0 @@
|
||||
---
|
||||
# CUDA Driver Setup
|
||||
- name: reboot the machine
|
||||
reboot:
|
||||
listen: "reboot the machine"
|
||||
@@ -1,22 +0,0 @@
|
||||
---
|
||||
# Cuda Driver Package Installation
|
||||
- name: copy the CUDA repo onto the machine
|
||||
copy:
|
||||
src: "{{ cuda.apt.repo }}"
|
||||
dest: "{{ general.working_dir }}/{{ cuda.apt.repo }}"
|
||||
|
||||
- name: get the CUDA signing key
|
||||
apt_key:
|
||||
state: present
|
||||
url: "{{ cuda.apt.signing_key_url }}"
|
||||
|
||||
- name: add the CUDA repo
|
||||
apt:
|
||||
deb: "{{ general.working_dir }}/{{ cuda.apt.repo }}"
|
||||
state: present
|
||||
|
||||
- name: install the CUDA drivers
|
||||
apt:
|
||||
name: "{{ cuda.apt.package }}"
|
||||
update_cache: yes
|
||||
notify: "reboot the machine"
|
||||
@@ -1,10 +0,0 @@
|
||||
---
|
||||
cuda:
|
||||
apt:
|
||||
package: cuda=11.* # known good with 10.0.130-1
|
||||
repo: cuda-11-3_11.3.1-1_amd64.deb # Network install
|
||||
dependency: cuda-runtime-11-3_11.3.1-1_amd64.deb
|
||||
signing_key_url: https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/7fa2af80.pub
|
||||
|
||||
general:
|
||||
working_dir: /tmp
|
||||
@@ -1,3 +0,0 @@
|
||||
---
|
||||
- import_tasks: debian.yml
|
||||
when: ansible_facts['os_family']|lower == 'debian' # debian, ubuntu
|
||||
@@ -1,43 +0,0 @@
|
||||
from horovod/horovod-cpu
|
||||
# Switch to root user to install additional software
|
||||
USER 0
|
||||
|
||||
|
||||
# Make sure we don't get notifications we can't answer during building.
|
||||
env DEBIAN_FRONTEND noninteractive
|
||||
|
||||
run apt-get -q -y update; apt-get -q -y upgrade
|
||||
run apt install net-tools
|
||||
|
||||
# Prepare scripts and configs
|
||||
add ./scripts/start /start
|
||||
|
||||
|
||||
# Set root password
|
||||
run echo 'root:password' >> /root/passwdfile
|
||||
|
||||
|
||||
# Create user and it's password
|
||||
run useradd -m -G sudo master && \
|
||||
echo 'master:password' >> /root/passwdfile
|
||||
|
||||
|
||||
# Apply root password
|
||||
run chpasswd -c SHA512 < /root/passwdfile && \
|
||||
rm /root/passwdfile
|
||||
|
||||
|
||||
# Port 22 is used for ssh
|
||||
expose 22
|
||||
|
||||
|
||||
# Assign /data as static volume.
|
||||
volume ["/data"]
|
||||
|
||||
|
||||
# Fix all permissions
|
||||
run chmod +x /start
|
||||
|
||||
|
||||
# Starting sshd
|
||||
cmd ["/start"]
|
||||
@@ -1 +0,0 @@
|
||||
Running official horovod dockerfile cpu version
|
||||
@@ -1,11 +0,0 @@
|
||||
#!/bin/bash
|
||||
# -----------------------------------------------------------------------------
|
||||
# docker-ubuntu-sshd /start script
|
||||
#
|
||||
# Authors: Art567
|
||||
# Updated: Sep 20th, 2015
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
# Run OpenSSH server in daemon mode
|
||||
/usr/sbin/sshd -D
|
||||
50
server/docker/containers/docker-ubuntu-sshd-gpu/Dockerfile
Normal file
50
server/docker/containers/docker-ubuntu-sshd-gpu/Dockerfile
Normal file
@@ -0,0 +1,50 @@
|
||||
# -----------------------------------------------------------------------------
|
||||
# This is base image of Ubuntu LTS with SSHD service.
|
||||
#
|
||||
# Authors: Art567
|
||||
# Updated: Sep 20th, 2015
|
||||
# Require: Docker (http://www.docker.io/)
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
# Base system is the latest LTS version of Ubuntu.
|
||||
# from consol/ubuntu-xfce-vnc
|
||||
|
||||
# due to dependency issues vnc is still work in progress
|
||||
from nvidia/cuda:11.2.2-cudnn8-devel-ubuntu20.04
|
||||
|
||||
# Switch to root user to install additional software
|
||||
USER 0
|
||||
|
||||
# Make sure we don't get notifications we can't answer during building.
|
||||
env DEBIAN_FRONTEND noninteractive
|
||||
|
||||
# Prepare scripts and configs
|
||||
add ./scripts/start /start
|
||||
|
||||
# Download and install everything from the repos.
|
||||
run apt-get -q -y update; apt-get -q -y upgrade && \
|
||||
apt-get -q -y install sudo openssh-server python3-pip && \
|
||||
mkdir /var/run/sshd
|
||||
|
||||
# Set root password
|
||||
run echo 'root:password' >> /root/passwdfile
|
||||
|
||||
# Create user and it's password
|
||||
run useradd -m -G sudo master && \
|
||||
echo 'master:password' >> /root/passwdfile
|
||||
|
||||
# Apply root password
|
||||
run chpasswd -c SHA512 < /root/passwdfile && \
|
||||
rm /root/passwdfile
|
||||
|
||||
# Port 22 is used for ssh
|
||||
expose 22
|
||||
|
||||
# Assign /data as static volume.
|
||||
volume ["/data"]
|
||||
|
||||
# Fix all permissions
|
||||
run chmod +x /start
|
||||
|
||||
# Starting sshd
|
||||
cmd ["/start"]
|
||||
72
server/docker/containers/docker-ubuntu-sshd-gpu/README.md
Normal file
72
server/docker/containers/docker-ubuntu-sshd-gpu/README.md
Normal file
@@ -0,0 +1,72 @@
|
||||
Ubuntu LTS with SSH (Docker)
|
||||
=========
|
||||
|
||||
A Docker file to build a [docker.io] base container with Ubuntu LTS and a sshd service
|
||||
[docker.io]: http://docker.io
|
||||
Nice and easy way to get any server up and running using docker
|
||||
|
||||
|
||||
Instructions
|
||||
-----------
|
||||
- Install Docker first.
|
||||
Read [installation instructions] (http://docs.docker.io/en/latest/installation/).
|
||||
|
||||
|
||||
- Clone this repository:
|
||||
|
||||
`$ git clone https://github.com/art567/docker-ubuntu-sshd.git`
|
||||
|
||||
|
||||
- Enter local directory:
|
||||
|
||||
`$ cd docker-ubuntu-sshd`
|
||||
|
||||
- Change passwords in Dockerfile:
|
||||
|
||||
`$ vi Dockerfile`
|
||||
|
||||
- Build the container:
|
||||
|
||||
`$ sudo docker build -t art567/ubuntu .`
|
||||
|
||||
|
||||
- Run the container:
|
||||
|
||||
`$ sudo docker run -d=true --name=ubuntu --restart=always -p=2222:22 -v=/opt/data:/data art567/ubuntu /start`
|
||||
|
||||
|
||||
- Your container will start and bind ssh to 2222 port.
|
||||
|
||||
|
||||
- Find your local IP Address:
|
||||
|
||||
`$ ifconfig`
|
||||
|
||||
|
||||
- Connect to the SSH server:
|
||||
|
||||
`$ ssh root@<ip-address> -p 2222`
|
||||
|
||||
|
||||
- If you don't want to deal with root:
|
||||
|
||||
`$ ssh master@<ip-address> -p 2222`
|
||||
|
||||
|
||||
**VERY IMPORTANT!!!**
|
||||
-----------
|
||||
|
||||
**Don't forget to change passwords in Dockerfile before building image!**
|
||||
|
||||
|
||||
Versions
|
||||
-----------
|
||||
Some branches represents Ubuntu versions.
|
||||
|
||||
Branch `master` is always represented by latest Ubuntu LTS
|
||||
|
||||
For example:
|
||||
- 12.04 - Ubuntu 12.04 LTS
|
||||
- 14.04 - Ubuntu 14.04 LTS
|
||||
- 16.04 - Ubuntu 16.04 LTS
|
||||
|
||||
@@ -8,4 +8,4 @@
|
||||
|
||||
|
||||
# Run OpenSSH server in daemon mode
|
||||
/usr/sbin/sshd -D
|
||||
/usr/sbin/sshd -D
|
||||
@@ -1 +0,0 @@
|
||||
Simple Ubuntu 20.04 image
|
||||
@@ -1,41 +0,0 @@
|
||||
from horovod/horovod
|
||||
# Switch to root user to install additional software
|
||||
USER 0
|
||||
|
||||
|
||||
# Make sure we don't get notifications we can't answer during building.
|
||||
env DEBIAN_FRONTEND noninteractive
|
||||
|
||||
|
||||
# Prepare scripts and configs
|
||||
add ./scripts/start /start
|
||||
|
||||
|
||||
# Set root password
|
||||
run echo 'root:password' >> /root/passwdfile
|
||||
|
||||
|
||||
# Create user and it's password
|
||||
run useradd -m -G sudo master && \
|
||||
echo 'master:password' >> /root/passwdfile
|
||||
|
||||
|
||||
# Apply root password
|
||||
run chpasswd -c SHA512 < /root/passwdfile && \
|
||||
rm /root/passwdfile
|
||||
|
||||
|
||||
# Port 22 is used for ssh
|
||||
expose 22
|
||||
|
||||
|
||||
# Assign /data as static volume.
|
||||
volume ["/data"]
|
||||
|
||||
|
||||
# Fix all permissions
|
||||
run chmod +x /start
|
||||
|
||||
|
||||
# Starting sshd
|
||||
cmd ["/start"]
|
||||
@@ -1 +0,0 @@
|
||||
Running official horovod dockerfile cpu version
|
||||
@@ -16,7 +16,6 @@ import (
|
||||
"github.com/lithammer/shortuuid"
|
||||
"github.com/phayes/freeport"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os/exec"
|
||||
"time"
|
||||
)
|
||||
@@ -34,15 +33,6 @@ type DockerVM struct {
|
||||
GPU string `json:"GPU"`
|
||||
}
|
||||
|
||||
type DockerContainers struct {
|
||||
DockerContainer []DockerContainer `json:"DockerContainer"`
|
||||
}
|
||||
|
||||
type DockerContainer struct {
|
||||
ContainerName string `json:"DockerContainerName"`
|
||||
ContainerDescription string `json:"ContainerDescription"`
|
||||
}
|
||||
|
||||
type ErrorLine struct {
|
||||
Error string `json:"error"`
|
||||
ErrorDetail ErrorDetail `json:"errorDetail"`
|
||||
@@ -54,7 +44,7 @@ type ErrorDetail struct {
|
||||
|
||||
var dockerRegistryUserID = ""
|
||||
|
||||
func BuildRunContainer(NumPorts int, GPU string, ContainerName string) (*DockerVM,error) {
|
||||
func BuildRunContainer(NumPorts int, GPU string) (*DockerVM,error) {
|
||||
//Docker Struct Variable
|
||||
var RespDocker *DockerVM = new(DockerVM)
|
||||
|
||||
@@ -91,27 +81,10 @@ func BuildRunContainer(NumPorts int, GPU string, ContainerName string) (*DockerV
|
||||
if err != nil {
|
||||
return nil,err
|
||||
}
|
||||
RespDocker.ImagePath = config.DefaultDockerFile
|
||||
|
||||
// We are checking if the container name is not nil and not equal to the default one used
|
||||
// which is docker-ubuntu-sshd
|
||||
if ContainerName != "" && ContainerName != "docker-ubuntu-sshd" {
|
||||
Containers, err := ViewAllContainers()
|
||||
if err != nil {
|
||||
return nil,err
|
||||
}
|
||||
|
||||
for _, dockerContainer := range Containers.DockerContainer {
|
||||
if dockerContainer.ContainerName == ContainerName {
|
||||
RespDocker.ImagePath = config.DockerContainers + ContainerName + "/"
|
||||
RespDocker.TagName = ContainerName
|
||||
break
|
||||
}
|
||||
}
|
||||
if RespDocker.ImagePath == config.DefaultDockerFile {
|
||||
return nil, errors.New("Container " + ContainerName + " does not exist in the server")
|
||||
}
|
||||
}
|
||||
RespDocker.ImagePath = config.DockerFile
|
||||
//if GPU == "true" {
|
||||
// RespDocker.ImagePath = "/home/asleepyguy/p2p-rendering-computation/server/docker/containers/docker-ubuntu-sshd-gpu/"
|
||||
//}
|
||||
|
||||
// Gets docker information from env variables
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
|
||||
@@ -257,7 +230,7 @@ func (d *DockerVM)runContainer(dockerClient *client.Client) error{
|
||||
for i := range d.Ports {
|
||||
cmd.WriteString("-p " + fmt.Sprint(d.Ports[i]) + ":" + fmt.Sprint(d.Ports[i]) + " ")
|
||||
}
|
||||
cmd.WriteString("-v=/opt/data:/data "+ d.TagName +" /start > /dev/null")
|
||||
cmd.WriteString("-v=/opt/data:/data p2p-ubuntu /start > /dev/null")
|
||||
//"-v=/opt/data:/data p2p-ubuntu /start > /dev/null"
|
||||
cmdStr := cmd.String()
|
||||
_, err := exec.Command("/bin/sh", "-c", cmdStr).Output()
|
||||
@@ -268,7 +241,7 @@ func (d *DockerVM)runContainer(dockerClient *client.Client) error{
|
||||
return nil
|
||||
}
|
||||
|
||||
// StopAndRemoveContainer
|
||||
// StopAndRemoveContainer TODO: Implement and remove docker instance running
|
||||
// Stop and remove a container
|
||||
// Reference (https://gist.github.com/frikky/e2efcea6c733ea8d8d015b7fe8a91bf6)
|
||||
func StopAndRemoveContainer(containername string) error {
|
||||
@@ -296,46 +269,6 @@ func StopAndRemoveContainer(containername string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ViewAllContainers returns all containers runnable and which can be built
|
||||
func ViewAllContainers() (*DockerContainers, error){
|
||||
// Traverse the folder path as per given in the config file
|
||||
config, err := config.ConfigInit()
|
||||
if err != nil {
|
||||
return nil,err
|
||||
}
|
||||
|
||||
folders, err := ioutil.ReadDir(config.DockerContainers)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
//Declare variable DockerContainers of type struct
|
||||
var Containers *DockerContainers = new(DockerContainers)
|
||||
|
||||
for _, f := range folders {
|
||||
if f.IsDir() {
|
||||
//Declare variable DockerContainer of type struct
|
||||
var Container DockerContainer
|
||||
|
||||
// Setting container name to folder name
|
||||
Container.ContainerName = f.Name()
|
||||
// Getting Description from file description.txt
|
||||
Description, err := ioutil.ReadFile(config.DockerContainers + "/" + Container.ContainerName + "/description.txt")
|
||||
// if we os.Open returns an error then handle it
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Get Description from description.txt
|
||||
Container.ContainerDescription = string(Description)
|
||||
|
||||
Containers.DockerContainer = append(Containers.DockerContainer, Container)
|
||||
}
|
||||
}
|
||||
|
||||
return Containers,nil
|
||||
}
|
||||
|
||||
func print(rd io.Reader) error {
|
||||
var lastLine string
|
||||
|
||||
|
||||
@@ -1,40 +1,17 @@
|
||||
package docker
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestDocker(t *testing.T) {
|
||||
// Testing by providing default container name
|
||||
_,err := BuildRunContainer(2,"false","docker-ubuntu-sshd")
|
||||
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
// Testing if no container name is provided if default is used
|
||||
_,err = BuildRunContainer(2,"false","")
|
||||
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestContainerHorovod(t *testing.T) {
|
||||
// Testing by providing the horovod cpu image
|
||||
_,err := BuildRunContainer(2,"false","cpuhorovod")
|
||||
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestViewAllContainers(t *testing.T) {
|
||||
_,err := ViewAllContainers()
|
||||
//TODO overwrite with custom docker paths
|
||||
resp,err := BuildRunContainer(2,"true")
|
||||
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
fmt.Print(resp.VNCPort)
|
||||
}
|
||||
|
||||
0
server/docker/kill-containers.sh
Normal file → Executable file
0
server/docker/kill-containers.sh
Normal file → Executable file
@@ -19,7 +19,8 @@ type Docker struct {
|
||||
|
||||
// Starts container using RPC calls
|
||||
func (l *Listener) StartContainer( reply *Docker) error {
|
||||
vm, err := docker.BuildRunContainer(3,"false","")
|
||||
fmt.Print("here")
|
||||
vm, err := docker.BuildRunContainer(3,"false")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -43,12 +43,7 @@ func Server() error{
|
||||
r.POST("/IpTable", func(c *gin.Context) {
|
||||
// Getting IPV4 address of client
|
||||
var ClientHost p2p.IpAddress
|
||||
|
||||
if p2p.Ip4or6(c.ClientIP()) == "version 6" {
|
||||
ClientHost.Ipv6 = c.ClientIP()
|
||||
} else {
|
||||
ClientHost.Ipv4 = c.ClientIP()
|
||||
}
|
||||
ClientHost.Ipv4 = c.ClientIP()
|
||||
|
||||
// Variable to store IP table information
|
||||
var IPTable p2p.IpAddresses
|
||||
@@ -82,6 +77,12 @@ func Server() error{
|
||||
c.String(http.StatusOK, fmt.Sprint(err))
|
||||
}
|
||||
|
||||
// Called step to remove duplicate IP addresses
|
||||
err = p2p.RemoveDuplicates()
|
||||
if err != nil {
|
||||
c.String(http.StatusOK, fmt.Sprint(err))
|
||||
}
|
||||
|
||||
// Reads IP addresses from ip table
|
||||
IpAddresses,err := p2p.ReadIpTable()
|
||||
if err != nil {
|
||||
@@ -96,15 +97,14 @@ func Server() error{
|
||||
// Get Number of ports to open and whether to use GPU or not
|
||||
Ports := c.DefaultQuery("ports","0")
|
||||
GPU := c.DefaultQuery("GPU","false")
|
||||
ContainerName := c.DefaultQuery("ContainerName","")
|
||||
var PortsInt int
|
||||
|
||||
// Convert Get Request value to int
|
||||
fmt.Sscanf(Ports, "%d", &PortsInt)
|
||||
|
||||
// Creates container and returns-back result to
|
||||
// Creates container and returns back result to
|
||||
// access container
|
||||
resp, err := docker.BuildRunContainer(PortsInt,GPU,ContainerName)
|
||||
resp, err := docker.BuildRunContainer(PortsInt,GPU)
|
||||
|
||||
if err != nil {
|
||||
c.String(http.StatusInternalServerError, fmt.Sprintf("error: %s", err))
|
||||
@@ -122,14 +122,23 @@ func Server() error{
|
||||
c.String(http.StatusOK, "success")
|
||||
})
|
||||
|
||||
//Show images avaliable
|
||||
r.GET("/ShowImages", func(c *gin.Context) {
|
||||
resp, err := docker.ViewAllContainers()
|
||||
if err != nil {
|
||||
// Future feature
|
||||
/*r.GET("/create_vm/:virtualization", func(c *gin.Context) {
|
||||
virtualization := c.Param("virtualization")
|
||||
// Runs based on Preallocated VM size
|
||||
if virtualization == "docker" {
|
||||
sshinfo,err := docker.RunVM()
|
||||
if err != nil {
|
||||
c.String(http.StatusInternalServerError, fmt.Sprintf("error: %s", err))
|
||||
}
|
||||
if sshinfo != nil {
|
||||
c.JSON(http.StatusOK, sshinfo)
|
||||
}
|
||||
|
||||
} else {
|
||||
c.String(200,"virtualization tool not selected")
|
||||
}
|
||||
c.JSON(http.StatusOK, resp)
|
||||
})
|
||||
})*/
|
||||
|
||||
// Port running on
|
||||
err := r.Run(":8088")
|
||||
|
||||
Reference in New Issue
Block a user