21 lines
355 B
Go
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"
|
|
}
|