diff options
| author | JP Dillingham <jp@dillingham.me> | 2026-10-23 15:00:28 -0500 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2026-10-23 15:00:28 -0500 |
| commit | aeb702dcd13715ea868456ee7470e753a2a305d3 (patch) | |
| tree | 8ec9d71b0de696e9ff6b7bfffe91673e62789343 /src/slskd/Core | |
| parent | 376b2378380b7d39fd0947c35cab0a636662b372 (diff) | |
| download | slskd-aeb702dcd13715ea868456ee7470e753a2a305d3.tar.gz | |
handle ipv6
Diffstat (limited to 'src/slskd/Core')
| -rw-r--r-- | src/slskd/Core/Blacklist.cs | 13 |
1 files changed, 13 insertions, 0 deletions
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 /// <returns>A value indicating whether the specified IP is contained within the blacklist.</returns> 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]; |
