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.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@RestController
@RequestMapping("api/admin/rcon")
public class RconController {
StatsService statsService;
private List<String> blockList = List.of(new String[]{"sm_ban", "ban", "sm_unban", "unban"});
@Autowired
public RconController(StatsService statsService) {
@ -31,6 +36,8 @@ public class RconController {
public ResponseEntity<String> rcon(HttpServletRequest request,
@RequestParam String srv,
@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);
}
}

Loading…
Cancel
Save