-
Notifications
You must be signed in to change notification settings - Fork 759
Feature/hetzner dns provider #5091
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
Open
ArcanConsulting
wants to merge
12
commits into
opnsense:master
Choose a base branch
from
ArcanConsulting:feature/hetzner-dns-provider
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
53f5091
ddclient: add Hetzner DNS provider
ArcanConsulting 46f441c
fix: use DELETE+POST workaround for Cloud API PUT bug
ArcanConsulting 67ac72c
Initial release v2.0.0
ArcanConsulting 9d25ebc
New plugin for comprehensive Hetzner DNS management in OPNsense.
ArcanConsulting a8faa61
Update Hetzner Cloud DNS plugin
ArcanConsulting c331cd1
- Reorganize repository for multi-plugin structure
ArcanConsulting 27e7f74
Fix gateway auto-selection to use sorted order instead of exact prior…
ArcanConsulting f2de5e7
Improve TXT record value display with smart formatting
ArcanConsulting e823ff1
## Changelog
ArcanConsulting 47ece7e
Add pagination to list_zones() for accounts with >25 zones
ArcanConsulting 23a6947
Merge branch 'master' into feature/hetzner-dns-provider
ArcanConsulting e36cc15
Hetzner Cloud API fixes and performance improvements
ArcanConsulting File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| PLUGIN_NAME= hclouddns | ||
| PLUGIN_VERSION= 2.0.0 | ||
| PLUGIN_COMMENT= Hetzner Cloud DNS Management with Multi-Zone and Failover | ||
| PLUGIN_MAINTAINER= info@arcan-it.de | ||
| PLUGIN_WWW= https://github.com/ArcanConsulting/os-hclouddns | ||
| PLUGIN_DEPENDS= python311 | ||
|
|
||
| .include "../../Mk/plugins.mk" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| Hetzner Cloud DNS Management Plugin for OPNsense | ||
|
|
||
| Features: | ||
| - Multi-account support (multiple Hetzner API tokens) | ||
| - Multi-zone DNS management | ||
| - Dynamic DNS with automatic failover between WAN interfaces | ||
| - IPv4 and IPv6 (Dual-Stack) support | ||
| - DNS record templates for quick setup | ||
| - Direct DNS management (view/edit/delete records) | ||
| - Change history with undo functionality | ||
| - Notifications (Email, Webhook, Ntfy) | ||
| - Configuration backup/restore | ||
|
|
||
| Supports both Hetzner Cloud API and legacy DNS Console API. | ||
|
|
||
| WWW: https://github.com/ArcanConsulting/os-hclouddns |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| etc/inc/plugins.inc.d/hclouddns.inc | ||
| etc/rc.syshook.d/monitor/50-hclouddns | ||
| opnsense/mvc/app/controllers/OPNsense/HCloudDNS/Api/AccountsController.php | ||
| opnsense/mvc/app/controllers/OPNsense/HCloudDNS/Api/EntriesController.php | ||
| opnsense/mvc/app/controllers/OPNsense/HCloudDNS/Api/GatewaysController.php | ||
| opnsense/mvc/app/controllers/OPNsense/HCloudDNS/Api/HetznerController.php | ||
| opnsense/mvc/app/controllers/OPNsense/HCloudDNS/Api/HistoryController.php | ||
| opnsense/mvc/app/controllers/OPNsense/HCloudDNS/Api/ServiceController.php | ||
| opnsense/mvc/app/controllers/OPNsense/HCloudDNS/Api/SettingsController.php | ||
| opnsense/mvc/app/controllers/OPNsense/HCloudDNS/DnsController.php | ||
| opnsense/mvc/app/controllers/OPNsense/HCloudDNS/forms/dialogAccount.xml | ||
| opnsense/mvc/app/controllers/OPNsense/HCloudDNS/forms/dialogEntry.xml | ||
| opnsense/mvc/app/controllers/OPNsense/HCloudDNS/forms/dialogGateway.xml | ||
| opnsense/mvc/app/controllers/OPNsense/HCloudDNS/forms/dialogScheduled.xml | ||
| opnsense/mvc/app/controllers/OPNsense/HCloudDNS/forms/failover.xml | ||
| opnsense/mvc/app/controllers/OPNsense/HCloudDNS/forms/general.xml | ||
| opnsense/mvc/app/controllers/OPNsense/HCloudDNS/IndexController.php | ||
| opnsense/mvc/app/controllers/OPNsense/HCloudDNS/SettingsController.php | ||
| opnsense/mvc/app/models/OPNsense/HCloudDNS/ACL/ACL.xml | ||
| opnsense/mvc/app/models/OPNsense/HCloudDNS/HCloudDNS.php | ||
| opnsense/mvc/app/models/OPNsense/HCloudDNS/HCloudDNS.xml | ||
| opnsense/mvc/app/models/OPNsense/HCloudDNS/Menu/Menu.xml | ||
| opnsense/mvc/app/views/OPNsense/HCloudDNS/accounts.volt | ||
| opnsense/mvc/app/views/OPNsense/HCloudDNS/dns.volt | ||
| opnsense/mvc/app/views/OPNsense/HCloudDNS/entries.volt | ||
| opnsense/mvc/app/views/OPNsense/HCloudDNS/gateways.volt | ||
| opnsense/mvc/app/views/OPNsense/HCloudDNS/general.volt | ||
| opnsense/mvc/app/views/OPNsense/HCloudDNS/index.volt | ||
| opnsense/mvc/app/views/OPNsense/HCloudDNS/settings.volt | ||
| opnsense/mvc/app/views/OPNsense/HCloudDNS/status.volt | ||
| opnsense/mvc/app/views/OPNsense/HCloudDNS/zones.volt | ||
| opnsense/scripts/ddclient/lib/account/hetzner_cloud.py | ||
| opnsense/scripts/ddclient/lib/account/hetzner_legacy.py | ||
| opnsense/scripts/HCloudDNS/create_record.py | ||
| opnsense/scripts/HCloudDNS/delete_record.py | ||
| opnsense/scripts/HCloudDNS/gateway_health.py | ||
| opnsense/scripts/HCloudDNS/get_hetzner_ip.py | ||
| opnsense/scripts/HCloudDNS/hcloud_api.py | ||
| opnsense/scripts/HCloudDNS/lib/__init__.py | ||
| opnsense/scripts/HCloudDNS/lib/hetzner_api.py | ||
| opnsense/scripts/HCloudDNS/list_records.py | ||
| opnsense/scripts/HCloudDNS/list_zones.py | ||
| opnsense/scripts/HCloudDNS/refresh_status.py | ||
| opnsense/scripts/HCloudDNS/simulate_failover.py | ||
| opnsense/scripts/HCloudDNS/status.py | ||
| opnsense/scripts/HCloudDNS/test_notify.py | ||
| opnsense/scripts/HCloudDNS/update_record.py | ||
| opnsense/scripts/HCloudDNS/update_records.py | ||
| opnsense/scripts/HCloudDNS/update_records_v2.py | ||
| opnsense/scripts/HCloudDNS/validate_token.py | ||
| opnsense/service/conf/actions.d/actions_hclouddns.conf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,135 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * Copyright (c) 2025 Arcan Consulting (www.arcan-it.de) | ||
| * All rights reserved. | ||
| * | ||
| * Redistribution and use in source and binary forms, with or without | ||
| * modification, are permitted provided that the following conditions are met: | ||
| * | ||
| * 1. Redistributions of source code must retain the above copyright notice, | ||
| * this list of conditions and the following disclaimer. | ||
| * | ||
| * 2. Redistributions in binary form must reproduce the above copyright | ||
| * notice, this list of conditions and the following disclaimer in the | ||
| * documentation and/or other materials provided with the distribution. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, | ||
| * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY | ||
| * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
| * AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, | ||
| * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
| * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
| * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
| * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
| * POSSIBILITY OF SUCH DAMAGE. | ||
| */ | ||
|
|
||
| /** | ||
| * Register HCloudDNS services | ||
| * @return array | ||
| */ | ||
| function hclouddns_services() | ||
| { | ||
| $services = array(); | ||
|
|
||
| $mdl = new \OPNsense\HCloudDNS\HCloudDNS(); | ||
| if ((string)$mdl->general->enabled == '1') { | ||
| $services[] = array( | ||
| 'description' => gettext('Hetzner Cloud Dynamic DNS'), | ||
| 'configd' => array( | ||
| 'restart' => array('hclouddns update'), | ||
| ), | ||
| 'name' => 'hclouddns', | ||
| ); | ||
| } | ||
|
|
||
| return $services; | ||
| } | ||
|
|
||
| /** | ||
| * Register cron jobs for HCloudDNS | ||
| * Only active when explicitly enabled - automatic triggers (gateway syshook, newwanip) | ||
| * handle most use cases without needing scheduled updates. | ||
| * @return array | ||
| */ | ||
| function hclouddns_cron() | ||
| { | ||
| $jobs = []; | ||
|
|
||
| $mdl = new \OPNsense\HCloudDNS\HCloudDNS(); | ||
| // Cron is only registered when both service AND cron are enabled | ||
| if ((string)$mdl->general->enabled == '1' && (string)$mdl->general->cronEnabled == '1') { | ||
| // Use cronInterval setting (in minutes) - cast to string first as model fields are objects | ||
| $minutes = intval((string)$mdl->general->cronInterval); | ||
| if (empty($minutes) || $minutes < 1) { | ||
| $minutes = 5; // Default 5 minutes | ||
| } | ||
| if ($minutes > 60) { | ||
| $minutes = 60; | ||
| } | ||
|
|
||
| // autocron format: [command, minute, hour, monthday, month, weekday] | ||
| $jobs[]['autocron'] = [ | ||
| '/usr/local/sbin/configctl hclouddns update', | ||
| "*/{$minutes}" | ||
| ]; | ||
| } | ||
|
|
||
| return $jobs; | ||
| } | ||
|
|
||
| /** | ||
| * Register plugin hooks - triggers on interface IP changes | ||
| * @return array | ||
| */ | ||
| function hclouddns_configure() | ||
| { | ||
| return [ | ||
| 'newwanip' => ['hclouddns_configure_do:2'], | ||
| ]; | ||
| } | ||
|
|
||
| /** | ||
| * Called when WAN IP changes - trigger DNS update | ||
| * @param bool $verbose | ||
| */ | ||
| function hclouddns_configure_do($verbose = false) | ||
| { | ||
| $mdl = new \OPNsense\HCloudDNS\HCloudDNS(); | ||
| if ((string)$mdl->general->enabled != '1') { | ||
| return; | ||
| } | ||
|
|
||
| service_log('Hetzner Cloud DDNS: Interface IP changed, updating DNS...', $verbose); | ||
|
|
||
| // Trigger update via configd | ||
| configd_run('hclouddns update'); | ||
|
|
||
| service_log("done.\n", $verbose); | ||
| } | ||
|
|
||
| /** | ||
| * Register syslog facility | ||
| * @return array | ||
| */ | ||
| function hclouddns_syslog() | ||
| { | ||
| $logfacilities = []; | ||
| $logfacilities['hclouddns'] = ['facility' => ['hclouddns']]; | ||
| return $logfacilities; | ||
| } | ||
|
|
||
| /** | ||
| * XML-RPC sync handler | ||
| * @return array | ||
| */ | ||
| function hclouddns_xmlrpc_sync() | ||
| { | ||
| $result = array(); | ||
| $result['id'] = 'hclouddns'; | ||
| $result['section'] = 'OPNsense.HCloudDNS'; | ||
| $result['description'] = gettext('Hetzner Cloud Dynamic DNS'); | ||
| return array($result); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| #!/bin/sh | ||
|
|
||
| # | ||
| # Copyright (c) 2025 Arcan Consulting (www.arcan-it.de) | ||
| # All rights reserved. | ||
| # | ||
| # Redistribution and use in source and binary forms, with or without | ||
| # modification, are permitted provided that the following conditions are met: | ||
| # | ||
| # 1. Redistributions of source code must retain the above copyright notice, | ||
| # this list of conditions and the following disclaimer. | ||
| # | ||
| # 2. Redistributions in binary form must reproduce the above copyright | ||
| # notice, this list of conditions and the following disclaimer in the | ||
| # documentation and/or other materials provided with the distribution. | ||
| # | ||
| # THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, | ||
| # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY | ||
| # AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
| # AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, | ||
| # OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
| # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
| # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
| # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
| # POSSIBILITY OF SUCH DAMAGE. | ||
| # | ||
|
|
||
| # HCloudDNS Gateway Monitor Syshook | ||
| # Called by rc.routing_configure when gateway status changes | ||
| # Arguments: $1 = comma-separated list of gateway names that triggered the alarm | ||
|
|
||
| GATEWAYS="${1}" | ||
|
|
||
| # Log the gateway alarm | ||
| logger -t hclouddns "Gateway alarm triggered for: ${GATEWAYS}" | ||
|
|
||
| # Trigger async DNS update via configd (non-blocking) | ||
| # The -d flag runs the command detached so we don't block the routing reconfigure | ||
| /usr/local/sbin/configctl -d hclouddns update | ||
|
|
||
| exit 0 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Updating records cannot be done with
PUT /.../rrsets/..., you must use one of the following endpoint:Also note, that those endpoint return "Actions", which describe async tasks that should be waited upon.