mirror of https://github.com/statping/statping
				
				
				
			TLS with TCP
							parent
							
								
									4618d56c18
								
							
						
					
					
						commit
						7630eb3263
					
				| 
						 | 
				
			
			@ -156,7 +156,7 @@
 | 
			
		|||
            </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>
 | 
			
		||||
            <div class="col-8 mt-1">
 | 
			
		||||
                <span @click="service.use_tls = !!service.use_tls" class="switch float-left">
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,6 +2,7 @@ package services
 | 
			
		|||
 | 
			
		||||
import (
 | 
			
		||||
	"bytes"
 | 
			
		||||
	"crypto/tls"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"google.golang.org/grpc"
 | 
			
		||||
	"net"
 | 
			
		||||
| 
						 | 
				
			
			@ -181,7 +182,18 @@ func CheckTcp(s *Service, record bool) *Service {
 | 
			
		|||
			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 record {
 | 
			
		||||
			recordFailure(s, fmt.Sprintf("Dial Error %v", err))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue