|
|
|
|
@ -8,15 +8,16 @@ import (
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func PortDial(address, port, protocol string, timeout int) {
|
|
|
|
|
red := color.New(color.FgRed).SprintFunc()
|
|
|
|
|
green := color.New(color.FgGreen).SprintFunc()
|
|
|
|
|
ip := digIp(address)
|
|
|
|
|
if ip == "" {
|
|
|
|
|
fmt.Printf("%v ping: %v: Name or service not known\n", protocol, address)
|
|
|
|
|
fmt.Printf("%v ping: %v: Name or service not known\n", protocol, red(address))
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
fmt.Printf("%v ping %v (%v) via port %v (timeout: %vs)...\n", protocol, address, ip, port, timeout)
|
|
|
|
|
dialTarget := ip + ":" + port
|
|
|
|
|
red := color.New(color.FgRed).SprintFunc()
|
|
|
|
|
green := color.New(color.FgGreen).SprintFunc()
|
|
|
|
|
|
|
|
|
|
for {
|
|
|
|
|
startTime := time.Now()
|
|
|
|
|
conn, err := net.DialTimeout(protocol, dialTarget, time.Duration(timeout)*time.Second)
|
|
|
|
|
|