18 lines
283 B
Go
18 lines
283 B
Go
package scan
|
|
|
|
import (
|
|
"net"
|
|
"strconv"
|
|
"time"
|
|
)
|
|
|
|
func TCPProbe(ip string, port int, timeout time.Duration) bool {
|
|
addr := net.JoinHostPort(ip, strconv.Itoa(port))
|
|
conn, err := net.DialTimeout("tcp", addr, timeout)
|
|
if err != nil {
|
|
return false
|
|
}
|
|
conn.Close()
|
|
return true
|
|
}
|