about summary refs log tree commit diff
path: root/ssh.go
diff options
context:
space:
mode:
authorEmile <hanemile@protonmail.com>2020-01-27 20:13:15 +0100
committerEmile <hanemile@protonmail.com>2020-01-27 20:13:15 +0100
commit651f15d9b8bde1b024f97a42e92634afdc1eeda7 (patch)
treec6dfb94751084d720559c04563b35d31ae9f074a /ssh.go
parent7be2a6d747a767d016b976de60ce2bb21d3a5203 (diff)
moved the source into an own folder
Diffstat (limited to 'ssh.go')
-rw-r--r--ssh.go63
1 files changed, 0 insertions, 63 deletions
diff --git a/ssh.go b/ssh.go
deleted file mode 100644
index fbbfc9c..0000000
--- a/ssh.go
+++ /dev/null
@@ -1,63 +0,0 @@
-package main
-
-// Handling incoming SSH connections
-func handlePass(ctx ssh.Context, pass string) bool {
-
-	// increase the counter tracking the amount of passwords catched
-	metrics_num_passwords++
-	log.Printf("%s@%s: '%s'", ctx.User(), ctx.RemoteAddr().String(), pass)
-
-	// get the ip of the remote user
-	stringip := strings.Split(ctx.RemoteAddr().String(), ":")[0]
-
-	// Define the request string for the geoip service
-	requestString := fmt.Sprintf("%s%s", "http://ip-api.com/json/", stringip)
-
-	// Send the GET request
-	resp, err := http.Get(requestString)
-	if err != nil {
-		log.Fatal(err)
-	}
-
-	// if the response status code from the geoip service is not a 200 code, return false
-	if resp.StatusCode != 200 {
-		return false
-	}
-
-	// Read the response
-	body, err := ioutil.ReadAll(resp.Body)
-	if err != nil {
-		log.Fatal(err)
-	}
-
-	// Unmarshal the response to json
-	var result geoipresult
-	err = json.Unmarshal(body, &result)
-	if err != nil {
-		fmt.Println("JSON ERROR, abort mission!")
-		log.Fatal(err)
-	}
-
-	// 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
-	} else {
-		metrics_city_num[result.City] += 1
-	}
-
-	// if the actual city is not known, create the city
-	// this is used for the grafana worldmap plugin
-	if (cities[result.City] == location{}) {
-		newCity := location{
-			key:       strings.ToLower(result.City),
-			latitude:  result.Lat,
-			longitude: result.Lon,
-			name:      result.City,
-		}
-
-		cities[result.City] = newCity
-	}
-
-	return false
-}
\ No newline at end of file