From aeb702dcd13715ea868456ee7470e753a2a305d3 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Fri, 23 Oct 2026 15:00:28 -0500 Subject: handle ipv6 --- src/slskd/Core/Blacklist.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src') diff --git a/src/slskd/Core/Blacklist.cs b/src/slskd/Core/Blacklist.cs index 517b5e4b..6f25b93c 100644 --- a/src/slskd/Core/Blacklist.cs +++ b/src/slskd/Core/Blacklist.cs @@ -39,6 +39,7 @@ using System.Diagnostics; using System.IO; using System.Linq; using System.Net; +using System.Net.Sockets; using System.Threading.Tasks; using NetTools; using Serilog; @@ -315,6 +316,18 @@ public class Blacklist /// A value indicating whether the specified IP is contained within the blacklist. public virtual bool Contains(IPAddress ip) { + // looks like '::ffff:1.2.3.4'; convert it back to IPv4 so the lookup below works + if (ip.IsIPv4MappedToIPv6) + { + ip = ip.MapToIPv4(); + } + + // only IPv4 ranges are supported + if (ip.AddressFamily != AddressFamily.InterNetwork) + { + return false; + } + // grab the first octet int first = ip.GetAddressBytes()[0]; -- cgit v1.2.3