aggiunta la country

This commit is contained in:
Michele 2017-03-07 17:03:44 +01:00
parent c244dc8922
commit 92c78583ce
3 changed files with 11 additions and 1 deletions

View file

@ -27,6 +27,8 @@ func hash(val []byte) string {
return hex.EncodeToString(h.Sum(nil))
}
// protocol:timestamp:ip:country
func consumer() {
for {
@ -59,6 +61,12 @@ func consumer() {
log.Printf("Date Error: %+v - %s - %s\n", err, prod.user, login)
continue
}
// verifica se esiste la country
if len(sval) <= 3 {
sval = append(sval, "NONE")
}
// genera l' _ID con user + timestamp + ip
mlID := hash([]byte(fmt.Sprintf("%s%s%s", prod.user, time.Unix(date, 0).Format("20060102T15"), sval[2]))) // Format("20060102T150405")
ml := MongoLogin{
@ -68,6 +76,7 @@ func consumer() {
IP: sval[2],
Date: time.Unix(date, 0),
Insert: time.Now(),
Country: sval[3],
}
allLogins[mlID] = ml

1
dbs.go
View file

@ -37,6 +37,7 @@ type MongoLogin struct {
IP string `json:"ip" bson:"ip" gorethink:"ip"`
Date time.Time `json:"date" bson:"date" gorethink:"date"`
Insert time.Time `json:"insert" bson:"insert" gorethink:"insert"`
Country string `json:"country" bson:"country" gorethink:"country"`
}
// Ips structure

View file

@ -12,7 +12,7 @@ import (
)
const (
_Version = "v4.0.4"
_Version = "v4.1.0"
_Producer = 0
_Consumer = 1
_Remover = 2