ownDynDNS - Self-hosted dynamic DNS php script for Speedport Smart 4 and netcup DNS API

git clone git://git.bcharge.de/ownDynDNS.git

About | Log | Files | Refs | License

commit 0365041406d0d3cc884eeaecc1c1b24b67cbcd78
parent 1e80e61044506296c9e6e7e30bc00a1169153dea
Author: Bakar Chargeishvili <bakar@bcharge.de>
Date:   Mon, 30 Dec 2024 13:13:30 +0100

Port repo for Speedport Smart 4

Diffstat:
MREADME.md | 30++++++++++--------------------
Anic/update.php | 59+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/Config.php | 5++---
Msrc/Handler.php | 3+--
Msrc/Payload.php | 3+--
Msrc/Soap.php | 7+++----
Dupdate.php | 32--------------------------------
7 files changed, 76 insertions(+), 63 deletions(-)

diff --git a/README.md b/README.md @@ -1,7 +1,9 @@ # ownDynDNS -Self-hosted dynamic DNS php script to update netcup DNS API from Router like AVM FRITZ!Box +This is a fork of [ownDynDNS](https://github.com/fernwerker/ownDynDNS) +a self-hosted dynamic DNS php script to update netcup DNS API modified to work +with dyndns feature Speedport Smart 4 router. -## Authors +## Authors of original repo * Felix Kretschmer [@fernwerker](https://github.com/fernwerker) * Philipp Tempel [@philipptempel](https://github.com/philipptempel) * Branko Wilhelm [@b2un0](https://github.com/b2un0) @@ -16,29 +18,17 @@ Self-hosted dynamic DNS php script to update netcup DNS API from Router like AVM * `apiPassword` -> API password which is generated in netcup CCP * `customerId` -> your netcup Customer ID * `debug` -> true|false enables debug mode and generates output of update.php (normal operation has no output) - -* Create each host record in your netcup CCP (DNS settings) before using the script. The script does not create any missing records. -### AVM FRITZ!Box Settings -* Go to "Internet" -> "Freigaben" -> "DynDNS" -* Choose "Benutzerdefiniert" -* Update-URL: `https://<url of your webspace>/update.php?user=<username>&password=<pass>&ipv4=<ipaddr>&ipv6=<ip6addr>&domain=<domain>` - * only the url needs to be adjusted, the rest is automatically filled by your AVM FRITZ!Box - * http or https is possible if valid SSL certificate (e.g. Let's Encrypt) -* Single Domain: - * Domainname: `<host record that is supposed to be updated>` -* Multiple Domains: - * Domainname: `<first host record that is supposed to be updated>,<second host record that is supposed to be updated>,....` -* Username: `<username as defined in .env file>` -* Password: `<password as definied in .env file>` +* Create each host record in your netcup CCP (DNS settings) before using the script. The script does not create any missing records. -# run as cronjob on a **nix based device -* see [examples](./examples) +### Router Settings +Will follow... ## References * DNS API Documentation: https://ccp.netcup.net/run/webservice/servers/endpoint.php * Source of dnsapi.php: https://ccp.netcup.net/run/webservice/servers/endpoint.php?PHPSOAPCLIENT ## License -Published under GNU General Public License v3.0 -&copy; Felix Kretschmer, 2021 +Published under GNU General Public License v3.0 +Originally by Felix Kretschmer, 2021 +Modified by Bakar Chargeishvili, 2024 diff --git a/nic/update.php b/nic/update.php @@ -0,0 +1,59 @@ +<?php + +error_reporting(-1); +ini_set('display_errors', 1); +ini_set('html_errors', 0); + +header('Content-Type: text/plain; charset=utf-8'); + +require_once __DIR__ . '/../src/Soap.php'; +require_once __DIR__ . '/../src/Config.php'; +require_once __DIR__ . '/../src/Payload.php'; +require_once __DIR__ . '/../src/Handler.php'; + +if (!file_exists('../.env')) { + throw new RuntimeException('.env file missing'); +} + +$config = parse_ini_file('../.env', false, INI_SCANNER_TYPED); + +// Initialize the $request array +$request = []; + +// Get auth info +$auth_user = $_SERVER['PHP_AUTH_USER'] ?? null; +$auth_pw = $_SERVER['PHP_AUTH_PW'] ?? null; + +// Populate the $request array +$request['user'] = $auth_user ?: 'Not provided'; +$request['password'] = $auth_pw ?: 'Not provided'; +$request['domain'] = $_GET['hostname'] ?? 'Not provided'; + +// Handle IP addresses +if (isset($_GET['myip'])) { + $ips = explode(',', $_GET['myip']); + if (count($ips) >= 2) { + $request['ipv6'] = $ips[0]; + $request['ipv4'] = $ips[1]; + } elseif (count($ips) == 1) { + // If only one IP is provided, assume it's IPv4 + $request['ipv4'] = $ips[0]; + $request['ipv6'] = 'Not provided'; + } +} else { + $request['ipv6'] = 'Not provided'; + $request['ipv4'] = 'Not provided'; +} + +// If you want to include all GET parameters +//$request['get_params'] = $_GET; + +// If you want to include all SERVER variables +//$request['server_vars'] = $_SERVER; + +// Output the results +print_r($request); + +// Call the Handler with the current domain +(new netcup\DNS\API\Handler($config, $request))->doRun(); + diff --git a/src/Config.php b/src/Config.php @@ -116,7 +116,7 @@ final class Config { return $this->log; } - + /** * @return string */ @@ -132,4 +132,4 @@ final class Config { return $this->debug; } -} -\ No newline at end of file +} diff --git a/src/Handler.php b/src/Handler.php @@ -188,4 +188,4 @@ final class Handler return $this; } -} -\ No newline at end of file +} diff --git a/src/Payload.php b/src/Payload.php @@ -175,4 +175,4 @@ final class Payload { return $this->force; } -} -\ No newline at end of file +} diff --git a/src/Soap.php b/src/Soap.php @@ -7,8 +7,8 @@ use SoapClient; use SoapFault; /** - * Example client to access the domain reselling API. - * Please note: We cannot guarantee the function of this client. + * Example client to access the domain reselling API. + * Please note: We cannot guarantee the function of this client. * @service DomainWebserviceSoapClient */ class DomainWebserviceSoapClient{ @@ -1374,4 +1374,4 @@ class Dnszone{ * @var boolean */ public $dnssecstatus; -} -\ No newline at end of file +} diff --git a/update.php b/update.php @@ -1,32 +0,0 @@ -<?php - -error_reporting(-1); -ini_set('display_errors', 1); -ini_set('html_errors', 0); - -header('Content-Type: text/plain; charset=utf-8'); - -require_once __DIR__ . '/src/Soap.php'; -require_once __DIR__ . '/src/Config.php'; -require_once __DIR__ . '/src/Payload.php'; -require_once __DIR__ . '/src/Handler.php'; - -if (!file_exists('.env')) { - throw new RuntimeException('.env file missing'); -} - -$config = parse_ini_file('.env', false, INI_SCANNER_TYPED); - -// Get the domains from the URL parameter and split them from the comma separated string -$domains = explode(',', $_REQUEST['domain']); - -// Loop through each domain and call the Handler -foreach ($domains as $domain) { - // Create a new request object with the current domain - $request = $_REQUEST; - $request['domain'] = trim($domain); - - - // Call the Handler with the current domain - (new netcup\DNS\API\Handler($config, $request))->doRun(); -}