diff --git a/src/main/java/net/frozenorb/apiv3/model/IpIntel.java b/src/main/java/net/frozenorb/apiv3/model/IpIntel.java index 66ba856..e3d3f37 100644 --- a/src/main/java/net/frozenorb/apiv3/model/IpIntel.java +++ b/src/main/java/net/frozenorb/apiv3/model/IpIntel.java @@ -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 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; } diff --git a/src/main/java/net/frozenorb/apiv3/model/IpLogEntry.java b/src/main/java/net/frozenorb/apiv3/model/IpLogEntry.java index a9d60d5..8ec23cd 100644 --- a/src/main/java/net/frozenorb/apiv3/model/IpLogEntry.java +++ b/src/main/java/net/frozenorb/apiv3/model/IpLogEntry.java @@ -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;