Dns_Module

Provides DNS functions to apnscp.
extends Module\Support\Dns uses NamespaceUtilitiesTrait
Methods Summary
public
# _proxy( )
Provider loader
public
# get_provider( )
Get DNS provider
public
# providers( )
Get known mail providers
public
# uuid_name( )
Get DNS UUID record name
public
# domain_expiration( string $domain )
Query database for domain expiration On multi-server lookups that perform DNS lookups independent, perform batch lookups and pull those records from the database A return of 0 indicates failure null indicates unknown expiration
public
# get_all_domains( )
Fetches all domains across all servers Used in multi-server layouts
public
# get_server_from_domain( string $domain , bool $all = false )
Get server on which a domain is hosted
public
# get_parent_domain( string $domain )
Get primary domain affiliated with account In multi-server setups query the master DB to find domains whose invoice matches the parent invoice or domains that share the same site ID
public
# get_whois_record( string $domain )
Query WHOIS server for record
public
# zone_exists( string $zone )
DNS zone exists
public
# configured( )
DNS handler is configured for account Weaker form of enabled()
public
# enabled( )
DNS is enabled for account Stricter version of configured(). Requires module to faithfully implement DNS functions.
protected
# owned_zone( string $zone )
Requested domain is manageable by the account
protected
# zoneAxfr( string $domain )
Perform a full zone transfer
public
# export( string $zone = NULL )
Export zone configuration in BIND-friendly notation
protected
# get_zone_data( string $domain )
Get all zone records parsed
public
# permitted_records( )
Get permitted records for DNS provider
public
# get_records_external( string $subdomain = '', string $rr = 'any', string $domain = NULL, array $nameservers = NULL )
Get DNS record(s) from a third-party nameserver When using same nameservers as hosting ns, ensure ns uses split-view
public static
# record2const( string $rr )
Translate RR into PHP constant NB Used by DNS Manager
public
# gethostbyaddr_t( string $ip , int $timeout = 1000 )
Returns the host name of the Internet host specified by $ip with timeout
public
# gethostbyname_t( string $name , int $timeout = 1000 )
Returns the IP of the Internet host specified by $host with timeout
public
# domain_hosted( string $domain , bool $ignore_on_account = false )
Check whether a domain is hosted on any server In multi-server setups, ensure all servers are named SERVER_NAME_SHORT (first component of "hostname" command)
public
# domain_on_account( string $domain )
Domain exists and is under the account on a multi-server instance Useful when doing cross-server transfers to ensure the domain to add is part of the account, which will allow the domain to be added via the aliases_add_domain @{see Aliases_Module::add_domain} Implementation details are available on github.com/apisnetworks/apnscp-modules
public
# get_pending_expirations( int $days = 30, bool $showExpired = true )
Get recently expiring domains Sample response: Array( [0] => Array( 'domain' => 'apnscp.com', 'ts' => 1469937612 ) )
public
# check_zone( string $zone , array $recs = array ( ) )
Check zone data with bind
public
# update( string $hostname , string $ip = NULL )
Update hostname with caller's IP4 address
public
# get_records( string $subdomain = '', string $rr = 'any', string $domain = NULL )
Get DNS record(s)
protected
# get_records_raw( string $subdomain = '', string $rr = 'ANY', string $domain = NULL )
get_records() unauthenticated DNS wrapper
public
# add_record( string $zone , string $subdomain , string $rr , string $param , int $ttl = 43200 )
Add a DNS record to a domain
public
# add_record_conditionally( string $zone , string $subdomain , string $rr , string $param , int $ttl = 43200 )
Add a DNS record to a domain if no other record exists Purposed for Lararia\Jobs\SimpleCommandJob
protected
# canonicalizeRecord( string & $zone , string & $subdomain , string & $rr , string & $param , int & $ttl = NULL )
Fixup a DNS record before submitting
protected
# hasCnameApexRestriction( )
Abides by DNS RFC that restricts DNS records from having an apex CNAME See also RFC 1034 section 3.6.2
public
# modify_record( string $zone , string $subdomain , string $rr , string $parameter , array $newdata )
Modify a DNS record
protected static
# createRecord( string $zone , array $data = array ( ) )
Create a record using appropriate driver
public
# record_exists( string $zone , string $subdomain , string $rr = 'ANY', string $parameter = '' )
DNS record exists
protected
# atomicUpdate( string $zone , Opcenter\Dns\Record $old , Opcenter\Dns\Record $newdata )
Perform an atomic update of a record allowing reversion on failure
public
# add_zone_backend( string $domain , string $ip )
Create DNS zone privileged mode
public
# ip_allocated( string $ip )
Check whether IP is assigned Assigned IP addresses will have PTRs. Unassigned will be empty.
public
# import_from_ns( string $domain , string $nameserver , string|null $key = NULL )
Import zone data for domain, overwriting configuration on server
public
# import_from_domain( string $domain , string $src )
Import records from hosted domain
public
# import( string $domain , string $axfr )
Import raw AXFR records into zone
public
# validate_template( string $file , array $overrideParams = array ( ) )
Validate DNS template
public
# get_zone_information( string $domain = NULL )
array get_zone_information (string) Reads zone information for a given domain on the nameservers.
public
# remove_record( string $zone , string $subdomain , string $rr , string $param = '' )
bool remove_record (string, string) Removes a record from a zone.
public
# release_ip( string $ip )
public
# get_default( string $key )
Get module default
public
# min_ttl( )
Get DNS minimum TTL

XXX


public
# _delete( )
protected
# __deleteIP( string $ip , string $domain = NULL )
Release PTR assignment from an IP
public
# remove_zone_backend( string $domain )
Remove zone from nameserver
public
# _edit( )
public
# _create( )
protected
# publicIpWrapper( string $which = 'cur', int $class = 4, string $svcvar = NULL )
Helper function to fetch IP address from config
public
# add_zone( string $domain , string $ip )
Add zone to DNS server
public
# parented( string $hostname )
Hostname has parent
protected
# getParent( string $hostname )
Get hostname parent
public
# get_public_ip( )
Get public IPv4 address(es)
public
# get_public_ip6( )
Get public IPv6 address(es)
public
# provisioning_records( string $zone )
Get base provisioning DNS records to setup automatically
public
# uuid( )
Get DNS UUID for host
protected
# __addIP( string $ip , string $hostname = '' )
Add an IP address to hosting
public
# domain_uses_nameservers( string $domain )
Lookup and compare nameservers for domain to host
public
# get_hosting_nameservers( string $domain = NULL )
Get configured hosting nameservers Toggled via config.ini > [dns] > hosting_ns
public
# get_authns_from_host( string $host )
Get authoritative nameservers for given hostname Example response: Array ( [0] => Array ( [host] => ns2.apisnetworks.com [type] => A [ip] => 96.126.122.82 [class] => IN [ttl] => 83137 ) )
protected
# get_authns_from_host_recursive( string $host , Net_DNS2_Resolver $resolver , string $seen = '' )
Fallback authoritative NS lookup Crawl the entire TLD hierarchy to find the last known nameserver
public
# remove_zone( string $domain , bool $force = false )
Remove a zone from DNS management No direct access to method. Use EditDomain or aliases:remove-domain to manage zone attachments. Certain DNS providers may also soft delete zones requiring manual removal.
public
# auth_test( string $provider = NULL, mixed $key = '' )
Test credentials against configured module
protected
# __changePTR( string $ip , string $hostname , string $chk = '' )
Change PTR name
public
# get_records_by_rr( string $rr , string $zone = NULL )
Query hosting nameservers for DNS records of named category {@see \get_zone_information()} example: Account has two MX records assigned, first the default MX on debug.com, and a second user-created MX on debug.debug.com. debug.debug.com was designated an e-mail domain through Mail Routing {@see \Email_Module::add_virtual_transport()} apis> $c->dns_get_records_by_rr("MX"); array(2) apis> array(2) { [0]=> array(4) { ["name"]=> string(10) "debug.com." ["class"]=> string(2) "IN" ["ttl"]=> string(5) "86400" ["parameter"]=> string(18) "10 mail.debug.com." } [1]=> array(4) { ["name"]=> string(16) "debug.debug.com." ["class"]=> string(2) "IN" ["ttl"]=> string(5) "86400" ["parameter"]=> string(24) "10 mail.debug.debug.com." } }
public
# verified( string $domain )
Domain has been verified and permitted addition
public
# verify( string $domain )
Perform verification on domain
public
# challenges( string $domain )
Get DNS zone challenges
public
# _verify_conf( Opcenter\Service\ConfigurationContext $ctx )
public
# _create_user( string $user )
public
# _delete_user( string $user )
public
# _edit_user( string $userold , string $usernew , array $oldpwd )
Methods inherited from Module\Support\Dns
addCache(), removeCache(), getCacheKey(), getZoneId(), getRecordId(), getRecordFromCache()
Methods inherited from Module\Skeleton\Standard
__construct(), setUserParameters(), autoloadModule(), __wakeup(), _invoke(), __debugInfo(), getExportedFunctions(), _reset(), cleanUserParameters(), query()
Methods used from NamespaceUtilitiesTrait trait
getBaseClassName() appendNamespace() getNamespace()
Constants Summary
public array DEPENDENCY_MAP
# array ( 0 => 'siteinfo', )
protected boolean HAS_ORIGIN_MARKER
apex markers are marked with @
# false
public string MASTER_NAMESERVER
primary nameserver
# ''
public array AUTHORITATIVE_NAMESERVERS
# array ( )
public array RECURSIVE_NAMESERVERS
# array ( 0 => '127.0.0.1', )
public string UUID_RECORD
# '_apnscp_uuid'
public int DYNDNS_TTL
# 300
public int DNS_TTL_MIN
# 5
public int DNS_TTL
# 43200
public string HOSTS_FILE
# '/etc/hosts'
public string DIG_SHLOOKUP
# 'dig +norec +aaonly +time=3 +tcp +short @%(nameserver)s %(hostname)s %(rr)s'
Constants inherited from Module\Support\Dns
DEPENDENCY_MAP
Constants inherited from Module\Skeleton\Standard
DEPENDENCY_MAP
Properties Summary
protected static array $zoneExistsCache

# array ( )
protected static string $dns_key

# NULL
protected static $rec_2_const
mapping of RR types to constants
# array ( 'ANY' => 268435456, 'A' => 1, 'AAAA' => 134217728, 'MX' => 16384, 'NS' => 2, 'SOA' => 32, 'TXT' => 32768, 'CNAME' => 16, 'SRV' => 33554432, 'PTR' => 2048, 'HINFO' => 4096, 'A6' => 16777216, 'NAPTR' => 67108864, 'CAA' => 8192, 'DS' => 0, 'RP' => 0, 'SSHFP' => 0, 'SPF' => 0, 'URI' => 0, 'CERT' => 0, )
protected static $nameservers
array of 1 or more nameservers used
# NULL
protected static array $permitted_records
Legal DNS resource records permitted by provider A AAAA MX CNAME DNAME HINFO TXT NS SRV
# array ( 0 => 'A', 1 => 'AAAA', 2 => 'A6', 3 => 'CAA', 4 => 'CNAME', 5 => 'DNAME', 6 => 'HINFO', 7 => 'MX', 8 => 'NAPTR', 9 => 'NS', 10 => 'SOA', 11 => 'SRV', 12 => 'TXT', )
protected $exportedFunctions

# array ( '*' => 2, 'get_public_ip' => 3, 'get_public_ip6' => 3, 'enabled' => 3, 'configured' => 15, 'get_whois_record' => 15, 'get_records_by_rr' => 10, 'get_records' => 10, 'record_exists' => 15, 'modify_record' => 10, 'remove_record' => 10, 'add_record' => 10, 'get_zone_information' => 10, 'get_all_domains' => 8, 'get_parent_domain' => 8, 'get_server_from_domain' => 8, 'release_ip' => 8, 'ip_allocated' => 8, 'gethostbyaddr_t' => 15, 'gethostbyname_t' => 15, 'get_provider' => 15, 'uuid' => 15, 'provisioning_records' => 2, 'remove_zone' => 10, 'remove_zone_backend' => 26, 'add_zone' => 8, 'add_zone_backend' => 26, 'providers' => 8, 'zone_exists' => 10, 'validate_template' => 8, 'import_from_domain' => 10, 'export' => 10, 'import' => 10, 'auth_test' => 10, )
Properties inherited from Module\Support\Dns
$zoneCache
Properties inherited from Module\Skeleton\Standard
$exportedFunctions, $username, $password, $domain, $user_id, $group_id, $permission_level, $session_id, $site, $site_id
Properties used from NamespaceUtilitiesTrait