Skip to content
Permalink
Browse files

Merge branch 'master' into mysql-patch

  • Loading branch information...
hunterlong committed Jun 6, 2019
2 parents bc5edac + 98190a2 commit 043946245ddbd1e3ac672de7b49286bef99dc719
@@ -232,6 +232,7 @@ dev-deps:
$(GOGET) github.com/ararog/timeago
$(GOGET) gopkg.in/natefinch/lumberjack.v2
$(GOGET) golang.org/x/crypto/bcrypt
$(GOGET) github.com/99designs/gqlgen

# remove files for a clean compile/build
clean:
@@ -261,6 +262,7 @@ tag:

generate:
cd source && go generate
cd handlers/graphql && go generate

# compress built binaries into tar.gz and zip formats
compress:
@@ -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
}

Large diffs are not rendered by default.

@@ -88,7 +88,7 @@ func Router() *mux.Router {
r.Handle("/settings/bulk_import", authenticated(bulkImportHandler, true)).Methods("POST")

// SERVICE Routes
r.Handle("/services", http.HandlerFunc(servicesHandler)).Methods("GET")
r.Handle("/services", authenticated(servicesHandler, true)).Methods("GET")
r.Handle("/service/{id}", http.HandlerFunc(servicesViewHandler)).Methods("GET")
r.Handle("/service/{id}/edit", authenticated(servicesViewHandler, true)).Methods("GET")
r.Handle("/service/{id}/delete_failures", authenticated(servicesDeleteFailuresHandler, true)).Methods("GET")
@@ -101,7 +101,7 @@ func Router() *mux.Router {
r.Handle("/api/groups/{id}", readOnly(apiGroupHandler, false)).Methods("GET")
r.Handle("/api/groups/{id}", authenticated(apiGroupUpdateHandler, false)).Methods("POST")
r.Handle("/api/groups/{id}", authenticated(apiGroupDeleteHandler, false)).Methods("DELETE")
r.Handle("/api/groups/reorder", authenticated(apiGroupReorderHandler, false)).Methods("POST")
r.Handle("/api/reorder/groups", authenticated(apiGroupReorderHandler, false)).Methods("POST")

// API Routes
r.Handle("/api", authenticated(apiIndexHandler, false))
@@ -112,7 +112,7 @@ func Router() *mux.Router {
r.Handle("/api/services", readOnly(apiAllServicesHandler, false)).Methods("GET")
r.Handle("/api/services", authenticated(apiCreateServiceHandler, false)).Methods("POST")
r.Handle("/api/services/{id}", readOnly(apiServiceHandler, false)).Methods("GET")
r.Handle("/api/services/reorder", authenticated(reorderServiceHandler, false)).Methods("POST")
r.Handle("/api/reorder/services", authenticated(reorderServiceHandler, false)).Methods("POST")
r.Handle("/api/services/{id}/running", authenticated(apiServiceRunningHandler, false)).Methods("POST")
r.Handle("/api/services/{id}/data", cached("30s", "application/json", http.HandlerFunc(apiServiceDataHandler))).Methods("GET")
r.Handle("/api/services/{id}/ping", cached("30s", "application/json", http.HandlerFunc(apiServicePingDataHandler))).Methods("GET")

0 comments on commit 0439462

Please sign in to comment.
You can’t perform that action at this time.