Table of Contents

Class IpLocationSqliteBuilder

Namespace
VpnHood.Net.IpLocations.Providers.SqliteProvider
Assembly
VpnHood.Net.IpLocations.Providers.SqliteProvider.dll

Provides the means to build the SQLite database IpLocationSqliteProvider reads, from the zip of country IP ranges BuildLocalIpRangeLocationDb(Stream, string, CancellationToken) builds.

public static class IpLocationSqliteBuilder
Inheritance
IpLocationSqliteBuilder
Inherited Members

Methods

Build(IAsset, SqliteConnection, CancellationToken)

Builds the database on a connection, which it opens when it is closed, unless the database already holds the zip's build, which the zip's stamp tells. A rebuild replaces the IpLocations and Metadata tables in one transaction, so one that fails or is canceled before its commit leaves the last build. The database is compacted after the commit: a failure or a cancellation there leaves the new build, not compacted.

public static Task Build(IAsset zip, SqliteConnection connection, CancellationToken cancellationToken)

Parameters

zip IAsset

The zip of country IP ranges.

connection SqliteConnection

The connection; the caller keeps owning it.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task

A task that represents the asynchronous operation.

Exceptions

ArgumentNullException

zip or connection is null.

Build(IAsset, string, CancellationToken)

Builds the database in a file, unless the file already holds the zip's build, which the zip's stamp tells.

public static Task Build(IAsset zip, string dbPath, CancellationToken cancellationToken)

Parameters

zip IAsset

The zip of country IP ranges.

dbPath string

The database file; its folder is made when missing.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task

A task that represents the asynchronous operation.

Exceptions

ArgumentNullException

zip is null.

ToBytes(IPAddress)

Converts an IP address to the database's key form: its 16 IPv6 bytes, an IPv4 address mapped to IPv6 first.

public static byte[] ToBytes(IPAddress ipAddress)

Parameters

ipAddress IPAddress

The IP address.

Returns

byte[]

The 16 bytes.