File tree Expand file tree Collapse file tree 3 files changed +21
-1
lines changed
Expand file tree Collapse file tree 3 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ final class Message
3434 * The OPT record uses the "ttl" field to store additional flags.
3535 */
3636 const TYPE_OPT = 41 ;
37+ const TYPE_SPF = 99 ; // Sender Policy Framework (SPF) - https://tools.ietf.org/html/rfc4408#section-3.1.1
3738 const TYPE_ANY = 255 ;
3839 const TYPE_CAA = 257 ;
3940
Original file line number Diff line number Diff line change @@ -171,7 +171,7 @@ private function parseRecord(Message $message)
171171 }
172172 } elseif (Message::TYPE_CNAME === $ type || Message::TYPE_PTR === $ type || Message::TYPE_NS === $ type ) {
173173 list ($ rdata , $ consumed ) = $ this ->readDomain ($ message ->data , $ consumed );
174- } elseif (Message::TYPE_TXT === $ type ) {
174+ } elseif (Message::TYPE_TXT === $ type || Message:: TYPE_SPF === $ type ) {
175175 $ rdata = array ();
176176 while ($ consumed < $ expected ) {
177177 $ len = ord ($ message ->data [$ consumed ]);
Original file line number Diff line number Diff line change @@ -305,6 +305,25 @@ public function testParseTXTResponse()
305305 $ this ->assertSame (array ('hello ' ), $ response ->answers [0 ]->data );
306306 }
307307
308+ public function testParseSPFResponse ()
309+ {
310+ $ data = "" ;
311+ $ data .= "04 69 67 6f 72 02 69 6f 00 " ; // answer: igor.io
312+ $ data .= "00 63 00 01 " ; // answer: type SPF, class IN
313+ $ data .= "00 01 51 80 " ; // answer: ttl 86400
314+ $ data .= "00 06 " ; // answer: rdlength 6
315+ $ data .= "05 68 65 6c 6c 6f " ; // answer: rdata length 5: hello
316+
317+ $ response = $ this ->parseAnswer ($ data );
318+
319+ $ this ->assertCount (1 , $ response ->answers );
320+ $ this ->assertSame ('igor.io ' , $ response ->answers [0 ]->name );
321+ $ this ->assertSame (Message::TYPE_SPF , $ response ->answers [0 ]->type );
322+ $ this ->assertSame (Message::CLASS_IN , $ response ->answers [0 ]->class );
323+ $ this ->assertSame (86400 , $ response ->answers [0 ]->ttl );
324+ $ this ->assertSame (array ('hello ' ), $ response ->answers [0 ]->data );
325+ }
326+
308327 public function testParseTXTResponseMultiple ()
309328 {
310329 $ data = "" ;
You can’t perform that action at this time.
0 commit comments