CodeLogic.NetUtils 4.6.73

This package has a SemVer 2.0.0 package version: 4.6.73+722f3a3.
dotnet add package CodeLogic.NetUtils --version 4.6.73
                    
NuGet\Install-Package CodeLogic.NetUtils -Version 4.6.73
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CodeLogic.NetUtils" Version="4.6.73" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CodeLogic.NetUtils" Version="4.6.73" />
                    
Directory.Packages.props
<PackageReference Include="CodeLogic.NetUtils" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CodeLogic.NetUtils --version 4.6.73
                    
#r "nuget: CodeLogic.NetUtils, 4.6.73"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package CodeLogic.NetUtils@4.6.73
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CodeLogic.NetUtils&version=4.6.73
                    
Install as a Cake Addin
#tool nuget:?package=CodeLogic.NetUtils&version=4.6.73
                    
Install as a Cake Tool

CodeLogic.NetUtils

NuGet License: MIT

DNSBL blacklist checking and MaxMind GeoIP geolocation for CodeLogic 4 — screen abusive IPs and locate visitors with one library.

Bundles two network-reputation tools behind a single NetUtilsLibrary. The DNSBL checker queries multiple blacklist zones (IPv4 and IPv6, primary plus fallback) in parallel and short-circuits private/loopback addresses without a DNS query. The GeoIP service does city-level lookups against a MaxMind GeoLite2/GeoIP2 .mmdb database — loaded from disk or auto-downloaded with your MaxMind credentials.

Install

dotnet add package CodeLogic.NetUtils

Quick start

using CL.NetUtils;

await Libraries.LoadAsync<NetUtilsLibrary>();   // register before ConfigureAsync()
await CodeLogic.ConfigureAsync();
await CodeLogic.StartAsync();

var net = Libraries.Get<NetUtilsLibrary>();

// 1. Is this IP on a blacklist? (uses the zones from config.netutils.json)
DnsblCheckResult check = await net.Dnsbl.CheckIpAsync("203.0.113.1");
if (check.IsBlacklisted)
    Console.WriteLine($"Listed by {check.MatchedService}");

// 2. Where is this IP? Guard with HasGeoIp — GeoIP needs a MaxMind database.
if (net.HasGeoIp)
{
    IpLocationResult geo = await net.GeoIp.LookupIpAsync("203.0.113.1");
    if (geo.IsSuccessful)
        Console.WriteLine($"{geo.CityName}, {geo.CountryName} ({geo.CountryCode})");
}

Local and private addresses (loopback, RFC 1918, IPv6 link/site-local and unique-local) are returned as not blacklisted without any DNS query.

Features

  • DNSBL checking — query multiple blacklist zones per address family with parallel lookups and primary/fallback providers.
  • Per-call overridesCheckIpAsync(ip, DnsblCheckRequest) supplies your own zones, timeout, and an async allowlist predicate.
  • Private-address short-circuit — loopback and RFC 1918 / IPv6 local ranges skip DNS and return not blacklisted.
  • IP geolocation — city-level country/city/coordinates/time-zone lookups via MaxMind GeoLite2/GeoIP2.
  • Auto-download — fetch and extract the .mmdb on startup using your MaxMind AccountId + LicenseKey.
  • Own result recordsDnsblCheckResult and IpLocationResult, each with success/error factories.

Configuration

Auto-generated on first run as config.netutils.json (section netutils):

{
  "Enabled": true,
  "Dnsbl": {
    "Enabled": true,
    "Ipv4Services": ["zen.spamhaus.org", "dnsbl.sorbs.net"],
    "Ipv4FallbackServices": ["b.barracudacentral.org"],
    "Ipv6Services": ["zen.spamhaus.org", "dnsbl6.sorbs.net"],
    "Ipv6FallbackServices": ["v6.b.barracudacentral.org"],
    "TimeoutSeconds": 5,
    "ParallelQueries": true,
    "DetailedLogging": false
  },
  "GeoIp": {
    "Enabled": true,
    "DatabasePath": "",
    "AutoUpdate": false,
    "AccountId": 0,
    "LicenseKey": "",
    "DownloadUrl": "https://download.maxmind.com/geoip/databases/GeoLite2-City/download?suffix=tar.gz",
    "DatabaseType": "GeoLite2-City",
    "TimeoutSeconds": 30
  }
}
Setting Default Description
Enabled true Master switch for the library.
Dnsbl.Enabled true Enable the DNSBL checker.
Dnsbl.Ipv4Services ["zen.spamhaus.org","dnsbl.sorbs.net"] Primary IPv4 blacklist zones.
Dnsbl.Ipv4FallbackServices ["b.barracudacentral.org"] Tried when primaries fail.
Dnsbl.Ipv6Services ["zen.spamhaus.org","dnsbl6.sorbs.net"] Primary IPv6 blacklist zones.
Dnsbl.Ipv6FallbackServices ["v6.b.barracudacentral.org"] IPv6 fallback zones.
Dnsbl.TimeoutSeconds 5 Per-check DNS timeout.
Dnsbl.ParallelQueries true Query zones concurrently.
Dnsbl.DetailedLogging false Log each zone query.
GeoIp.Enabled true Enable the GeoIP service.
GeoIp.DatabasePath "" Explicit .mmdb path; blank auto-resolves to {dataDir}/geoip/{DatabaseType}.mmdb.
GeoIp.AutoUpdate false Download/refresh the database on startup.
GeoIp.AccountId 0 MaxMind account id (required for download).
GeoIp.LicenseKey "" MaxMind license key (secret; required for download).
GeoIp.DownloadUrl MaxMind GeoLite2-City Download endpoint (tar.gz).
GeoIp.DatabaseType GeoLite2-City Database/edition id.
GeoIp.TimeoutSeconds 30 Download timeout.

Documentation

Full guide: CL.NetUtils documentation

Requirements

  • CodeLogic 4 · .NET 10
  • MaxMind.GeoIP2 5.x · SharpCompress 0.x
  • A MaxMind GeoLite2/GeoIP2 .mmdb for GeoIP (on disk, or auto-downloaded with credentials)

License

MIT — see LICENSE.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.6.73 163 7/13/2026
4.6.72 42 6/20/2026
4.6.69-preview 34 6/20/2026
4.5.2 106 5/24/2026
4.5.2-preview.68 63 6/20/2026
4.5.1 159 5/24/2026
4.5.1-preview.56 91 5/24/2026
4.4.2-preview.53 60 5/24/2026
4.4.1 111 5/24/2026
4.0.5 105 5/15/2026
4.0.4 110 5/9/2026
4.0.3 109 5/9/2026
4.0.1 565 4/19/2026
3.3.2 643 4/18/2026
3.3.1 107 4/18/2026
3.3.0 101 4/18/2026
3.2.11 119 4/18/2026
3.2.10 112 4/18/2026
3.2.9 102 4/18/2026
3.2.8 102 4/18/2026
Loading failed

# CL.NetUtils — Changelog

All notable changes to **CodeLogic.NetUtils** are documented here. Versions follow
[Semantic Versioning](https://semver.org/).

## 2026-06-20

### Documentation

- Full rewrite of the README and the deep docs page to house style: NuGet + MIT
 badges, blockquote tagline, concise quick-start, feature list, and a complete
 configuration table covering every `Dnsbl.*` and `GeoIp.*` field.
- Documented the correct load pattern (`Libraries.LoadAsync<NetUtilsLibrary>()`
 → `ConfigureAsync` → `StartAsync` → `Libraries.Get`) and both `Dnsbl` /
 `GeoIp` accessors, with the `HasGeoIp` guard for the optional GeoIP service.
- Documented both `CheckIpAsync` overloads, the default IPv4/IPv6 blacklist
 zones, and the per-call `DnsblCheckRequest` (per-call zone lists, timeout, and
 async allowlist predicate).
- Documented the `DnsblCheckResult` and `IpLocationResult` records field by
 field, including `IpLocationResult.IsSuccessful`.
- Documented GeoIP database resolution and auto-download: `DatabasePath` vs the
 `{dataDir}/geoip/{DatabaseType}.mmdb` fallback, and `DownloadDatabaseAsync`
 fetching/extracting the `.mmdb` via HTTP Basic Auth with `AccountId` +
 `LicenseKey`.

## [4.5.2] — 2026-06-20

### Documentation

- Corrected the README Quick Start to match the real API: `Dnsbl.CheckIpAsync`
 (was `CheckAsync`) returning `DnsblCheckResult.IsBlacklisted` / `MatchedService`
 (was `IsListed`), and the async `GeoIp.LookupIpAsync` returning
 `IpLocationResult.CountryName` / `CityName` (was a synchronous `Lookup`).
- Documented the `DnsblCheckRequest` overload of `CheckIpAsync` — per-call
 service lists plus an optional async allowlist predicate (`IsAllowedAsync`).
- Documented the `DnsblCheckResult` and `IpLocationResult` result records and
 the `IpLocationResult.IsSuccessful` helper.
- Documented that local/private addresses are short-circuited as not blacklisted.
- Added the `GeoIp.DownloadUrl` field to the sample `config.netutils.json`.

## [4.5.0] — 2026-05-24

### Changed

- **Unified versioning.** All CodeLogic.Libs now share a single version line
 controlled by `version.txt` in the repo root. This is a version alignment
 release — no functional changes to this library.
## [4.0.4] — 2026-04-16

### Changed

- README + manifest refresh for the v4 baseline. No functional changes vs 4.0.3.
- `LibraryManifest.Version` now reads from assembly metadata.

## [4.0.2] — 2026-04-09

### Added

- `DnsblCheckRequest` overload that accepts a caller-supplied DNSBL service
 list — useful when the calling app stores its own service registry instead
 of relying on the bundled defaults.

### Changed

- Annotated NetUtils configuration with `[ConfigField]` for the admin UI surface.
- Aligned with the v4 baseline across all libraries.

## [4.0.0] — 2026-04-09

Major rewrite. Republished as v4.0.0 to reset the version line under the
unified v4 baseline. GeoIP, DNSBL, and IP/CIDR utilities.

### Notes

- Earlier history is retained in the
 [git log](https://github.com/Media2A/CodeLogic.Libs/commits/main/CL.NetUtils).