Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
README upd
  • Loading branch information
Kirill committed Aug 23, 2021
1 parent b574500 commit cf7f199
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
+ [Connection test failed or error returned](#connection-test-failed-or-error-returned)
+ [Cloudflare no longer listed as a DDNS provider after a DSM update](#cloudflare-no-longer-listed-as-a-ddns-provider-after-a-dsm-update)
* [Default Cloudflare ports](#default-cloudflare-ports)
* [Debug script](#debug)


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

## Debug

You can run this script directly to see output logs

* SSH into your Synology system

* Run this command:

```
/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"
```

* Check output logs

## Credits

<small><i><a href='http://ecotrust-canada.github.io/markdown-toc/'>Table of contents generated with markdown-toc</a></i></small>
Expand Down
13 changes: 8 additions & 5 deletions cloudflare.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ function __construct($argv)
*
* @return bool
*/
function isCFTokenValid() {
function isCFTokenValid()
{
$res = $this->callCFapi("GET", "client/v4/user/tokens/verify");
if ($res['success']) {
return true;
Expand All @@ -118,7 +119,7 @@ function makeUpdateDNS()
$json = $this->callCFapi("PATCH", "client/v4/zones/${zoneId}/dns_records/${recordId}", $dnsRecord);

if (!$json['success']) {
echo Output::BAD_HTTP_REQUEST
echo Output::BAD_HTTP_REQUEST;
exit();
}
}
Expand All @@ -128,7 +129,7 @@ function makeUpdateDNS()

function badParam($msg = '')
{
echo (strlen($msg) > 0) ? $msg : echo Output::BAD_PARAMS;
echo (strlen($msg) > 0) ? $msg : Output::BAD_PARAMS;
exit();
}

Expand Down Expand Up @@ -207,7 +208,8 @@ function setZones()
* Find hostname for full domain name
* example: domain.com.uk --> vpn.domain.com.uk
*/
function isZonesContainFullname($arZones, $fullname){
function isZonesContainFullname($arZones, $fullname)
{
$res = [];
foreach($arZones as $arZone) {
if (strpos($fullname, $arZone['hostname']) !== false) {
Expand Down Expand Up @@ -255,7 +257,8 @@ function setRecord($arHostData, string $ip, $type)
/**
* Call CloudFlare v4 API @link https://api.cloudflare.com/#getting-started-endpoints
*/
function callCFapi($method, $path, $data = []) {
function callCFapi($method, $path, $data = [])
{
$options = [
CURLOPT_URL => self::API_URL . '/' . $path,
CURLOPT_HTTPHEADER => ["Authorization: Bearer $this->apiKey", "Content-Type: application/json"],
Expand Down
Binary file modified example3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit cf7f199

Please sign in to comment.