Log country

This commit is contained in:
Torjus Håkestad 2021-09-17 09:27:00 +02:00
parent 2b016aecb2
commit a76a95b300
2 changed files with 9 additions and 2 deletions

View File

@ -6,6 +6,7 @@ import (
"net"
"os"
"time"
"unicode/utf8"
gossh "golang.org/x/crypto/ssh"
@ -90,11 +91,17 @@ func (hs *HoneypotServer) passwordHandler(ctx ssh.Context, password string) bool
ConnectionUUID: sessUUID,
}
country := hs.LookupCountry(la.RemoteIP)
if utf8.RuneCountInString(country) > 2 {
hs.Logger.Warnw("Too many characters in country", "country", country, "runecount", utf8.RuneCountInString(country))
country = "??"
}
la.Country = country
hs.Logger.Infow("Login attempt",
"remote_ip", la.RemoteIP.String(),
"username", la.Username,
"password", la.Password)
"password", la.Password,
"country", la.Country)
if err := hs.attemptStore.AddAttempt(&la); err != nil {
hs.Logger.Warnw("Error adding attempt to store", "error", err)

View File

@ -5,7 +5,7 @@ import (
"runtime"
)
var Version = "v0.1.8"
var Version = "v0.1.9"
var Build string
func FullVersion() string {