Close #18: Support monitoring TCP services

This commit is contained in:
TwinProduction
2020-10-04 19:49:02 -04:00
parent 6a3f65db7f
commit 3ecfe4d322
7 changed files with 155 additions and 27 deletions

View File

@ -2,6 +2,7 @@ package client
import (
"crypto/tls"
"net"
"net/http"
"time"
)
@ -33,3 +34,12 @@ func GetHttpClient(insecure bool) *http.Client {
return secureHttpClient
}
}
func CanCreateConnectionToTcpService(address string) bool {
conn, err := net.DialTimeout("tcp", address, 5*time.Second)
if err != nil {
return false
}
_ = conn.Close()
return true
}

View File

@ -1,6 +1,8 @@
package client
import "testing"
import (
"testing"
)
func TestGetHttpClient(t *testing.T) {
if secureHttpClient != nil {