Пример #1
0
 private boolean analizeBlockMediaType(
     OutputStream clientOs, Browser b, OperatingSystem os, InetAddress ip) throws IOException {
   if (decoder.getHeader("Content-Type") != null
       && !configurator.isAccepted(
           MediaType.valueOf(decoder.getHeader("Content-Type").replace(" ", "")), b, os, ip)) {
     logger.info("Block analyzer blocked request with code 456. Returning");
     decoder.generateProxyResponse(clientOs, "456");
     return true;
   }
   return false;
 }
Пример #2
0
  private boolean analizeBlockIP(
      OutputStream clientOs, Browser b, OperatingSystem os, InetAddress ip) throws IOException {
    try {
      if (decoder.getHeader("Host") == null) return false;
      URL url = new URL("http://" + decoder.getHeader("Host").replace(" ", ""));
      if (!configurator.isAccepted(InetAddress.getByName(url.getHost()), b, os, ip)) {
        logger.info("Block analyzer blocked request with code 453. Returning");
        decoder.generateProxyResponse(clientOs, "453");

        return true;
      }
    } catch (UnknownHostException e) {
      System.out.println("UNKNOWN HOST: " + e.getMessage());
    }
    return false;
  }
Пример #3
0
 private boolean analizeBlockAll(
     OutputStream clientOs, Browser b, OperatingSystem os, InetAddress ip) throws IOException {
   if (configurator.blockAll(b, os, ip)) {
     logger.info("Block analyzer blocked request with code 452. Returning");
     decoder.generateProxyResponse(clientOs, "452");
     return true;
   }
   return false;
 }
Пример #4
0
  private boolean analizeBlockSize(
      OutputStream clientOs, Browser b, OperatingSystem os, InetAddress ip) throws IOException {
    if (decoder.getHeader("Content-Length") == null) {
      return false;
    }
    Integer length = -1;
    try {
      length = Integer.parseInt(decoder.getHeader("Content-Length").replace(" ", ""));
    } catch (NumberFormatException e) {
      System.out.println("Content-Length inv‡lido");
      return true;
    }
    if (configurator.getMaxSize(b, os, ip) != -1 && length > configurator.getMaxSize(b, os, ip)) {
      logger.info("Block analyzer blocked request with code 451. Returning");
      decoder.generateProxyResponse(clientOs, "451");

      return true;
    }
    return false;
  }
Пример #5
0
  public boolean analyzeChunkedSize(
      Decoder decoder,
      OutputStream clientOs,
      int totalSize,
      Browser b,
      OperatingSystem os,
      InetAddress ip)
      throws IOException {
    if (decoder.getHeader("Transfer-Encoding") == null) {
      return false;
    }
    int max = configurator.getMaxSize(b, os, ip);
    if (max == -1) return false;
    if (totalSize > max) {
      logger.info("Block analyzer blocked request with code 451. Returning");
      decoder.generateProxyResponse(clientOs, "451");

      return true;
    }
    return false;
  }