Skip to content

Commit 6c8d9a4

Browse files
committed
add SOA queries
thanks @vstakhov
1 parent 57c96e3 commit 6c8d9a4

File tree

4 files changed

+57
-5
lines changed

4 files changed

+57
-5
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ $ echo "extension=rdns.so" >> /etc/php.ini
5151

5252
```
5353
$ sudo apt-get install libev-dev
54-
$ wget https://github.com/weheartwebsites/php-rdns/releases/download/v0.1.1/rdns-0.1.1.tgz
55-
$ tar xvfz rdns-0.1.1.tgz
56-
$ cd rdns-0.1.1/
54+
$ wget https://github.com/weheartwebsites/php-rdns/releases/download/v0.1.2/rdns-0.1.2.tgz
55+
$ tar xvfz rdns-0.1.2.tgz
56+
$ cd rdns-0.1.2/
5757
$ phpize
5858
$ ./configure
5959
$ make

php_rdns.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ extern zend_module_entry rdns_module_entry;
2323
#include "TSRM.h"
2424
#endif
2525

26-
#define PHP_RDNS_VERSION "0.1.1"
26+
#define PHP_RDNS_VERSION "0.1.2"
2727
#define PHP_RDNS_EXTNAME "RDNS"
2828

2929
#endif /* PHP_RDNS_H */

rdns.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ static PHP_MINIT_FUNCTION(rdns)
122122
RDNS_TYPE_CONST(TXT);
123123
RDNS_TYPE_CONST(SRV);
124124
RDNS_TYPE_CONST(AAAA);
125+
RDNS_TYPE_CONST(SOA);
125126
#undef RDNS_TYPE_CONST
126127

127128
return SUCCESS;
@@ -135,7 +136,7 @@ static PHP_MINFO_FUNCTION(rdns)
135136
php_info_print_table_header(2, "RDNS Support", "enabled");
136137
php_info_print_table_row(2, "RDNS Version", PHP_RDNS_VERSION);
137138
php_info_print_table_row(2, "RDNS GitHub", "https://github.com/weheartwebsites/php-rdns");
138-
php_info_print_table_row(2, "RDNS librdns", "$Id: 40d4eb2ad845643fe6a949f98042bb14c1ea24ba $");
139+
php_info_print_table_row(2, "RDNS librdns", "$Id: 429e2100724fa709e64011951edee8d1e747d04e $");
139140
php_info_print_table_end();
140141
}
141142
/* }}} */
@@ -279,6 +280,18 @@ rdns_reply_callback(struct rdns_reply *reply, void *arg)
279280
add_assoc_long(result_item, "pri", entry->content.srv.priority);
280281
add_assoc_long(result_item, "weight", entry->content.srv.weight);
281282
add_assoc_long(result_item, "port", entry->content.srv.port);
283+
} else if (entry->type == RDNS_REQUEST_SOA) {
284+
add_assoc_string_ex(result_item, ZEND_STRS("type"), "SOA", 1);
285+
add_assoc_string_ex(result_item, ZEND_STRS("mname"),
286+
entry->content.soa.mname, 1);
287+
add_assoc_string_ex(result_item, ZEND_STRS("rname"),
288+
entry->content.soa.admin, 1);
289+
add_assoc_long(result_item, "serial", entry->content.soa.serial);
290+
add_assoc_long(result_item, "refresh", entry->content.soa.refresh);
291+
add_assoc_long(result_item, "retry", entry->content.soa.retry);
292+
add_assoc_long(result_item, "expire", entry->content.soa.expire);
293+
add_assoc_long(result_item, "minimum-ttl",
294+
entry->content.soa.minimum);
282295
}
283296

284297
entry = entry->next;

tests/013-soa-request.phpt

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
--TEST--
2+
Check RDNS::addRequest
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded("rdns") ||
6+
!@fsockopen('php.net', 80))
7+
print "skip";
8+
?>
9+
--FILE--
10+
<?php
11+
$rdns = new RDNS;
12+
$rdns->addServer('8.8.8.8');
13+
$rdns->addRequest('gimper.net', RDNS_SOA);
14+
$reply = $rdns->getReplies();
15+
$r0 = $reply[0][0];
16+
ksort($r0);
17+
print_r(array_keys($r0));
18+
var_dump($r0['host']);
19+
var_dump($r0['type']);
20+
var_dump($r0['class']);
21+
?>
22+
--EXPECT--
23+
Array
24+
(
25+
[0] => class
26+
[1] => expire
27+
[2] => host
28+
[3] => minimum-ttl
29+
[4] => mname
30+
[5] => refresh
31+
[6] => retry
32+
[7] => rname
33+
[8] => serial
34+
[9] => ttl
35+
[10] => type
36+
)
37+
string(10) "gimper.net"
38+
string(3) "SOA"
39+
string(2) "IN"

0 commit comments

Comments
 (0)