diff --git a/cmd/action.go b/cmd/action.go index de03e0e..4de9c9c 100644 --- a/cmd/action.go +++ b/cmd/action.go @@ -38,7 +38,6 @@ var CliAction = func(ctx *cli.Context) error { if CreateVM != "" { var PortsInt int - PortsInt = 0 if Ports != "" { // Convert Get Request value to int diff --git a/cmd/flags.go b/cmd/flags.go index b8abb56..50ec9d9 100644 --- a/cmd/flags.go +++ b/cmd/flags.go @@ -53,7 +53,7 @@ var AppConfigFlags = []cli.Flag{ Name: "Ports", Usage: "Number of ports to open for the Docker Container", EnvVars: []string{"NUM_PORTS"}, - Destination: &ID, + Destination: &Ports, }, &cli.BoolFlag{ Name: "GPU", diff --git a/p2p/50.bin b/p2p/50.bin index 9bbe743..1a20dba 100644 Binary files a/p2p/50.bin and b/p2p/50.bin differ diff --git a/p2p/ip_table.json b/p2p/ip_table.json index 3cdd859..d166993 100644 --- a/p2p/ip_table.json +++ b/p2p/ip_table.json @@ -1,7 +1,10 @@ { "ip_address": [ { - "ipv4": "145.40.90.151" + "ipv4": "145.40.90.151", + "latency": 271458528, + "download": 738.0909641092161, + "upload": 1715.925379038264 } ] } \ No newline at end of file diff --git a/p2p/iptable.go b/p2p/iptable.go index 5f7f5bc..a6ba6e0 100644 --- a/p2p/iptable.go +++ b/p2p/iptable.go @@ -65,7 +65,7 @@ func (i *IpAddresses) WriteIpTable() error { return err } - err = ioutil.WriteFile(config.SpeedTestFile, file, 0644) + err = ioutil.WriteFile(config.IPTable, file, 0644) if err != nil { return err } diff --git a/server/docker/docker.go b/server/docker/docker.go index 3dfd142..b3e347b 100644 --- a/server/docker/docker.go +++ b/server/docker/docker.go @@ -145,52 +145,53 @@ func (d *DockerVM)imageBuild(dockerClient *client.Client) error { func (d *DockerVM)runContainer(dockerClient *client.Client) error{ ctx, _ := context.WithTimeout(context.Background(), time.Second*2000) - //Exposed ports for docker config file - var ExposedPort nat.PortSet - - ExposedPort = nat.PortSet{ - "22/tcp": struct{}{}, - "6901/tcp": struct{}{}, - } - - // Port forwarding for VNC and SSH ports - PortForwarding := nat.PortMap{ - "22/tcp": []nat.PortBinding{ - { - HostIP: "0.0.0.0", - HostPort: fmt.Sprint(d.SSHPort), - }, - }, - "6901/tcp": []nat.PortBinding{ - { - HostIP: "0.0.0.0", - HostPort: fmt.Sprint(d.VNCPort), - }, - }, - } - - for i := range d.Ports { - - Port, err := nat.NewPort("tcp",fmt.Sprint(d.Ports[i])) - if err != nil { - return err - } - - // Exposed Ports - ExposedPort[Port] = struct{}{} - - PortForwarding[Port] = []nat.PortBinding{ - { - HostIP: "0.0.0.0", - HostPort: fmt.Sprint(d.Ports[i]), - }, - } - } // The first mode runs using the Docker Api. As the API supports using // CPU and uses a shell script for GPU call because till this point of // implementation docker api does not support the flag "--gpu all" if d.GPU != "true" { + //Exposed ports for docker config file + var ExposedPort nat.PortSet + + ExposedPort = nat.PortSet{ + "22/tcp": struct{}{}, + "6901/tcp": struct{}{}, + } + + // Port forwarding for VNC and SSH ports + PortForwarding := nat.PortMap{ + "22/tcp": []nat.PortBinding{ + { + HostIP: "0.0.0.0", + HostPort: fmt.Sprint(d.SSHPort), + }, + }, + "6901/tcp": []nat.PortBinding{ + { + HostIP: "0.0.0.0", + HostPort: fmt.Sprint(d.VNCPort), + }, + }, + } + + for i := range d.Ports { + + Port, err := nat.NewPort("tcp",fmt.Sprint(d.Ports[i])) + if err != nil { + return err + } + + // Exposed Ports + ExposedPort[Port] = struct{}{} + + PortForwarding[Port] = []nat.PortBinding{ + { + HostIP: "0.0.0.0", + HostPort: fmt.Sprint(d.Ports[i]), + }, + } + } + config := &container.Config{ Image: d.TagName, Entrypoint: []string{"/dockerstartup/vnc_startup.sh", "/start"},