mirror of
https://github.com/tendermint/tendermint.git
synced 2026-07-31 20:36:13 +00:00
A few notes: - this is not all the deletion that we can do, but this is the most "simple" case: it leaves in shims, and there's some trivial additional cleanup to the transport that can happen but that requires writing more code, and I wanted this to be easy to review above all else. - This should land *after* we cut the branch for 0.35, but I'm anticipating that to happen soon, and I wanted to run this through CI.
33 lines
629 B
Go
33 lines
629 B
Go
package p2p
|
|
|
|
import (
|
|
"fmt"
|
|
mrand "math/rand"
|
|
|
|
tmrand "github.com/tendermint/tendermint/libs/rand"
|
|
"github.com/tendermint/tendermint/types"
|
|
)
|
|
|
|
//------------------------------------------------
|
|
|
|
// nolint:gosec // G404: Use of weak random number generator
|
|
func CreateRoutableAddr() (addr string, netAddr *NetAddress) {
|
|
for {
|
|
var err error
|
|
addr = fmt.Sprintf("%X@%v.%v.%v.%v:26656",
|
|
tmrand.Bytes(20),
|
|
mrand.Int()%256,
|
|
mrand.Int()%256,
|
|
mrand.Int()%256,
|
|
mrand.Int()%256)
|
|
netAddr, err = types.NewNetAddressString(addr)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
if netAddr.Routable() {
|
|
break
|
|
}
|
|
}
|
|
return
|
|
}
|