Lds.IpAccess.MongoDb 0.3.0
Lds.IpAccess.MongoDb
The MongoDB store of Lds.IpAccess: the downloaded lists' last good
copies, so a restart puts them in place within seconds; the access log, kept for 90 days; and, with
AddIpAccessStoredRules, the administrator's policy and people's addresses. Without it, Lds.IpAccess keeps them in
memory.
It is built on the plain MongoDB.Driver, referenced at the oldest version an application may run (3.10.0), so it
works beside any version of MongoDB.Entities: the application hands over the database it already opened.
Adding it
builder.Services.AddIpAccess(builder.Configuration);
builder.Services.AddIpAccessMongoDb(sp => sp.GetRequiredService<IMongoDatabase>());
With MongoDB.Entities, hand over the IMongoDatabase the application's context was opened on. AddIpAccessMongoDb
may come before or after AddIpAccess.
What it keeps
| Collection (default name) | What | Kept |
|---|---|---|
ipAccessLists |
One document per list, _id the list's name (Country, DataCentre, Tor, PrivateRelay): the edition, its SHA-256, the content packed with gzip, the number of ranges, when it was downloaded and checked, the last error |
Replaced on each new edition |
ipAccessBlockedRequests |
One document per turned-away request: when, the address, the country, the verdict by name, the path, the person | 90 days, removed by MongoDB (TTL index IpAccess_At_ttl on At) |
ipAccessPrivateRelayDays |
One document per day, _id the day (2026-10-12): the requests let in from iCloud Private Relay and the addresses they came from |
Until removed |
ipAccessPolicy |
With AddIpAccessStoredRules: one document, _id policy: geo-fencing on or off, the countries, the allowed addresses, each restricted path's addresses, who changed it and when |
Replaced on each change |
ipAccessPeople |
With AddIpAccessStoredRules: one document per person, _id their identity: their name, only from these addresses, the entries, who changed them and when |
Until removed |
- The names are
IpAccessMongoDbOptions, given asAddIpAccessMongoDb(database, o => o.ListsCollection = "..."). Two applications in one database need different names, or they share one access log. - Names are stored as text, never as numbers: the list's kind and the verdict read the same whatever the order of the package's enums.
- The documents are mapped by hand: the package registers no class map and no convention, so it cannot disturb an application's own mapping.
- A packed list is a few MB (Apple's 12 MB list packs to about 2 MB). One packed past 15 MB is refused, and the copy in use stays.
- The TTL index is created on the first write and is idempotent. MongoDB's TTL monitor runs about once a minute, so a record may outlive its 90 days by that much.
No packages depend on Lds.IpAccess.MongoDb.
.NET 10.0
- Lds.IpAccess (>= 0.3.0)
- MongoDB.Driver (>= 3.10.0)