-
-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Group records in database by ipVersion
#514
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work 🎖️ Also good job on the high quality PR description 💯
However, I think we should have some migration from the older updates.json format to this newer one. We can run this migration when creating the persistent database object I think, and re-write the file (sort the ipv4 apart from the ipv6 events). Let me know if you need some help doing this, but if you feel comfortable enough with Go, go for it! 😉
I thought a bit about migration but didn't find an obvious way to do it. The problem is that the result of the migration depends on the config. For example, if the database contains both ipv4 and ipv6 addresses, we don't know whether they should be splitted into two groups or stay within one. In my example above, splitting would be correct. If the config contained a single item with ipVersion "ipv4 or ipv6", the migration should keep the addresses in a single group and add the key With access to the config, the migration could be done correctly, but I don't know how much effort it would be to get the config info to the place where the database is written. Smells like bad design to me, but I might be overseeing something. While we're talking about changing the database format: I think it would make sense to include a version field. This would make future changes to the database format easier. |
I found a solution I'm quite happy with. I implemented a method on The migration itself adds a I've written some tests for the common cases. I'm still very much a beginner with Go, so feel free to nit-pick on all the stuff I did wrong ;-) |
@qdm12 did you get a chance to look at this yet? |
Yes it's in progress 😄 I'll probably submit a review tomorrow 🙏 Sorry for the delay and thanks for your patience (and work!!)! |
Hi, thanks for the review. I'll try to work through it within the next couple of days. |
Hey @qdm12, I just tried to get back into this work but noticed that all my knowledge of this project and Go is gone. I also don't have time currently to pursue this further, sry. I hope that you'll find the time to finish this PR and get it merged. |
Hey @felixwrt I have been reworking/twisting this around, and I think I came up with a very simple solution: just filter the IPs by IP version (v4 or v6 or v4Orv6) when getting events, without a database migration/change. Effectively the ips field is still a mixed bag of IPv4 and Ipv6, but the program takes care to filter them according to the ip version defined. The commit is 942ae51 with about ~20 lines. This should fix it without migration etc. 😉 |
I will merge this since it should do the trick with minimal code changes. |
@qdm12 Thanks for solving this issue ! Works now for me. |
Currently, items in the database (
updates.json
) are grouped bydomain
andhost
. This leads to problems when there are multiple config items that contain the same domain and host.I'm using two separate config items with the same host and domain but different
ipVersion
values to update both the ipv4 and ipv6 address. In this setup,ddns-updater
currently uses the history of both ip versions which leads to incorrect info displayed in the UI.This PR adds
ipVersion
as an additional item that is used to group IPs in the database. With this change, the history is displayed correctly.Example
config.json
:updates.json
using current master:updates.json
with the changes proposed in this PR:UI (current master):
UI (with the changes proposed here):
Let me know if this looks good to you. Thanks!