Skip to content

Commit

Permalink
Merge pull request #426 from Plaenkler/add-custom-provider
Browse files Browse the repository at this point in the history
[ADD] Provider Custom
  • Loading branch information
Plaenkler authored Oct 3, 2024
2 parents bd9410f + 0388151 commit b0f60a1
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,21 @@ The user-friendly interface allows for straightforward secure setup and manageme
- [x] Supports multiple IP resolvers
- [x] Deploy as Windows Service
- [x] Available as Docker Container
- [x] Custom update URL with check

## 🏷️ Supported providers

`Strato` `DDNSS` `Dynu` `Aliyun` `NoIP` `DD24` `INWX`

> **Note:** If your DynDNS provider is not listed open an issue and I will integrate it.
### Custom provider

Select the provider **Custom** from the provider list.
Then enter the user-defined URL in the **URL** field.
Use the placeholder `<ipv4>` at the point where the IPv4 address is to be inserted.
In the **“Check”** field, enter a string that will be used for checking to ensure that the update server's response is successful.

## 📜 Installation guide

### 🐋 Deploy with Docker
Expand Down
31 changes: 31 additions & 0 deletions pkg/ddns/providers/custom.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package providers

import (
"fmt"
"net/http"
"strings"
)

type UpdateCustomRequest struct {
Domain string `json:"URL"`
Check string `json:"Check"`
}

func UpdateCustom(request interface{}, ipAddr string) error {
r, ok := request.(*UpdateCustomRequest)
if !ok {
return fmt.Errorf("invalid request type: %T", request)
}
if !strings.Contains(r.Domain, "<ipv4>") {
return fmt.Errorf("no <ipv4> placeholder found in URL")
}
r.Domain = strings.Replace(r.Domain, "<ipv4>", ipAddr, -1)
resp, err := SendHTTPRequest(http.MethodGet, r.Domain, nil)
if err != nil {
return err
}
if !strings.Contains(resp, r.Check) {
return fmt.Errorf("check string '%s' not found in response", r.Check)
}
return nil
}
1 change: 1 addition & 0 deletions pkg/ddns/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type provider struct {
}

var updaters = map[string]provider{
"Custom": {Updater: providers.UpdateCustom, Request: providers.UpdateCustomRequest{}},
"Strato": {Updater: providers.UpdateStrato, Request: providers.UpdateStratoRequest{}},
"DDNSS": {Updater: providers.UpdateDDNSS, Request: providers.UpdateDDNSSRequest{}},
"Dynu": {Updater: providers.UpdateDynu, Request: providers.UpdateDynuRequest{}},
Expand Down

0 comments on commit b0f60a1

Please sign in to comment.