Constructor
new DynamicDNS(options)
Creates a new class with the given options.
Parameters:
| Name | Type | Description |
|---|---|---|
options |
object | See getDefaultOptions() for more details. |
- Source:
Members
(static, readonly) ApiResponses
This is a static array that contains a list of all the possible Google API responses to the update query. This is used to return the result to the caller.
currentIP :string
Holds the current set host name IP address.
Type:
- string
- Source:
lastGotHostIpAddress :number
Holds the time stamp the last time the host IP address was resolved. This is used in conjunction with hostIPAddressCacheExpires to
determine if we need to resolve the host IP address again. This is only used if useHostIPAddressCache is set to true.
Type:
- number
- Source:
options :DEDA-Google-DDNS.DynamicDNS.DefaultOptions
The class options as defined by getDefaultOptions() On initialization the constructor options parameters are merged with the default options.
Type:
- Source:
publicIP :string
Holds the current public IP address.
Type:
- string
- Source:
unresolvedHostNameError :number
Keeps track of the number of unresolved host name error. This is used to throw an exception if the maxUnresolvedHostNameFail is reached.
Type:
- number
- Source:
Methods
(static) getDefaultOptions() → {DEDA-Google-DDNS.DynamicDNS.DefaultOptions}
Returns a list of all possible options for this class with their default values.
- Source:
Returns:
Returns the component default options.
getCurrentIP() → {promise}
Uses the DNS protocol to resolve a IPv4 addresses (A records) for the hostname. NOTE: This can and may return multiple IP addresses as of this version only the first IP address is returned. This can be extended to support multiple IPs in the future.
- Source:
Returns:
Returns a promise that is resolved when the host IP address is resolve. Otherwise rejected with an error message.
- Type
- promise
getPublicIP() → {Promise}
Returns a promise with the public IP address of the current network hosting this application.
This method uses the HTTP GET url options.publicIpUrl to fetch the external IP address.
This method can be overwritten to extend or implement different methods of fetching the external/public IP.
- Source:
Returns:
Returns a promise that is resolved with the public IP if successful otherwise returns an error object {error: message}.
- Type
- Promise
parseResult(body, expectedIP, currentIP) → {DEDA-Google-DDNS.DynamicDNS.ApiResponse}
Pareses the Update request body and returns an object the represents the results.
Parameters:
| Name | Type | Description |
|---|---|---|
body |
string | The HTTP update response body as sent back from the request. |
expectedIP |
string | The expected IP address that the update should have changed to. This is used to validate the result. |
currentIP |
string | The current IP address of the dom before it was changed. This is used for message reporting only. |
Returns:
- Returns the response that response the given body.
(async) sync(forceopt) → {Promise}
Synchronizes the DNS IP address with the current public IP address. This method will get the current IP and the DNS IP and compare them. If they have changed then a request is sent to Google to update the current IP address. This is an asynchronous method that returns a promise when current status.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
force |
boolean |
<optional> |
false | Forces the update of the DNS regardless if it has changed or not. |
- Source:
Returns:
Returns a promise that is resolved with the status of the sync call.
- Type
- Promise
update(ip)
Sends a request using the Google Domain Dynamic DNS API to update the IP address to the current IP address.
Parameters:
| Name | Type | Description |
|---|---|---|
ip |
string | The IP address to update the Google Dynamic DNS. |
- Source:
validateIPv4(ip) → {boolean}
Checks if the given IP address is a valid IPv4 address.
Parameters:
| Name | Type | Description |
|---|---|---|
ip |
string | And IPv4 address to validate. |
- Source:
Returns:
Returns true if the given ip is valid otherwise returns false.
- Type
- boolean
Type Definitions
ApiResponse
Type:
- Object
Properties:
| Name | Type | Attributes | Description |
|---|---|---|---|
response |
string | The response code as defined by the Google API |
|
status |
string | This could either be 'success' or 'error' |
|
message |
string | A full human readable description of the response. This is provided for both the error and success status. |
|
ip |
string |
<optional> |
If the response is either 'good' or 'nochg' then the IP address is the IP that is currently set for the domain DNS. |
- Source:
DefaultOptions
Type:
- Object
Properties:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
username |
string | The dynamic DNS username. |
||
password |
string | The dynamic DNS password. |
||
hostname |
string | The dynamic DNS hostname. |
||
publicIpUrl |
string |
<optional> |
https://domains.google.com/checkip | The HTTP/HTTPS URL used to check the current public IP of the device. |
updateIpUrl |
string |
<optional> |
https://domains.google.com/nic/update?hostname=%HOSTNAME%&myip=%IPADDRESS% | The HTTPS URL of the Google DNS API update. |
userAgent |
string |
<optional> |
Nodejs google-ddns | The HTTP header User-Agent to send when updating the IP address. This is required by the Google Dynamic DNS API. |
failOnUnresolvedHostName |
boolean |
<optional> |
false | Indicates whether to fail or keep going during synchronizing if the current host name was not resolved. This typically happens if the domain was created and has not yet been applied or propagated. See TTL (Time-to-Live) for more information. Every though this can fail the update can sill be successful. |
maxUnresolvedHostNameFail |
number |
<optional> |
3 | This works in conjunction with failOnUnresolvedHostName to make sure we don't keep failing over and over with no error back reporting. |
useHostIPAddressCache |
boolean |
<optional> |
true | Indicates whether to cache and use the last resolved host IP address or resolve every-time. Generally speaking we don't need to resolve the host every-time since it will not change unless we change it. This saves having to do a DNS request every interval. Use the hostIPAddressCacheExpires to do a check every once in a while. |
hostIPAddressCacheExpires |
number |
<optional> |
3600 | If useHostIPAddressCache is set to true, this timer is used to force a host IP address checked/resolution every once in a while rather than never. The time is in seconds and defaults to every hour. |
debug |
boolean |
<optional> |
false | Set the debug mode on or off. The debug mode will write debug and status information to the console. |
- Source: