[PR #514] Group records in database by ipVersion #724

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

Original Pull Request: https://github.com/qdm12/ddns-updater/pull/514

State: closed
Merged: Yes


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!

**Original Pull Request:** https://github.com/qdm12/ddns-updater/pull/514 **State:** closed **Merged:** Yes --- 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!
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#724