Add hashed ip fields in IpIntel + IpLogEntry
This commit is contained in:
parent
e100009f4a
commit
6473ee2bd1
@ -1,5 +1,7 @@
|
||||
package net.frozenorb.apiv3.model;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.hash.Hashing;
|
||||
import com.mongodb.async.SingleResultCallback;
|
||||
import com.mongodb.async.client.MongoCollection;
|
||||
import fr.javatic.mongo.jacksonCodec.Entity;
|
||||
@ -25,6 +27,7 @@ public final class IpIntel {
|
||||
private static final MongoCollection<IpIntel> ipIntelCollection = APIv3.getDatabase().getCollection("ipIntel", IpIntel.class);
|
||||
|
||||
@Getter @Id private String id;
|
||||
@Getter private String hashedIp;
|
||||
@Getter private Instant lastUpdatedAt;
|
||||
@Getter private MaxMindResult result;
|
||||
|
||||
@ -127,6 +130,7 @@ public final class IpIntel {
|
||||
|
||||
private IpIntel(String ip, MaxMindResult result) {
|
||||
this.id = ip;
|
||||
this.hashedIp = Hashing.sha256().hashString(id + APIv3.getConfig().getProperty("ipHashing.salt"), Charsets.UTF_8).toString();
|
||||
this.lastUpdatedAt = Instant.now();
|
||||
this.result = result;
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package net.frozenorb.apiv3.model;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.hash.Hashing;
|
||||
import com.mongodb.async.SingleResultCallback;
|
||||
import com.mongodb.async.client.MongoCollection;
|
||||
import fr.javatic.mongo.jacksonCodec.Entity;
|
||||
@ -26,6 +28,7 @@ public final class IpLogEntry {
|
||||
@Getter @Id private String id;
|
||||
@Getter private UUID user;
|
||||
@Getter private String userIp;
|
||||
@Getter private String hashedUserIp;
|
||||
@Getter private Instant firstSeenAt;
|
||||
@Getter private Instant lastSeenAt;
|
||||
@Getter private int uses;
|
||||
@ -68,6 +71,7 @@ public final class IpLogEntry {
|
||||
this.id = new ObjectId().toString();
|
||||
this.user = user.getId();
|
||||
this.userIp = userIp;
|
||||
this.hashedUserIp = Hashing.sha256().hashString(userIp + APIv3.getConfig().getProperty("ipHashing.salt"), Charsets.UTF_8).toString();
|
||||
this.firstSeenAt = Instant.now();
|
||||
this.lastSeenAt = Instant.now();
|
||||
this.uses = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user