Browse Source

blocklist

master
gsd 1 year ago
parent
commit
53e663ec2d
  1. 7
      src/main/java/app/controllers/admin/RconController.java

7
src/main/java/app/controllers/admin/RconController.java

@ -12,11 +12,16 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@RestController @RestController
@RequestMapping("api/admin/rcon") @RequestMapping("api/admin/rcon")
public class RconController { public class RconController {
StatsService statsService; StatsService statsService;
private List<String> blockList = List.of(new String[]{"sm_ban", "ban", "sm_unban", "unban"});
@Autowired @Autowired
public RconController(StatsService statsService) { public RconController(StatsService statsService) {
@ -31,6 +36,8 @@ public class RconController {
public ResponseEntity<String> rcon(HttpServletRequest request, public ResponseEntity<String> rcon(HttpServletRequest request,
@RequestParam String srv, @RequestParam String srv,
@RequestParam String command) { @RequestParam String command) {
if (blockList.contains(Arrays.stream(command.split(" ")).limit(1).findFirst().orElse("")))
return new ResponseEntity<>("banned", HttpStatus.OK);
return new ResponseEntity<>(statsService.rconExecute(srv, command), HttpStatus.OK); return new ResponseEntity<>(statsService.rconExecute(srv, command), HttpStatus.OK);
} }
} }

Loading…
Cancel
Save