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.
 
 
 
 
 

29 lines
558 B

package main
import (
"math/rand"
"net"
"strings"
)
func getIPPortFromConn(conn net.Conn) string {
ip := getIPFromConn(conn)
port := getPortFromConn(conn)
return ip + ":" + port
}
func getIPFromConn(conn net.Conn) string {
s := conn.RemoteAddr().String()
s = strings.Split(s, ":")[0]
s = strings.Trim(s, ":")
return s
}
func getPortFromConn(conn net.Conn) string {
s := conn.RemoteAddr().String()
s = strings.Split(s, ":")[1]
s = strings.Trim(s, ":")
return s
}
func randInt(min int, max int) int {
r := rand.Intn(max-min) + min
return r
}