MCPcopy Create free account
hub / github.com/boringproxy/boringproxy / genRandomCode

Function genRandomCode

utils.go:59–69  ·  view source on GitHub ↗
(length int)

Source from the content-addressed store, hash-verified

57const chars string = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
58
59func genRandomCode(length int) (string, error) {
60 id := ""
61 for i := 0; i < length; i++ {
62 randIndex, err := rand.Int(rand.Reader, big.NewInt(int64(len(chars))))
63 if err != nil {
64 return "", err
65 }
66 id += string(chars[randIndex.Int64()])
67 }
68 return id, nil
69}
70
71func randomOpenPort() (int, error) {
72 listener, err := net.Listen("tcp", "127.0.0.1:0")

Callers 2

AddTokenMethod · 0.85
handleCreateTunnelMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected