Skip to content

Commit

Permalink
fix:resolve gosec check problem
Browse files Browse the repository at this point in the history
  • Loading branch information
hongzhen-ma committed Aug 18, 2020
1 parent 4e1ad12 commit 0ea62c1
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions pkg/util/net.go
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
package util

import (
"crypto/rand"
"fmt"
"math"
"math/big"
"math/rand"
"net"
"strings"
"time"

kubeovnv1 "github.com/alauda/kube-ovn/pkg/apis/kubeovn/v1"
"k8s.io/klog"
)

// GenerateMac generates mac address.
func GenerateMac() string {
prefix := "00:00:00"
newRand := rand.New(rand.NewSource(time.Now().UnixNano()))
mac := fmt.Sprintf("%s:%02X:%02X:%02X", prefix, newRand.Intn(255), newRand.Intn(255), newRand.Intn(255))
b := make([]byte, 3)
_, err := rand.Read(b)
if err != nil {
klog.Errorf("generate mac error: %v", err)
}

mac := fmt.Sprintf("%s:%02X:%02X:%02X", prefix, b[0], b[1], b[2])
return mac
}

Expand Down

0 comments on commit 0ea62c1

Please sign in to comment.