Browse Source

cc 2

master
gsd 1 week ago
parent
commit
dae0f3a5e8
  1. 6
      src/main/java/app/annotations/impl/WaitAfterNextAspect.java
  2. 6
      src/main/java/app/annotations/impl/WebAccessAspect.java
  3. 5
      src/main/java/app/services/db/web/CollectStatisticService.java
  4. 2
      src/main/java/app/services/io/readers/GeoIPCity.java
  5. 2
      src/main/java/app/services/io/readers/GeoIPCountry.java

6
src/main/java/app/annotations/impl/WaitAfterNextAspect.java

@ -33,10 +33,10 @@ public class WaitAfterNextAspect {
final String hash = new StringBuilder().append(getSteam64fromCookie(request)).append(getIp(request)).append(order).toString(); final String hash = new StringBuilder().append(getSteam64fromCookie(request)).append(getIp(request)).append(order).toString();
if (hash.isEmpty()) return; if (hash.isEmpty()) return;
if (wait_order.contains(hash)) { if (wait_order.contains(hash)) {
logger.error(hash); logger.error("ratelimit throws on " + hash);
throw new WaitRateLimit(); throw new WaitRateLimit();
} }
logger.info(hash); //logger.info(hash);
wait_order.add(hash); wait_order.add(hash);
} }
@ -46,7 +46,7 @@ public class WaitAfterNextAspect {
final String hash = new StringBuilder().append(getSteam64fromCookie(request)).append(getIp(request)).append(order).toString(); final String hash = new StringBuilder().append(getSteam64fromCookie(request)).append(getIp(request)).append(order).toString();
if (hash.isEmpty()) return; if (hash.isEmpty()) return;
if (wait_order.contains(hash)) { if (wait_order.contains(hash)) {
logger.warn(hash); //logger.warn(hash);
wait_order.remove(hash); wait_order.remove(hash);
} }
} }

6
src/main/java/app/annotations/impl/WebAccessAspect.java

@ -114,7 +114,11 @@ public class WebAccessAspect {
} }
if(request.getHeader("Cookie") == null) { if(request.getHeader("Cookie") == null) {
logger.warn("[{}] Request not contain cookies but need his: {}?{}", request.getHeader("X-Forwarded-For"), request.getRequestURI(), request.getQueryString()); if ("/api/profile/current".equals(request.getRequestURI()) && "requests=pohuy&steam64=null".equals(request.getQueryString())) {
//ignore logging
} else
logger.warn("[{}] Request not contain cookies but need his: {}?{}", request.getHeader("X-Forwarded-For"), request.getRequestURI(), request.getQueryString());
throw new NeedCookie(); throw new NeedCookie();
} }
String[] rawCookieParams = request.getHeader("Cookie").split(";"); String[] rawCookieParams = request.getHeader("Cookie").split(";");

5
src/main/java/app/services/db/web/CollectStatisticService.java

@ -42,9 +42,10 @@ public class CollectStatisticService extends BaseUpdater {
} }
} }
try { try {
if (!collectableStatistic.isStatsRequests()) if (collectableStatistic.isStatsRequests())
logger.info(collectableStatistic.toString()); return null;
logger.info(collectableStatistic.toString());
jdbcTemplate.update("INSERT INTO web_statistic (steam64, client_ip, method, path, query, useragent) VALUES (?, ?, ?, ?, ?, ?)", jdbcTemplate.update("INSERT INTO web_statistic (steam64, client_ip, method, path, query, useragent) VALUES (?, ?, ?, ?, ?, ?)",
collectableStatistic.getSteam64(), collectableStatistic.getClient_ip(), collectableStatistic.getSteam64(), collectableStatistic.getClient_ip(),
collectableStatistic.getMethod(), collectableStatistic.getPath(), collectableStatistic.getMethod(), collectableStatistic.getPath(),

2
src/main/java/app/services/io/readers/GeoIPCity.java

@ -29,7 +29,7 @@ public class GeoIPCity extends BaseReader {
if (ip == null || ip.isEmpty() || ip.startsWith("10.") || ip.startsWith("127.") || ip.startsWith("192.168")) return "Unknown"; if (ip == null || ip.isEmpty() || ip.startsWith("10.") || ip.startsWith("127.") || ip.startsWith("192.168")) return "Unknown";
return databaseReader.city(InetAddress.getByName(ip)).getCity().getName(); return databaseReader.city(InetAddress.getByName(ip)).getCity().getName();
} catch (Exception e) { } catch (Exception e) {
logger.error("[IGNORING] Cannot fetch city of ip", e); logger.error("[IGNORING] Cannot fetch city of ip: " + ip, e);
return "Unknown"; return "Unknown";
} }
} }

2
src/main/java/app/services/io/readers/GeoIPCountry.java

@ -29,7 +29,7 @@ public class GeoIPCountry extends BaseReader {
if (ip == null || ip.isEmpty() || ip.startsWith("10.") || ip.startsWith("127.") || ip.startsWith("192.168")) return "Unknown"; if (ip == null || ip.isEmpty() || ip.startsWith("10.") || ip.startsWith("127.") || ip.startsWith("192.168")) return "Unknown";
return databaseReader.country(InetAddress.getByName(ip)).getCountry().getName(); return databaseReader.country(InetAddress.getByName(ip)).getCountry().getName();
} catch (Exception e) { } catch (Exception e) {
logger.error("[IGNORING] Cannot fetch country of ip"); logger.error("[IGNORING] Cannot fetch country of ip: " + ip);
return "Unknown"; return "Unknown";
} }
} }

Loading…
Cancel
Save