status/scanner/tcp.go
2023-09-30 16:56:37 +00:00

21 lines
355 B
Go

package scanner
import (
"net"
"time"
)
func CheckTCPOpen(host string) (bool, string) {
// Just check if the connection is successful
timeout := time.Second
conn, err := net.DialTimeout("tcp", host, timeout)
if err != nil || conn == nil {
// If timeout or anything else
return false, err.Error()
}
defer conn.Close()
return true, "OK"
}