Browse Source

found alt per ip *.*.*.*

master
gsd 2 years ago
parent
commit
69a5363da8
  1. 32
      src/main/java/app/controllers/admin/DBController.java
  2. 19
      src/main/java/app/services/db/DetectService.java

32
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<String> getAltAccountPerAccount(HttpServletRequest request,
@RequestParam(value = "steam64", required = false, defaultValue = "") String steam64) {
return detectService.getAccountsPerSteamID(SteamIDConverter.getSteamID(steam64)).stream().map(s -> s.community_url).toList();
}
}

19
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<SteamID> 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`")
List<String> founded_steamid = new ArrayList<>();
for (Map.Entry<String, Server> 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(SteamIDConverter::getSteamID).toList();
.getResultStream().map(String::valueOf).toList());
}
return founded_steamid.stream().distinct().map(SteamIDConverter::getSteamID).toList();
}
public List getAttachedDiscordAccountPerSteam(SteamID steamID) {

Loading…
Cancel
Save