|
|
|
@ -26,6 +26,7 @@ public class RconController { |
|
|
|
StatsService statsService; |
|
|
|
private List<String> blockList = List.of(new String[]{"sm_ban", "ban", "sm_unban", "unban"}); |
|
|
|
private List<String> allowList = List.of(new String[]{"sm_map", "map"}); |
|
|
|
private final boolean allowAll = true; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
public RconController(StatsService statsService) { |
|
|
|
@ -40,11 +41,13 @@ 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); |
|
|
|
if (!allowAll) { |
|
|
|
if (blockList.contains(Arrays.stream(command.split(" ")).limit(1).findFirst().orElse(""))) |
|
|
|
return new ResponseEntity<>("banned", HttpStatus.OK); |
|
|
|
|
|
|
|
if (!allowList.contains(Arrays.stream(command.split(" ")).limit(1).findFirst().orElse(""))) |
|
|
|
return new ResponseEntity<>("not allowed", HttpStatus.OK); |
|
|
|
if (!allowList.contains(Arrays.stream(command.split(" ")).limit(1).findFirst().orElse(""))) |
|
|
|
return new ResponseEntity<>("not allowed", HttpStatus.OK); |
|
|
|
} |
|
|
|
|
|
|
|
return new ResponseEntity<>(statsService.rconExecute(srv, command), HttpStatus.OK); |
|
|
|
} |
|
|
|
|