]> jfr.im git - irc/rizon/acid.git/commitdiff
Merge branch 'add-spoof-check-on-user' into 'master'
authorKristina <redacted>
Sun, 10 Sep 2017 08:40:09 +0000 (08:40 +0000)
committerKristina <redacted>
Sun, 10 Sep 2017 08:40:09 +0000 (08:40 +0000)
Add a public method to check if a user's IP is spoofed

See merge request !74

acid/src/main/java/net/rizon/acid/core/User.java

index 3303f200290af19d27f8a59086a9505522fc9824..784c293e4c79264e9eba2a30e855b48efbfaa86e 100644 (file)
@@ -49,7 +49,7 @@ public class User implements Comparable<User>
                this.UID = UID;
                this.ip = ip;
                // Check if this IP isn't spoofed.
-               if (!this.ip.equals("255.255.255.255") && !this.ip.equals("0"))
+               if (!isSpoofed())
                {
                        // Cloak IP if IP is visible host, else cloak hostname.
                        this.cloakedIp = Acidictive.cloakGenerator.cloak(this.ip);
@@ -81,6 +81,11 @@ public class User implements Comparable<User>
                this.getServer().incUsers();
        }
 
+       public final boolean isSpoofed()
+       {
+               return this.ip.equals("255.255.255.255") || this.ip.equals("0");
+       }
+
        public void onQuit()
        {
                for (Iterator<Channel> it = chanList.iterator(); it.hasNext();)