@@ -64,6 +64,8 @@ public static async Task<bool> ClientOnBlackListAsync(string remoteIp)
64
64
if ( response . IsSuccessful )
65
65
{
66
66
var ipdb = JsonConvert . DeserializeObject < Ipdb > ( response . Content ! ) ;
67
+ var isPublic = ipdb ? . Data ? . IsPublic ?? false ;
68
+ var ipVersion = ipdb ? . Data ? . IpVersion ?? 4 ;
67
69
var abuseScore = ipdb ? . Data ? . AbuseConfidenceScore ?? 0 ;
68
70
var tor = ipdb ? . Data ? . IsTor ?? false ;
69
71
var usageType = ipdb ? . Data ? . UsageType ;
@@ -74,8 +76,11 @@ public static async Task<bool> ClientOnBlackListAsync(string remoteIp)
74
76
var isVpnBot = IsVpnBotUsageType ( usageType ) && abuseScore >= 3 ;
75
77
76
78
// Block disallowed, no need to report
77
- if ( isDisallowed )
78
- shouldBlock = true ;
79
+ if ( ipVersion == 6 || isPublic == false || isDisallowed || IsBlackListed ( isp ) )
80
+ {
81
+ IpCache . Set ( remoteIp , new IpCacheEntry { IsBlocked = true } , CacheDuration ) ;
82
+ return true ;
83
+ }
79
84
80
85
if ( isVpnBot )
81
86
{
@@ -328,12 +333,6 @@ private static void LogTor(string remoteIp, string reason)
328
333
ReportTorEndpoint ( remoteIp , $ "Blocked due to { reason } ") ;
329
334
}
330
335
331
- private static void LogBlockedType ( string remoteIp , string reason )
332
- {
333
- ServerSetup . ConnectionLogger ( $ "Blocking { remoteIp } - Usage: { reason } ", LogLevel . Warning ) ;
334
- ReportSuspiciousEndpoint ( remoteIp , "Blocked due to Web Spam or Port Scanning" ) ;
335
- }
336
-
337
336
private static bool IsDisallowedUsageType ( string ? usageType )
338
337
{
339
338
return usageType switch
@@ -358,5 +357,11 @@ private static bool IsVpnBotUsageType(string? usageType)
358
357
_ => false
359
358
} ;
360
359
360
+ private static bool IsBlackListed ( string ? isp ) => isp switch
361
+ {
362
+ "Driftnet Ltd" or "DigitalOcean, LLC" => true ,
363
+ _ => false
364
+ } ;
365
+
361
366
private static bool IsKeyCodeValid ( string ? keyCode ) => ! string . IsNullOrWhiteSpace ( keyCode ) ;
362
367
}
0 commit comments