Skip to content

Commit 744a81b

Browse files
btafoyaMika56
authored andcommitted
Add DNSRecordGetterDirect, allowing to specify the nameserver to use for the query. (#20)
1 parent 81db7f9 commit 744a81b

8 files changed

+597
-143
lines changed

.idea/spfcheck.iml

-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.travis.yml

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1+
sudo: required
2+
13
language: php
24

5+
services:
6+
- docker
7+
38
php:
49
- 5.4
510
- 5.5
@@ -16,6 +21,7 @@ matrix:
1621
before_script:
1722
- composer self-update
1823
- composer install --prefer-source --no-interaction --dev
24+
- docker run -d --rm --name pdns -p 53:53/udp -p 53:53/tcp -p 80:80 -e "WEBPASSWD=password" raspberrypython/powerdns-sqlite3:latest
1925

2026
script:
2127
- mkdir -p build/logs

README.md

+11-3
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,28 @@ Run `composer require mika56/spfcheck` or add this to your composer.json:
1313
```json
1414
{
1515
"require": {
16-
"mika56/spfcheck": "dev-master"
16+
"mika56/spfcheck": "^1"
1717
}
1818
}
1919
```
2020

2121
## Usage
22-
Create a new instance of SPFCheck. The constructor requires a DNSRecordGetterInterface to be passed. Currently, only DNSRecordGetter exists, which uses PHP's DNS functions to get data.
22+
Create a new instance of SPFCheck. The constructor requires a DNSRecordGetterInterface to be passed. Currently, you have two options:
23+
- `DNSRecordGetter` which uses PHP's DNS functions to get data
24+
- `DNSRecordGetterDirect` which uses the [PHP DNS Direct Query Module](https://github.com/purplepixie/phpdns) to get data.
2325
```php
2426
<?php
2527
use Mika56\SPFCheck\SPFCheck;
2628
use Mika56\SPFCheck\DNSRecordGetter;
2729

2830
require('vendor/autoload.php');
29-
$checker = new SPFCheck(new DNSRecordGetter());
31+
32+
$checker = new SPFCheck(new DNSRecordGetter()); // Uses php's dns_get_record method for lookup.
33+
var_dump($checker->isIPAllowed('127.0.0.1', 'test.com'));
34+
35+
// or
36+
37+
$checker = new SPFCheck(new DNSRecordGetterDirect("8.8.8.8")); // Uses phpdns, allowing you to set the nameserver you wish to use for the dns queries.
3038
var_dump($checker->isIPAllowed('127.0.0.1', 'test.com'));
3139
```
3240

composer.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,16 @@
1212
{
1313
"name": "Mikael Peigney",
1414
"email": "[email protected]"
15+
},
16+
{
17+
"name": "Brian Tafoya",
18+
"email": "[email protected]"
1519
}
1620
],
1721
"require": {
1822
"symfony/http-foundation": "2.8.* || ^3.0",
19-
"php": ">=5.4"
23+
"php": ">=5.4",
24+
"purplepixie/phpdns": "^2.0"
2025
},
2126
"autoload": {
2227
"psr-4": {

0 commit comments

Comments
 (0)