Options
All
  • Public
  • Public/Protected
  • All
Menu

cloudflare-dynamic-dns

Index

Variables

Private BASE_URL

BASE_URL: string = "https://api.cloudflare.com/client/v4"

Private URL

URL: string = "https://myexternalip.com/raw"

Functions

Private createDnsRecord

  • createDnsRecord(zoneId: string, dnsRecordName: string, ip: string, auth: Auth, callback: function): void
  • Creates a DNS record with the specified information.

    Parameters

    • zoneId: string

      The zone ID.

    • dnsRecordName: string

      The DNS record name.

    • ip: string

      The IP to update the record with.

    • auth: Auth

      CloudFlare API authentication information.

    • callback: function

      Callback function called with any error that occurred.

        • (error?: Error): void
        • Parameters

          • Optional error: Error

          Returns void

    Returns void

Private createOrUpdateDnsRecord

  • createOrUpdateDnsRecord(auth: Auth, ip: string, recordName: string, zoneName: string, callback: function): void
  • Creates or updates a CloudFlare DNS record, depending on whether it already exists. An error is returned if there are multiple DNS records for the specified record name.

    Parameters

    • auth: Auth

      CloudFlare API authentication information.

    • ip: string

      The IP to update the record with.

    • recordName: string

      The name of the record.

    • zoneName: string

      The name of the zone.

    • callback: function

      Callback function called with any error that occurred.

        • (error?: Error): void
        • Parameters

          • Optional error: Error

          Returns void

    Returns void

Private deleteDnsRecord

  • deleteDnsRecord(auth: Auth, recordName: string, zoneName: string, callback: function): void
  • Deletes the specified DNS record from CloudFlare. This function is only used for testing this module.

    Parameters

    • auth: Auth

      CloudFlare API authentication information.

    • recordName: string

      The name of the record.

    • zoneName: string

      The name of the zone.

    • callback: function

      Callback function called with any error that occurred.

        • (err?: Error): void
        • Parameters

          • Optional err: Error

          Returns void

    Returns void

Private getDnsRecord

  • getDnsRecord(auth: Auth, recordName: string, zoneName: string, callback: function): void
  • Gets the specified DNS record from CloudFlare. This function is only used for testing this module.

    Parameters

    • auth: Auth

      CloudFlare API authentication information.

    • recordName: string

      The name of the record.

    • zoneName: string

      The name of the zone.

    • callback: function

      Callback function called with any error that occurred as well as the ID of the record retrieved.

        • (err?: Error, dnsRecordId?: string): void
        • Parameters

          • Optional err: Error
          • Optional dnsRecordId: string

          Returns void

    Returns void

Private getDnsRecordId

  • getDnsRecordId(zoneId: string, dnsRecordName: string, auth: Auth, callback: function): void
  • Gets the DNS record ID associated with the specified record name.

    Parameters

    • zoneId: string

      The zone ID.

    • dnsRecordName: string

      The DNS record name.

    • auth: Auth

      CloudFlare API authentication information.

    • callback: function

      Callback function called with any error that occurred, as well as the DNS record ID.

        • (error?: Error, dnsRecordId?: string): void
        • Parameters

          • Optional error: Error
          • Optional dnsRecordId: string

          Returns void

    Returns void

Private getExternalIp

  • getExternalIp(callback: function): void
  • Gets the current external IP from the myexternalip.com API.

    Parameters

    • callback: function

      Callback function called with any error that occurred as well as the IP address returned from the API.

        • (error?: Error, ip?: string): void
        • Parameters

          • Optional error: Error
          • Optional ip: string

          Returns void

    Returns void

Private getResults

  • getResults(path: string, auth: Auth, callback: function, method?: string, body?: string, startPage?: number): void
  • Gets results from the CloudFlare API.

    Parameters

    • path: string

      The URI.

    • auth: Auth

      CloudFlare API authentication information.

    • callback: function

      Callback function called with any error that occurred, as well as the API results.

        • (error?: Error, results?: any[]): void
        • Parameters

          • Optional error: Error
          • Optional results: any[]

          Returns void

    • Default value method: string = "GET"

      The HTTP method.

    • Optional body: string

      The request body.

    • Default value startPage: number = 1

      The start page associated with the request.

    Returns void

Private getZoneId

  • getZoneId(zoneName: string, auth: Auth, callback: function): void
  • Gets the zone ID associated with the specified zone name.

    Parameters

    • zoneName: string

      The zone name.

    • auth: Auth

      CloudFlare API authentication information.

    • callback: function

      Callback function called with any error that occurred, as well as the zone ID.

        • (error?: Error, id?: string): void
        • Parameters

          • Optional error: Error
          • Optional id: string

          Returns void

    Returns void

Private httpsRequest

  • httpsRequest(url: string, callback: function, method?: string, headers?: object, body?: string): void
  • Creates an HTTPS request to the specified URL.

    Parameters

    • url: string

      The URL of the HTTP request.

    • callback: function

      Called when a response is received with any error that occurred as well as the response and response body if one is received.

        • (error?: Error, response?: http.IncomingMessage, body?: string): void
        • Parameters

          • Optional error: Error
          • Optional response: http.IncomingMessage
          • Optional body: string

          Returns void

    • Default value method: string = "GET"

      The HTTP method associated with the request.

    • Default value headers: object = {}

      An object containing the headers of the request.

      • [name: string]: string
    • Optional body: string

      The body of the request.

    Returns void

Private isArray

  • isArray(val: any): boolean
  • Returns whether or not the value is an array.

    Parameters

    • val: any

    Returns boolean

Private isObject

  • isObject(val: any): boolean
  • Returns whether or not the value is an object.

    Parameters

    • val: any

    Returns boolean

Private isString

  • isString(val: any): boolean
  • Returns whether or not the value is a string.

    Parameters

    • val: any

    Returns boolean

Private isUndefined

  • isUndefined(val: any): boolean
  • Returns whether or not the value is undefined.

    Parameters

    • val: any

    Returns boolean

update

  • update(options: IOptions, callback: function): void
  • Updates the specified CloudFlare DNS record with an IP address, creating it if it does not exist.

    Parameters

    • options: IOptions

      The options associated with the update request.

    • callback: function

      Callback function called with any error that occurred as well as the new IP address if the request succeeded.

        • (err?: Error, newIp?: string): void
        • Parameters

          • Optional err: Error
          • Optional newIp: string

          Returns void

    Returns void

Private updateDnsRecord

  • updateDnsRecord(zoneId: string, recordId: string, ip: string, auth: Auth, callback: function): void
  • Updates a DNS record with the specified information.

    Parameters

    • zoneId: string

      The zone ID.

    • recordId: string

      The DNS record ID.

    • ip: string

      The IP to update the record with.

    • auth: Auth

      CloudFlare API authentication information.

    • callback: function

      Callback function called with any error that occurred.

        • (error?: Error): void
        • Parameters

          • Optional error: Error

          Returns void

    Returns void

Generated using TypeDoc