Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Model/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ final class Message
* The OPT record uses the "ttl" field to store additional flags.
*/
const TYPE_OPT = 41;
const TYPE_SPF = 99; // Sender Policy Framework (SPF) - https://tools.ietf.org/html/rfc4408#section-3.1.1
const TYPE_ANY = 255;
const TYPE_CAA = 257;

Expand Down
2 changes: 1 addition & 1 deletion src/Protocol/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ private function parseRecord(Message $message)
}
} elseif (Message::TYPE_CNAME === $type || Message::TYPE_PTR === $type || Message::TYPE_NS === $type) {
list($rdata, $consumed) = $this->readDomain($message->data, $consumed);
} elseif (Message::TYPE_TXT === $type) {
} elseif (Message::TYPE_TXT === $type || Message::TYPE_SPF === $type) {
$rdata = array();
while ($consumed < $expected) {
$len = ord($message->data[$consumed]);
Expand Down
19 changes: 19 additions & 0 deletions tests/Protocol/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,25 @@ public function testParseTXTResponse()
$this->assertSame(array('hello'), $response->answers[0]->data);
}

public function testParseSPFResponse()
{
$data = "";
$data .= "04 69 67 6f 72 02 69 6f 00"; // answer: igor.io
$data .= "00 63 00 01"; // answer: type SPF, class IN
$data .= "00 01 51 80"; // answer: ttl 86400
$data .= "00 06"; // answer: rdlength 6
$data .= "05 68 65 6c 6c 6f"; // answer: rdata length 5: hello

$response = $this->parseAnswer($data);

$this->assertCount(1, $response->answers);
$this->assertSame('igor.io', $response->answers[0]->name);
$this->assertSame(Message::TYPE_SPF, $response->answers[0]->type);
$this->assertSame(Message::CLASS_IN, $response->answers[0]->class);
$this->assertSame(86400, $response->answers[0]->ttl);
$this->assertSame(array('hello'), $response->answers[0]->data);
}

public function testParseTXTResponseMultiple()
{
$data = "";
Expand Down