diff --git a/docs/DesignVIrtualization b/docs/DesignVIrtualization index 26a2425..2b931e0 100644 --- a/docs/DesignVIrtualization +++ b/docs/DesignVIrtualization @@ -1,11 +1,11 @@ Virtualization Design ====================== -In this Repo the initial choice is to use docker containers and to use it's default parameters when creating -a container. Alphine linux will be the Default OS used because of being light weight. +The virtualization tool will be treated as a separate module. In our implementation +we will use docker as it's easier to configure and set. -Methods to be created -- Build OS Image from DockerFile -- Run Image Built -- Possibility to kill image by server admin or client side user. -- Track stats of the docker container by server admin or client side user. \ No newline at end of file +Methods to be created +- Build OS Image from DockerFile +- Run Image Built +- Possibility to kill image by server admin or client side user. +- Track stats of the docker container by server admin or client side user. diff --git a/go.mod b/go.mod index 9aeb3d7..a41b8fc 100644 --- a/go.mod +++ b/go.mod @@ -25,6 +25,8 @@ require ( github.com/shirou/gopsutil v3.20.12+incompatible github.com/sirupsen/logrus v1.7.0 // indirect 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 google.golang.org/grpc v1.35.0 // indirect ) diff --git a/go.sum b/go.sum index 0187063..10a58a3 100644 --- a/go.sum +++ b/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/yuin/goldmark v1.1.27/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/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= 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/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.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= 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-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= diff --git a/main b/main new file mode 100755 index 0000000..eac34bb Binary files /dev/null and b/main differ diff --git a/p2p/upnp.go b/p2p/upnp.go new file mode 100644 index 0000000..e23ed62 --- /dev/null +++ b/p2p/upnp.go @@ -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) + } +} diff --git a/server/docker/requirements.txt b/server/docker/requirements.txt index cf56a0e..f97f7c1 100644 --- a/server/docker/requirements.txt +++ b/server/docker/requirements.txt @@ -1,3 +1,2 @@ docker click -pymake diff --git a/server/server.go b/server/server.go index eac1cda..45b75ef 100644 --- a/server/server.go +++ b/server/server.go @@ -3,20 +3,20 @@ package server import ( "github.com/gin-gonic/gin" "net/http" - "fmt" + //"fmt" ) func Server() { r := gin.Default() - + // Gets default information of the server r.GET("/server_info", func(c *gin.Context) { 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") - // Runs based on Preallocated VM size + // Runs based on Preallocated VM size if virtualization == "docker" { sshinfo,err := docker.RunVM() if err != nil { @@ -27,10 +27,10 @@ func Server() { } } else { - c.String(200,"virtualization tool not selected") + c.String(200,"virtualization tool not selected") } - }) + })*/ // Port running on r.Run(":8088") -} \ No newline at end of file +}