Skip to content

Commit

Permalink
feat(LoginPlayerHelper): 修改IP地址判断逻辑以提高准确性
Browse files Browse the repository at this point in the history
  • Loading branch information
shulng committed Sep 6, 2024
1 parent 149834d commit d92660f
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package cc.baka9.catseedlogin.bukkit.object;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
Expand Down Expand Up @@ -102,9 +104,14 @@ public static boolean recordCurrentIP(Player player) {
List<String> storedIPs = getStoredIPs(storedPlayer);
Long exitTime = playerExitTimes.get(playerName);

if (currentIP.equals("127.0.0.1")) {
return false;
}
try {
InetAddress localHost = InetAddress.getByName("localhost");
if (InetAddress.getByName(currentIP).equals(localHost)) {
return false;
}
} catch (UnknownHostException e) {
return false;
}

if (Config.Settings.IPTimeout == 0) {
return storedIPs.contains(currentIP);
Expand Down

0 comments on commit d92660f

Please sign in to comment.