add timeout to tcp checker

Signed-off-by: Christian Richter <crichter@owncloud.com>
This commit is contained in:
Christian Richter committed 2024-10-14 08:39:42 +02:00
1 parent 941e688ae6
commit 6064386787
1 file changed
+2 -1
+2 -1
View File
@@ -3,12 +3,13 @@ package handlers
import (
"context"
"net"
"time"
)
// NewTCPCheck returns a check that connects to a given tcp endpoint.
func NewTCPCheck(address string) func(ctx context.Context) error {
return func(_ context.Context) error {
conn, err := net.Dial("tcp", address)
conn, err := net.DialTimeout("tcp", address, 3*time.Second)
if err != nil {
return err
}