Skip to content

Commit

Permalink
feat(api/v1/registry/container): better random ports generator
Browse files Browse the repository at this point in the history
(cherry picked from commit 1a1bb95)
  • Loading branch information
ivanilves committed Aug 8, 2018
1 parent d3eb4b9 commit 0f27fcc
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions api/v1/registry/container/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package container

import (
"bufio"
"crypto/rand"
crand "crypto/rand"
"fmt"
"io"
"math/rand"
"net/http"
"time"

Expand Down Expand Up @@ -32,11 +33,13 @@ type Container struct {
}

func getRandomPort() int {
rand.Seed(time.Now().UnixNano())

b := make([]byte, 1)

rand.Read(b)
crand.Read(b)

return basePort + int(b[0])
return basePort + int(b[0]) + rand.Intn(200)
}

func getDockerClient() (*dockerclient.DockerClient, error) {
Expand Down

0 comments on commit 0f27fcc

Please sign in to comment.