Skip to content

Commit

Permalink
Merge pull request #20 from exonet/tsi/pdns-42
Browse files Browse the repository at this point in the history
PowerDNS 4.2 / PHP 7.4 support
  • Loading branch information
styxit authored Jan 29, 2020
2 parents 323b821 + 80ab231 commit 9cdd9d8
Show file tree
Hide file tree
Showing 31 changed files with 479 additions and 152 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/.idea/
/vendor/
composer.lock
.phpunit.result.cache
1 change: 0 additions & 1 deletion .styleci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ enabled:

disabled:
- align_double_arrow
- simplified_null_return
16 changes: 16 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
dist: xenial
language: php

services:
- mysql

env:
- PDNS_VERSION=41
- PDNS_VERSION=42

php:
- 7.1
- 7.2
- 7.3
- 7.4

cache:
directories:
- vendor
- $HOME/.composer/cache

before_install:
- mysql -e 'CREATE DATABASE powerdns;'
- if [[ "$PDNS_VERSION" == "41" ]]; then mysql -u root powerdns < .travis/pdns-41.sql; fi
- if [[ "$PDNS_VERSION" == "42" ]]; then mysql -u root powerdns < .travis/pdns-42.sql; fi

install:
- sudo ./.travis/install-pdns.sh
- composer install

15 changes: 15 additions & 0 deletions .travis/install-pdns.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh

# Use the PowerDNS repo as source.
if [ "$PDNS_VERSION" = "41" ]; then
sudo echo 'deb [arch=amd64] http://repo.powerdns.com/ubuntu xenial-auth-41 main' > /etc/apt/sources.list.d/pdns.list
fi

if [ "$PDNS_VERSION" = "42" ]; then
sudo echo 'deb [arch=amd64] http://repo.powerdns.com/ubuntu xenial-auth-42 main' > /etc/apt/sources.list.d/pdns.list
fi

# Get the specific release and install.
curl https://repo.powerdns.com/FD380FBB-pub.asc | sudo apt-key add - && sudo apt-get update && sudo apt-get install pdns-server pdns-backend-mysql
sudo cp "$TRAVIS_BUILD_DIR/.travis/pdns.conf" /etc/powerdns/pdns.conf
sudo service pdns restart
89 changes: 89 additions & 0 deletions .travis/pdns-41.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
CREATE TABLE domains (
id INT AUTO_INCREMENT,
name VARCHAR(255) NOT NULL,
master VARCHAR(128) DEFAULT NULL,
last_check INT DEFAULT NULL,
type VARCHAR(6) NOT NULL,
notified_serial INT DEFAULT NULL,
account VARCHAR(40) CHARACTER SET 'utf8' DEFAULT NULL,
PRIMARY KEY (id)
) Engine=InnoDB CHARACTER SET 'latin1';

CREATE UNIQUE INDEX name_index ON domains(name);


CREATE TABLE records (
id BIGINT AUTO_INCREMENT,
domain_id INT DEFAULT NULL,
name VARCHAR(255) DEFAULT NULL,
type VARCHAR(10) DEFAULT NULL,
content VARCHAR(64000) DEFAULT NULL,
ttl INT DEFAULT NULL,
prio INT DEFAULT NULL,
change_date INT DEFAULT NULL,
disabled TINYINT(1) DEFAULT 0,
ordername VARCHAR(255) BINARY DEFAULT NULL,
auth TINYINT(1) DEFAULT 1,
PRIMARY KEY (id)
) Engine=InnoDB CHARACTER SET 'latin1';

CREATE INDEX nametype_index ON records(name,type);
CREATE INDEX domain_id ON records(domain_id);
CREATE INDEX ordername ON records (ordername);


CREATE TABLE supermasters (
ip VARCHAR(64) NOT NULL,
nameserver VARCHAR(255) NOT NULL,
account VARCHAR(40) CHARACTER SET 'utf8' NOT NULL,
PRIMARY KEY (ip, nameserver)
) Engine=InnoDB CHARACTER SET 'latin1';


CREATE TABLE comments (
id INT AUTO_INCREMENT,
domain_id INT NOT NULL,
name VARCHAR(255) NOT NULL,
type VARCHAR(10) NOT NULL,
modified_at INT NOT NULL,
account VARCHAR(40) CHARACTER SET 'utf8' DEFAULT NULL,
comment TEXT CHARACTER SET 'utf8' NOT NULL,
PRIMARY KEY (id)
) Engine=InnoDB CHARACTER SET 'latin1';

CREATE INDEX comments_name_type_idx ON comments (name, type);
CREATE INDEX comments_order_idx ON comments (domain_id, modified_at);


CREATE TABLE domainmetadata (
id INT AUTO_INCREMENT,
domain_id INT NOT NULL,
kind VARCHAR(32),
content TEXT,
PRIMARY KEY (id)
) Engine=InnoDB CHARACTER SET 'latin1';

CREATE INDEX domainmetadata_idx ON domainmetadata (domain_id, kind);


CREATE TABLE cryptokeys (
id INT AUTO_INCREMENT,
domain_id INT NOT NULL,
flags INT NOT NULL,
active BOOL,
content TEXT,
PRIMARY KEY(id)
) Engine=InnoDB CHARACTER SET 'latin1';

CREATE INDEX domainidindex ON cryptokeys(domain_id);


CREATE TABLE tsigkeys (
id INT AUTO_INCREMENT,
name VARCHAR(255),
algorithm VARCHAR(50),
secret VARCHAR(255),
PRIMARY KEY (id)
) Engine=InnoDB CHARACTER SET 'latin1';

CREATE UNIQUE INDEX namealgoindex ON tsigkeys(name, algorithm);
89 changes: 89 additions & 0 deletions .travis/pdns-42.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
CREATE TABLE domains (
id INT AUTO_INCREMENT,
name VARCHAR(255) NOT NULL,
master VARCHAR(128) DEFAULT NULL,
last_check INT DEFAULT NULL,
type VARCHAR(6) NOT NULL,
notified_serial INT UNSIGNED DEFAULT NULL,
account VARCHAR(40) CHARACTER SET 'utf8' DEFAULT NULL,
PRIMARY KEY (id)
) Engine=InnoDB CHARACTER SET 'latin1';

CREATE UNIQUE INDEX name_index ON domains(name);


CREATE TABLE records (
id BIGINT AUTO_INCREMENT,
domain_id INT DEFAULT NULL,
name VARCHAR(255) DEFAULT NULL,
type VARCHAR(10) DEFAULT NULL,
content VARCHAR(64000) DEFAULT NULL,
ttl INT DEFAULT NULL,
prio INT DEFAULT NULL,
disabled TINYINT(1) DEFAULT 0,
ordername VARCHAR(255) BINARY DEFAULT NULL,
auth TINYINT(1) DEFAULT 1,
PRIMARY KEY (id)
) Engine=InnoDB CHARACTER SET 'latin1';

CREATE INDEX nametype_index ON records(name,type);
CREATE INDEX domain_id ON records(domain_id);
CREATE INDEX ordername ON records (ordername);


CREATE TABLE supermasters (
ip VARCHAR(64) NOT NULL,
nameserver VARCHAR(255) NOT NULL,
account VARCHAR(40) CHARACTER SET 'utf8' NOT NULL,
PRIMARY KEY (ip, nameserver)
) Engine=InnoDB CHARACTER SET 'latin1';


CREATE TABLE comments (
id INT AUTO_INCREMENT,
domain_id INT NOT NULL,
name VARCHAR(255) NOT NULL,
type VARCHAR(10) NOT NULL,
modified_at INT NOT NULL,
account VARCHAR(40) CHARACTER SET 'utf8' DEFAULT NULL,
comment TEXT CHARACTER SET 'utf8' NOT NULL,
PRIMARY KEY (id)
) Engine=InnoDB CHARACTER SET 'latin1';

CREATE INDEX comments_name_type_idx ON comments (name, type);
CREATE INDEX comments_order_idx ON comments (domain_id, modified_at);


CREATE TABLE domainmetadata (
id INT AUTO_INCREMENT,
domain_id INT NOT NULL,
kind VARCHAR(32),
content TEXT,
PRIMARY KEY (id)
) Engine=InnoDB CHARACTER SET 'latin1';

CREATE INDEX domainmetadata_idx ON domainmetadata (domain_id, kind);


CREATE TABLE cryptokeys (
id INT AUTO_INCREMENT,
domain_id INT NOT NULL,
flags INT NOT NULL,
active BOOL,
content TEXT,
PRIMARY KEY(id)
) Engine=InnoDB CHARACTER SET 'latin1';

CREATE INDEX domainidindex ON cryptokeys(domain_id);


CREATE TABLE tsigkeys (
id INT AUTO_INCREMENT,
name VARCHAR(255),
algorithm VARCHAR(50),
secret VARCHAR(255),
PRIMARY KEY (id)
) Engine=InnoDB CHARACTER SET 'latin1';

CREATE UNIQUE INDEX namealgoindex ON tsigkeys(name, algorithm);

23 changes: 23 additions & 0 deletions .travis/pdns.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
launch=gmysql
gmysql-host=localhost
gmysql-user=root
gmysql-password=
gmysql-dbname=powerdns
gmysql-port=3306
gmysql-dnssec=yes

api=yes
api-key=apiKey

webserver=yes
webserver-port=8001
webserver-address=0.0.0.0
webserver-allow-from=0.0.0.0/0,::/0

default-soa-name=ns1.powerdns-php
default-soa-mail=hostmaster@powerdns-php

default-ksk-algorithm=rsasha256
default-ksk-size=2048
default-zsk-algorithm=rsasha256
default-zsk-size=1024
20 changes: 19 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,25 @@ All notable changes to `powerdns-php` will be documented in this file.
Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) principles.

## Unreleased
[Compare v1.1.0 - Unreleased](https://github.com/exonet/powerdns-php/compare/v1.1.0...develop)
[Compare v2.0.0 - Unreleased](https://github.com/exonet/powerdns-php/compare/v2.0.0...develop)

## [v2.0.0](https://github.com/exonet/powerdns-php/releases/tag/v2.0.0) - 2020-01-29
[Compare v1.1.0 - v2.0.0](https://github.com/exonet/powerdns-php/compare/v1.1.0...v2.0.0)
### Breaking
- Renamed `SOA-EDIT-API` to `SOA-EDIT` when creating a new zone.
- Implemented new `SOA-EDIT-API` logic when creating a new zone that defaults to `DEFAULT` so the `SOA-EDIT` value will be used.

This change will break your SOA increment if not configured correctly in the zone meta data. You need to update the zone
meta yourself in whatever backend you use for PowerDNS. See the following quote from the [PowerDNS website (section API)](https://doc.powerdns.com/md/authoritative/upgrading/):

> Incompatible change: SOA-EDIT-API now follows SOA-EDIT-DNSUPDATE instead of SOA-EDIT (incl. the fact that it now has
> a default value of DEFAULT). You must update your existing SOA-EDIT-API metadata (set SOA-EDIT to your previous
> SOA-EDIT-API value, and SOA-EDIT-API to SOA-EDIT to keep the old behaviour).
### Added
- PowerDNS 4.2 support (see 'breaking' above).
- PHP 7.4 support
- Functional tests for SOA increments.

## [v1.1.0](https://github.com/exonet/powerdns-php/releases/tag/v1.1.0) - 2019-10-21
[Compare v1.0.1 - v1.1.0](https://github.com/exonet/powerdns-php/compare/v1.0.1...v1.1.0)
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# The MIT License (MIT)

Copyright (c) 2019 Exonet <development@exonet.nl>
Copyright (c) 2020 Exonet <development@exonet.nl>

> Permission is hereby granted, free of charge, to any person obtaining a copy
> of this software and associated documentation files (the "Software"), to deal
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
"psr/log": "^1.0"
},
"require-dev": {
"limedeck/phpunit-detailed-printer": "^4",
"mockery/mockery": "^1.2",
"phpunit/phpunit": ">=7.0"
"phpunit/phpunit": "^7"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion examples/CliLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public static function __callStatic($foreground_color, $args)
/**
* {@inheritdoc}
*/
public function log($level, $message, array $context = []) : void
public function log($level, $message, array $context = []): void
{
$foreground = self::$color[$level]['foreground'];
$background = self::$color[$level]['background'] ?? null;
Expand Down
1 change: 1 addition & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
bootstrap="vendor/autoload.php"
cacheTokens="false"
colors="true"
printerClass="LimeDeck\Testing\Printer"
>
<testsuites>
<testsuite name="PowerDNS API Client">
Expand Down
6 changes: 3 additions & 3 deletions src/AbstractZone.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function __construct(Connector $connector, ?string $canonicalDomain = nul
*
* @return $this The current class instance.
*/
public function setZone(string $canonicalDomain) : self
public function setZone(string $canonicalDomain): self
{
$fixDot = substr($canonicalDomain, -1) !== '.';

Expand All @@ -61,7 +61,7 @@ public function setZone(string $canonicalDomain) : self
*
* @return ZoneResource The zone resource.
*/
public function resource() : ZoneResource
public function resource(): ZoneResource
{
if ($this->zoneResource === null) {
$zoneData = $this->connector->get($this->getZonePath());
Expand All @@ -81,7 +81,7 @@ public function resource() : ZoneResource
*
* @return string The API zone path.
*/
protected function getZonePath(?string $path = null) : string
protected function getZonePath(?string $path = null): string
{
return sprintf('zones/%s%s', $this->zone, $path);
}
Expand Down
Loading

0 comments on commit 9cdd9d8

Please sign in to comment.