mirror of https://github.com/statping/statping
TLS with TCP
parent
4618d56c18
commit
7630eb3263
|
@ -156,7 +156,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-if="service.type.match(/^(http)$/)" class="form-group row">
|
<div v-if="service.type.match(/^(tcp|http)$/)" class="form-group row">
|
||||||
<label class="col-sm-4 col-form-label">Use TLS Certificate</label>
|
<label class="col-sm-4 col-form-label">Use TLS Certificate</label>
|
||||||
<div class="col-8 mt-1">
|
<div class="col-8 mt-1">
|
||||||
<span @click="service.use_tls = !!service.use_tls" class="switch float-left">
|
<span @click="service.use_tls = !!service.use_tls" class="switch float-left">
|
||||||
|
|
|
@ -2,6 +2,7 @@ package services
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"crypto/tls"
|
||||||
"fmt"
|
"fmt"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"net"
|
"net"
|
||||||
|
@ -181,7 +182,18 @@ func CheckTcp(s *Service, record bool) *Service {
|
||||||
domain = fmt.Sprintf("[%v]:%v", s.Domain, s.Port)
|
domain = fmt.Sprintf("[%v]:%v", s.Domain, s.Port)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
conn, err := net.DialTimeout(s.Type, domain, time.Duration(s.Timeout)*time.Second)
|
|
||||||
|
tlsConfig, err := s.LoadTLSCert()
|
||||||
|
if err != nil {
|
||||||
|
log.Errorln(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
dialer := &net.Dialer{
|
||||||
|
KeepAlive: time.Duration(s.Timeout) * time.Second,
|
||||||
|
Timeout: time.Duration(s.Timeout) * time.Second,
|
||||||
|
}
|
||||||
|
|
||||||
|
conn, err := tls.DialWithDialer(dialer, s.Type, domain, tlsConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if record {
|
if record {
|
||||||
recordFailure(s, fmt.Sprintf("Dial Error %v", err))
|
recordFailure(s, fmt.Sprintf("Dial Error %v", err))
|
||||||
|
|
Loading…
Reference in New Issue