Skip to content

Commit

Permalink
Adjust random password generation to match IONOS restrictions
Browse files Browse the repository at this point in the history
  • Loading branch information
NotTheEvilOne committed Nov 17, 2021
1 parent 2b33f4f commit 97f9006
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions pkg/controller/infrastructure/ensurer/dhcp_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
)

// Constant ionosPasswordGeneratedLength is the length of the generated random password
const ionosPasswordGeneratedLength = 32
const ionosPasswordGeneratedLength = 500
// Constant ionosVolumeType is the volume type
const ionosVolumeType = "SSD"

Expand Down Expand Up @@ -60,7 +60,17 @@ func createDHCPServer(ctx context.Context, client *ionossdk.APIClient, datacente
seededRand := rand.New(rand.NewSource(time.Now().Unix()))

for i := 0; i < ionosPasswordGeneratedLength; i++ {
passwordBuilder.WriteString(string(32 + seededRand.Intn(94)))
randomChar := seededRand.Intn(62)

if randomChar > 35 {
randomChar += 13
} else if randomChar > 9 {
randomChar += 7
}

randomChar += 48

passwordBuilder.WriteString(string(randomChar))
}

password = passwordBuilder.String()
Expand Down

0 comments on commit 97f9006

Please sign in to comment.