"fmt"
"net"
"regexp"
- "time"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/config"
Help: "Indicates if probe failed due to regex",
})
registry.MustRegister(probeFailedDueToRegex)
- deadline := time.Now().Add(module.Timeout)
+ deadline, _ := ctx.Deadline()
conn, err := dialTCP(ctx, target, module, registry)
if err != nil {
log.Errorf("Error dialing TCP: %v", err)
}
}
if scanner.Err() != nil {
+ log.Errorf("Error reading from connection: %v", scanner.Err().Error())
return false
}
if match == nil {
testCTX, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
registry := prometheus.NewRegistry()
- if !probeTCP(testCTX, ln.Addr().String(), Module{Timeout: time.Second}, registry) {
+ if !probeTCP(testCTX, ln.Addr().String(), Module{}, registry) {
t.Fatalf("TCP module failed, expected success.")
}
<-ch
registry := prometheus.NewRegistry()
testCTX, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
- if probeTCP(testCTX, ":0", Module{Timeout: time.Second}, registry) {
+ if probeTCP(testCTX, ":0", Module{}, registry) {
t.Fatalf("TCP module suceeded, expected failure.")
}
}
defer cancel()
module := Module{
- Timeout: time.Second,
TCP: TCPProbe{
QueryResponse: []QueryResponse{
{Send: "NICK prober"},
testCTX, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
-
+ time.Sleep(time.Millisecond * 100)
module := Module{
- Timeout: time.Second,
TCP: TCPProbe{
QueryResponse: []QueryResponse{
{
// Force IPv4
module := Module{
- Timeout: time.Second,
TCP: TCPProbe{
PreferredIPProtocol: "ip4",
},
// Force IPv6
module = Module{
- Timeout: time.Second,
- TCP: TCPProbe{},
+ TCP: TCPProbe{},
}
registry = prometheus.NewRegistry()
// Prefer IPv4
module = Module{
- Timeout: time.Second,
TCP: TCPProbe{
PreferredIPProtocol: "ip4",
},
// Prefer IPv6
module = Module{
- Timeout: time.Second,
TCP: TCPProbe{
PreferredIPProtocol: "ip6",
},
// Prefer nothing
module = Module{
- Timeout: time.Second,
- TCP: TCPProbe{},
+ TCP: TCPProbe{},
}
registry = prometheus.NewRegistry()
// No protocol
module = Module{
- Timeout: time.Second,
- TCP: TCPProbe{},
+ TCP: TCPProbe{},
}
registry = prometheus.NewRegistry()