Skip to content
Snippets Groups Projects
Commit e06633f2 authored by Mark Tearle's avatar Mark Tearle
Browse files

Move to RFC2136 on cloud-mooneye

parent b2bb67db
Branches
No related merge requests found
......@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "7a250215a88065189d17512fceab45dd",
"content-hash": "dc9ea773c012d95dc4d3a74b07416eee",
"packages": [
{
"name": "abhilashpujari/php-restservice",
......@@ -1124,6 +1124,53 @@
],
"time": "2021-01-26T20:46:41+00:00"
},
{
"name": "pear/net_dns2",
"version": "v1.5.2",
"source": {
"type": "git",
"url": "https://github.com/mikepultz/netdns2.git",
"reference": "d5dbae0b0c0567923d25b3ae5e2bf1e9cbcedf76"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/mikepultz/netdns2/zipball/d5dbae0b0c0567923d25b3ae5e2bf1e9cbcedf76",
"reference": "d5dbae0b0c0567923d25b3ae5e2bf1e9cbcedf76",
"shasum": ""
},
"require": {
"php": ">=5.4"
},
"require-dev": {
"phpunit/phpunit": "^9"
},
"type": "library",
"autoload": {
"psr-0": {
"Net_DNS2": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-2-Clause"
],
"authors": [
{
"name": "Mike Pultz",
"email": "mike@mikepultz.com",
"homepage": "https://mikepultz.com/",
"role": "lead"
}
],
"description": "Native PHP DNS Resolver and Updater Library",
"homepage": "https://netdns2.com/",
"keywords": [
"PEAR",
"dns",
"network"
],
"time": "2020-10-11T17:33:54+00:00"
},
{
"name": "phpmailer/phpmailer",
"version": "v6.2.0",
......
......@@ -9,6 +9,13 @@ function get_config() {
# API key for dynu.com
'QV_DYNU_API' => "ABCD1234",
# RFC2136 host
'QV_RFC2136_HOST' => "1.2.3.4",
# RFC2136 key
'QV_RFC2136_KEYNAME' => "mykey",
'QV_RFC2136_KEY' => "secret",
# Domain at desec.io
'QV_DOMAIN' => "quovadis-challenges.ucc.asn.au",
......
......@@ -35,7 +35,39 @@ function stripQuotes($text) {
}
function get_txt($config, $name) {
return get_desec_txt($config, $name);
return get_rfc2136_txt($config, $name);
}
function get_rfc2136_txt($config, $name) {
//
// create new resolver object, passing in an array of name
// servers to use for lookups
//
$r = new Net_DNS2_Resolver(array('nameservers' => array($config['QV_RFC2136_HOST'])));
//
// execute the query request for the name TXT
//
try {
$result = $r->query($name . "." . $config['QV_DOMAIN'], 'TXT');
} catch(Net_DNS2_Exception $e) {
echo "::query() failed: ", $e->getMessage(), "\n";
return "";
}
//
// loop through the answer, printing out the TXT results returned.
//
foreach($result->answer as $txtrr)
{
return $txtrr;
}
//
return "";
}
function get_dynu_domainid($config, $name) {
......@@ -176,7 +208,72 @@ function check_challenge($challenge) {
//
function update_txt($config, $name, $txt) {
return update_desec_txt($config, $name, $txt);
return update_rfc2136_txt($config, $name, $txt);
}
function delete_rfc2136_txt($config, $name) {
// create a new Updater object
//
$u = new Net_DNS2_Updater($config['QV_DOMAIN'], array('nameservers' => array($config['QV_RFC2136_HOST'])));
try {
$u->deleteAny($name . "." . $config['QV_DOMAIN'], 'TXT');
// add a TSIG to authenticate the request
//
$u->signTSIG($config['QV_RFC2136_KEYNAME'], $config['QV_RFC2136_KEY']);
//
// execute the request
//
$u->update();
return "$name deleted";
} catch(Net_DNS2_Exception $e) {
echo "::update() for deleteAny failed: ", $e->getMessage(), "\n";
}
return "";
}
function update_rfc2136_txt($config, $name, $txt) {
delete_rfc2136_txt($config, $name);
// create a new Updater object
//
$u = new Net_DNS2_Updater($config['QV_DOMAIN'], array('nameservers' => array($config['QV_RFC2136_HOST'])));
try {
//
// create a new MX RR object to add to the example.com zone
//
$txtrr = Net_DNS2_RR::fromString($name . "." . $config['QV_DOMAIN'] . ' TXT "'. $txt . '"');
//
// add the record
//
$u->add($txtrr);
// add a TSIG to authenticate the request
//
$u->signTSIG($config['QV_RFC2136_KEYNAME'], $config['QV_RFC2136_KEY']);
//
// execute the request
//
$u->update();
return $txt;
} catch(Net_DNS2_Exception $e) {
echo "::update() failed: ", $e->getMessage(), "\n";
}
return "";
}
function update_dynu_txt($config, $name, $txt) {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment