From 69a5363da875a21fc86ee802e56abf081ac30454 Mon Sep 17 00:00:00 2001 From: gsd Date: Tue, 26 Sep 2023 19:51:12 +0300 Subject: [PATCH] found alt per ip *.*.*.* --- .../app/controllers/admin/DBController.java | 32 +++++++++++++++++++ .../java/app/services/db/DetectService.java | 21 ++++++++++-- 2 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 src/main/java/app/controllers/admin/DBController.java diff --git a/src/main/java/app/controllers/admin/DBController.java b/src/main/java/app/controllers/admin/DBController.java new file mode 100644 index 0000000..8ad918d --- /dev/null +++ b/src/main/java/app/controllers/admin/DBController.java @@ -0,0 +1,32 @@ +package app.controllers.admin; + +import app.annotations.enums.AuthMethod; +import app.annotations.interfaces.CheckPermitionFlag; +import app.annotations.interfaces.CheckWebAccess; +import app.services.db.DetectService; +import app.utils.SteamIDConverter; +import jakarta.servlet.http.HttpServletRequest; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +@RestController +@RequestMapping(value = "api/admin/db") +public class DBController { + + DetectService detectService; + + @Autowired + public DBController(DetectService detectService) { + this.detectService = detectService; + } + + @GetMapping(value = "/alt") + @CheckWebAccess + @CheckPermitionFlag(flag = "d") + public List getAltAccountPerAccount(HttpServletRequest request, + @RequestParam(value = "steam64", required = false, defaultValue = "") String steam64) { + return detectService.getAccountsPerSteamID(SteamIDConverter.getSteamID(steam64)).stream().map(s -> s.community_url).toList(); + } +} diff --git a/src/main/java/app/services/db/DetectService.java b/src/main/java/app/services/db/DetectService.java index 29cb460..269ba95 100644 --- a/src/main/java/app/services/db/DetectService.java +++ b/src/main/java/app/services/db/DetectService.java @@ -1,11 +1,15 @@ package app.services.db; +import app.entities.Stats; import app.entities.other.SteamID; +import app.entities.server.Server; import app.utils.SteamIDConverter; import jakarta.persistence.EntityManager; import jakarta.persistence.PersistenceContext; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; @@ -16,10 +20,21 @@ public class DetectService { @PersistenceContext EntityManager entityManager; + private Stats stats; + + @Autowired + public DetectService(Stats stats) { + this.stats = stats; + } + public List getAccountsPerSteamID(SteamID steamID) { - return entityManager.createNativeQuery("select `steam_id` FROM all_users_con_2 WHERE `connect_ip` in (SELECT `connect_ip` FROM `all_users_con_2` WHERE `steam_id` LIKE ?1) GROUP BY `steam_id`") - .setParameter(1, steamID.steam2) - .getResultStream().map(SteamIDConverter::getSteamID).toList(); + List founded_steamid = new ArrayList<>(); + for (Map.Entry stringServerEntry : stats.getServers().entrySet()) { + founded_steamid.addAll(entityManager.createNativeQuery("SELECT * FROM "+stringServerEntry.getValue().getDb()+"."+"`user_connections` WHERE `connect_ip` in (SELECT `connect_ip` FROM " + stringServerEntry.getValue().getDb() + "." +" `user_connections` WHERE `steam_id` LIKE ?1) GROUP BY `steam_id`") + .setParameter(1, steamID.steam2) + .getResultStream().map(String::valueOf).toList()); + } + return founded_steamid.stream().distinct().map(SteamIDConverter::getSteamID).toList(); } public List getAttachedDiscordAccountPerSteam(SteamID steamID) {