in client.go [120:165]
func runClient(testID EthrTestID, title string, clientParam EthrClientParam, server string) {
initClient(title)
hostName, hostIP, port, err := getServerIPandPort(server)
if err != nil {
return
}
ip := net.ParseIP(hostIP)
if ip != nil {
if ip.To4() != nil {
gIPVersion = ethrIPv4
} else {
gIPVersion = ethrIPv6
}
} else {
return
}
if gIsExternalClient {
if testID.Protocol != ICMP && port == "" {
ui.printErr("In external mode, port cannot be empty for TCP tests.")
return
}
} else {
if port != "" {
ui.printErr("In client mode, port (%s) cannot be specified in destination (%s).", port, server)
ui.printMsg("Hint: Use external mode (-x).")
return
}
port = gEthrPortStr
}
ui.printMsg("Using destination: %s, ip: %s, port: %s", hostName, hostIP, port)
test, err := newTest(hostIP, testID, clientParam)
if err != nil {
ui.printErr("Failed to create the new test.")
return
}
test.remoteAddr = server
test.remoteIP = hostIP
test.remotePort = port
if testID.Protocol == ICMP {
test.dialAddr = hostIP
} else {
test.dialAddr = fmt.Sprintf("[%s]:%s", hostIP, port)
}
runTest(test)
}