ENUM DNS Lua Service

Introduction

The ENUM DNS Lua service is used for initiating Lua scripts running within the N2SVCD LogicApp.

The service receives a DNS query operation from an instance of the N2SVCD DnsServerApp configured to receive DNS messages from an external client.

During the transaction, the service communicates with the DnsServerApp using the DNS-S-REQUEST and DNS-S-RESPONSE messages.

Configuration

The ENUM DNS Lua service is configured within an N2SVCD LogicApp. A simple configuration might be:

<?xml version="1.0" encoding="utf-8"?>
<n2svcd>
  ...
  <applications>
    ...
    <application name="Logic"
                 module="LogicApp">
      ...
        <parameters>
            ...
            <parameter name="script_key_opcode_0" value="dns_query"/>
        </parameters>
      <config>
        <services>
          <service module="DnsServerApp::DnsLuaService"
                   libs="../apps/dns_s/lib;../../n2sns/lua/lib"
                   lua_lib_path="../lua/lib/?.lua;../../n2sns/lua/lib/?.lua;../../n2sns/lua/3rdparty/?.lua"
                   script_dir="../../n2sns/lua/svc"/>
        </services>
        <agents>
          ...
          <agent module="DBApp::DBLuaAgent"
                 libs="../apps/db/lib"/>
        </agents>
      </config>
    </application>
    ...
  </application>
  ...
</n2svcd>

Note that the DNS opcode 0 script must be overridden using DNS Lua Service parameter configuration to the service script name dns_query with the following parameter:

            <parameter name="script_key_opcode_0" value="dns_query"/>

In addition to the Common LogicApp Service Configuration, the following service attributes apply under a normal installation:

Attribute Type XML Type Description
module String Attribute [Required] The service module type. Must be set to DnsServerApp::DnsLuaService
libs String Attribute [Required] The location of the service module. Must include N2SVCD DNS libraries, e.g. ../apps/dns_s/lib
lua_lib_path String Attribute [Required] The location of the Lua libraries. Must include N2SVCD common and N2SNS common and third-party libraries, i.e. ../lua/lib/?.lua;../../n2sns/lua/lib/?.lua;../../n2sns/lua/3rdparty/?.lua
script_dir String Attribute [Required] The directory containing the scripts used by this service. In a standard N2SVCD installation, this must be ../../n2sns/lua/svc

Script Selection

The script to be executed for requests is determined by the N2SVCD DnsServerApp.

For all received DNS query requests, this will be query.lua.

Script Global Variables

Scripts run with this service have access to the Common Lua Service Global Variables.

The following service-specific global variables are available:

Variable Type Description
DB_APP_ROUTE String The [database application route][../../../../n2svcd/technical_guide/logic/agents/db_agent.html#dbi_select_route] to use when querying the N2SVCD DNS database.
(Default: nil, use default application route)
EDR_STREAM_KEY String A non-default EDR stream key to use when writing EDRs.
TTL Integer The TTL value to return for each DNS answer in a successful query response.
(Default: 30)
NAPTR_SEND_FLAGS String A (case-insensitive) whitelist of provisioned flags to return in DNS NAPTR responses. Any other flags provisioned against a DNS record will not be silently removed.
(Default: adsu)
NO_MATCH_CODE Integer Sets the response code to use when no record for the query can be found.
(Default: 3, no such domain)