mirror of https://github.com/statping/statping
enabled IPv6 services
parent
15a6dc0652
commit
98190a23ff
|
@ -122,10 +122,18 @@ func (s *Service) dnsCheck() (float64, error) {
|
|||
return subTime, err
|
||||
}
|
||||
|
||||
func isIPv6(address string) bool {
|
||||
return strings.Count(address, ":") >= 2
|
||||
}
|
||||
|
||||
// checkIcmp will send a ICMP ping packet to the service
|
||||
func (s *Service) checkIcmp(record bool) *Service {
|
||||
p := fastping.NewPinger()
|
||||
ra, err := net.ResolveIPAddr("ip4:icmp", s.Domain)
|
||||
resolveIP := "ip4:icmp"
|
||||
if isIPv6(s.Domain) {
|
||||
resolveIP = "ip6:icmp"
|
||||
}
|
||||
ra, err := net.ResolveIPAddr(resolveIP, s.Domain)
|
||||
if err != nil {
|
||||
recordFailure(s, fmt.Sprintf("Could not send ICMP to service %v, %v", s.Domain, err))
|
||||
return s
|
||||
|
@ -158,17 +166,20 @@ func (s *Service) checkTcp(record bool) *Service {
|
|||
domain := fmt.Sprintf("%v", s.Domain)
|
||||
if s.Port != 0 {
|
||||
domain = fmt.Sprintf("%v:%v", s.Domain, s.Port)
|
||||
if isIPv6(s.Domain) {
|
||||
domain = fmt.Sprintf("[%v]:%v", s.Domain, s.Port)
|
||||
}
|
||||
}
|
||||
conn, err := net.DialTimeout(s.Type, domain, time.Duration(s.Timeout)*time.Second)
|
||||
if err != nil {
|
||||
if record {
|
||||
recordFailure(s, fmt.Sprintf("%v Dial Error %v", s.Type, err))
|
||||
recordFailure(s, fmt.Sprintf("Dial Error %v", err))
|
||||
}
|
||||
return s
|
||||
}
|
||||
if err := conn.Close(); err != nil {
|
||||
if record {
|
||||
recordFailure(s, fmt.Sprintf("TCP Socket Close Error %v", err))
|
||||
recordFailure(s, fmt.Sprintf("%v Socket Close Error %v", strings.ToUpper(s.Type), err))
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@
|
|||
<small class="form-text text-muted">A status code of 200 is success, or view all the <a target="_blank" href="https://www.restapitutorial.com/httpstatuscodes.html">HTTP Status Codes</a></small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row{{if (ne .Type "tcp") and (ne .Type "udp")}} d-none{{end}}">
|
||||
<div class="form-group row{{if (ne .Type "tcp") and (ne .Type "udp") and (ne .Type "icmp")}} d-none{{end}}">
|
||||
<label for="port" class="col-sm-4 col-form-label">TCP Port</label>
|
||||
<div class="col-sm-8">
|
||||
<input type="number" name="port" class="form-control" value="{{if ne .Port 0}}{{.Port}}{{end}}" id="service_port" placeholder="8080">
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by go generate; DO NOT EDIT.
|
||||
// This file was generated by robots at
|
||||
// 2019-06-06 10:46:32.255497 -0700 PDT m=+0.592441879
|
||||
// 2019-06-06 12:04:13.726602 -0700 PDT m=+0.597015740
|
||||
//
|
||||
// This contains the most recently Markdown source for the Statping Wiki.
|
||||
package source
|
||||
|
|
Loading…
Reference in New Issue