CodeLogic.NetUtils 4.9.98

This package has a SemVer 2.0.0 package version: 4.9.98+32aff20.
dotnet add package CodeLogic.NetUtils --version 4.9.98
                    
NuGet\Install-Package CodeLogic.NetUtils -Version 4.9.98
                    
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.9.98" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CodeLogic.NetUtils" Version="4.9.98" />
                    
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.9.98
                    
#r "nuget: CodeLogic.NetUtils, 4.9.98"
                    
#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.9.98
                    
#: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.9.98
                    
Install as a Cake Addin
#tool nuget:?package=CodeLogic.NetUtils&version=4.9.98
                    
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 overrides — CheckIpAsync(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 records — DnsblCheckResult 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.9+ · .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 (1)

Showing the top 1 NuGet packages that depend on CodeLogic.NetUtils:

Package Downloads
CodeLogic.WebLogic

Web application toolkit for CodeLogic 4 — routing, templates, forms, an ordered security pipeline, auth flows and realtime. No third-party dependencies beyond CodeLogic.*.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.9.98 121 10/25/2026
4.8.93 64 9/23/2026
4.8.87 101 9/13/2026
4.8.85 51 9/12/2026
4.6.75-preview 56 8/1/2026
4.6.73 222 7/13/2026
4.6.72 66 6/20/2026
4.6.69-preview 60 6/20/2026
4.5.2 135 5/24/2026
4.5.2-preview.68 91 6/20/2026
4.5.1 181 5/24/2026
4.5.1-preview.56 113 5/24/2026
4.4.2-preview.53 84 5/24/2026
4.4.1 135 5/24/2026
4.0.5 124 5/15/2026
4.0.4 130 5/9/2026
4.0.3 132 5/9/2026
4.0.1 583 4/19/2026
3.3.2 662 4/18/2026
3.3.1 124 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-10-24

### Changed

- Requires **CodeLogic 4.9+**. The official libraries move to the 4.9 line together with the framework,
 whose live config changes the stateful libraries now use. No API changes in this library.

## 2026-09-12

### Changed

- Unified the version line with the CodeLogic framework on **4.8.x**. Every official
 library and the framework now share one `major.minor`, so a given `4.8.<patch>`
 means the same generation across all packages.
- `version.txt` moved from `4.6` to `4.8`. The patch component remains the CI run
 number, composed at pack time; `AssemblyVersion` stays pinned at `Major.Minor.0.0`
 (now `4.8.0.0`) so every patch in the line loads interchangeably.

## 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/zyntal-com/CodeLogic.Libs/commits/main/CL.NetUtils).