Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ dependencies: [
]
```

### Upgrading from 0.5.x

Existing lookup calls, ULT2 files, and on-disk caches work with 0.6.0. If you
build from custom TSVs, the builder now stops on malformed rows, and
`ip2asn build-ultra` writes a JSON report to stdout.
[0.6.0 upgrade guide](https://ip2asn.networkweather.com/documentation/swiftip2asn/upgradingto060/)

## Quick Start

### Simple API (Recommended)
Expand Down
8 changes: 6 additions & 2 deletions Sources/SwiftIP2ASN/SwiftIP2ASN.docc/SwiftIP2ASN.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ keep input order, duplicates, and a `nil` at each miss.

## Topics

### Upgrade guides

- <doc:UpgradingTo060>

### Essentials

- ``IP2ASN``
Expand Down Expand Up @@ -145,8 +149,8 @@ keep input order, duplicates, and a `nil` at each miss.
## Data Sources

The database is sourced from [iptoasn.com](https://iptoasn.com), which aggregates
BGP routing data from global route collectors. The hosted database at
`pkgs.networkweather.com` is updated daily.
BGP routing data from global route collectors. The weekly update checks both source TSVs and publishes a new database and
manifest to `pkgs.networkweather.com` when either source changes.

## Requirements

Expand Down
32 changes: 32 additions & 0 deletions Sources/SwiftIP2ASN/SwiftIP2ASN.docc/UpgradingTo060.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Upgrading to 0.6.0

Update your Swift package dependency, keep your existing lookup code and ULT2 databases, and check any scripts that build a database from TSV files.

## Update an app from 0.5.x

Choose 0.6.0 in your package manager. If your `Package.swift` pins an exact 0.5.x release, change the pin to `exact: "0.6.0"`. If your version requirement already allows 0.6.0, run `swift package update swift-ip2asn` and check the version in `Package.resolved`. The minimum toolchain is Swift 6.1.

Both tuple-returning `lookup` calls and typed `lookupResult` calls compile as before. Existing ULT2 files and the on-disk cache work with 0.6.0. Apps using ``RemoteDatabase`` can keep their refresh schedule. When validators are available, `refresh()` sends them to the server and bypasses URLSession’s local HTTP cache. This fixes a refresh that could return HTTP 404 after a successful download.

If you use ``IPRange`` for subnet membership, partial-byte prefixes such as IPv4 `/25` and IPv6 `/127` now work correctly. An out-of-range prefix length passed to `init(start:prefixLength:)` makes `contains` return `false`.

## Update a custom database build

The ULT2 builder now stops on malformed input and identifies the source file, line, and reason. If an existing TSV stops building, check the reported row for missing columns, an invalid endpoint or ASN, a reversed range, or an overlap with another routed range. Start and end addresses are inclusive, so two routed rows sharing an endpoint overlap. Each row can contain up to 1 MiB. Blank lines and rows with ASN 0 are counted and skipped.

A successful `ip2asn build-ultra` writes the compressed database to the output path and a JSON report to standard output. Scripts can capture the report and read the output digest and range count.

```sh
ip2asn build-ultra ip2asn-v4.tsv ip2asn-v6.tsv out.ultra > build-report.json &&
jq '{sha256: .artifact.sha256, ranges: .database.totalRangeCount, rows: .rows}' build-report.json
```

The report counts every input row in `rows.total`. Subtract `rows.blank` and `rows.unrouted` to get the number of stored ranges. Build errors go to standard error and return a nonzero exit status. If your pipeline uses the provenance manifest, continue generating it with the existing manifest options.

Scripts that run `bench-ultra` or `bench-compressed` should check the exit status before reading timings. An invalid iteration count exits with status 2, and a database load error exits with status 1.

## Check which data you loaded

The 0.6.0 package bundles the database generated on November 16, 2026. The project checks the upstream data weekly, and the hosted database can advance independently of the Swift package. To identify the database your app actually used, read its `metadata.buildIdentifier` and `metadata.generationTimestamp`. The CLI command `ip2asn inspect` reports the identity of its bundled database, and `ip2asn inspect --database out.ultra` inspects a specific file.

[Full 0.6.0 release notes](https://github.com/Network-Weather/Swift-IP2ASN/releases/tag/v0.6.0)
Loading