21 lines
353 B
Go
21 lines
353 B
Go
package scanner
|
|
|
|
import (
|
|
"context"
|
|
"net"
|
|
)
|
|
|
|
func CheckTCPOpen(ctx context.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"
|
|
}
|