@@ -17,17 +17,13 @@ class DNS extends Validator
1717 protected const DEFAULT_DNS_SERVER = '8.8.8.8 ' ;
1818
1919 // Memory from isValid to be used in getDescription
20- /**
21- * @var mixed
22- */
23- protected mixed $ logs = [];
2420 /**
2521 * @var array<string>
2622 */
27- public array $ recordValues = [];
28- public string $ domain = '' ;
29- public int $ count = 0 ;
30- public string $ reason = '' ;
23+ public array $ records = []; // Records found, even if wrong value
24+ public string $ value = '' ; // Domain being validated
25+ public int $ count = 0 ; // Amount of records found
26+ public string $ reason = '' ; // Override for when reason is known ahead of time
3127
3228 /**
3329 * @param string $target Expected value for the DNS record
@@ -56,11 +52,11 @@ public function getDescription(): string
5652 $ messages [] = "DNS verification failed with resolver {$ this ->dnsServer }" ;
5753
5854 if ($ this ->count === 0 ) {
59- $ messages [] = 'Domain ' . $ this ->domain . ' is missing ' . $ typeVerbose . ' record ' ;
55+ $ messages [] = 'Domain ' . $ this ->value . ' is missing ' . $ typeVerbose . ' record ' ;
6056 return implode ('. ' , $ messages ) . '. ' ;
6157 }
6258
63- $ recordValuesVerbose = implode ("', ' " , $ this ->recordValues );
59+ $ records = implode ("', ' " , $ this ->records );
6460
6561 $ countVerbose = match ($ this ->count ) {
6662 1 => 'one ' ,
@@ -77,10 +73,10 @@ public function getDescription(): string
7773 };
7874
7975 if ($ this ->count === 1 ) {
80- $ messages [] = "Domain {$ this ->domain } has incorrect {$ typeVerbose } value ' {$ recordValuesVerbose }' " ;
76+ $ messages [] = "Domain {$ this ->value } has incorrect {$ typeVerbose } value ' {$ records }' " ;
8177 } else {
8278 // Two or more
83- $ messages [] = "Domain {$ this ->domain } has {$ countVerbose } incompatible {$ typeVerbose } records: ' {$ recordValuesVerbose }' " ;
79+ $ messages [] = "Domain {$ this ->value } has {$ countVerbose } incompatible {$ typeVerbose } records: ' {$ records }' " ;
8480 }
8581
8682 if ($ this ->type === Record::TYPE_CAA ) {
@@ -90,14 +86,6 @@ public function getDescription(): string
9086 return implode ('. ' , $ messages ) . '. ' ;
9187 }
9288
93- /**
94- * @return mixed
95- */
96- public function getLogs (): mixed
97- {
98- return $ this ->logs ;
99- }
100-
10189 /**
10290 * Check if DNS record value matches specific value
10391 *
@@ -112,9 +100,9 @@ public function isValid(mixed $value): bool
112100 }
113101
114102 $ this ->count = 0 ;
115- $ this ->domain = \strval ($ value );
103+ $ this ->value = \strval ($ value );
116104 $ this ->reason = self ::FAILURE_REASON_UNKNOWN ;
117- $ this ->recordValues = [];
105+ $ this ->records = [];
118106
119107 $ dns = new Client ($ this ->dnsServer );
120108
@@ -130,10 +118,8 @@ public function isValid(mixed $value): bool
130118 return $ record ->type === $ this ->type ;
131119 });
132120
133- $ this ->logs = $ query ;
134121 } catch (\Exception $ e ) {
135122 $ this ->reason = self ::FAILURE_REASON_QUERY ;
136- $ this ->logs = ['error ' => $ e ->getMessage ()];
137123 return false ;
138124 }
139125
@@ -152,7 +138,12 @@ public function isValid(mixed $value): bool
152138 \array_shift ($ parts );
153139 $ parentDomain = \implode ('. ' , $ parts );
154140 $ validator = new self ($ this ->target , $ this ->type , $ this ->dnsServer );
155- return $ validator ->isValid ($ parentDomain );
141+ $ result = $ validator ->isValid ($ parentDomain );
142+ $ this ->records = $ validator ->records ;
143+ $ this ->value = $ validator ->value ;
144+ $ this ->count = $ validator ->count ;
145+ $ this ->reason = $ validator ->reason ;
146+ return $ result ;
156147 }
157148
158149 return false ;
@@ -167,12 +158,12 @@ public function isValid(mixed $value): bool
167158 $ rdata = \trim ($ rdata , '" ' ); // certainly.com;validationmethods=tls-alpn-01;retrytimeout=3600
168159 $ rdata = \explode ('; ' , $ rdata , 2 )[0 ]; // certainly.com
169160
170- $ this ->recordValues [] = $ rdata ;
161+ $ this ->records [] = $ rdata ;
171162 if ($ rdata === $ this ->target ) {
172163 return true ;
173164 }
174165 } else {
175- $ this ->recordValues [] = $ record ->rdata ;
166+ $ this ->records [] = $ record ->rdata ;
176167 }
177168
178169 if ($ record ->rdata === $ this ->target ) {
0 commit comments