PageRenderTime 45ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/test/dnsd_test.php

https://github.com/blekkzor/pinetd2
PHP | 57 lines | 18 code | 20 blank | 19 comment | 2 complexity | c2f927dd3c66402107b926bfe79b6210 MD5 | raw file
Possible License(s): GPL-2.0
  1. <?php
  2. require(dirname(__FILE__).'/DNSd_updater.class.php');
  3. $dnsd = new DNSd_updater('MyPeer', '127.0.0.1', 'qwerty', 10053);
  4. echo 'Connected to '.$dnsd->getNode()."\n";
  5. $id = $dnsd->getZone('example.zone');
  6. if (is_null($id)) { // zone not found?
  7. // let's create it
  8. $id = $dnsd->createZone('example.zone');
  9. if (!$id) die("Failed to create zone!\n");
  10. // Now, let's have some fun with our zone
  11. // addRecord(zone, host, type, value, ttl)
  12. $dnsd->addRecord($id, '', 'A', '127.0.0.1', 600);
  13. // NS record on a full domain (notice the "." at the end)
  14. $dnsd->addRecord($id, '', 'NS', 'localhost.');
  15. // a MX
  16. $dnsd->addRecord($id, '', 'MX', array('data' => 'mail.example.com.', 'mx_priority' => 10));
  17. // SOA...
  18. $dnsd->addRecord($id, '', 'SOA', array('data' => 'localhost.', 'resp_person' => 'root', 'serial' => '2009021500', 'refresh' => 10800, 'retry' => 3600, 'expire' => 604800, 'minimum' => 3600));
  19. // Let's put a host for www
  20. $dnsd->addRecord($id, 'www', 'A', '127.0.0.1');
  21. // wildcard cname
  22. $dnsd->addRecord($id, '*', 'CNAME', 'www');
  23. // ipv6 address
  24. $dnsd->addRecord($id, 'ipv6', 'AAAA', '::1');
  25. $dnsd->addRecord($id, 'ipv6', 'A', '127.0.0.1');
  26. }
  27. // Listing records in a zone
  28. // dumpZone(zone[, start[, limit]])
  29. //$dnsd->dumpZone('shigoto');
  30. // Deleting a record (the id can be found via dumpZone, or via the value returned by addRecord)
  31. //$dnsd->deleteRecord(7);
  32. // createDomain(domain, zone)
  33. $dnsd->createDomain('example.com', $id);
  34. //$dnsd->createDomain('test.com', $id);
  35. //$dnsd->createDomain('test2.com', $id);
  36. //$dnsd->createDomain('test3.com', $id);
  37. //$dnsd->deleteDomain('test2.com');