20 lines
334 B
Go
20 lines
334 B
Go
package scanner
|
|
|
|
import (
|
|
"net"
|
|
)
|
|
|
|
func CheckTCPOpen(ctx Context, host string) (bool, string) {
|
|
// Just check if the connection is successful
|
|
d := net.Dialer{}
|
|
conn, err := d.DialContext(ctx, "tcp", host)
|
|
|
|
if err != nil {
|
|
// If timeout or anything else
|
|
return false, err.Error()
|
|
}
|
|
|
|
defer conn.Close()
|
|
|
|
return true, "OK"
|
|
}
|