Database Interaction

use solutedns\System\db;
$db = db::get();
$db->PDO_STATEMENT

With the db class you can directly call any PDO statement available in PHP. Depending on the namespace your in you might need to call the global PDO class by adding an backslash before the PDO class name itself.

$stmt = $db->prepare("SELECT id FROM domains where name = :domain");
$stmt->execute(array(':domain' => 'example.com'));
$row = $stmt->fetch(PDO::FETCH_ASSOC);

Zone Exists

use solutedns\Dns\Zones;
$zones = new Zones();
$zones->exists(string);

Attributes:

domainstring
Zone name

Please note an Error Code may be returned instead of a boolean.

$domain = 'example.com';
boolean

Slave Zone

use solutedns\Dns\Zones;
$zones = new Zones();
$zones->slave(string);

Attributes:

domainstring
Zone name

Please note an Error Code may be returned instead of a boolean.

$domain = 'example.com';
boolean

Update SOA

use solutedns\Dns\Zones;
$zones = new Zones();
$zones->update(string, integer);

Attributes:

domainstring
Zone name
domain idint
Avoid an extra lookup when the domain id is known [optional]

Please note an Error Code may be returned instead of a boolean.

$domain = 'example.com';
$domain_id = 22;
boolean

Records in Zone

use solutedns\Dns\Records;
$records = new Records();
$records->size(string);

Attributes:

domainstring
Zone name

Please note an Error Code may be returned instead of an integer or boolean.

$domain = 'example.com';
integer/false

Pre Validate

use solutedns\Dns\Validate;
$validate = new Validate();
$validate->pre(array);

Attributes:

domainstring
Zone name
typestring
Record type
Namestring
Record name
contentstring
Record content
priointeger
Record prioirity
ttlinteger
Record time to live

Please note this is an preliminary validation function. No zone checks are performed being but not limited to: unique record, zone exists and non-alias targeting checks.

array(
  'domain' => 'example.com',
  'name' => 'example.com',
  'type' => 'A',
  'content' => '192.168.2.1',
  'ttl' => 3600,
  'prio' => 0,
);
Success
NULL

Error
array {
  'code' => 'INVALID_IPV4'
  'desc' => 'IPv4 address does not seem to be valid.'
  'field' => 'content'
}

Zone Backup

use solutedns\DNS\Backup;
$backup = new Backup();
$backup->backup(string);

Attributes:

domainstring
Zone name

Please note for this function to work you must have configured a support database.

$backup->backup('example.com')
Success
array {
  ['success']=> bool(true)
  ['zone']=> {
    ['id']=> int
    ['domain']=> string
    ['backup_id']=> string
  }
}

Error
array {
  ['error']=> {
    ['code']=> int
    ['desc']=> string
  }
}

Zone Restore

use solutedns\DNS\Backup;
$backup = new Backup();
$backup->restore(int);

Attributes:

backup idint
The id of the backup to recover.

Please note for this function to work you must have configured a support database.

$backup->restore(1245)
Success
array {
  ['success']=> array {
    [0]=> array {
      ['id']=> string
      ['type']=> string
      ['content']=> string
      ['name']=> string
      ['prio']=> int
      ['ttl']=> int
    }
  }
}

Error
array {
  ['error']=> {
    ['code']=> int
    ['desc']=> string
  }
}

Audit Logging

use solutedns\System\Audit;
$audit = new Audit();

Functions:

setUser()string
Set a username or id of who is making changes.
setEnv()string
Set an environment where the changes have been triggered.

Please note for this function to work you must have configured a support database.

$audit->setUser(string);
$audit->setEnv(string);
void

SSH Session

use solutedns\Dns\Dnssec;
$dnssec= new Dnssec();
$dnssec->session();

All functions which use an SSH connection to the nameserver have an session parameter. This can be used to avoid the function reconnecting to the server every time it’s called. This is typically useful when performing multiple actions which require SSH access.

You can either store the session in an variable and send it along with each function call:

$session = $dnssec->session();
$dnssec->rectify('example.com', $session);
$dnssec->rectify('demo.com', $session);

Or store the session in the class itself:

$dnssec->session();
$dnssec->rectify('example.com');
$dnssec->rectify('demo.com');
$dnssec->session();

$dnssec->secure('example.net');
$dnssec->nsec3('example.net');
$dnssec->rectify('example.net');
Object/Exception

Support Database

To enable support functions like zone backup/restore and audit logging a support database must be connected to the SoluteDNS Core. In order to do so you have to add a PDO object to the [‘database’][‘support’] configurable.

The following tables should be created in the support database in order for SoluteDNS to function properly:

CREATE TABLE sdns_backup (
  id                    INT AUTO_INCREMENT,
  domain_id             INT,
  domain                VARCHAR(255) NOT NULL,
  serial                INT,
  data                  TEXT NOT NULL,
  time                  INT NOT NULL,
  PRIMARY KEY (id)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

CREATE INDEX domain_id_idx ON sdns_backup(domain_id);
CREATE INDEX domain_idx ON sdns_backup(domain);

CREATE TABLE sdns_audit (
  id                    INT AUTO_INCREMENT,
  domain_id             INT,
  domain                VARCHAR(255) NOT NULL,
  user                  VARCHAR(255) NOT NULL,
  env                   VARCHAR(255) NOT NULL,
  type                  VARCHAR(255) NOT NULL,
  data                  TEXT NOT NULL,
  time                  INT NOT NULL,
  PRIMARY KEY (id)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

CREATE INDEX domain_id_idx ON sdns_audit(domain_id);
CREATE INDEX domain_idx ON sdns_audit(domain);

config.php

return [
  'license' => 'PRO_xxxxxxxxxxxxxxxxx',
  'database' => [
    'host' => '127.0.0.1',
    'port' => '',
    'name' => 'ns',
    'user' => 'pdns',
    'pass' => 'password',
    'type' => 'native', # native/master
    'support' => new PDO(...)
  ]
]