From 932efbc49ad77594610616c56099c1da703a952d Mon Sep 17 00:00:00 2001 From: Emile Date: Mon, 27 Jan 2020 20:49:30 +0100 Subject: snake_case → camelCase MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/http.go | 4 ++-- src/main.go | 8 ++++---- src/ssh.go | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/http.go b/src/http.go index 86ad3d1..47f0d75 100644 --- a/src/http.go +++ b/src/http.go @@ -49,10 +49,10 @@ func indexHandler(w http.ResponseWriter, req *http.Request) { func metricsHandler(w http.ResponseWriter, req *http.Request) { // return the overall amount of passwords catched - fmt.Fprintf(w, "num_passwords %d\n", metrics_num_passwords) + fmt.Fprintf(w, "num_passwords %d\n", metricsNumPasswords) // return the amount of passwords catched from a given city - for k, v := range metrics_city_num { + for k, v := range metricsCityNum { fmt.Fprintf(w, "a_metric{city=\"%s\"} %d\n", strings.ToLower(k), v) } } diff --git a/src/main.go b/src/main.go index 39ddadb..a95834a 100644 --- a/src/main.go +++ b/src/main.go @@ -10,14 +10,14 @@ import ( ) var ( - metrics_num_passwords int - metrics_city_num map[string]int - cities map[string]location + metricsNumPasswords int + metricsCityNum map[string]int + cities map[string]location ) func main() { // create a map mapping a city to an amount of hits - metrics_city_num = make(map[string]int) + metricsCityNum = make(map[string]int) // create a cities map mapping a city to a location cities = make(map[string]location) diff --git a/src/ssh.go b/src/ssh.go index 71dc12a..3eb426b 100644 --- a/src/ssh.go +++ b/src/ssh.go @@ -15,7 +15,7 @@ import ( func handlePass(ctx ssh.Context, pass string) bool { // increase the counter tracking the amount of passwords catched - metrics_num_passwords++ + metricsNumPasswords++ log.Printf("%s@%s: '%s'", ctx.User(), ctx.RemoteAddr().String(), pass) // get the ip of the remote user @@ -51,10 +51,10 @@ func handlePass(ctx ssh.Context, pass string) bool { // if an entry for the city does not exists yet, create the city // if the city does allready exist, increase it's value by one - if metrics_city_num[result.City] == 0 { - metrics_city_num[result.City] = 1 + if metricsCityNum[result.City] == 0 { + metricsCityNum[result.City] = 1 } else { - metrics_city_num[result.City] += 1 + metricsCityNum[result.City] += 1 } // if the actual city is not known, create the city -- cgit 1.4.1