Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
CentralNic
Badcow-DNS
Commits
f63b7d49
Commit
f63b7d49
authored
Nov 10, 2018
by
Samuel Williams
Browse files
CS fixes.
parent
761c2ae3
Changes
47
Hide whitespace changes
Inline
Side-by-side
lib/AlignedBuilder.php
View file @
f63b7d49
...
...
@@ -52,8 +52,8 @@ class AlignedBuilder implements ZoneBuilderInterface
*/
public
function
build
(
ZoneInterface
$zone
)
{
$master
=
'$ORIGIN '
.
$zone
->
getName
()
.
PHP_EOL
.
'$TTL '
.
$zone
->
getDefaultTtl
()
.
PHP_EOL
;
$master
=
'$ORIGIN '
.
$zone
->
getName
()
.
PHP_EOL
.
'$TTL '
.
$zone
->
getDefaultTtl
()
.
PHP_EOL
;
$rrs
=
$zone
->
getResourceRecords
();
$current
=
SOA
::
TYPE
;
...
...
@@ -74,7 +74,7 @@ class AlignedBuilder implements ZoneBuilderInterface
}
if
(
$rr
->
getType
()
!==
$current
)
{
$master
.
=
PHP_EOL
.
ResourceRecord
::
COMMENT_DELIMINATOR
.
$rr
->
getType
()
.
' RECORDS'
.
PHP_EOL
;
$master
.
=
PHP_EOL
.
ResourceRecord
::
COMMENT_DELIMINATOR
.
$rr
->
getType
()
.
' RECORDS'
.
PHP_EOL
;
$current
=
$rr
->
getType
();
}
...
...
@@ -93,7 +93,7 @@ class AlignedBuilder implements ZoneBuilderInterface
);
if
(
null
!=
$rr
->
getComment
())
{
$master
.
=
ResourceRecord
::
COMMENT_DELIMINATOR
.
$rr
->
getComment
();
$master
.
=
ResourceRecord
::
COMMENT_DELIMINATOR
.
$rr
->
getComment
();
}
$master
.
=
PHP_EOL
;
...
...
@@ -113,17 +113,17 @@ class AlignedBuilder implements ZoneBuilderInterface
public
static
function
compareResourceRecords
(
ResourceRecord
$a
,
ResourceRecord
$b
)
{
if
(
$a
->
getType
()
===
$b
->
getType
())
{
return
strcmp
(
$a
->
getName
()
.
$a
->
getRdata
()
->
output
(),
$b
->
getName
()
.
$b
->
getRdata
()
->
output
());
return
strcmp
(
$a
->
getName
()
.
$a
->
getRdata
()
->
output
(),
$b
->
getName
()
.
$b
->
getRdata
()
->
output
());
}
$_a
=
array_search
(
$a
->
getType
(),
self
::
$order
);
$_b
=
array_search
(
$b
->
getType
(),
self
::
$order
);
if
(
$_a
!==
false
&&
$_b
!==
false
)
{
if
(
false
!==
$_a
&&
false
!==
$_b
)
{
return
$_a
-
$_b
;
}
if
(
$_a
===
false
)
{
if
(
false
===
$_a
)
{
return
1
;
}
...
...
lib/Ip/Toolbox.php
View file @
f63b7d49
...
...
@@ -21,6 +21,7 @@ class Toolbox
* E.g. 2001:db8:9a::42 -> 2001:0db8:009a:0000:0000:0000:0000:0042
*
* @param string $ip IPv6 address
*
* @throws \InvalidArgumentException
*
* @return string
...
...
@@ -67,6 +68,7 @@ class Toolbox
* E.g.: 2001:0000:0000:ab80:2390:0000:0000:000a -> 2001:0:0:ab80:2390::a
*
* @param string $ip IPv6 address
*
* @throws \InvalidArgumentException
*
* @return string Contracted IPv6 address
...
...
@@ -92,8 +94,8 @@ class Toolbox
continue
;
}
$streak_i
=
(
$streak_i
===
-
1
)
?
$i
:
$streak_i
;
$streak
+=
1
;
$streak_i
=
(
-
1
===
$streak_i
)
?
$i
:
$streak_i
;
++
$streak
;
if
(
$streak
>=
$longestStreak
)
{
$longestStreak
=
$streak
;
...
...
@@ -133,7 +135,7 @@ class Toolbox
{
$octets
=
array_reverse
(
explode
(
'.'
,
$ip
));
return
implode
(
'.'
,
$octets
)
.
'.in-addr.arpa.'
;
return
implode
(
'.'
,
$octets
)
.
'.in-addr.arpa.'
;
}
/**
...
...
@@ -156,6 +158,6 @@ class Toolbox
$ip
=
str_replace
(
':'
,
''
,
$ip
);
$ip
=
strrev
(
$ip
);
return
implode
(
'.'
,
str_split
(
$ip
))
.
'.ip6.arpa.'
;
return
implode
(
'.'
,
str_split
(
$ip
))
.
'.ip6.arpa.'
;
}
}
lib/Rdata/A.php
View file @
f63b7d49
...
...
@@ -11,8 +11,6 @@
namespace
Badcow\DNS\Rdata
;
use
Badcow\DNS\Validator
;
class
A
implements
RdataInterface
{
use
RdataTrait
;
...
...
lib/Rdata/AAAA.php
View file @
f63b7d49
...
...
@@ -11,8 +11,6 @@
namespace
Badcow\DNS\Rdata
;
use
Badcow\DNS\Validator
;
class
AAAA
extends
A
{
const
TYPE
=
'AAAA'
;
...
...
lib/Rdata/CNAME.php
View file @
f63b7d49
...
...
@@ -11,8 +11,6 @@
namespace
Badcow\DNS\Rdata
;
use
Badcow\DNS\Validator
;
class
CNAME
implements
RdataInterface
{
use
RdataTrait
;
...
...
lib/Rdata/DNAME.php
View file @
f63b7d49
...
...
@@ -19,7 +19,7 @@ namespace Badcow\DNS\Rdata;
* suffix are redirected to another part of the DNS.
* Based on RFC6672
*
* @
link
http://tools.ietf.org/html/rfc6672
* @
see
http://tools.ietf.org/html/rfc6672
*/
class
DNAME
extends
CNAME
{
...
...
lib/Rdata/DNSSEC/Algorithms.php
View file @
f63b7d49
<?php
/*
* This file is part of Badcow DNS Library.
*
* (c) Samuel Williams <sam@badcow.co>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
Badcow\DNS\Rdata\DNSSEC
;
/**
* Algorithms listed in {@link https://tools.ietf.org/html/rfc4034#appendix-A.1}
*/
class
Algorithms
{
/**
* RSA/MD5
*/
const
RSAMD5
=
1
;
/**
* Diffie-Hellman
*/
const
DH
=
2
;
/**
* DSA/SHA-1
*/
const
DSA
=
3
;
/**
* Elliptic Curve
*/
const
ECC
=
4
;
/**
* RSA/SHA-1
*/
const
RSASHA1
=
5
;
/**
* Indirect
*/
const
INDIRECT
=
252
;
/**
* Private
*/
const
PRIVATEDNS
=
253
;
/**
* Private
*/
const
PRIVATEOID
=
254
;
private
static
$mnemonic
=
[
self
::
RSAMD5
=>
'RSAMD5'
,
self
::
DH
=>
'DH'
,
self
::
DSA
=>
'DSA'
,
self
::
ECC
=>
'ECC'
,
self
::
RSASHA1
=>
'RSASHA1'
,
self
::
INDIRECT
=>
'INDIRECT'
,
self
::
PRIVATEDNS
=>
'PRIVATEDNS'
,
self
::
PRIVATEOID
=>
'PRIVATEOID'
,
];
/**
* Get the associated mnemonic of an algorithm.
*
* @param int $algorithmId
* @return string
*/
public
static
function
getMnemonic
(
$algorithmId
)
{
return
self
::
$mnemonic
[
$algorithmId
];
}
}
\ No newline at end of file
<?php
/*
* This file is part of Badcow DNS Library.
*
* (c) Samuel Williams <sam@badcow.co>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
Badcow\DNS\Rdata\DNSSEC
;
/**
* Algorithms listed in {@link https://tools.ietf.org/html/rfc4034#appendix-A.1}.
*/
class
Algorithms
{
/**
* RSA/MD5.
*/
const
RSAMD5
=
1
;
/**
* Diffie-Hellman.
*/
const
DH
=
2
;
/**
* DSA/SHA-1.
*/
const
DSA
=
3
;
/**
* Elliptic Curve.
*/
const
ECC
=
4
;
/**
* RSA/SHA-1.
*/
const
RSASHA1
=
5
;
/**
* Indirect.
*/
const
INDIRECT
=
252
;
/**
* Private.
*/
const
PRIVATEDNS
=
253
;
/**
* Private.
*/
const
PRIVATEOID
=
254
;
private
static
$mnemonic
=
[
self
::
RSAMD5
=>
'RSAMD5'
,
self
::
DH
=>
'DH'
,
self
::
DSA
=>
'DSA'
,
self
::
ECC
=>
'ECC'
,
self
::
RSASHA1
=>
'RSASHA1'
,
self
::
INDIRECT
=>
'INDIRECT'
,
self
::
PRIVATEDNS
=>
'PRIVATEDNS'
,
self
::
PRIVATEOID
=>
'PRIVATEOID'
,
];
/**
* Get the associated mnemonic of an algorithm.
*
* @param int $algorithmId
*
* @return string
*/
public
static
function
getMnemonic
(
$algorithmId
)
{
return
self
::
$mnemonic
[
$algorithmId
];
}
}
lib/Rdata/DNSSEC/DNSKEY.php
View file @
f63b7d49
<?php
/*
* This file is part of Badcow DNS Library.
*
* (c) Samuel Williams <sam@badcow.co>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
Badcow\DNS\Rdata\DNSSEC
;
use
Badcow\DNS\Rdata\RdataInterface
;
use
Badcow\DNS\Rdata\RdataTrait
;
/**
* Class DNSKEY
*
* {@link https://tools.ietf.org/html/rfc4034#section-2.1}
*
* @package Badcow\DNS\Rdata
*/
class
DNSKEY
implements
RdataInterface
{
use
RdataTrait
;
const
TYPE
=
'DNSKEY'
;
/**
* {@link https://tools.ietf.org/html/rfc4034#section-2.1.1}
*
* @var int
*/
private
$flags
;
/**
* The Protocol Field MUST have value 3, and the DNSKEY RR MUST be
* treated as invalid during signature verification if it is found to be
* some value other than 3.
* {@link https://tools.ietf.org/html/rfc4034#section-2.1.2}
*
* @var int
*/
private
$protocol
=
3
;
/**
* The Algorithm field identifies the public key's cryptographic
* algorithm and determines the format of the Public Key field.
* {@link https://tools.ietf.org/html/rfc4034#section-2.1.3}
*
* @var int
*/
private
$algorithm
;
/**
* The Public Key field is a Base64 encoding of the Public Key.
* Whitespace is allowed within the Base64 text.
* {@link https://tools.ietf.org/html/rfc4034#section-2.1.4}
*
* @var string
*/
private
$publicKey
;
/**
* @return int
*/
public
function
getFlags
()
{
return
$this
->
flags
;
}
/**
* @param int $flags
*/
public
function
setFlags
(
$flags
)
{
$this
->
flags
=
$flags
;
}
/**
* @return int
*/
public
function
getProtocol
()
{
return
$this
->
protocol
;
}
/**
* @return int
*/
public
function
getAlgorithm
()
{
return
$this
->
algorithm
;
}
/**
* @param int $algorithm
*/
public
function
setAlgorithm
(
$algorithm
)
{
$this
->
algorithm
=
$algorithm
;
}
/**
* @return string
*/
public
function
getPublicKey
()
{
return
$this
->
publicKey
;
}
/**
* @param string $publicKey
*/
public
function
setPublicKey
(
$publicKey
)
{
$this
->
publicKey
=
$publicKey
;
}
/**
* {@inheritdoc}
*/
public
function
output
()
{
return
sprintf
(
'%s %s %s %s'
,
$this
->
flags
,
$this
->
protocol
,
$this
->
algorithm
,
$this
->
publicKey
);
}
}
\ No newline at end of file
<?php
/*
* This file is part of Badcow DNS Library.
*
* (c) Samuel Williams <sam@badcow.co>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
Badcow\DNS\Rdata\DNSSEC
;
use
Badcow\DNS\Rdata\RdataInterface
;
use
Badcow\DNS\Rdata\RdataTrait
;
/**
* Class DNSKEY.
*
* {@link https://tools.ietf.org/html/rfc4034#section-2.1}
*/
class
DNSKEY
implements
RdataInterface
{
use
RdataTrait
;
const
TYPE
=
'DNSKEY'
;
/**
* {@link https://tools.ietf.org/html/rfc4034#section-2.1.1}.
*
* @var int
*/
private
$flags
;
/**
* The Protocol Field MUST have value 3, and the DNSKEY RR MUST be
* treated as invalid during signature verification if it is found to be
* some value other than 3.
* {@link https://tools.ietf.org/html/rfc4034#section-2.1.2}.
*
* @var int
*/
private
$protocol
=
3
;
/**
* The Algorithm field identifies the public key's cryptographic
* algorithm and determines the format of the Public Key field.
* {@link https://tools.ietf.org/html/rfc4034#section-2.1.3}.
*
* @var int
*/
private
$algorithm
;
/**
* The Public Key field is a Base64 encoding of the Public Key.
* Whitespace is allowed within the Base64 text.
* {@link https://tools.ietf.org/html/rfc4034#section-2.1.4}.
*
* @var string
*/
private
$publicKey
;
/**
* @return int
*/
public
function
getFlags
()
{
return
$this
->
flags
;
}
/**
* @param int $flags
*/
public
function
setFlags
(
$flags
)
{
$this
->
flags
=
$flags
;
}
/**
* @return int
*/
public
function
getProtocol
()
{
return
$this
->
protocol
;
}
/**
* @return int
*/
public
function
getAlgorithm
()
{
return
$this
->
algorithm
;
}
/**
* @param int $algorithm
*/
public
function
setAlgorithm
(
$algorithm
)
{
$this
->
algorithm
=
$algorithm
;
}
/**
* @return string
*/
public
function
getPublicKey
()
{
return
$this
->
publicKey
;
}
/**
* @param string $publicKey
*/
public
function
setPublicKey
(
$publicKey
)
{
$this
->
publicKey
=
$publicKey
;
}
/**
* {@inheritdoc}
*/
public
function
output
()
{
return
sprintf
(
'%s %s %s %s'
,
$this
->
flags
,
$this
->
protocol
,
$this
->
algorithm
,
$this
->
publicKey
);
}
}
lib/Rdata/DNSSEC/DS.php
View file @
f63b7d49
<?php
/*
* This file is part of Badcow DNS Library.
*
* (c) Samuel Williams <sam@badcow.co>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
Badcow\DNS\Rdata\DNSSEC
;
use
Badcow\DNS\Rdata\RdataInterface
;
use
Badcow\DNS\Rdata\RdataTrait
;
class
DS
implements
RdataInterface
{
use
RdataTrait
;
const
TYPE
=
'DS'
;
const
DIGEST_SHA1
=
1
;
/**
* @var int
*/
private
$keyTag
;
/**
* The Algorithm field lists the algorithm number of the DNSKEY RR
* referred to by the DS record.
* {@link https://tools.ietf.org/html/rfc4034#section-5.1.2}
*
* @var int
*/
private
$algorithm
;
/**
* @var int
*/
private
$digestType
=
self
::
DIGEST_SHA1
;
/**
* @var string
*/
private
$digest
;
/**
* @return int
*/
public
function
getKeyTag
()
{
return
$this
->
keyTag
;
}
/**
* @param int $keyTag
*/
public
function
setKeyTag
(
$keyTag
)
{
$this
->
keyTag
=
(
int
)
$keyTag
;
}
/**
* @return int
*/
public
function
getAlgorithm
()
{
return
$this
->
algorithm
;
}
/**