You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
629 B

  1. package p2p
  2. import (
  3. "fmt"
  4. mrand "math/rand"
  5. tmrand "github.com/tendermint/tendermint/libs/rand"
  6. "github.com/tendermint/tendermint/types"
  7. )
  8. //------------------------------------------------
  9. // nolint:gosec // G404: Use of weak random number generator
  10. func CreateRoutableAddr() (addr string, netAddr *NetAddress) {
  11. for {
  12. var err error
  13. addr = fmt.Sprintf("%X@%v.%v.%v.%v:26656",
  14. tmrand.Bytes(20),
  15. mrand.Int()%256,
  16. mrand.Int()%256,
  17. mrand.Int()%256,
  18. mrand.Int()%256)
  19. netAddr, err = types.NewNetAddressString(addr)
  20. if err != nil {
  21. panic(err)
  22. }
  23. if netAddr.Routable() {
  24. break
  25. }
  26. }
  27. return
  28. }