diff --git a/exception.go b/exception.go index a6cfe04..0960868 100644 --- a/exception.go +++ b/exception.go @@ -16,7 +16,7 @@ import ( var activeTree *iptree.IPTree var treeLock sync.Mutex -var isExceptionUpdate bool = false +var isExceptionUpdate = false type awsIPRanges struct { Prefixes []struct { diff --git a/http.go b/http.go index 805cdb2..cf1974e 100644 --- a/http.go +++ b/http.go @@ -98,14 +98,14 @@ func newRouter() *mux.Router { // To maintain compatibility with previous API versions, wrap legacy API // calls to add the type field and route to the correct handler r.HandleFunc("/{value:(?:[0-9]{1,3}\\.){3}[0-9]{1,3}}", - auth(wrapLegacyIpRequest(httpGetReputation))).Methods("GET") + auth(wrapLegacyIPRequest(httpGetReputation))).Methods("GET") r.HandleFunc("/{value:(?:[0-9]{1,3}\\.){3}[0-9]{1,3}}", - auth(wrapLegacyIpRequest(httpPutReputation))).Methods("PUT") + auth(wrapLegacyIPRequest(httpPutReputation))).Methods("PUT") r.HandleFunc("/{value:(?:[0-9]{1,3}\\.){3}[0-9]{1,3}}", - auth(wrapLegacyIpRequest(httpDeleteReputation))).Methods("DELETE") + auth(wrapLegacyIPRequest(httpDeleteReputation))).Methods("DELETE") r.HandleFunc("/violations/{value:(?:[0-9]{1,3}\\.){3}[0-9]{1,3}}", - auth(wrapLegacyIpRequest(httpPutViolation))).Methods("PUT") - r.HandleFunc("/violations", auth(wrapLegacyIpRequest(httpPutViolations))).Methods("PUT") + auth(wrapLegacyIPRequest(httpPutViolation))).Methods("PUT") + r.HandleFunc("/violations", auth(wrapLegacyIPRequest(httpPutViolations))).Methods("PUT") r.HandleFunc("/violations", auth(httpGetViolations)).Methods("GET") r.HandleFunc("/dump", auth(httpGetAllReputation)).Methods("GET") @@ -122,7 +122,7 @@ func startAPI() error { return http.ListenAndServe(sruntime.cfg.Listen, mwHandler(newRouter())) } -func wrapLegacyIpRequest(rf func(http.ResponseWriter, *http.Request)) func(http.ResponseWriter, *http.Request) { +func wrapLegacyIPRequest(rf func(http.ResponseWriter, *http.Request)) func(http.ResponseWriter, *http.Request) { return func(w http.ResponseWriter, r *http.Request) { m := mux.Vars(r) m["type"] = "ip" diff --git a/http_test.go b/http_test.go index b6dfcff..511c049 100644 --- a/http_test.go +++ b/http_test.go @@ -198,25 +198,25 @@ func TestHandlers(t *testing.T) { c := 0 for _, rep := range reputations { if rep.Object == "192.168.2.20" { - c += 1 + c++ assert.Equal(t, "192.168.2.20", rep.Object) assert.Equal(t, "ip", rep.Type) assert.Equal(t, 25, rep.Reputation) } if rep.Object == "192.168.0.1" { - c += 1 + c++ assert.Equal(t, "192.168.0.1", rep.Object) assert.Equal(t, "ip", rep.Type) assert.Equal(t, 50, rep.Reputation) } if rep.Object == "riker@mozilla.com" { - c += 1 + c++ assert.Equal(t, "riker@mozilla.com", rep.Object) assert.Equal(t, "email", rep.Type) assert.Equal(t, 50, rep.Reputation) } if rep.IP == "254.254.254.254" { - c += 1 + c++ assert.Equal(t, "254.254.254.254", rep.IP) assert.Equal(t, "", rep.Object) assert.Equal(t, "", rep.Type) diff --git a/validators.go b/validators.go index 9e41cd9..bc20083 100644 --- a/validators.go +++ b/validators.go @@ -7,11 +7,11 @@ import ( ) var validators = map[string]func(string) error{ - "ip": validateTypeIp, + "ip": validateTypeIP, "email": validateTypeEmail, } -func validateTypeIp(val string) error { +func validateTypeIP(val string) error { if net.ParseIP(val) == nil { return fmt.Errorf("invalid ip format %v", val) }