@foreach (var row in AsciiArtPixelMatrix)
@@ -130,6 +130,9 @@
+
@if (!string.IsNullOrEmpty(statusMessage))
@@ -310,6 +313,7 @@
private bool showDescription = false;
private bool isCheckingAbuse = false;
private bool showJson = true; // Default to showing JSON
+ private bool enableAI = true; // Default to AI enabled
private string formattedJson = string.Empty;
private Albatross.Services.AbuseIPDBApiResponse? abuseIpResult;
@@ -419,6 +423,12 @@
showDescription = !showDescription;
}
+ private void ToggleAI()
+ {
+ enableAI = !enableAI;
+ statusMessage = enableAI ? "AI analysis enabled" : "AI analysis disabled";
+ }
+
private async void ToggleJsonDisplay()
{
showJson = !showJson;
@@ -452,7 +462,7 @@
// Log to browser console for debugging
await JSRuntime.InvokeVoidAsync("console.log", "Checking IP: " + ipAddress);
- abuseIpResult = await AbuseIPDBService.CheckIPAsync(ipAddress, 30, true);
+ abuseIpResult = await AbuseIPDBService.CheckIPAsync(ipAddress, 30, true, enableAI);
// Format the JSON for display
var options = new JsonSerializerOptions { WriteIndented = true };
diff --git a/Services/AbuseIPDBService.cs b/Services/AbuseIPDBService.cs
index bd84e81..efab371 100644
--- a/Services/AbuseIPDBService.cs
+++ b/Services/AbuseIPDBService.cs
@@ -430,8 +430,9 @@ private string GetTimestamp()
///
The IP address to check, optionally with maxAgeInDays delimited by semicolon (e.g., "8.8.8.8;60")
///
Reports older than this many days won't be included (default 30). This is overridden if specified in ipAddress parameter
///
Whether to include detailed report information
+ ///
Whether to enable AI reputation analysis (default true)
///
Complete AbuseIPDB information for the specified IP address
- public async Task
CheckIPAsync(string ipAddress, int maxAgeInDays = 30, bool verbose = true)
+ public async Task CheckIPAsync(string ipAddress, int maxAgeInDays = 30, bool verbose = true, bool enableAI = true)
{
// Parse the input to extract IP address and optionally maxAgeInDays
string actualIpAddress;
@@ -462,11 +463,12 @@ public async Task CheckIPAsync(string ipAddress, int maxAg
try
{
var verboseParam = verbose.ToString().ToLower();
+ var enableAIParam = enableAI.ToString().ToLower();
var timestamp = GetTimestamp();
// Include timestamp as a URI parameter
var requestUrl =
- $"{_cloudflareWorkerUrl}?ipAddress={actualIpAddress}&maxAgeInDays={actualMaxAgeInDays}&verbose={verboseParam}×tamp={timestamp}"
+ $"{_cloudflareWorkerUrl}?ipAddress={actualIpAddress}&maxAgeInDays={actualMaxAgeInDays}&verbose={verboseParam}&enableAI={enableAIParam}×tamp={timestamp}"
.ToLower();
Console.WriteLine($"Requesting: {requestUrl}");
diff --git a/cloudflare-worker.template.js b/cloudflare-worker.template.js
index b05f915..1d3f8d5 100644
--- a/cloudflare-worker.template.js
+++ b/cloudflare-worker.template.js
@@ -399,9 +399,10 @@ async function handleCombinedRequest(request, env) {
const ipAddress = url.searchParams.get('ipaddress'); // lowercase parameter name
const maxAgeInDays = url.searchParams.get('maxageindays') || 30; // lowercase parameter name
const verbose = url.searchParams.get('verbose') === 'true';
+ const enableAI = url.searchParams.get('enableai') === 'true'; // AI toggle parameter
// Debug: Log the parsed parameters
- console.log('Parsed parameters:', { ipAddress, maxAgeInDays, verbose });
+ console.log('Parsed parameters:', { ipAddress, maxAgeInDays, verbose, enableAI });
// Validate required parameters
if (!ipAddress) {
@@ -493,13 +494,23 @@ async function handleCombinedRequest(request, env) {
radarError = `Cloudflare Radar API error: ${status} ${statusText}`;
}
- // Generate AI-based reputation analysis using the collected data
- console.log('Generating AI reputation analysis...');
- const aiReputation = await generateAIReputation(env, ipAddress, abuseIPDBData, radarData);
- console.log('AI reputation analysis result:', {
- success: aiReputation.success,
- error: aiReputation.error
- });
+ // Generate AI-based reputation analysis using the collected data (only if enabled)
+ let aiReputation = null;
+ if (enableAI) {
+ console.log('Generating AI reputation analysis...');
+ aiReputation = await generateAIReputation(env, ipAddress, abuseIPDBData, radarData);
+ console.log('AI reputation analysis result:', {
+ success: aiReputation.success,
+ error: aiReputation.error
+ });
+ } else {
+ console.log('AI reputation analysis disabled by client request');
+ aiReputation = {
+ success: false,
+ error: 'AI analysis disabled',
+ analysis: null
+ };
+ }
// Combine the responses into a single response object
const combinedResponse = {
@@ -526,7 +537,7 @@ async function handleCombinedRequest(request, env) {
sources: {
abuseipdb: abuseIPDBError ? 'error' : 'success',
radar: radarError ? 'error' : 'success',
- ai: aiReputation.success ? 'success' : 'error'
+ ai: enableAI ? (aiReputation.success ? 'success' : 'error') : 'disabled'
}
}
};
diff --git a/wwwroot/index.html b/wwwroot/index.html
index 56e82c7..a407573 100644
--- a/wwwroot/index.html
+++ b/wwwroot/index.html
@@ -4,11 +4,45 @@
- Albatross
+ Albatross - Cloud IP Analysis & Reputation Checker
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+