44import dev .aikido .agent_api .context .Context ;
55import dev .aikido .agent_api .context .ContextObject ;
66import dev .aikido .agent_api .context .RouteMetadata ;
7+ import dev .aikido .agent_api .storage .ServiceConfigStore ;
78import dev .aikido .agent_api .storage .ServiceConfiguration ;
89import dev .aikido .agent_api .storage .statistics .StatisticsStore ;
910
@@ -43,11 +44,11 @@ public static Res report(ContextObject newContext) {
4344 if (endpointAllowlistRes != null )
4445 return endpointAllowlistRes ;
4546
46- Res blockedIpsRes = checkBlockedIps (newContext .getRemoteAddress (), config );
47+ Res blockedIpsRes = checkBlockedIps (newContext .getRemoteAddress ());
4748 if (blockedIpsRes != null )
4849 return blockedIpsRes ;
4950
50- return checkBlockedUserAgents (newContext .getHeader ("user-agent" ), config );
51+ return checkBlockedUserAgents (newContext .getHeader ("user-agent" ));
5152 }
5253
5354 private static Res checkEndpointAllowlist (RouteMetadata routeMetadata , String remoteAddress , ServiceConfiguration config ) {
@@ -60,8 +61,8 @@ private static Res checkEndpointAllowlist(RouteMetadata routeMetadata, String re
6061 return null ; // not blocked
6162 }
6263
63- private static Res checkBlockedIps (String remoteAddress , ServiceConfiguration config ) {
64- ServiceConfiguration .BlockedResult ipBlocked = config .isIpBlocked (remoteAddress );
64+ private static Res checkBlockedIps (String remoteAddress ) {
65+ ServiceConfiguration .BlockedResult ipBlocked = ServiceConfigStore .isIpBlocked (remoteAddress );
6566 if (ipBlocked .blocked ()) {
6667 String msg = "Your IP address is blocked. Reason: " + ipBlocked .description ();
6768 msg += " (Your IP: " + remoteAddress + ")" ;
@@ -70,11 +71,11 @@ private static Res checkBlockedIps(String remoteAddress, ServiceConfiguration co
7071 return null ; // not blocked
7172 }
7273
73- private static Res checkBlockedUserAgents (String userAgent , ServiceConfiguration config ) {
74+ private static Res checkBlockedUserAgents (String userAgent ) {
7475 if (userAgent == null || userAgent .isEmpty ()) {
7576 return null ; // not blocked
7677 }
77- if (config .isBlockedUserAgent (userAgent )) {
78+ if (ServiceConfigStore .isBlockedUserAgent (userAgent )) {
7879 String msg = "You are not allowed to access this resource because you have been identified as a bot." ;
7980 return new Res (msg , 403 );
8081 }
0 commit comments