status/scanner/tcp.go
2023-10-03 10:56:35 +00:00

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"
}