[PR #514] [MERGED] Group records in database by ipVersion #719

Open
opened 2025-11-20 04:25:50 -05:00 by saavagebueno · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/qdm12/ddns-updater/pull/514
Author: @felixwrt
Created: 8/4/2023
Status: Merged
Merged: 1/15/2024
Merged by: @qdm12

Base: masterHead: ipFilter2


📝 Commits (1)

  • 1e8f876 fix(internal/persistence/json): get events by IP version

📊 Changes

2 files changed (+32 additions, -6 deletions)

View changed files

📝 cmd/updater/main.go (+4 -2)
📝 internal/persistence/json/queries.go (+28 -4)

📄 Description

Currently, items in the database (updates.json) are grouped by domain and host. 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:

{
    "settings": [
        {
            "provider": "strato",
            "domain": "my.domain",
            "host": "@",
            "password": "pw",
            "ip_version": "ipv4",
            "provider_ip": false
        },
        {
            "provider": "strato",
            "domain": "my.domain",
            "host": "@",
            "password": "pw",
            "ip_version": "ipv6",
            "provider_ip": false
        }
    ]
}

updates.json using current master:

{
    "records": [
      {
        "domain": "my.domain",
        "host": "@",
        "ips": [
          {
            "ip": "2001:fff:8987:4000:3e18:ffff:fe03:ffff",
            "time": "2023-07-30T01:44:10.54280786Z"
          },
          {
            "ip": "97.155.132.1",
            "time": "2023-07-31T01:44:16.306989718Z"
          },
          {
            "ip": "2001:fff:89a4:9a00:3e18:ffff:fe03:ffff",
            "time": "2023-07-31T01:44:16.505670661Z"
          },
          {
            "ip": "2001:fff:8984:1d00:3e18:ffff:fe03:ffff",
            "time": "2023-08-01T01:44:10.520411731Z"
          },
          {
            "ip": "97.155.133.27",
            "time": "2023-08-02T01:39:10.529543713Z"
          },
          {
            "ip": "2001:fff:89a0:f500:3e18:ffff:fe03:ffff",
            "time": "2023-08-02T01:39:10.724642214Z"
          }
        ]
      }
    ]
  }

updates.json with the changes proposed in this PR:

{
  "records": [
    {
      "domain": "my.domain",
      "host": "@",
      "ipVersion": "ipv4",
      "ips": [
        {
          "ip": "97.155.132.1",
          "time": "2023-07-31T01:44:16.306989718Z"
        },
        {
          "ip": "97.155.133.27",
          "time": "2023-08-02T01:39:10.529543713Z"
        }
      ]
    },
    {
      "domain": "wirth.one",
      "host": "@",
      "ipVersion": "ipv6",
      "ips": [
        {
          "ip": "2001:fff:8987:4000:3e18:ffff:fe03:ffff",
          "time": "2023-07-30T01:44:10.54280786Z"
        },
        {
          "ip": "2001:fff:89a4:9a00:3e18:ffff:fe03:ffff",
          "time": "2023-07-31T01:44:16.505670661Z"
        },
        {
          "ip": "2001:fff:8984:1d00:3e18:ffff:fe03:ffff",
          "time": "2023-08-01T01:44:10.520411731Z"
        },
        {
          "ip": "2001:fff:89a0:f500:3e18:ffff:fe03:ffff",
          "time": "2023-08-02T01:39:10.724642214Z"
        }
      ]
    }
  ]
}

UI (current master):
Screenshot 2023-08-04 150336

UI (with the changes proposed here):
Screenshot 2023-08-04 150147

Let me know if this looks good to you. Thanks!


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/qdm12/ddns-updater/pull/514 **Author:** [@felixwrt](https://github.com/felixwrt) **Created:** 8/4/2023 **Status:** ✅ Merged **Merged:** 1/15/2024 **Merged by:** [@qdm12](https://github.com/qdm12) **Base:** `master` ← **Head:** `ipFilter2` --- ### 📝 Commits (1) - [`1e8f876`](https://github.com/qdm12/ddns-updater/commit/1e8f87659ef9b819b1d5e66a9b45f0a0502d1b49) fix(internal/persistence/json): get events by IP version ### 📊 Changes **2 files changed** (+32 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `cmd/updater/main.go` (+4 -2) 📝 `internal/persistence/json/queries.go` (+28 -4) </details> ### 📄 Description Currently, items in the database (`updates.json`) are grouped by `domain` and `host`. 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`: ```json { "settings": [ { "provider": "strato", "domain": "my.domain", "host": "@", "password": "pw", "ip_version": "ipv4", "provider_ip": false }, { "provider": "strato", "domain": "my.domain", "host": "@", "password": "pw", "ip_version": "ipv6", "provider_ip": false } ] } ``` `updates.json` using current master: ```json { "records": [ { "domain": "my.domain", "host": "@", "ips": [ { "ip": "2001:fff:8987:4000:3e18:ffff:fe03:ffff", "time": "2023-07-30T01:44:10.54280786Z" }, { "ip": "97.155.132.1", "time": "2023-07-31T01:44:16.306989718Z" }, { "ip": "2001:fff:89a4:9a00:3e18:ffff:fe03:ffff", "time": "2023-07-31T01:44:16.505670661Z" }, { "ip": "2001:fff:8984:1d00:3e18:ffff:fe03:ffff", "time": "2023-08-01T01:44:10.520411731Z" }, { "ip": "97.155.133.27", "time": "2023-08-02T01:39:10.529543713Z" }, { "ip": "2001:fff:89a0:f500:3e18:ffff:fe03:ffff", "time": "2023-08-02T01:39:10.724642214Z" } ] } ] } ``` `updates.json` with the changes proposed in this PR: ```json { "records": [ { "domain": "my.domain", "host": "@", "ipVersion": "ipv4", "ips": [ { "ip": "97.155.132.1", "time": "2023-07-31T01:44:16.306989718Z" }, { "ip": "97.155.133.27", "time": "2023-08-02T01:39:10.529543713Z" } ] }, { "domain": "wirth.one", "host": "@", "ipVersion": "ipv6", "ips": [ { "ip": "2001:fff:8987:4000:3e18:ffff:fe03:ffff", "time": "2023-07-30T01:44:10.54280786Z" }, { "ip": "2001:fff:89a4:9a00:3e18:ffff:fe03:ffff", "time": "2023-07-31T01:44:16.505670661Z" }, { "ip": "2001:fff:8984:1d00:3e18:ffff:fe03:ffff", "time": "2023-08-01T01:44:10.520411731Z" }, { "ip": "2001:fff:89a0:f500:3e18:ffff:fe03:ffff", "time": "2023-08-02T01:39:10.724642214Z" } ] } ] } ``` UI (current master): ![Screenshot 2023-08-04 150336](https://github.com/qdm12/ddns-updater/assets/104097293/564f038b-7f79-487d-a506-740de4411911) UI (with the changes proposed here): ![Screenshot 2023-08-04 150147](https://github.com/qdm12/ddns-updater/assets/104097293/5f8cacf1-52f2-4daa-9a1d-1a7dc56f2af2) Let me know if this looks good to you. Thanks! --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
saavagebueno added the pull-request label 2025-11-20 04:25:50 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/ddns-updater#719