Skip to content
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

feat(provider): add netcup #361

Merged
merged 14 commits into from
Jun 14, 2023
Merged

feat(provider): add netcup #361

merged 14 commits into from
Jun 14, 2023

Conversation

Azorimor
Copy link
Contributor

@Azorimor Azorimor commented Sep 7, 2022

This PR adds basic support to use Netcup as provider (#282). The implementation only updates the IP of the given host. Additional settings (TTL, Retry, Refresh, ...) can be set manually in the netcup customercontrolpanel / dashboard.

All requests to the netcup api are send to the same endpoint. The different functions are defined by the body of the request. For example the following requests (and more) are necessary. (see doc) The requests are implemented in netcup/client.go.

Login (Create Session on server, which is valid for 15 minutes (logout not implemented, because 15 min as default seems ok))
body:

"action": "login",
"param": {
  "customernumber": "111",
  "apikey": "xxxxx",
  "apipassword": "yyyy"
}

Copy link
Owner

@qdm12 qdm12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! 👍

I requested quite a bit of code changes, feel free to let me know if you don't have the time/will to do it and I can pick it up from your fork and finish it up myself as well, and you can test it after modifications. If you want to do it, feel free to comment and I'll wait for you no problem (I'm also moving out/in so quite busy over here)

docs/netcup.md Outdated Show resolved Hide resolved
internal/settings/errors/intermediary.go Outdated Show resolved Hide resolved
internal/settings/providers/netcup/client.go Outdated Show resolved Hide resolved
internal/settings/providers/netcup/client.go Outdated Show resolved Hide resolved
internal/settings/providers/netcup/client.go Outdated Show resolved Hide resolved
internal/settings/providers/netcup/client.go Outdated Show resolved Hide resolved
internal/settings/providers/netcup/client.go Outdated Show resolved Hide resolved
internal/settings/providers/netcup/client.go Outdated Show resolved Hide resolved
internal/settings/providers/netcup/client.go Outdated Show resolved Hide resolved
internal/settings/providers/netcup/client.go Outdated Show resolved Hide resolved
@qdm12 qdm12 force-pushed the provider-netcup branch 2 times, most recently from 08250d1 to 14ca260 Compare October 1, 2022 21:47
@qdm12
Copy link
Owner

qdm12 commented Oct 1, 2022

@Azorimor I pushed changes fixing all the comments above, I have built the image qmcgaw/ddns-updater:netcup can you please try it 🙏 ? Thanks!

@Azorimor
Copy link
Contributor Author

Azorimor commented Oct 3, 2022

Thanks for your feedback. I tested the changes and it did not work. Console Output:

Running version unknown built on an unknown date (commit unknown)
[...]
💰 Help me? https://www.paypal.me/qmcgaw https://github.com/sponsors/qdm12
2022/10/03 11:12:24 INFO reading JSON config from file /workspace/data/config.json
2022/10/03 11:12:24 INFO Found single setting to update record
2022/10/03 11:12:24 INFO Reading history from database: domain xxxxx.xx host test
2022/10/03 11:12:24 INFO healthcheck server: listening on 127.0.0.1:9999
2022/10/03 11:12:24 INFO backup: disabled
2022/10/03 11:12:24 INFO http server: listening on :8000
2022/10/03 11:12:24 INFO IP address of test.xxxxx.xx  is 185.yyy.yyy.192 and your IP address is yy.207.1yy.3xx
2022/10/03 11:12:24 INFO Updating record [domain: xxxxx.xx | host: test | provider: netcup | ip: ipv4 or ipv6] to use yy.207.1yy.3xx
2022/10/03 11:12:24 ERROR logging in: session received is empty

I am currently bussy. I can look into this in 1-2 weeks.
The response from the login endpoint of the api looks like this by manually making the request (dummy data):

{
  "serverrequestid": "3FWpNX0RgYY0RNI5=",
  "clientrequestid": "",
  "action": "login",
  "status": "success",
  "statuscode": 2000,
  "shortmessage": "Login successful",
  "longmessage": "Session has been created successful.",
  "responsedata": {
    "apisessionid": "NTg5MzI0MDDDN3Rmc3ZBbW9IYVRqR2JYYYYCUm1RSTUzMVUXXX"
  }
}

There is probably something wrong with handling the response data.

I also tested, that the login does work (commonResponse for login request does contain "ShortMessage" : "Login successfull")

@qdm12
Copy link
Owner

qdm12 commented Oct 4, 2022

Thanks for the feedback!

Indeed, fixed in Azorimor@abf0a12 and re-pushed the image with tag :netcup.

@qdm12
Copy link
Owner

qdm12 commented Oct 11, 2022

Hey @Azorimor does the newer image work? I have a report from someone that the netcup log shows it works, but it actually fails and the returned IP address is the older one, not the newer one. Did you experience the same problem?

@scrapix
Copy link

scrapix commented Dec 4, 2022

Hey @qdm12 first, thank you lots for this great piece of work!
I have tried to use the docker container with the default compose file and received an error log.

image: qmcgaw/ddns-updater:netcup

2022/12/04 23:00:24 ERROR mismatching IP address received: expected ${0.0.0.0.-current-IP} but received ${1.2.1.2.-IP-savedAtNetcupCurrently}

log-cleaned.log

Following project might have a solution https://github.com/Hentra/dyndns-netcup-go

@qdm12
Copy link
Owner

qdm12 commented Dec 6, 2022

Hi @scrapix thanks for the feedback.
Does it actually update it, even though it logs an error?

I saw in the update response data from your logs there are two records:

{"id":"${ID}","hostname":"@","type":"A","priority":"0","destination":"${0.0.0.0.-current-IP}","deleterecord":false,"state":"unknown"},
{"id":"${ID}","hostname":"@","type":"A","priority":"0","destination":"${1.2.1.2.-IP-savedAtNetcupCurrently}","deleterecord":false,"state":"yes"},

So it looks like it's adding the record twice, but with the new one in unknown state???

@scrapix
Copy link

scrapix commented Dec 6, 2022

@qdm12 it did not update the records :/ the other project I've mentioned actually updates the records at (and can create new ones). While not supporting many different providers.

@qdm12
Copy link
Owner

qdm12 commented Dec 7, 2022

I believe I spotted a few JSON decoding programming errors (most likely in my refactor of this branch, so 100% my bad). These are fixed in f4714b6 largely thanks to the logs you attached! 👍

I re-pushed image qmcgaw/ddns-updater:netcup (amd64 only)

@scrapix
Copy link

scrapix commented Dec 9, 2022

I'll try asap again!

@qdm12 qdm12 mentioned this pull request Apr 13, 2023
@qdm12 qdm12 changed the title Provider netcup feat(provider): add netcup Apr 13, 2023
@qdm12 qdm12 mentioned this pull request Jun 12, 2023
@qdm12
Copy link
Owner

qdm12 commented Jun 12, 2023

Rebased it on the master branch

@Assaro
Copy link

Assaro commented Jun 12, 2023

I have been able to test it and it works just fine


========================================
========================================
============= ddns-updater =============
========================================
=========== Made with ❤️ by ============
======= https://github.com/qdm12 =======
========================================
========================================

Running version unknown built on an unknown date (commit unknown)

📣 Environment variables parsing was changed on 12 June, please report any issue you might have

🔧 Need help? https://github.com/qdm12/ddns-updater/discussions/new
🐛 Bug? https://github.com/qdm12/ddns-updater/issues/new
✨ New feature? https://github.com/qdm12/ddns-updater/issues/new
☕ Discussion? https://github.com/qdm12/ddns-updater/discussions/new
💻 Email? quentin.mcgaw@gmail.com
💰 Help me? https://www.paypal.me/qmcgaw https://github.com/sponsors/qdm12
2023-06-12T20:31:03Z INFO reading JSON config from file /updater/data/config.json
2023-06-12T20:31:03Z INFO Found single setting to update record
2023-06-12T20:31:04Z INFO Reading history from database: domain redacted.com host ddns
2023-06-12T20:31:04Z INFO [healthcheck server] listening on 127.0.0.1:9999
2023-06-12T20:31:04Z INFO [backup] disabled
2023-06-12T20:31:04Z INFO [http server] listening on :8000
2023-06-12T20:31:04Z WARN obtaining ipv4 or ipv6 address: try 1 of 3: no IP address found: from "https://diagnostic.opendns.com/myip"
2023-06-12T20:31:04Z INFO obtaining ipv4 or ipv6 address: succeeded after 2 tries
2023-06-12T20:31:04Z INFO IP address of ddns.redacted.com is 46.38.243.234 and your IP address is 1.1.1.1
2023-06-12T20:31:04Z INFO Updating record [domain: redacted.com | host: ddns | provider: netcup | ip: ipv4 or ipv6] to use 1.1.1.1

The IP and domain have been changed for privacy reasons

@qdm12
Copy link
Owner

qdm12 commented Jun 12, 2023

Awesome thanks @Assaro I'll rebase and merge it tomorrow!

@qdm12 qdm12 merged commit 09eb9e7 into qdm12:master Jun 14, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants