Skip to content

Commit cf7f199

Browse files
author
Kirill
committed
bug fixes
README upd
1 parent b574500 commit cf7f199

3 files changed

Lines changed: 23 additions & 5 deletions

File tree

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
+ [Connection test failed or error returned](#connection-test-failed-or-error-returned)
1111
+ [Cloudflare no longer listed as a DDNS provider after a DSM update](#cloudflare-no-longer-listed-as-a-ddns-provider-after-a-dsm-update)
1212
* [Default Cloudflare ports](#default-cloudflare-ports)
13+
* [Debug script](#debug)
1314

1415

1516
## What this script does
@@ -147,6 +148,20 @@ Source [Identifying network ports compatible with Cloudflare's proxy](https://su
147148
| 2086 | 8443 |
148149
| 2095 | |
149150

151+
## Debug
152+
153+
You can run this script directly to see output logs
154+
155+
* SSH into your Synology system
156+
157+
* Run this command:
158+
159+
```
160+
/usr/bin/php -d open_basedir=/usr/syno/bin/ddns -f /usr/syno/bin/ddns/cloudflare.php "" "your-CloudFlare-token" "your---domains---divided---by---dashes" "ip-address"
161+
```
162+
163+
* Check output logs
164+
150165
## Credits
151166

152167
<small><i><a href='http://ecotrust-canada.github.io/markdown-toc/'>Table of contents generated with markdown-toc</a></i></small>

cloudflare.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ function __construct($argv)
9494
*
9595
* @return bool
9696
*/
97-
function isCFTokenValid() {
97+
function isCFTokenValid()
98+
{
9899
$res = $this->callCFapi("GET", "client/v4/user/tokens/verify");
99100
if ($res['success']) {
100101
return true;
@@ -118,7 +119,7 @@ function makeUpdateDNS()
118119
$json = $this->callCFapi("PATCH", "client/v4/zones/${zoneId}/dns_records/${recordId}", $dnsRecord);
119120

120121
if (!$json['success']) {
121-
echo Output::BAD_HTTP_REQUEST
122+
echo Output::BAD_HTTP_REQUEST;
122123
exit();
123124
}
124125
}
@@ -128,7 +129,7 @@ function makeUpdateDNS()
128129

129130
function badParam($msg = '')
130131
{
131-
echo (strlen($msg) > 0) ? $msg : echo Output::BAD_PARAMS;
132+
echo (strlen($msg) > 0) ? $msg : Output::BAD_PARAMS;
132133
exit();
133134
}
134135

@@ -207,7 +208,8 @@ function setZones()
207208
* Find hostname for full domain name
208209
* example: domain.com.uk --> vpn.domain.com.uk
209210
*/
210-
function isZonesContainFullname($arZones, $fullname){
211+
function isZonesContainFullname($arZones, $fullname)
212+
{
211213
$res = [];
212214
foreach($arZones as $arZone) {
213215
if (strpos($fullname, $arZone['hostname']) !== false) {
@@ -255,7 +257,8 @@ function setRecord($arHostData, string $ip, $type)
255257
/**
256258
* Call CloudFlare v4 API @link https://api.cloudflare.com/#getting-started-endpoints
257259
*/
258-
function callCFapi($method, $path, $data = []) {
260+
function callCFapi($method, $path, $data = [])
261+
{
259262
$options = [
260263
CURLOPT_URL => self::API_URL . '/' . $path,
261264
CURLOPT_HTTPHEADER => ["Authorization: Bearer $this->apiKey", "Content-Type: application/json"],

example3.png

-31.3 KB
Loading

0 commit comments

Comments
 (0)