🚀 Feature: Allow custom maxmind database download url. #426

Closed
opened 2025-10-09 16:45:52 +03:00 by OVERLORD · 7 comments
Owner

Originally created by @wargio on GitHub.

Feature description

For networking reasons the files that pocket-id tries to pull from might not be reachable. it would be nice to be able to set a custom url like http://internal.domain/mirror/latest-GeoLite2-City.mmdb.

Pitch

This should be configurable like for the license key

Originally created by @wargio on GitHub. ### Feature description For networking reasons the files that pocket-id tries to pull from might not be reachable. it would be nice to be able to set a custom url like `http://internal.domain/mirror/latest-GeoLite2-City.mmdb`. ### Pitch This should be configurable like for the license key
OVERLORD added the feature label 2025-10-09 16:45:52 +03:00
Author
Owner

@stonith404 commented on GitHub:

I think it makes more sense if you mount the database to the container like @kmendell said. Updating the database doesn't require a restart and the update can easily be automated with a cron job.

In my view, implementing environment-specific features like this directly in the app isn’t necessary, especially when a simple workaround is available. Adding such features would only complicate Pocket ID unnecessarily.

@stonith404 commented on GitHub: I think it makes more sense if you mount the database to the container like @kmendell said. Updating the database doesn't require a restart and the update can easily be automated with a cron job. In my view, implementing environment-specific features like this directly in the app isn’t necessary, especially when a simple workaround is available. Adding such features would only complicate Pocket ID unnecessarily.
Author
Owner

@kmendell commented on GitHub:

@wargio you can manually mount a GeoLite2 DB into the container I believe, Does this not work for you?

@kmendell commented on GitHub: @wargio you can manually mount a GeoLite2 DB into the container I believe, Does this not work for you?
Author
Owner

@kmendell commented on GitHub:

Understood, Just wanted to clarify to make sure I understood.

@kmendell commented on GitHub: Understood, Just wanted to clarify to make sure I understood.
Author
Owner

@wargio commented on GitHub:

I think, given how the license is used, you can replace entirely the license key env with just the URL

@wargio commented on GitHub: I think, given how the license is used, you can replace entirely the license key env with just the URL
Author
Owner

@wargio commented on GitHub:

Well this will not update the dB every x hours. And to update it I will need to restart the app

@wargio commented on GitHub: Well this will not update the dB every x hours. And to update it I will need to restart the app
Author
Owner

@stonith404 commented on GitHub:

Fair enough I didn't think about that. In that case it would make sense to add a custom database URL.

@stonith404 commented on GitHub: Fair enough I didn't think about that. In that case it would make sense to add a custom database URL.
Author
Owner

@wargio commented on GitHub:

The issue is if i update the DB it needs to be done when the DB is not open.

This is a race condition.

It is true that based on the code (see below) the db is opened and closed each time you call GetLocationByIP but still this falls into a race condition which may crash the application.

https://github.com/stonith404/pocket-id/blob/main/backend/internal/service/geolite_service.go#L46

The same issue happens also when the updater is invoked while an auditlog is generated. there should be a sync.Mutex object in the GeoLiteService struct which should be locked when you overwrite the mmdb file.

https://github.com/stonith404/pocket-id/blob/main/backend/internal/service/geolite_service.go#L137

I have opened a PR for this: https://github.com/stonith404/pocket-id/pull/138

@wargio commented on GitHub: The issue is if i update the DB it needs to be done when the DB is not open. **This is a race condition.** It is true that based on the code (see below) the db is opened and closed each time you call `GetLocationByIP` but still this falls into a race condition which may crash the application. https://github.com/stonith404/pocket-id/blob/main/backend/internal/service/geolite_service.go#L46 The same issue happens also when the updater is invoked while an auditlog is generated. there should be a `sync.Mutex` object in the `GeoLiteService` struct which should be locked when you overwrite the mmdb file. https://github.com/stonith404/pocket-id/blob/main/backend/internal/service/geolite_service.go#L137 I have opened a PR for this: https://github.com/stonith404/pocket-id/pull/138
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/pocket-id-pocket-id-2#426