added p2p module code base code
This commit is contained in:
@@ -1,11 +1,11 @@
|
|||||||
Virtualization Design
|
Virtualization Design
|
||||||
======================
|
======================
|
||||||
|
|
||||||
In this Repo the initial choice is to use docker containers and to use it's default parameters when creating
|
The virtualization tool will be treated as a separate module. In our implementation
|
||||||
a container. Alphine linux will be the Default OS used because of being light weight.
|
we will use docker as it's easier to configure and set.
|
||||||
|
|
||||||
Methods to be created
|
Methods to be created
|
||||||
- Build OS Image from DockerFile
|
- Build OS Image from DockerFile
|
||||||
- Run Image Built
|
- Run Image Built
|
||||||
- Possibility to kill image by server admin or client side user.
|
- Possibility to kill image by server admin or client side user.
|
||||||
- Track stats of the docker container by server admin or client side user.
|
- Track stats of the docker container by server admin or client side user.
|
||||||
|
|||||||
2
go.mod
2
go.mod
@@ -25,6 +25,8 @@ require (
|
|||||||
github.com/shirou/gopsutil v3.20.12+incompatible
|
github.com/shirou/gopsutil v3.20.12+incompatible
|
||||||
github.com/sirupsen/logrus v1.7.0 // indirect
|
github.com/sirupsen/logrus v1.7.0 // indirect
|
||||||
github.com/urfave/cli/v2 v2.3.0
|
github.com/urfave/cli/v2 v2.3.0
|
||||||
|
gitlab.com/NebulousLabs/fastrand v0.0.0-20181126182046-603482d69e40 // indirect
|
||||||
|
gitlab.com/NebulousLabs/go-upnp v0.0.0-20181011194642-3a71999ed0d3
|
||||||
golang.org/x/net v0.0.0-20210119194325-5f4716e94777 // indirect
|
golang.org/x/net v0.0.0-20210119194325-5f4716e94777 // indirect
|
||||||
google.golang.org/grpc v1.35.0 // indirect
|
google.golang.org/grpc v1.35.0 // indirect
|
||||||
)
|
)
|
||||||
|
|||||||
5
go.sum
5
go.sum
@@ -188,6 +188,10 @@ github.com/urfave/cli/v2 v2.3.0 h1:qph92Y649prgesehzOrQjdWyxFOp/QVM+6imKHad91M=
|
|||||||
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
|
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
|
||||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
|
gitlab.com/NebulousLabs/fastrand v0.0.0-20181126182046-603482d69e40 h1:dizWJqTWjwyD8KGcMOwgrkqu1JIkofYgKkmDeNE7oAs=
|
||||||
|
gitlab.com/NebulousLabs/fastrand v0.0.0-20181126182046-603482d69e40/go.mod h1:rOnSnoRyxMI3fe/7KIbVcsHRGxe30OONv8dEgo+vCfA=
|
||||||
|
gitlab.com/NebulousLabs/go-upnp v0.0.0-20181011194642-3a71999ed0d3 h1:qXqiXDgeQxspR3reot1pWme00CX1pXbxesdzND+EjbU=
|
||||||
|
gitlab.com/NebulousLabs/go-upnp v0.0.0-20181011194642-3a71999ed0d3/go.mod h1:sleOmkovWsDEQVYXmOJhx69qheoMTmCuPYyiCFCihlg=
|
||||||
go.opencensus.io v0.22.0 h1:C9hSCOW830chIVkdja34wa6Ky+IzWllkUinR+BtRZd4=
|
go.opencensus.io v0.22.0 h1:C9hSCOW830chIVkdja34wa6Ky+IzWllkUinR+BtRZd4=
|
||||||
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
|
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
@@ -247,6 +251,7 @@ golang.org/x/term v0.0.0-20201113234701-d7a72108b828/go.mod h1:Nr5EML6q2oocZ2LXR
|
|||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/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.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.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
|
|||||||
43
p2p/upnp.go
Normal file
43
p2p/upnp.go
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"log"
|
||||||
|
"gitlab.com/NebulousLabs/go-upnp"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
// connect to router
|
||||||
|
d, err := upnp.Discover()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// discover external IP
|
||||||
|
ip, err := d.ExternalIP()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
fmt.Println("Your external IP is:", ip)
|
||||||
|
|
||||||
|
// forward a port
|
||||||
|
/* err = d.Forward(63390, "upnp test")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
} */
|
||||||
|
|
||||||
|
// un-forward a port
|
||||||
|
err = d.Clear(63390)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// record router's location
|
||||||
|
loc := d.Location()
|
||||||
|
|
||||||
|
// connect to router directly
|
||||||
|
d, err = upnp.Load(loc)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,3 +1,2 @@
|
|||||||
docker
|
docker
|
||||||
click
|
click
|
||||||
pymake
|
|
||||||
|
|||||||
@@ -3,20 +3,20 @@ package server
|
|||||||
import (
|
import (
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"net/http"
|
"net/http"
|
||||||
"fmt"
|
//"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Server() {
|
func Server() {
|
||||||
r := gin.Default()
|
r := gin.Default()
|
||||||
|
|
||||||
// Gets default information of the server
|
// Gets default information of the server
|
||||||
r.GET("/server_info", func(c *gin.Context) {
|
r.GET("/server_info", func(c *gin.Context) {
|
||||||
c.JSON(http.StatusOK, ServerInfo())
|
c.JSON(http.StatusOK, ServerInfo())
|
||||||
})
|
})
|
||||||
|
|
||||||
r.GET("/create_vm/:virtualization", func(c *gin.Context) {
|
/*r.GET("/create_vm/:virtualization", func(c *gin.Context) {
|
||||||
virtualization := c.Param("virtualization")
|
virtualization := c.Param("virtualization")
|
||||||
// Runs based on Preallocated VM size
|
// Runs based on Preallocated VM size
|
||||||
if virtualization == "docker" {
|
if virtualization == "docker" {
|
||||||
sshinfo,err := docker.RunVM()
|
sshinfo,err := docker.RunVM()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -27,10 +27,10 @@ func Server() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
c.String(200,"virtualization tool not selected")
|
c.String(200,"virtualization tool not selected")
|
||||||
}
|
}
|
||||||
})
|
})*/
|
||||||
|
|
||||||
// Port running on
|
// Port running on
|
||||||
r.Run(":8088")
|
r.Run(":8088")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user