cloudflare-ddns-sync 2.0.5 → 2.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/README.md +34 -32
- package/dist/contracts/Callbacks.d.ts +2 -2
- package/dist/contracts/DomainRecordList.d.ts +1 -1
- package/dist/contracts/Record.d.ts +1 -1
- package/dist/contracts/ZoneMap.d.ts +1 -1
- package/dist/contracts/cloudflare/RecordData.d.ts +2 -2
- package/dist/contracts/cloudflare/ZoneData.d.ts +1 -1
- package/dist/contracts/cloudflare/index.js +5 -1
- package/dist/contracts/index.js +5 -1
- package/dist/index.js +5 -1
- package/dist/lib/cron.js +1 -1
- package/dist/lib/ip-utils.js +5 -1
- package/package.json +15 -16
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -5,12 +5,11 @@
|
|
|
5
5
|
[](https://www.npmjs.com/package/cloudflare-ddns-sync)
|
|
6
6
|
[](https://www.npmjs.com/package/cloudflare-ddns-sync-cli)
|
|
7
7
|
|
|
8
|
-
|
|
9
8
|
## Overview
|
|
10
9
|
|
|
11
10
|
Cloudflare-DDNS-Sync is a simple module that updates Cloudflare DNS records.
|
|
12
11
|
|
|
13
|
-
For a more detailed overview, have a look at the [Documentation](https://cddnss.knaup.
|
|
12
|
+
For a more detailed overview, have a look at the [Documentation](https://cddnss.knaup.pw/)
|
|
14
13
|
|
|
15
14
|
You may also have a look at the **official** [CLI version](https://www.npmjs.com/package/cloudflare-ddns-sync-cli) of Cloudflare-DDNS-Sync.
|
|
16
15
|
|
|
@@ -18,7 +17,7 @@ You may also have a look at the **official** [CLI version](https://www.npmjs.com
|
|
|
18
17
|
|
|
19
18
|
### Prerequisites
|
|
20
19
|
|
|
21
|
-
- Node
|
|
20
|
+
- Node (14, 16, 18)
|
|
22
21
|
- Cloudflare Account
|
|
23
22
|
|
|
24
23
|
### Installation
|
|
@@ -34,27 +33,27 @@ in your project folder.
|
|
|
34
33
|
## Usage
|
|
35
34
|
|
|
36
35
|
> Hint: If a record is not existing, CDS will automatically create it when
|
|
37
|
-
syncing.
|
|
36
|
+
> syncing.
|
|
38
37
|
|
|
39
38
|
### Javascript Example
|
|
40
39
|
|
|
41
40
|
```javascript
|
|
42
|
-
const Cddnss = require(
|
|
41
|
+
const Cddnss = require("cloudflare-ddns-sync").default;
|
|
43
42
|
|
|
44
|
-
const cddnss = new Cddnss(
|
|
43
|
+
const cddnss = new Cddnss("your@email.com", "<your-cloudflare-api-key>");
|
|
45
44
|
|
|
46
45
|
const records = [
|
|
47
46
|
{
|
|
48
|
-
name:
|
|
49
|
-
type:
|
|
50
|
-
proxied: true,
|
|
51
|
-
ttl: 1,
|
|
52
|
-
priority: 0,
|
|
53
|
-
content:
|
|
47
|
+
name: "test-1.domain.com",
|
|
48
|
+
type: "A", // optional
|
|
49
|
+
proxied: true, // optional
|
|
50
|
+
ttl: 1, // optional
|
|
51
|
+
priority: 0, // optional
|
|
52
|
+
content: "1.2.3.4", // optional
|
|
54
53
|
},
|
|
55
54
|
{
|
|
56
|
-
name: "test-2.domain.com"
|
|
57
|
-
}
|
|
55
|
+
name: "test-2.domain.com",
|
|
56
|
+
},
|
|
58
57
|
];
|
|
59
58
|
|
|
60
59
|
cddnss.syncRecords(records).then((result) => {
|
|
@@ -65,21 +64,24 @@ cddnss.syncRecords(records).then((result) => {
|
|
|
65
64
|
### Typescript Example
|
|
66
65
|
|
|
67
66
|
```typescript
|
|
68
|
-
import Cddnss, {Record, RecordData} from
|
|
67
|
+
import Cddnss, { Record, RecordData } from "cloudflare-ddns-sync";
|
|
69
68
|
|
|
70
|
-
const cddnss: Cddnss = new Cddnss(
|
|
69
|
+
const cddnss: Cddnss = new Cddnss(
|
|
70
|
+
"your@email.com",
|
|
71
|
+
"<your-cloudflare-api-key>"
|
|
72
|
+
);
|
|
71
73
|
|
|
72
74
|
const records: Array<Record> = [
|
|
73
75
|
{
|
|
74
|
-
name:
|
|
75
|
-
type:
|
|
76
|
-
proxied: true,
|
|
77
|
-
ttl: 1,
|
|
78
|
-
priority: 0,
|
|
79
|
-
content:
|
|
76
|
+
name: "test-1.yourdomain.com",
|
|
77
|
+
type: "A", // optional
|
|
78
|
+
proxied: true, // optional
|
|
79
|
+
ttl: 1, // optional
|
|
80
|
+
priority: 0, // optional
|
|
81
|
+
content: "1.2.3.4", // optional
|
|
80
82
|
},
|
|
81
83
|
{
|
|
82
|
-
name: "test-2.yourdomain.com"
|
|
84
|
+
name: "test-2.yourdomain.com",
|
|
83
85
|
},
|
|
84
86
|
];
|
|
85
87
|
|
|
@@ -108,18 +110,18 @@ Cron expressions have the following syntax:
|
|
|
108
110
|
|
|
109
111
|
- getIp(): Promise\<string\>
|
|
110
112
|
- getIpv6(): Promise\<string\>
|
|
111
|
-
- getRecordDataForDomain(domain: string): Promise\<Array\<[RecordData](https://cddnss.knaup.
|
|
112
|
-
- getRecordDataForDomains(domains: Array\<string\>): Promise\<[DomainRecordList](https://cddnss.knaup.
|
|
113
|
-
- getRecordDataForRecord(record: [Record](https://cddnss.knaup.
|
|
114
|
-
- getRecordDataForRecords(records: Array\<[Record](https://cddnss.knaup.
|
|
113
|
+
- getRecordDataForDomain(domain: string): Promise\<Array\<[RecordData](https://cddnss.knaup.pw/types/recorddata)\>\>
|
|
114
|
+
- getRecordDataForDomains(domains: Array\<string\>): Promise\<[DomainRecordList](https://cddnss.knaup.pw/types/domainrecordlist)\>
|
|
115
|
+
- getRecordDataForRecord(record: [Record](https://cddnss.knaup.pw/types/record)): Promise\<[RecordData](https://cddnss.knaup.pw/types/recorddata)\>
|
|
116
|
+
- getRecordDataForRecords(records: Array\<[Record](https://cddnss.knaup.pw/types/record)\>): Promise\<Array\<[RecordData](https://cddnss.knaup.pw/types/recorddata)\>\>
|
|
115
117
|
- removeRecord(recordName: string, recordType?: string): Promise\<void\>
|
|
116
118
|
- stopSyncOnIpChange(changeListenerId: string): void
|
|
117
|
-
- syncByCronTime(cronExpression: string, records: Array\<[Record](https://cddnss.knaup.
|
|
118
|
-
- syncOnIpChange(records: Array\<[Record](https://cddnss.knaup.
|
|
119
|
-
- syncRecord(record: [Record](https://cddnss.knaup.
|
|
120
|
-
- syncRecords(records: Array\<[Record](https://cddnss.knaup.
|
|
119
|
+
- syncByCronTime(cronExpression: string, records: Array\<[Record](https://cddnss.knaup.pw/types/recorddata)\>, callback: [MultiSyncCallback](https://cddnss.knaup.pw/types/multisynccallback), ip?: string): [ScheduledTask](https://www.npmjs.com/package/node-cron#scheduledtask-methods)
|
|
120
|
+
- syncOnIpChange(records: Array\<[Record](https://cddnss.knaup.pw/types/record)\>, callback: multisynccallback): Promise\<string\>
|
|
121
|
+
- syncRecord(record: [Record](https://cddnss.knaup.pw/types/record), ip?: string): Promise\<[RecordData](https://cddnss.knaup.pw/types/recorddata)\>
|
|
122
|
+
- syncRecords(records: Array\<[Record](https://cddnss.knaup.pw/types/record)\>, ip?: string): Promise\<Array\<[RecordData](https://cddnss.knaup.pw/types/recorddata)\>\>
|
|
121
123
|
|
|
122
|
-
For a more detailed view, have a look at the [Documentation](https://cddnss.knaup.
|
|
124
|
+
For a more detailed view, have a look at the [Documentation](https://cddnss.knaup.pw/)
|
|
123
125
|
|
|
124
126
|
## Get Your Cloudflare API Key
|
|
125
127
|
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { RecordData } from './index';
|
|
2
|
-
export
|
|
3
|
-
export
|
|
2
|
+
export type SingleSyncCallback = (syncResult: RecordData) => void;
|
|
3
|
+
export type MultiSyncCallback = (syncResult: Array<RecordData>) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type ZoneMap = Map<string, string>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type RecordData = {
|
|
2
2
|
id: string;
|
|
3
3
|
type: string;
|
|
4
4
|
name: string;
|
|
@@ -13,7 +13,7 @@ export declare type RecordData = {
|
|
|
13
13
|
created_on: string;
|
|
14
14
|
meta: RecordMetaData;
|
|
15
15
|
};
|
|
16
|
-
export
|
|
16
|
+
export type RecordMetaData = {
|
|
17
17
|
auto_added: boolean;
|
|
18
18
|
managed_by_apps: boolean;
|
|
19
19
|
managed_by_argo_tunnel: boolean;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/dist/contracts/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/dist/lib/cron.js
CHANGED
|
@@ -9,7 +9,7 @@ class Cron {
|
|
|
9
9
|
const cronExpressionIsInvalid = !this.isValid(cronExpression);
|
|
10
10
|
if (cronExpressionIsInvalid) {
|
|
11
11
|
// eslint-disable-next-line max-len
|
|
12
|
-
throw new Error(`'${cronExpression}' is not a valid cron expression.\nHere you can see how cron expressions work: https://cddnss.knaup.
|
|
12
|
+
throw new Error(`'${cronExpression}' is not a valid cron expression.\nHere you can see how cron expressions work: https://cddnss.knaup.pw/cron-expression-syntax`);
|
|
13
13
|
}
|
|
14
14
|
return node_cron_1.default.schedule(cronExpression, () => {
|
|
15
15
|
callback();
|
package/dist/lib/ip-utils.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cloudflare-ddns-sync",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.6",
|
|
4
4
|
"description": "A simple module to update DNS records on Cloudflare whenever you want",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"author": "Steffen Knaup <SteffenKnaup@hotmail.de>",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"dyndns",
|
|
14
14
|
"sync"
|
|
15
15
|
],
|
|
16
|
-
"homepage": "https://cddnss.knaup.
|
|
16
|
+
"homepage": "https://cddnss.knaup.pw/",
|
|
17
17
|
"repository": {
|
|
18
18
|
"type": "git",
|
|
19
19
|
"url": "git://github.com:Steffen982/cloudflare-ddns-sync.git"
|
|
@@ -29,25 +29,24 @@
|
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"cloudflare": "2.9.1",
|
|
32
|
-
"node-cron": "3.0.
|
|
32
|
+
"node-cron": "3.0.2",
|
|
33
33
|
"parse-domain": "4.1.0",
|
|
34
34
|
"public-ip": "4.0.4",
|
|
35
35
|
"what-is-my-ip-address": "1.0.3"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@types/chai": "4.3.
|
|
38
|
+
"@types/chai": "4.3.4",
|
|
39
39
|
"@types/minimist": "1.2.2",
|
|
40
|
-
"@types/mocha": "9.
|
|
41
|
-
"@types/node": "
|
|
42
|
-
"@types/node-cron": "3.0.
|
|
43
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
44
|
-
"@typescript-eslint/parser": "5.
|
|
45
|
-
"c8": "7.
|
|
46
|
-
"chai": "4.3.
|
|
47
|
-
"eslint": "8.
|
|
48
|
-
"minimist": "1.2.
|
|
49
|
-
"mocha": "9.
|
|
50
|
-
"
|
|
51
|
-
"typescript": "4.5.4"
|
|
40
|
+
"@types/mocha": "9.1.1",
|
|
41
|
+
"@types/node": "18.11.17",
|
|
42
|
+
"@types/node-cron": "3.0.6",
|
|
43
|
+
"@typescript-eslint/eslint-plugin": "5.46.1",
|
|
44
|
+
"@typescript-eslint/parser": "5.46.1",
|
|
45
|
+
"c8": "7.12.0",
|
|
46
|
+
"chai": "4.3.7",
|
|
47
|
+
"eslint": "8.30.0",
|
|
48
|
+
"minimist": "1.2.7",
|
|
49
|
+
"mocha": "9.2.2",
|
|
50
|
+
"typescript": "4.9.4"
|
|
52
51
|
}
|
|
53
52
|
}
|