udp_raw.go 316 B

12345678910111213141516
  1. package udp
  2. import mathrand "math/rand"
  3. type SendPortGetter interface {
  4. // UDPSendPort returns the port to use
  5. UDPSendPort(maxPort int) uint16
  6. }
  7. type randomSendPort struct{}
  8. func (randomSendPort) UDPSendPort(maxPort int) uint16 {
  9. return uint16(mathrand.Intn(maxPort))
  10. }
  11. var RandomSendPort = randomSendPort{}