mirror of
https://github.com/pocket-id/pocket-id.git
synced 2025-12-09 14:42:59 +03:00
🚀 Feature: Allow custom maxmind database download url. #426
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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
@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.
@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:
Understood, Just wanted to clarify to make sure I understood.
@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:
Well this will not update the dB every x hours. And to update it I will need to restart the app
@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.
@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
GetLocationByIPbut 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.Mutexobject in theGeoLiteServicestruct 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