SG Optimizer - Version 7.2.7

Version Description

Download this release

Release Info

Developer elenachavdarova
Plugin Icon 128x128 SG Optimizer
Version 7.2.7
Comparing to
See all releases

Code changes from version 7.2.6 to 7.2.7

Files changed (115) hide show
  1. core/Analysis/Analysis.php +5 -1
  2. core/CDN/Cdn.php +142 -0
  3. core/Combinator/Js_Combinator.php +2 -0
  4. core/File_Cacher/Cache.php +1 -1
  5. core/File_Cacher/File_Cacher.php +5 -1
  6. core/Helper/File_Cacher_Trait.php +2 -2
  7. core/Install_Service/Install_7_2_7.php +59 -0
  8. core/Install_Service/Install_Service.php +2 -0
  9. core/Lazy_Load/Lazy_Load.php +4 -0
  10. core/Site_Tools_Client/Site_Tools_Client.php +87 -0
  11. core/Supercacher/Supercacher.php +41 -39
  12. readme.txt +11 -1
  13. sg-cachepress.php +2 -2
  14. templates/memcached.tpl +9 -7
  15. vendor/autoload.php +15 -2
  16. vendor/composer/InstalledVersions.php +7 -7
  17. vendor/composer/autoload_namespaces.php +0 -1
  18. vendor/composer/autoload_static.php +0 -7
  19. vendor/composer/installed.json +2 -56
  20. vendor/composer/installed.php +13 -22
  21. vendor/composer/platform_check.php +2 -2
  22. vendor/pear/net_dns2/.gitattributes +0 -8
  23. vendor/pear/net_dns2/.gitignore +0 -1
  24. vendor/pear/net_dns2/LICENSE +0 -33
  25. vendor/pear/net_dns2/Net/DNS2.php +0 -1365
  26. vendor/pear/net_dns2/Net/DNS2/BitMap.php +0 -206
  27. vendor/pear/net_dns2/Net/DNS2/Cache.php +0 -263
  28. vendor/pear/net_dns2/Net/DNS2/Cache/File.php +0 -199
  29. vendor/pear/net_dns2/Net/DNS2/Cache/Shm.php +0 -270
  30. vendor/pear/net_dns2/Net/DNS2/Exception.php +0 -96
  31. vendor/pear/net_dns2/Net/DNS2/Header.php +0 -229
  32. vendor/pear/net_dns2/Net/DNS2/Lookups.php +0 -561
  33. vendor/pear/net_dns2/Net/DNS2/Notifier.php +0 -220
  34. vendor/pear/net_dns2/Net/DNS2/Packet.php +0 -401
  35. vendor/pear/net_dns2/Net/DNS2/Packet/Request.php +0 -168
  36. vendor/pear/net_dns2/Net/DNS2/Packet/Response.php +0 -145
  37. vendor/pear/net_dns2/Net/DNS2/PrivateKey.php +0 -377
  38. vendor/pear/net_dns2/Net/DNS2/Question.php +0 -196
  39. vendor/pear/net_dns2/Net/DNS2/RR.php +0 -616
  40. vendor/pear/net_dns2/Net/DNS2/RR/A.php +0 -108
  41. vendor/pear/net_dns2/Net/DNS2/RR/AAAA.php +0 -129
  42. vendor/pear/net_dns2/Net/DNS2/RR/AFSDB.php +0 -126
  43. vendor/pear/net_dns2/Net/DNS2/RR/AMTRELAY.php +0 -259
  44. vendor/pear/net_dns2/Net/DNS2/RR/ANY.php +0 -81
  45. vendor/pear/net_dns2/Net/DNS2/RR/APL.php +0 -295
  46. vendor/pear/net_dns2/Net/DNS2/RR/ATMA.php +0 -162
  47. vendor/pear/net_dns2/Net/DNS2/RR/AVC.php +0 -27
  48. vendor/pear/net_dns2/Net/DNS2/RR/CAA.php +0 -138
  49. vendor/pear/net_dns2/Net/DNS2/RR/CDNSKEY.php +0 -29
  50. vendor/pear/net_dns2/Net/DNS2/RR/CDS.php +0 -29
  51. vendor/pear/net_dns2/Net/DNS2/RR/CERT.php +0 -243
  52. vendor/pear/net_dns2/Net/DNS2/RR/CNAME.php +0 -105
  53. vendor/pear/net_dns2/Net/DNS2/RR/CSYNC.php +0 -155
  54. vendor/pear/net_dns2/Net/DNS2/RR/DHCID.php +0 -159
  55. vendor/pear/net_dns2/Net/DNS2/RR/DLV.php +0 -27
  56. vendor/pear/net_dns2/Net/DNS2/RR/DNAME.php +0 -105
  57. vendor/pear/net_dns2/Net/DNS2/RR/DNSKEY.php +0 -150
  58. vendor/pear/net_dns2/Net/DNS2/RR/DS.php +0 -139
  59. vendor/pear/net_dns2/Net/DNS2/RR/EID.php +0 -82
  60. vendor/pear/net_dns2/Net/DNS2/RR/EUI48.php +0 -139
  61. vendor/pear/net_dns2/Net/DNS2/RR/EUI64.php +0 -140
  62. vendor/pear/net_dns2/Net/DNS2/RR/HINFO.php +0 -125
  63. vendor/pear/net_dns2/Net/DNS2/RR/HIP.php +0 -239
  64. vendor/pear/net_dns2/Net/DNS2/RR/IPSECKEY.php +0 -338
  65. vendor/pear/net_dns2/Net/DNS2/RR/ISDN.php +0 -142
  66. vendor/pear/net_dns2/Net/DNS2/RR/KEY.php +0 -37
  67. vendor/pear/net_dns2/Net/DNS2/RR/KX.php +0 -131
  68. vendor/pear/net_dns2/Net/DNS2/RR/L32.php +0 -132
  69. vendor/pear/net_dns2/Net/DNS2/RR/L64.php +0 -139
  70. vendor/pear/net_dns2/Net/DNS2/RR/LOC.php +0 -392
  71. vendor/pear/net_dns2/Net/DNS2/RR/LP.php +0 -129
  72. vendor/pear/net_dns2/Net/DNS2/RR/MX.php +0 -127
  73. vendor/pear/net_dns2/Net/DNS2/RR/NAPTR.php +0 -183
  74. vendor/pear/net_dns2/Net/DNS2/RR/NID.php +0 -139
  75. vendor/pear/net_dns2/Net/DNS2/RR/NIMLOC.php +0 -82
  76. vendor/pear/net_dns2/Net/DNS2/RR/NS.php +0 -105
  77. vendor/pear/net_dns2/Net/DNS2/RR/NSAP.php +0 -214
  78. vendor/pear/net_dns2/Net/DNS2/RR/NSEC.php +0 -136
  79. vendor/pear/net_dns2/Net/DNS2/RR/NSEC3.php +0 -262
  80. vendor/pear/net_dns2/Net/DNS2/RR/NSEC3PARAM.php +0 -172
  81. vendor/pear/net_dns2/Net/DNS2/RR/OPENPGPKEY.php +0 -111
  82. vendor/pear/net_dns2/Net/DNS2/RR/OPT.php +0 -244
  83. vendor/pear/net_dns2/Net/DNS2/RR/PTR.php +0 -104
  84. vendor/pear/net_dns2/Net/DNS2/RR/PX.php +0 -138
  85. vendor/pear/net_dns2/Net/DNS2/RR/RP.php +0 -118
  86. vendor/pear/net_dns2/Net/DNS2/RR/RRSIG.php +0 -280
  87. vendor/pear/net_dns2/Net/DNS2/RR/RT.php +0 -127
  88. vendor/pear/net_dns2/Net/DNS2/RR/SIG.php +0 -410
  89. vendor/pear/net_dns2/Net/DNS2/RR/SMIMEA.php +0 -27
  90. vendor/pear/net_dns2/Net/DNS2/RR/SOA.php +0 -192
  91. vendor/pear/net_dns2/Net/DNS2/RR/SPF.php +0 -27
  92. vendor/pear/net_dns2/Net/DNS2/RR/SRV.php +0 -145
  93. vendor/pear/net_dns2/Net/DNS2/RR/SSHFP.php +0 -205
  94. vendor/pear/net_dns2/Net/DNS2/RR/TA.php +0 -27
  95. vendor/pear/net_dns2/Net/DNS2/RR/TALINK.php +0 -121
  96. vendor/pear/net_dns2/Net/DNS2/RR/TKEY.php +0 -259
  97. vendor/pear/net_dns2/Net/DNS2/RR/TLSA.php +0 -146
  98. vendor/pear/net_dns2/Net/DNS2/RR/TSIG.php +0 -456
  99. vendor/pear/net_dns2/Net/DNS2/RR/TXT.php +0 -129
  100. vendor/pear/net_dns2/Net/DNS2/RR/TYPE65534.php +0 -107
  101. vendor/pear/net_dns2/Net/DNS2/RR/URI.php +0 -135
  102. vendor/pear/net_dns2/Net/DNS2/RR/WKS.php +0 -187
  103. vendor/pear/net_dns2/Net/DNS2/RR/X25.php +0 -112
  104. vendor/pear/net_dns2/Net/DNS2/Resolver.php +0 -284
  105. vendor/pear/net_dns2/Net/DNS2/Socket.php +0 -440
  106. vendor/pear/net_dns2/Net/DNS2/Updater.php +0 -606
  107. vendor/pear/net_dns2/README.md +0 -40
  108. vendor/pear/net_dns2/composer.json +0 -40
  109. vendor/pear/net_dns2/package.php +0 -50
  110. vendor/pear/net_dns2/package.xml +0 -592
  111. vendor/pear/net_dns2/tests/Tests_Net_DNS2_AllTests.php +0 -73
  112. vendor/pear/net_dns2/tests/Tests_Net_DNS2_DNSSECTest.php +0 -49
  113. vendor/pear/net_dns2/tests/Tests_Net_DNS2_ParserTest.php +0 -292
  114. vendor/pear/net_dns2/tests/Tests_Net_DNS2_ResolverTest.php +0 -49
  115. vendor/siteground/siteground-i18n/src/i18n_Service.php +14 -5
core/Analysis/Analysis.php CHANGED
@@ -102,7 +102,6 @@ class Analysis {
102
  'data' => array(),
103
  'timeStamp' => time(),
104
  'optimizations' => array(),
105
- 'human_readable_timestamp' => date( 'd M Y, G:i e' ),
106
  );
107
  $options = array();
108
 
@@ -339,6 +338,11 @@ class Analysis {
339
  $test_data['scores']['score']['score'] = $test_data['scores']['score']['score'] * 100;
340
  }
341
 
 
 
 
 
 
342
  $data[] = array(
343
  'option_name' => $result['option_name'],
344
  'result' => $test_data,
102
  'data' => array(),
103
  'timeStamp' => time(),
104
  'optimizations' => array(),
 
105
  );
106
  $options = array();
107
 
338
  $test_data['scores']['score']['score'] = $test_data['scores']['score']['score'] * 100;
339
  }
340
 
341
+ // Show human readable timestamp with local timezone.
342
+ $date = new \DateTime( '@'.$test_data['timeStamp'] );
343
+ $date->setTimezone( new \DateTimeZone( \wp_timezone_string() ));
344
+ $test_data['human_readable_timestamp'] = $date->format( 'd M Y, G:i e' );
345
+
346
  $data[] = array(
347
  'option_name' => $result['option_name'],
348
  'result' => $test_data,
core/CDN/Cdn.php ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace SiteGround_Optimizer\CDN;
3
+
4
+ use SiteGround_Optimizer\Site_Tools_Client\Site_Tools_Client;
5
+
6
+ /**
7
+ * CDN class.
8
+ */
9
+ class Cdn {
10
+ /**
11
+ * Get the CDN type.
12
+ *
13
+ * @since 7.2.7
14
+ *
15
+ * @return array $result The CDN check result.
16
+ */
17
+ public static function is_siteground_cdn() {
18
+ // Prepare arguments.
19
+ $args = array(
20
+ 'api' => 'domain-all',
21
+ 'cmd' => 'list',
22
+ 'params' => (object) array(),
23
+ 'settings' => array(
24
+ 'json' => 1,
25
+ 'show_fields' => array(
26
+ 'settings.cdn_enabled',
27
+ 'name',
28
+ ),
29
+ ),
30
+ );
31
+
32
+ // Connect to the socket.
33
+ $result = Site_Tools_Client::call_site_tools_client( $args );
34
+
35
+ // Bail if we do not get the result.
36
+ if ( ! $result ) {
37
+ return false;
38
+ }
39
+
40
+ // Loop the result and check if the CDN is enabled for the current site.
41
+ foreach ( $result['json'] as $site ) {
42
+ $matches = Site_Tools_Client::get_site_tools_matching_domain();
43
+
44
+ if ( $matches[1] !== $site['name'] ) {
45
+ continue;
46
+ }
47
+
48
+ if ( 1 === (int) $site['settings']['cdn_enabled'] ) {
49
+ return true;
50
+ }
51
+ }
52
+
53
+ return false;
54
+ }
55
+
56
+ /**
57
+ * Check if site is using CDN Premium.
58
+ *
59
+ * @since 7.2.7
60
+ *
61
+ * @return boolean If the site is using CDN Premium.
62
+ */
63
+ public static function is_siteground_cdn_premium() {
64
+ // Prepare the arguments.
65
+ $args = array(
66
+ 'api' => 'site',
67
+ 'cmd' => 'list',
68
+ 'params' => (object) array(),
69
+ 'settings' => array(
70
+ 'json' => 1,
71
+ 'show_fields' => array(
72
+ 'features',
73
+ ),
74
+ ),
75
+ );
76
+
77
+ // Connect to the socket.
78
+ $result = Site_Tools_Client::call_site_tools_client( $args );
79
+
80
+ // Bail if we do not get the result.
81
+ if ( ! $result ) {
82
+ return false;
83
+ }
84
+
85
+ // Check if it is premium CDN.
86
+ if ( isset( $result['json']['features']['cdn_cache_type'] ) ) {
87
+ return true;
88
+ }
89
+
90
+ return false;
91
+ }
92
+
93
+ /**
94
+ * Check if the CDN Premium has pending status.
95
+ *
96
+ * @since 7.2.7
97
+ *
98
+ * @return boolean True or false if premium is pending.
99
+ */
100
+ public static function is_siteground_cdn_premium_pending() {
101
+ // Prepare arguments.
102
+ $args = array(
103
+ 'api' => 'domain-all',
104
+ 'cmd' => 'list',
105
+ 'params' => (object) array(),
106
+ 'settings' => array(
107
+ 'json' => 1,
108
+ 'show_fields' => array(
109
+ 'settings.cdn_enabled',
110
+ 'name',
111
+ 'sg_cdn',
112
+ ),
113
+ ),
114
+ );
115
+
116
+ // Connect to the socket.
117
+ $result = Site_Tools_Client::call_site_tools_client( $args );
118
+
119
+ // Bail if we do not get the result.
120
+ if ( ! $result ) {
121
+ return false;
122
+ }
123
+
124
+ // Loop the result and check if the CDN is enabled for the current site.
125
+ foreach ( $result['json'] as $site ) {
126
+ $matches = Site_Tools_Client::get_site_tools_matching_domain();
127
+
128
+ if ( $matches[1] !== $site['name'] ) {
129
+ continue;
130
+ }
131
+
132
+ if (
133
+ 1 === (int) $site['settings']['cdn_enabled'] &&
134
+ 0 === (int) $site['sg_cdn']
135
+ ) {
136
+ return true;
137
+ }
138
+ }
139
+
140
+ return false;
141
+ }
142
+ }
core/Combinator/Js_Combinator.php CHANGED
@@ -501,6 +501,8 @@ class Js_Combinator extends Abstract_Combinator {
501
  'wp-polyfill',
502
  'wp-url',
503
  'wp-hooks',
 
 
504
  );
505
 
506
  /**
501
  'wp-polyfill',
502
  'wp-url',
503
  'wp-hooks',
504
+ 'sv_wc_payment_form_valid_payment_data',
505
+ 'sv_wc_payment_form_handler_init',
506
  );
507
 
508
  /**
core/File_Cacher/Cache.php CHANGED
@@ -133,7 +133,7 @@ class Cache {
133
 
134
  if (
135
  ( @file_exists( '/etc/yum.repos.d/baseos.repo' ) && @file_exists( '/Z' ) ) &&
136
- empty( $_COOKIE[ 'wordpress_logged_in_' . "COOKIEHASH" ] )
137
  ) {
138
  $should_send_miss = false;
139
  }
133
 
134
  if (
135
  ( @file_exists( '/etc/yum.repos.d/baseos.repo' ) && @file_exists( '/Z' ) ) &&
136
+ empty( $_COOKIE[ $this->logged_in_cookie ] )
137
  ) {
138
  $should_send_miss = false;
139
  }
core/File_Cacher/File_Cacher.php CHANGED
@@ -588,7 +588,7 @@ class File_Cacher extends Supercacher {
588
  * @since 7.0.1
589
  */
590
  public function schedule_cleanup() {
591
- $interval = intval( get_option( 'siteground_optimizer_file_caching_interval_cleanup', 0 ) );
592
 
593
  wp_clear_scheduled_hook( 'siteground_optimizer_clear_cache_dir' );
594
 
@@ -996,6 +996,7 @@ class File_Cacher extends Supercacher {
996
 
997
  return false;
998
  }
 
999
  /**
1000
  * Toggle the File Cache on and off.
1001
  *
@@ -1027,6 +1028,9 @@ class File_Cacher extends Supercacher {
1027
  $data['enable_cache'] = 1;
1028
  $data['autoflush_cache'] = 1;
1029
  }
 
 
 
1030
  } else {
1031
  $file_cacher->remove_config();
1032
  $file_cacher->remove_advanced_cache();
588
  * @since 7.0.1
589
  */
590
  public function schedule_cleanup() {
591
+ $interval = intval( get_option( 'siteground_optimizer_file_caching_interval_cleanup', 604800 ) );
592
 
593
  wp_clear_scheduled_hook( 'siteground_optimizer_clear_cache_dir' );
594
 
996
 
997
  return false;
998
  }
999
+
1000
  /**
1001
  * Toggle the File Cache on and off.
1002
  *
1028
  $data['enable_cache'] = 1;
1029
  $data['autoflush_cache'] = 1;
1030
  }
1031
+
1032
+ // Schedule cleanup.
1033
+ $file_cacher->schedule_cleanup();
1034
  } else {
1035
  $file_cacher->remove_config();
1036
  $file_cacher->remove_advanced_cache();
core/Helper/File_Cacher_Trait.php CHANGED
@@ -222,13 +222,13 @@ trait File_Cacher_Trait {
222
  )
223
  );
224
 
225
- foreach ( apache_request_headers() as $header => $value ) {
226
  $lowercase_header = strtolower( $header );
227
 
228
  // Do not cache if any of the ignore headers exists and matche the ignore header value.
229
  if (
230
  array_key_exists( $lowercase_header, $ignore_headers ) &&
231
- trim( $value ) === $ignore_headers[ $lowercase_header ]
232
  ) {
233
  return true;
234
  }
222
  )
223
  );
224
 
225
+ foreach ( apache_response_headers() as $header => $value ) {
226
  $lowercase_header = strtolower( $header );
227
 
228
  // Do not cache if any of the ignore headers exists and matche the ignore header value.
229
  if (
230
  array_key_exists( $lowercase_header, $ignore_headers ) &&
231
+ stripos( trim( $value ), $ignore_headers[ $lowercase_header ] )
232
  ) {
233
  return true;
234
  }
core/Install_Service/Install_7_2_7.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace SiteGround_Optimizer\Install_Service;
3
+
4
+ use SiteGround_Optimizer\Memcache\Memcache;
5
+ use SiteGround_Optimizer\Options\Options;
6
+
7
+ class Install_7_2_7 extends Install {
8
+ /**
9
+ * The default install version. Overridden by the installation packages.
10
+ *
11
+ * @since 7.2.7
12
+ *
13
+ * @access protected
14
+ *
15
+ * @var string $version The install version.
16
+ */
17
+ protected static $version = '7.2.7';
18
+
19
+ /**
20
+ * Run the install procedure.
21
+ *
22
+ * @since 7.2.7
23
+ */
24
+ public function install() {
25
+ $this->fb_cache_cleanup();
26
+ $this->update_memcached_dropin();
27
+ }
28
+
29
+ /**
30
+ * Fix FileBased cache cleanup interval.
31
+ */
32
+ public function fb_cache_cleanup() {
33
+ if ( ! Options::is_enabled( 'siteground_optimizer_file_caching' ) ) {
34
+ return;
35
+ }
36
+
37
+ // Get the cleanup interval set.
38
+ $interval = intval( get_option( 'siteground_optimizer_file_caching_interval_cleanup', 604800 ) );
39
+
40
+ // Bail if cleanup interval is disabled.
41
+ if ( 0 === $interval ) {
42
+ return;
43
+ }
44
+
45
+ // Schedule the cleanup.
46
+ wp_schedule_single_event( time() + $interval, 'siteground_optimizer_clear_cache_dir' );
47
+ }
48
+
49
+ /**
50
+ * Update Memcached dropin
51
+ */
52
+ public function update_memcached_dropin() {
53
+ if ( Options::is_enabled( 'siteground_optimizer_enable_memcached' ) ) {
54
+ $memcached = new Memcache();
55
+ $memcached->remove_memcached_dropin();
56
+ $memcached->create_memcached_dropin();
57
+ }
58
+ }
59
+ }
core/Install_Service/Install_Service.php CHANGED
@@ -36,6 +36,7 @@ use SiteGround_Optimizer\Install_Service\Install_7_1_0;
36
  use SiteGround_Optimizer\Install_Service\Install_7_1_5;
37
  use SiteGround_Optimizer\Install_Service\Install_7_2_2;
38
  use SiteGround_Optimizer\Install_Service\Install_7_2_3;
 
39
  use SiteGround_Optimizer\Install_Service\Install_Cleanup;
40
  use SiteGround_Optimizer\Supercacher\Supercacher;
41
 
@@ -83,6 +84,7 @@ class Install_Service {
83
  new Install_7_1_5(),
84
  new Install_7_2_2(),
85
  new Install_7_2_3(),
 
86
  );
87
  }
88
 
36
  use SiteGround_Optimizer\Install_Service\Install_7_1_5;
37
  use SiteGround_Optimizer\Install_Service\Install_7_2_2;
38
  use SiteGround_Optimizer\Install_Service\Install_7_2_3;
39
+ use SiteGround_Optimizer\Install_Service\Install_7_2_7;
40
  use SiteGround_Optimizer\Install_Service\Install_Cleanup;
41
  use SiteGround_Optimizer\Supercacher\Supercacher;
42
 
84
  new Install_7_1_5(),
85
  new Install_7_2_2(),
86
  new Install_7_2_3(),
87
+ new Install_7_2_7(),
88
  );
89
  }
90
 
core/Lazy_Load/Lazy_Load.php CHANGED
@@ -34,6 +34,10 @@ class Lazy_Load {
34
  'option' => 'textwidgets',
35
  'hook' => 'widget_text',
36
  ),
 
 
 
 
37
  array(
38
  'option' => 'thumbnails',
39
  'hook' => 'post_thumbnail_html',
34
  'option' => 'textwidgets',
35
  'hook' => 'widget_text',
36
  ),
37
+ array(
38
+ 'option' => 'textwidgets',
39
+ 'hook' => 'widget_block_content',
40
+ ),
41
  array(
42
  'option' => 'thumbnails',
43
  'hook' => 'post_thumbnail_html',
core/Site_Tools_Client/Site_Tools_Client.php ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace SiteGround_Optimizer\Site_Tools_Client;
3
+
4
+ /**
5
+ * Site Tools Client class.
6
+ */
7
+ class Site_Tools_Client {
8
+ /**
9
+ * SiteTools Client Unix Socket.
10
+ *
11
+ * @since 7.2.7
12
+ *
13
+ * @var string Path to the SiteTools UNIX socket file.
14
+ */
15
+ const SITE_TOOLS_SOCK_FILE = '/chroot/tmp/site-tools.sock';
16
+
17
+ /**
18
+ * Open socket and run a specific command.
19
+ *
20
+ * @since 7.2.7
21
+ *
22
+ * @param array $args The command arguments.
23
+ * @param bool $json_object Wheather to force json object upon json encode.
24
+ * @return boolean|array $result Array with results or false.
25
+ */
26
+ public static function call_site_tools_client( $args, $json_object = false ) {
27
+ // Bail if the socket does not exists.
28
+ if ( ! file_exists( self::SITE_TOOLS_SOCK_FILE ) ) {
29
+ return false;
30
+ }
31
+
32
+ // Bail if no arguments present.
33
+ if ( empty( $args ) ) {
34
+ return false;
35
+ }
36
+
37
+ // Open unix socket connection.
38
+ $fp = stream_socket_client( 'unix://' . self::SITE_TOOLS_SOCK_FILE, $errno, $errstr, 5 );
39
+
40
+ // Bail if the connection fails.
41
+ if ( false === $fp ) {
42
+ return false;
43
+ }
44
+
45
+ // Build the request params.
46
+ $request = array(
47
+ 'api' => $args['api'],
48
+ 'cmd' => $args['cmd'],
49
+ 'params' => $args['params'],
50
+ 'settings' => $args['settings'],
51
+ );
52
+
53
+ // Generate the json_encode flags based on passed variable.
54
+ $flags = ( false === $json_object ) ? 0 : JSON_FORCE_OBJECT;
55
+
56
+ // Sent the params to the Unix socket.
57
+ fwrite( $fp, json_encode( $request, $flags ) . "\n" );
58
+
59
+ // Fetch the response.
60
+ $response = fgets( $fp, 32 * 1024 );
61
+
62
+ // Close the connection.
63
+ fclose( $fp );
64
+
65
+ // Decode the response.
66
+ $result = @json_decode( $response, true );
67
+
68
+ if ( false === $result || isset( $result['err_code'] ) ) {
69
+ return false;
70
+ }
71
+
72
+ return $result;
73
+ }
74
+
75
+ /**
76
+ * Gets the site tools matching domain.
77
+ *
78
+ * @since 7.2.7
79
+ *
80
+ * @return array $matches Matches from the search.
81
+ */
82
+ public static function get_site_tools_matching_domain() {
83
+ preg_match( '/^(?:https?:\/\/)?(?:www\.)?([^\/]+)/im', get_home_url(), $matches );
84
+
85
+ return $matches;
86
+ }
87
+ }
core/Supercacher/Supercacher.php CHANGED
@@ -5,6 +5,8 @@ use SiteGround_Optimizer\File_Cacher\File_Cacher;
5
  use SiteGround_Optimizer\Front_End_Optimization\Front_End_Optimization;
6
  use SiteGround_Optimizer\Options\Options;
7
  use SiteGround_Helper\Helper_Service;
 
 
8
 
9
  /**
10
  * SG CachePress main plugin class
@@ -235,7 +237,7 @@ class Supercacher {
235
  }
236
 
237
  // Flush the cache for the URL.
238
- return self::call_site_tools_client( $hostname, $main_path, $url );
239
  }
240
 
241
  /**
@@ -247,55 +249,29 @@ class Supercacher {
247
  *
248
  * @return bool True if the cache is purged successfully, false otherwise.
249
  */
250
- public static function call_site_tools_client( $hostname, $main_path, $url ) {
251
- // Full path to the Unix socket.
252
- $sock_addr = '/chroot/tmp/site-tools.sock';
253
-
254
- // Bail if the socket does not exists.
255
- if ( ! file_exists( $sock_addr ) ) {
256
- return false;
257
- }
258
-
259
- // Open unix socket connection.
260
- $fp = stream_socket_client( 'unix://' . $sock_addr, $errno, $errstr, 5 );
261
-
262
- // Bail if the connection fails.
263
- if ( false === $fp ) {
264
- return false;
265
- }
266
-
267
  // Build the request params.
268
- $request = array(
269
- 'api' => 'domain-all',
270
- 'cmd' => 'update',
271
  'settings' => array( 'json' => 1 ),
272
- 'params' => array(
273
  'flush_cache' => '1',
274
  'id' => $hostname,
275
  'path' => $main_path,
276
  ),
277
  );
278
 
279
- // Sent the params to the Unix socket.
280
- fwrite( $fp, json_encode( $request, JSON_FORCE_OBJECT ) . "\n" );
281
-
282
- // Fetch the response.
283
- $response = fgets( $fp, 32 * 1024 );
284
-
285
- // Close the connection.
286
- fclose( $fp );
287
-
288
- // Decode the response.
289
- $result = @json_decode( $response, true );
290
 
291
  do_action( 'siteground_optimizer_flush_cache', $url );
292
 
293
- if ( false === $result ) {
294
  return false;
295
  }
296
 
297
- if ( isset( $result['err_code'] ) ) {
298
- error_log( 'There was an issue purging the cache for this URL: ' . $url . '. Error code: ' . $result['err_code'] . '. Message: ' . $result['message'] . '.' );
299
  return false;
300
  }
301
 
@@ -372,8 +348,32 @@ class Supercacher {
372
  return false;
373
  }
374
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
375
  // Make the request.
376
- $response = wp_remote_get( $url );
377
 
378
  // Check for errors.
379
  if ( is_wp_error( $response ) ) {
@@ -389,13 +389,15 @@ class Supercacher {
389
 
390
  // Check if the url has a cache header.
391
  if (
392
- isset( $headers[ 'x-proxy-cache' ] ) &&
393
- 'HIT' === strtoupper( $headers[ 'x-proxy-cache' ] )
394
  ) {
395
  return true;
396
  }
397
 
398
  if ( $maybe_dynamic ) {
 
 
399
  return self::test_cache( $url, false );
400
  }
401
 
5
  use SiteGround_Optimizer\Front_End_Optimization\Front_End_Optimization;
6
  use SiteGround_Optimizer\Options\Options;
7
  use SiteGround_Helper\Helper_Service;
8
+ use SiteGround_Optimizer\CDN\Cdn;
9
+ use SiteGround_Optimizer\Site_Tools_Client\Site_Tools_Client;
10
 
11
  /**
12
  * SG CachePress main plugin class
237
  }
238
 
239
  // Flush the cache for the URL.
240
+ return self::flush_dynamic_cache( $hostname, $main_path, $url );
241
  }
242
 
243
  /**
249
  *
250
  * @return bool True if the cache is purged successfully, false otherwise.
251
  */
252
+ public static function flush_dynamic_cache( $hostname, $main_path, $url ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
253
  // Build the request params.
254
+ $args = array(
255
+ 'api' => 'domain-all',
256
+ 'cmd' => 'update',
257
  'settings' => array( 'json' => 1 ),
258
+ 'params' => array(
259
  'flush_cache' => '1',
260
  'id' => $hostname,
261
  'path' => $main_path,
262
  ),
263
  );
264
 
265
+ $site_tools_result = Site_Tools_Client::call_site_tools_client( $args, true );
 
 
 
 
 
 
 
 
 
 
266
 
267
  do_action( 'siteground_optimizer_flush_cache', $url );
268
 
269
+ if ( false === $site_tools_result ) {
270
  return false;
271
  }
272
 
273
+ if ( isset( $site_tools_result['err_code'] ) ) {
274
+ error_log( 'There was an issue purging the cache for this URL: ' . $url . '. Error code: ' . $site_tools_result['err_code'] . '. Message: ' . $site_tools_result['message'] . '.' );
275
  return false;
276
  }
277
 
348
  return false;
349
  }
350
 
351
+ // Define the arguments. No arguments necessary by default.
352
+ $args = array();
353
+
354
+ // Check if SiteGround CDN is active.
355
+ if (
356
+ Cdn::is_siteground_cdn() &&
357
+ ! Cdn::is_siteground_cdn_premium() ||
358
+ Cdn::is_siteground_cdn_premium_pending()
359
+ ) {
360
+ // Get the proper domain.
361
+ $matches = Site_Tools_Client::get_site_tools_matching_domain();
362
+
363
+ // Set the Host header so we can test the cache status locally from the server.
364
+ $args['headers'] = array(
365
+ 'Host' => $matches[1],
366
+ );
367
+
368
+ // Store the original url.
369
+ $initial_url = $url;
370
+
371
+ // Set the url to be the one of the host.
372
+ $url = 'https://' . \gethostname() . str_replace( $matches[0], '', $url );
373
+ }
374
+
375
  // Make the request.
376
+ $response = wp_remote_get( $url, $args );
377
 
378
  // Check for errors.
379
  if ( is_wp_error( $response ) ) {
389
 
390
  // Check if the url has a cache header.
391
  if (
392
+ isset( $headers['x-proxy-cache'] ) &&
393
+ 'HIT' === strtoupper( $headers['x-proxy-cache'] )
394
  ) {
395
  return true;
396
  }
397
 
398
  if ( $maybe_dynamic ) {
399
+ // Restore the url in cases of CDN check's second attempt to get the proper caching status.
400
+ $url = isset( $initial_url ) ? $initial_url : $url;
401
  return self::test_cache( $url, false );
402
  }
403
 
readme.txt CHANGED
@@ -464,6 +464,16 @@ Our plugin uses a cookie in order to function properly. It does not store person
464
 
465
  == Changelog ==
466
 
 
 
 
 
 
 
 
 
 
 
467
  = Version 7.2.6 =
468
  Release Date: Nov 21st, 2022
469
 
@@ -514,7 +524,7 @@ Release Date: June 23rd, 2022
514
  * Improved Memcached service
515
 
516
  = Version 7.1.4 =
517
- Release Date: June 21th, 2022
518
 
519
  * Improved older PHP versions support
520
 
464
 
465
  == Changelog ==
466
 
467
+ = Version 7.2.7 =
468
+ Release Date: Nov 30rd, 2022
469
+
470
+ * Improved Memcache Health status checks
471
+ * Improved FileBased Cache cleanup
472
+ * Improved FileBased Cache Headers checks
473
+ * Improved LazyLoad for sidebar images
474
+ * Improved Speed Test results
475
+ * Improved Test URL cache status
476
+
477
  = Version 7.2.6 =
478
  Release Date: Nov 21st, 2022
479
 
524
  * Improved Memcached service
525
 
526
  = Version 7.1.4 =
527
+ Release Date: June 21st, 2022
528
 
529
  * Improved older PHP versions support
530
 
sg-cachepress.php CHANGED
@@ -10,7 +10,7 @@
10
  * Plugin Name: SiteGround Optimizer
11
  * Plugin URI: https://siteground.com
12
  * Description: This plugin will link your WordPress application with all the performance optimizations provided by SiteGround
13
- * Version: 7.2.6
14
  * Author: SiteGround
15
  * Author URI: https://www.siteground.com
16
  * Text Domain: sg-cachepress
@@ -32,7 +32,7 @@ if ( ! defined( 'WPINC' ) ) {
32
 
33
  // Define version constant.
34
  if ( ! defined( __NAMESPACE__ . '\VERSION' ) ) {
35
- define( __NAMESPACE__ . '\VERSION', '7.2.6' );
36
  }
37
 
38
  // Define slug constant.
10
  * Plugin Name: SiteGround Optimizer
11
  * Plugin URI: https://siteground.com
12
  * Description: This plugin will link your WordPress application with all the performance optimizations provided by SiteGround
13
+ * Version: 7.2.7
14
  * Author: SiteGround
15
  * Author URI: https://www.siteground.com
16
  * Text Domain: sg-cachepress
32
 
33
  // Define version constant.
34
  if ( ! defined( __NAMESPACE__ . '\VERSION' ) ) {
35
+ define( __NAMESPACE__ . '\VERSION', '7.2.7' );
36
  }
37
 
38
  // Define slug constant.
templates/memcached.tpl CHANGED
@@ -447,14 +447,16 @@ class WP_Object_Cache {
447
  // Unix socket to connect to.
448
  $per_user_unix_socket = "/home/.tmp/memcached.sock";
449
 
450
- // Verify the file exists before initiating stat
451
- if ( file_exists( $per_user_unix_socket ) ) {
452
- $stat = stat( $per_user_unix_socket );
453
 
454
- if ( $stat !== false && ( $stat["mode"] & 0140000 ) == 0140000 ) {
455
- // Use UNIX socket for memcached connection
456
- $this->mc['default']->addServer( $per_user_unix_socket, 0, 1 );
457
- }
 
 
 
 
458
  }
459
 
460
  global $blog_id, $table_prefix;
447
  // Unix socket to connect to.
448
  $per_user_unix_socket = "/home/.tmp/memcached.sock";
449
 
450
+ $stat = @stat( $per_user_unix_socket );
 
 
451
 
452
+ if ( ! $stat ) {
453
+ error_log( 'Memcache disabled from SiteTools' );
454
+ @rename( __FILE__, dirname( __FILE__ ) . '/object-cache-socket-missing.php' );
455
+ }
456
+
457
+ if ( ( $stat["mode"] & 0140000 ) == 0140000 ) {
458
+ // Use UNIX socket for memcached connection
459
+ $this->mc['default']->addServer( $per_user_unix_socket, 0, 1 );
460
  }
461
 
462
  global $blog_id, $table_prefix;
vendor/autoload.php CHANGED
@@ -3,8 +3,21 @@
3
  // autoload.php @generated by Composer
4
 
5
  if (PHP_VERSION_ID < 50600) {
6
- echo 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
7
- exit(1);
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  }
9
 
10
  require_once __DIR__ . '/composer/autoload_real.php';
3
  // autoload.php @generated by Composer
4
 
5
  if (PHP_VERSION_ID < 50600) {
6
+ if (!headers_sent()) {
7
+ header('HTTP/1.1 500 Internal Server Error');
8
+ }
9
+ $err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
10
+ if (!ini_get('display_errors')) {
11
+ if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
12
+ fwrite(STDERR, $err);
13
+ } elseif (!headers_sent()) {
14
+ echo $err;
15
+ }
16
+ }
17
+ trigger_error(
18
+ $err,
19
+ E_USER_ERROR
20
+ );
21
  }
22
 
23
  require_once __DIR__ . '/composer/autoload_real.php';
vendor/composer/InstalledVersions.php CHANGED
@@ -28,7 +28,7 @@ class InstalledVersions
28
  {
29
  /**
30
  * @var mixed[]|null
31
- * @psalm-var array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}|array{}|null
32
  */
33
  private static $installed;
34
 
@@ -39,7 +39,7 @@ class InstalledVersions
39
 
40
  /**
41
  * @var array[]
42
- * @psalm-var array<string, array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
43
  */
44
  private static $installedByVendor = array();
45
 
@@ -243,7 +243,7 @@ class InstalledVersions
243
 
244
  /**
245
  * @return array
246
- * @psalm-return array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}
247
  */
248
  public static function getRootPackage()
249
  {
@@ -257,7 +257,7 @@ class InstalledVersions
257
  *
258
  * @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect.
259
  * @return array[]
260
- * @psalm-return array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}
261
  */
262
  public static function getRawData()
263
  {
@@ -280,7 +280,7 @@ class InstalledVersions
280
  * Returns the raw data of all installed.php which are currently loaded for custom implementations
281
  *
282
  * @return array[]
283
- * @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
284
  */
285
  public static function getAllRawData()
286
  {
@@ -303,7 +303,7 @@ class InstalledVersions
303
  * @param array[] $data A vendor/composer/installed.php data set
304
  * @return void
305
  *
306
- * @psalm-param array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>} $data
307
  */
308
  public static function reload($data)
309
  {
@@ -313,7 +313,7 @@ class InstalledVersions
313
 
314
  /**
315
  * @return array[]
316
- * @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
317
  */
318
  private static function getInstalled()
319
  {
28
  {
29
  /**
30
  * @var mixed[]|null
31
+ * @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}|array{}|null
32
  */
33
  private static $installed;
34
 
39
 
40
  /**
41
  * @var array[]
42
+ * @psalm-var array<string, array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
43
  */
44
  private static $installedByVendor = array();
45
 
243
 
244
  /**
245
  * @return array
246
+ * @psalm-return array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}
247
  */
248
  public static function getRootPackage()
249
  {
257
  *
258
  * @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect.
259
  * @return array[]
260
+ * @psalm-return array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}
261
  */
262
  public static function getRawData()
263
  {
280
  * Returns the raw data of all installed.php which are currently loaded for custom implementations
281
  *
282
  * @return array[]
283
+ * @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
284
  */
285
  public static function getAllRawData()
286
  {
303
  * @param array[] $data A vendor/composer/installed.php data set
304
  * @return void
305
  *
306
+ * @psalm-param array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $data
307
  */
308
  public static function reload($data)
309
  {
313
 
314
  /**
315
  * @return array[]
316
+ * @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
317
  */
318
  private static function getInstalled()
319
  {
vendor/composer/autoload_namespaces.php CHANGED
@@ -7,5 +7,4 @@ $baseDir = dirname($vendorDir);
7
 
8
  return array(
9
  'Sepia' => array($vendorDir . '/sepia/po-parser/src'),
10
- 'Net_DNS2' => array($vendorDir . '/pear/net_dns2'),
11
  );
7
 
8
  return array(
9
  'Sepia' => array($vendorDir . '/sepia/po-parser/src'),
 
10
  );
vendor/composer/autoload_static.php CHANGED
@@ -83,13 +83,6 @@ class ComposerStaticInite5a5909d13acb78dadbeeac3e22ac679
83
  0 => __DIR__ . '/..' . '/sepia/po-parser/src',
84
  ),
85
  ),
86
- 'N' =>
87
- array (
88
- 'Net_DNS2' =>
89
- array (
90
- 0 => __DIR__ . '/..' . '/pear/net_dns2',
91
- ),
92
- ),
93
  );
94
 
95
  public static $classMap = array (
83
  0 => __DIR__ . '/..' . '/sepia/po-parser/src',
84
  ),
85
  ),
 
 
 
 
 
 
 
86
  );
87
 
88
  public static $classMap = array (
vendor/composer/installed.json CHANGED
@@ -384,60 +384,6 @@
384
  },
385
  "install-path": "../matthiasmullie/path-converter"
386
  },
387
- {
388
- "name": "pear/net_dns2",
389
- "version": "v1.5.2",
390
- "version_normalized": "1.5.2.0",
391
- "source": {
392
- "type": "git",
393
- "url": "https://github.com/mikepultz/netdns2.git",
394
- "reference": "d5dbae0b0c0567923d25b3ae5e2bf1e9cbcedf76"
395
- },
396
- "dist": {
397
- "type": "zip",
398
- "url": "https://api.github.com/repos/mikepultz/netdns2/zipball/d5dbae0b0c0567923d25b3ae5e2bf1e9cbcedf76",
399
- "reference": "d5dbae0b0c0567923d25b3ae5e2bf1e9cbcedf76",
400
- "shasum": ""
401
- },
402
- "require": {
403
- "php": ">=5.4"
404
- },
405
- "require-dev": {
406
- "phpunit/phpunit": "^9"
407
- },
408
- "time": "2020-10-11T17:33:54+00:00",
409
- "type": "library",
410
- "installation-source": "dist",
411
- "autoload": {
412
- "psr-0": {
413
- "Net_DNS2": ""
414
- }
415
- },
416
- "notification-url": "https://packagist.org/downloads/",
417
- "license": [
418
- "BSD-2-Clause"
419
- ],
420
- "authors": [
421
- {
422
- "name": "Mike Pultz",
423
- "email": "mike@mikepultz.com",
424
- "homepage": "https://mikepultz.com/",
425
- "role": "lead"
426
- }
427
- ],
428
- "description": "Native PHP DNS Resolver and Updater Library",
429
- "homepage": "https://netdns2.com/",
430
- "keywords": [
431
- "PEAR",
432
- "dns",
433
- "network"
434
- ],
435
- "support": {
436
- "issues": "https://github.com/mikepultz/netdns2/issues",
437
- "source": "https://github.com/mikepultz/netdns2"
438
- },
439
- "install-path": "../pear/net_dns2"
440
- },
441
  {
442
  "name": "sepia/po-parser",
443
  "version": "4.2.2",
@@ -569,9 +515,9 @@
569
  "source": {
570
  "type": "git",
571
  "url": "git@gitlab.siteground.com:wordpress/siteground-i18n.git",
572
- "reference": "b242d643714a172f4d000e3b6a05a6069c8dd30b"
573
  },
574
- "time": "2022-01-31T13:14:49+00:00",
575
  "default-branch": true,
576
  "type": "library",
577
  "installation-source": "source",
384
  },
385
  "install-path": "../matthiasmullie/path-converter"
386
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
387
  {
388
  "name": "sepia/po-parser",
389
  "version": "4.2.2",
515
  "source": {
516
  "type": "git",
517
  "url": "git@gitlab.siteground.com:wordpress/siteground-i18n.git",
518
+ "reference": "714db79a69f373acd8f8023aededc27e94463041"
519
  },
520
+ "time": "2022-11-22T15:52:04+00:00",
521
  "default-branch": true,
522
  "type": "library",
523
  "installation-source": "source",
vendor/composer/installed.php CHANGED
@@ -1,69 +1,60 @@
1
  <?php return array(
2
  'root' => array(
 
3
  'pretty_version' => 'dev-develop',
4
  'version' => 'dev-develop',
 
5
  'type' => 'wordpress-plugin',
6
  'install_path' => __DIR__ . '/../../',
7
  'aliases' => array(),
8
- 'reference' => 'e5e4784cbe8bd388b3f101c04036b8c12a55b548',
9
- 'name' => 'siteground/sg-cachepress',
10
  'dev' => true,
11
  ),
12
  'versions' => array(
13
  'a5hleyrich/wp-background-processing' => array(
14
  'pretty_version' => '1.0.2',
15
  'version' => '1.0.2.0',
 
16
  'type' => 'library',
17
  'install_path' => __DIR__ . '/../a5hleyrich/wp-background-processing',
18
  'aliases' => array(),
19
- 'reference' => '2cbee1abd1b49e1133cd8f611df4d4fc5a8b9800',
20
  'dev_requirement' => false,
21
  ),
22
  'charles-rumley/php-po-to-json' => array(
23
  'pretty_version' => 'dev-master',
24
  'version' => 'dev-master',
 
25
  'type' => 'package',
26
  'install_path' => __DIR__ . '/../charles-rumley/php-po-to-json',
27
  'aliases' => array(
28
  0 => '9999999-dev',
29
  ),
30
- 'reference' => 'c2d228fbbb69b90b6c331141b89c4faf985e6152',
31
  'dev_requirement' => false,
32
  ),
33
  'composer/installers' => array(
34
  'pretty_version' => 'v1.12.0',
35
  'version' => '1.12.0.0',
 
36
  'type' => 'composer-plugin',
37
  'install_path' => __DIR__ . '/./installers',
38
  'aliases' => array(),
39
- 'reference' => 'd20a64ed3c94748397ff5973488761b22f6d3f19',
40
  'dev_requirement' => false,
41
  ),
42
  'matthiasmullie/minify' => array(
43
  'pretty_version' => '1.3.69',
44
  'version' => '1.3.69.0',
 
45
  'type' => 'library',
46
  'install_path' => __DIR__ . '/../matthiasmullie/minify',
47
  'aliases' => array(),
48
- 'reference' => 'a61c949cccd086808063611ef9698eabe42ef22f',
49
  'dev_requirement' => false,
50
  ),
51
  'matthiasmullie/path-converter' => array(
52
  'pretty_version' => '1.1.3',
53
  'version' => '1.1.3.0',
54
- 'type' => 'library',
55
- 'install_path' => __DIR__ . '/../matthiasmullie/path-converter',
56
- 'aliases' => array(),
57
  'reference' => 'e7d13b2c7e2f2268e1424aaed02085518afa02d9',
58
- 'dev_requirement' => false,
59
- ),
60
- 'pear/net_dns2' => array(
61
- 'pretty_version' => 'v1.5.2',
62
- 'version' => '1.5.2.0',
63
  'type' => 'library',
64
- 'install_path' => __DIR__ . '/../pear/net_dns2',
65
  'aliases' => array(),
66
- 'reference' => 'd5dbae0b0c0567923d25b3ae5e2bf1e9cbcedf76',
67
  'dev_requirement' => false,
68
  ),
69
  'roundcube/plugin-installer' => array(
@@ -75,10 +66,10 @@
75
  'sepia/po-parser' => array(
76
  'pretty_version' => '4.2.2',
77
  'version' => '4.2.2.0',
 
78
  'type' => 'library',
79
  'install_path' => __DIR__ . '/../sepia/po-parser',
80
  'aliases' => array(),
81
- 'reference' => '8a6bbcd4a231b19e1b052c1c46b0fe2935331afe',
82
  'dev_requirement' => false,
83
  ),
84
  'shama/baton' => array(
@@ -90,54 +81,54 @@
90
  'siteground/sg-cachepress' => array(
91
  'pretty_version' => 'dev-develop',
92
  'version' => 'dev-develop',
 
93
  'type' => 'wordpress-plugin',
94
  'install_path' => __DIR__ . '/../../',
95
  'aliases' => array(),
96
- 'reference' => 'e5e4784cbe8bd388b3f101c04036b8c12a55b548',
97
  'dev_requirement' => false,
98
  ),
99
  'siteground/siteground-data' => array(
100
  'pretty_version' => 'dev-master',
101
  'version' => 'dev-master',
 
102
  'type' => 'library',
103
  'install_path' => __DIR__ . '/../siteground/siteground-data',
104
  'aliases' => array(
105
  0 => '9999999-dev',
106
  ),
107
- 'reference' => 'c264465ed26f2a8509b2a2b59ccc64c73971b343',
108
  'dev_requirement' => false,
109
  ),
110
  'siteground/siteground-emails' => array(
111
  'pretty_version' => 'dev-master',
112
  'version' => 'dev-master',
 
113
  'type' => 'library',
114
  'install_path' => __DIR__ . '/../siteground/siteground-emails',
115
  'aliases' => array(
116
  0 => '9999999-dev',
117
  ),
118
- 'reference' => '488bda959c356fd330d0ecfb45885fc0f421f5b7',
119
  'dev_requirement' => false,
120
  ),
121
  'siteground/siteground-helper' => array(
122
  'pretty_version' => 'dev-master',
123
  'version' => 'dev-master',
 
124
  'type' => 'library',
125
  'install_path' => __DIR__ . '/../siteground/siteground-helper',
126
  'aliases' => array(
127
  0 => '9999999-dev',
128
  ),
129
- 'reference' => 'b735bf5df36006a0e8435a6ba79b5b5cfa0e66dc',
130
  'dev_requirement' => false,
131
  ),
132
  'siteground/siteground-i18n' => array(
133
  'pretty_version' => 'dev-master',
134
  'version' => 'dev-master',
 
135
  'type' => 'library',
136
  'install_path' => __DIR__ . '/../siteground/siteground-i18n',
137
  'aliases' => array(
138
  0 => '9999999-dev',
139
  ),
140
- 'reference' => 'b242d643714a172f4d000e3b6a05a6069c8dd30b',
141
  'dev_requirement' => false,
142
  ),
143
  ),
1
  <?php return array(
2
  'root' => array(
3
+ 'name' => 'siteground/sg-cachepress',
4
  'pretty_version' => 'dev-develop',
5
  'version' => 'dev-develop',
6
+ 'reference' => '7e9d9c9b0046aecbd94d5a5b34f7548290f18c84',
7
  'type' => 'wordpress-plugin',
8
  'install_path' => __DIR__ . '/../../',
9
  'aliases' => array(),
 
 
10
  'dev' => true,
11
  ),
12
  'versions' => array(
13
  'a5hleyrich/wp-background-processing' => array(
14
  'pretty_version' => '1.0.2',
15
  'version' => '1.0.2.0',
16
+ 'reference' => '2cbee1abd1b49e1133cd8f611df4d4fc5a8b9800',
17
  'type' => 'library',
18
  'install_path' => __DIR__ . '/../a5hleyrich/wp-background-processing',
19
  'aliases' => array(),
 
20
  'dev_requirement' => false,
21
  ),
22
  'charles-rumley/php-po-to-json' => array(
23
  'pretty_version' => 'dev-master',
24
  'version' => 'dev-master',
25
+ 'reference' => 'c2d228fbbb69b90b6c331141b89c4faf985e6152',
26
  'type' => 'package',
27
  'install_path' => __DIR__ . '/../charles-rumley/php-po-to-json',
28
  'aliases' => array(
29
  0 => '9999999-dev',
30
  ),
 
31
  'dev_requirement' => false,
32
  ),
33
  'composer/installers' => array(
34
  'pretty_version' => 'v1.12.0',
35
  'version' => '1.12.0.0',
36
+ 'reference' => 'd20a64ed3c94748397ff5973488761b22f6d3f19',
37
  'type' => 'composer-plugin',
38
  'install_path' => __DIR__ . '/./installers',
39
  'aliases' => array(),
 
40
  'dev_requirement' => false,
41
  ),
42
  'matthiasmullie/minify' => array(
43
  'pretty_version' => '1.3.69',
44
  'version' => '1.3.69.0',
45
+ 'reference' => 'a61c949cccd086808063611ef9698eabe42ef22f',
46
  'type' => 'library',
47
  'install_path' => __DIR__ . '/../matthiasmullie/minify',
48
  'aliases' => array(),
 
49
  'dev_requirement' => false,
50
  ),
51
  'matthiasmullie/path-converter' => array(
52
  'pretty_version' => '1.1.3',
53
  'version' => '1.1.3.0',
 
 
 
54
  'reference' => 'e7d13b2c7e2f2268e1424aaed02085518afa02d9',
 
 
 
 
 
55
  'type' => 'library',
56
+ 'install_path' => __DIR__ . '/../matthiasmullie/path-converter',
57
  'aliases' => array(),
 
58
  'dev_requirement' => false,
59
  ),
60
  'roundcube/plugin-installer' => array(
66
  'sepia/po-parser' => array(
67
  'pretty_version' => '4.2.2',
68
  'version' => '4.2.2.0',
69
+ 'reference' => '8a6bbcd4a231b19e1b052c1c46b0fe2935331afe',
70
  'type' => 'library',
71
  'install_path' => __DIR__ . '/../sepia/po-parser',
72
  'aliases' => array(),
 
73
  'dev_requirement' => false,
74
  ),
75
  'shama/baton' => array(
81
  'siteground/sg-cachepress' => array(
82
  'pretty_version' => 'dev-develop',
83
  'version' => 'dev-develop',
84
+ 'reference' => '7e9d9c9b0046aecbd94d5a5b34f7548290f18c84',
85
  'type' => 'wordpress-plugin',
86
  'install_path' => __DIR__ . '/../../',
87
  'aliases' => array(),
 
88
  'dev_requirement' => false,
89
  ),
90
  'siteground/siteground-data' => array(
91
  'pretty_version' => 'dev-master',
92
  'version' => 'dev-master',
93
+ 'reference' => 'c264465ed26f2a8509b2a2b59ccc64c73971b343',
94
  'type' => 'library',
95
  'install_path' => __DIR__ . '/../siteground/siteground-data',
96
  'aliases' => array(
97
  0 => '9999999-dev',
98
  ),
 
99
  'dev_requirement' => false,
100
  ),
101
  'siteground/siteground-emails' => array(
102
  'pretty_version' => 'dev-master',
103
  'version' => 'dev-master',
104
+ 'reference' => '488bda959c356fd330d0ecfb45885fc0f421f5b7',
105
  'type' => 'library',
106
  'install_path' => __DIR__ . '/../siteground/siteground-emails',
107
  'aliases' => array(
108
  0 => '9999999-dev',
109
  ),
 
110
  'dev_requirement' => false,
111
  ),
112
  'siteground/siteground-helper' => array(
113
  'pretty_version' => 'dev-master',
114
  'version' => 'dev-master',
115
+ 'reference' => 'b735bf5df36006a0e8435a6ba79b5b5cfa0e66dc',
116
  'type' => 'library',
117
  'install_path' => __DIR__ . '/../siteground/siteground-helper',
118
  'aliases' => array(
119
  0 => '9999999-dev',
120
  ),
 
121
  'dev_requirement' => false,
122
  ),
123
  'siteground/siteground-i18n' => array(
124
  'pretty_version' => 'dev-master',
125
  'version' => 'dev-master',
126
+ 'reference' => '714db79a69f373acd8f8023aededc27e94463041',
127
  'type' => 'library',
128
  'install_path' => __DIR__ . '/../siteground/siteground-i18n',
129
  'aliases' => array(
130
  0 => '9999999-dev',
131
  ),
 
132
  'dev_requirement' => false,
133
  ),
134
  ),
vendor/composer/platform_check.php CHANGED
@@ -4,8 +4,8 @@
4
 
5
  $issues = array();
6
 
7
- if (!(PHP_VERSION_ID >= 50400)) {
8
- $issues[] = 'Your Composer dependencies require a PHP version ">= 5.4.0". You are running ' . PHP_VERSION . '.';
9
  }
10
 
11
  if ($issues) {
4
 
5
  $issues = array();
6
 
7
+ if (!(PHP_VERSION_ID >= 50300)) {
8
+ $issues[] = 'Your Composer dependencies require a PHP version ">= 5.3.0". You are running ' . PHP_VERSION . '.';
9
  }
10
 
11
  if ($issues) {
vendor/pear/net_dns2/.gitattributes DELETED
@@ -1,8 +0,0 @@
1
- # Auto detect text files and perform LF normalization
2
- * text=auto
3
-
4
- # Always perform LF normalization on these files
5
- *.json text
6
- *.md text
7
- *.php text
8
- *.xml text
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/.gitignore DELETED
@@ -1 +0,0 @@
1
- TODO
 
vendor/pear/net_dns2/LICENSE DELETED
@@ -1,33 +0,0 @@
1
- Net_DNS2 - DNS Library for handling lookups and updates.
2
-
3
- Copyright (c) 2010-2020, Mike Pultz <mike@mikepultz.com>.
4
- All rights reserved.
5
-
6
- Redistribution and use in source and binary forms, with or without
7
- modification, are permitted provided that the following conditions
8
- are met:
9
-
10
- * Redistributions of source code must retain the above copyright
11
- notice, this list of conditions and the following disclaimer.
12
-
13
- * Redistributions in binary form must reproduce the above copyright
14
- notice, this list of conditions and the following disclaimer in
15
- the documentation and/or other materials provided with the
16
- distribution.
17
-
18
- * Neither the name of Mike Pultz nor the names of his contributors
19
- may be used to endorse or promote products derived from this
20
- software without specific prior written permission.
21
-
22
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25
- FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26
- COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28
- BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31
- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32
- ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33
- POSSIBILITY OF SUCH DAMAGE.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2.php DELETED
@@ -1,1365 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 0.6.0
17
- *
18
- */
19
-
20
- /*
21
- * register the auto-load function
22
- *
23
- */
24
- spl_autoload_register('Net_DNS2::autoload');
25
-
26
- /**
27
- * This is the base class for the Net_DNS2_Resolver and Net_DNS2_Updater classes.
28
- *
29
- */
30
- class Net_DNS2
31
- {
32
- /*
33
- * the current version of this library
34
- */
35
- const VERSION = '1.5.2';
36
-
37
- /*
38
- * the default path to a resolv.conf file
39
- */
40
- const RESOLV_CONF = '/etc/resolv.conf';
41
-
42
- /*
43
- * override options from the resolv.conf file
44
- *
45
- * if this is set, then certain values from the resolv.conf file will override
46
- * local settings. This is disabled by default to remain backwards compatible.
47
- *
48
- */
49
- public $use_resolv_options = false;
50
-
51
- /*
52
- * use TCP only (true/false)
53
- */
54
- public $use_tcp = false;
55
-
56
- /*
57
- * DNS Port to use (53)
58
- */
59
- public $dns_port = 53;
60
-
61
- /*
62
- * the ip/port for use as a local socket
63
- */
64
- public $local_host = '';
65
- public $local_port = 0;
66
-
67
- /*
68
- * timeout value for socket connections
69
- */
70
- public $timeout = 5;
71
-
72
- /*
73
- * randomize the name servers list
74
- */
75
- public $ns_random = false;
76
-
77
- /*
78
- * default domains
79
- */
80
- public $domain = '';
81
-
82
- /*
83
- * domain search list - not actually used right now
84
- */
85
- public $search_list = [];
86
-
87
- /*
88
- * enable cache; either "shared", "file" or "none"
89
- */
90
- public $cache_type = 'none';
91
-
92
- /*
93
- * file name to use for shared memory segment or file cache
94
- */
95
- public $cache_file = '/tmp/net_dns2.cache';
96
-
97
- /*
98
- * the max size of the cache file (in bytes)
99
- */
100
- public $cache_size = 50000;
101
-
102
- /*
103
- * the method to use for storing cache data; either "serialize" or "json"
104
- *
105
- * json is faster, but can't remember the class names (everything comes back
106
- * as a "stdClass Object"; all the data is the same though. serialize is
107
- * slower, but will have all the class info.
108
- *
109
- * defaults to 'serialize'
110
- */
111
- public $cache_serializer = 'serialize';
112
-
113
- /*
114
- * by default, according to RFC 1034
115
- *
116
- * CNAME RRs cause special action in DNS software. When a name server
117
- * fails to find a desired RR in the resource set associated with the
118
- * domain name, it checks to see if the resource set consists of a CNAME
119
- * record with a matching class. If so, the name server includes the CNAME
120
- * record in the response and restarts the query at the domain name
121
- * specified in the data field of the CNAME record.
122
- *
123
- * this can cause "unexpected" behavious, since i'm sure *most* people
124
- * don't know DNS does this; there may be cases where Net_DNS2 returns a
125
- * positive response, even though the hostname the user looked up did not
126
- * actually exist.
127
- *
128
- * strict_query_mode means that if the hostname that was looked up isn't
129
- * actually in the answer section of the response, Net_DNS2 will return an
130
- * empty answer section, instead of an answer section that could contain
131
- * CNAME records.
132
- *
133
- */
134
- public $strict_query_mode = false;
135
-
136
- /*
137
- * if we should set the recursion desired bit to 1 or 0.
138
- *
139
- * by default this is set to true, we want the DNS server to perform a recursive
140
- * request. If set to false, the RD bit will be set to 0, and the server will
141
- * not perform recursion on the request.
142
- */
143
- public $recurse = true;
144
-
145
- /*
146
- * request DNSSEC values, by setting the DO flag to 1; this actually makes
147
- * the resolver add a OPT RR to the additional section, and sets the DO flag
148
- * in this RR to 1
149
- *
150
- */
151
- public $dnssec = false;
152
-
153
- /*
154
- * set the DNSSEC AD (Authentic Data) bit on/off; the AD bit on the request
155
- * side was previously undefined, and resolvers we instructed to always clear
156
- * the AD bit when sending a request.
157
- *
158
- * RFC6840 section 5.7 defines setting the AD bit in the query as a signal to
159
- * the server that it wants the value of the AD bit, without needed to request
160
- * all the DNSSEC data via the DO bit.
161
- *
162
- */
163
- public $dnssec_ad_flag = false;
164
-
165
- /*
166
- * set the DNSSEC CD (Checking Disabled) bit on/off; turning this off, means
167
- * that the DNS resolver will perform it's own signature validation- so the DNS
168
- * servers simply pass through all the details.
169
- *
170
- */
171
- public $dnssec_cd_flag = false;
172
-
173
- /*
174
- * the EDNS(0) UDP payload size to use when making DNSSEC requests
175
- * see RFC 4035 section 4.1 - EDNS Support.
176
- *
177
- * there is some different ideas on the suggest size to supprt; but it seems to
178
- * be "at least 1220 bytes, but SHOULD support 4000 bytes.
179
- *
180
- * we'll just support 4000
181
- *
182
- */
183
- public $dnssec_payload_size = 4000;
184
-
185
- /*
186
- * the last exeception that was generated
187
- */
188
- public $last_exception = null;
189
-
190
- /*
191
- * the list of exceptions by name server
192
- */
193
- public $last_exception_list = [];
194
-
195
- /*
196
- * name server list
197
- */
198
- public $nameservers = [];
199
-
200
- /*
201
- * local sockets
202
- */
203
- protected $sock = [ Net_DNS2_Socket::SOCK_DGRAM => [], Net_DNS2_Socket::SOCK_STREAM => [] ];
204
-
205
- /*
206
- * the TSIG or SIG RR object for authentication
207
- */
208
- protected $auth_signature = null;
209
-
210
- /*
211
- * the shared memory segment id for the local cache
212
- */
213
- protected $cache = null;
214
-
215
- /*
216
- * internal setting for enabling cache
217
- */
218
- protected $use_cache = false;
219
-
220
- /**
221
- * Constructor - base constructor for the Resolver and Updater
222
- *
223
- * @param mixed $options array of options or null for none
224
- *
225
- * @throws Net_DNS2_Exception
226
- * @access public
227
- *
228
- */
229
- public function __construct(array $options = null)
230
- {
231
- //
232
- // load any options that were provided
233
- //
234
- if (!empty($options)) {
235
-
236
- foreach ($options as $key => $value) {
237
-
238
- if ($key == 'nameservers') {
239
-
240
- $this->setServers($value);
241
- } else {
242
-
243
- $this->$key = $value;
244
- }
245
- }
246
- }
247
-
248
- //
249
- // if we're set to use the local shared memory cache, then
250
- // make sure it's been initialized
251
- //
252
- switch($this->cache_type) {
253
- case 'shared':
254
- if (extension_loaded('shmop')) {
255
-
256
- $this->cache = new Net_DNS2_Cache_Shm;
257
- $this->use_cache = true;
258
- } else {
259
-
260
- throw new Net_DNS2_Exception(
261
- 'shmop library is not available for cache',
262
- Net_DNS2_Lookups::E_CACHE_SHM_UNAVAIL
263
- );
264
- }
265
- break;
266
- case 'file':
267
-
268
- $this->cache = new Net_DNS2_Cache_File;
269
- $this->use_cache = true;
270
-
271
- break;
272
- case 'none':
273
- $this->use_cache = false;
274
- break;
275
- default:
276
-
277
- throw new Net_DNS2_Exception(
278
- 'un-supported cache type: ' . $this->cache_type,
279
- Net_DNS2_Lookups::E_CACHE_UNSUPPORTED
280
- );
281
- }
282
- }
283
-
284
- /**
285
- * autoload call-back function; used to auto-load classes
286
- *
287
- * @param string $name the name of the class
288
- *
289
- * @return void
290
- * @access public
291
- *
292
- */
293
- static public function autoload($name)
294
- {
295
- //
296
- // only auto-load our classes
297
- //
298
- if (strncmp($name, 'Net_DNS2', 8) == 0) {
299
-
300
- include str_replace('_', '/', $name) . '.php';
301
- }
302
-
303
- return;
304
- }
305
-
306
- /**
307
- * sets the name servers to be used
308
- *
309
- * @param mixed $nameservers either an array of name servers, or a file name
310
- * to parse, assuming it's in the resolv.conf format
311
- *
312
- * @return boolean
313
- * @throws Net_DNS2_Exception
314
- * @access public
315
- *
316
- */
317
- public function setServers($nameservers)
318
- {
319
- //
320
- // if it's an array, then use it directly
321
- //
322
- // otherwise, see if it's a path to a resolv.conf file and if so, load it
323
- //
324
- if (is_array($nameservers)) {
325
-
326
- $this->nameservers = $nameservers;
327
-
328
- } else {
329
-
330
- //
331
- // temporary list of name servers; do it this way rather than just
332
- // resetting the local nameservers value, just incase an exception
333
- // is thrown here; this way we might avoid ending up with an empty
334
- // namservers list.
335
- //
336
- $ns = [];
337
-
338
- //
339
- // check to see if the file is readable
340
- //
341
- if (is_readable($nameservers) === true) {
342
-
343
- $data = file_get_contents($nameservers);
344
- if ($data === false) {
345
- throw new Net_DNS2_Exception(
346
- 'failed to read contents of file: ' . $nameservers,
347
- Net_DNS2_Lookups::E_NS_INVALID_FILE
348
- );
349
- }
350
-
351
- $lines = explode("\n", $data);
352
-
353
- foreach ($lines as $line) {
354
-
355
- $line = trim($line);
356
-
357
- //
358
- // ignore empty lines, and lines that are commented out
359
- //
360
- if ( (strlen($line) == 0)
361
- || ($line[0] == '#')
362
- || ($line[0] == ';')
363
- ) {
364
- continue;
365
- }
366
-
367
- //
368
- // ignore lines with no spaces in them.
369
- //
370
- if (strpos($line, ' ') === false) {
371
- continue;
372
- }
373
-
374
- list($key, $value) = preg_split('/\s+/', $line, 2);
375
-
376
- $key = trim(strtolower($key));
377
- $value = trim(strtolower($value));
378
-
379
- switch($key) {
380
- case 'nameserver':
381
-
382
- //
383
- // nameserver can be a IPv4 or IPv6 address
384
- //
385
- if ( (self::isIPv4($value) == true)
386
- || (self::isIPv6($value) == true)
387
- ) {
388
-
389
- $ns[] = $value;
390
- } else {
391
-
392
- throw new Net_DNS2_Exception(
393
- 'invalid nameserver entry: ' . $value,
394
- Net_DNS2_Lookups::E_NS_INVALID_ENTRY
395
- );
396
- }
397
- break;
398
-
399
- case 'domain':
400
- $this->domain = $value;
401
- break;
402
-
403
- case 'search':
404
- $this->search_list = preg_split('/\s+/', $value);
405
- break;
406
-
407
- case 'options':
408
- $this->parseOptions($value);
409
- break;
410
-
411
- default:
412
- ;
413
- }
414
- }
415
-
416
- //
417
- // if we don't have a domain, but we have a search list, then
418
- // take the first entry on the search list as the domain
419
- //
420
- if ( (strlen($this->domain) == 0)
421
- && (count($this->search_list) > 0)
422
- ) {
423
- $this->domain = $this->search_list[0];
424
- }
425
-
426
- } else {
427
- throw new Net_DNS2_Exception(
428
- 'resolver file file provided is not readable: ' . $nameservers,
429
- Net_DNS2_Lookups::E_NS_INVALID_FILE
430
- );
431
- }
432
-
433
- //
434
- // store the name servers locally
435
- //
436
- if (count($ns) > 0) {
437
- $this->nameservers = $ns;
438
- }
439
- }
440
-
441
- //
442
- // remove any duplicates; not sure if we should bother with this- if people
443
- // put duplicate name servers, who I am to stop them?
444
- //
445
- $this->nameservers = array_unique($this->nameservers);
446
-
447
- //
448
- // check the name servers
449
- //
450
- $this->checkServers();
451
-
452
- return true;
453
- }
454
-
455
- /**
456
- * return the internal $sock array
457
- *
458
- * @return array
459
- * @access public
460
- */
461
- public function getSockets()
462
- {
463
- return $this->sock;
464
- }
465
-
466
- /**
467
- * give users access to close all open sockets on the resolver object; resetting each
468
- * array, calls the destructor on the Net_DNS2_Socket object, which calls the close()
469
- * method on each object.
470
- *
471
- * @return boolean
472
- * @access public
473
- *
474
- */
475
- public function closeSockets()
476
- {
477
- $this->sock[Net_DNS2_Socket::SOCK_DGRAM] = [];
478
- $this->sock[Net_DNS2_Socket::SOCK_STREAM] = [];
479
-
480
- return true;
481
- }
482
-
483
- /**
484
- * parses the options line from a resolv.conf file; we don't support all the options
485
- * yet, and using them is optional.
486
- *
487
- * @param string $value is the options string from the resolv.conf file.
488
- *
489
- * @return boolean
490
- * @access private
491
- *
492
- */
493
- private function parseOptions($value)
494
- {
495
- //
496
- // if overrides are disabled (the default), or the options list is empty for some
497
- // reason, then we don't need to do any of this work.
498
- //
499
- if ( ($this->use_resolv_options == false) || (strlen($value) == 0) ) {
500
-
501
- return true;
502
- }
503
-
504
- $options = preg_split('/\s+/', strtolower($value));
505
-
506
- foreach ($options as $option) {
507
-
508
- //
509
- // override the timeout value from the resolv.conf file.
510
- //
511
- if ( (strncmp($option, 'timeout', 7) == 0) && (strpos($option, ':') !== false) ) {
512
-
513
- list($key, $val) = explode(':', $option);
514
-
515
- if ( ($val > 0) && ($val <= 30) ) {
516
-
517
- $this->timeout = $val;
518
- }
519
-
520
- //
521
- // the rotate option just enabled the ns_random option
522
- //
523
- } else if (strncmp($option, 'rotate', 6) == 0) {
524
-
525
- $this->ns_random = true;
526
- }
527
- }
528
-
529
- return true;
530
- }
531
-
532
- /**
533
- * checks the list of name servers to make sure they're set
534
- *
535
- * @param mixed $default a path to a resolv.conf file or an array of servers.
536
- *
537
- * @return boolean
538
- * @throws Net_DNS2_Exception
539
- * @access protected
540
- *
541
- */
542
- protected function checkServers($default = null)
543
- {
544
- if (empty($this->nameservers)) {
545
-
546
- if (isset($default)) {
547
-
548
- $this->setServers($default);
549
- } else {
550
-
551
- throw new Net_DNS2_Exception(
552
- 'empty name servers list; you must provide a list of name '.
553
- 'servers, or the path to a resolv.conf file.',
554
- Net_DNS2_Lookups::E_NS_INVALID_ENTRY
555
- );
556
- }
557
- }
558
-
559
- return true;
560
- }
561
-
562
- /**
563
- * adds a TSIG RR object for authentication
564
- *
565
- * @param string $keyname the key name to use for the TSIG RR
566
- * @param string $signature the key to sign the request.
567
- * @param string $algorithm the algorithm to use
568
- *
569
- * @return boolean
570
- * @access public
571
- * @since function available since release 1.1.0
572
- *
573
- */
574
- public function signTSIG(
575
- $keyname, $signature = '', $algorithm = Net_DNS2_RR_TSIG::HMAC_MD5
576
- ) {
577
- //
578
- // if the TSIG was pre-created and passed in, then we can just used
579
- // it as provided.
580
- //
581
- if ($keyname instanceof Net_DNS2_RR_TSIG) {
582
-
583
- $this->auth_signature = $keyname;
584
-
585
- } else {
586
-
587
- //
588
- // otherwise create the TSIG RR, but don't add it just yet; TSIG needs
589
- // to be added as the last additional entry- so we'll add it just
590
- // before we send.
591
- //
592
- $this->auth_signature = Net_DNS2_RR::fromString(
593
- strtolower(trim($keyname)) .
594
- ' TSIG '. $signature
595
- );
596
-
597
- //
598
- // set the algorithm to use
599
- //
600
- $this->auth_signature->algorithm = $algorithm;
601
- }
602
-
603
- return true;
604
- }
605
-
606
- /**
607
- * adds a SIG RR object for authentication
608
- *
609
- * @param string $filename the name of a file to load the signature from.
610
- *
611
- * @return boolean
612
- * @throws Net_DNS2_Exception
613
- * @access public
614
- * @since function available since release 1.1.0
615
- *
616
- */
617
- public function signSIG0($filename)
618
- {
619
- //
620
- // check for OpenSSL
621
- //
622
- if (extension_loaded('openssl') === false) {
623
-
624
- throw new Net_DNS2_Exception(
625
- 'the OpenSSL extension is required to use SIG(0).',
626
- Net_DNS2_Lookups::E_OPENSSL_UNAVAIL
627
- );
628
- }
629
-
630
- //
631
- // if the SIG was pre-created, then use it as-is
632
- //
633
- if ($filename instanceof Net_DNS2_RR_SIG) {
634
-
635
- $this->auth_signature = $filename;
636
-
637
- } else {
638
-
639
- //
640
- // otherwise, it's filename which needs to be parsed and processed.
641
- //
642
- $private = new Net_DNS2_PrivateKey($filename);
643
-
644
- //
645
- // create a new Net_DNS2_RR_SIG object
646
- //
647
- $this->auth_signature = new Net_DNS2_RR_SIG();
648
-
649
- //
650
- // reset some values
651
- //
652
- $this->auth_signature->name = $private->signname;
653
- $this->auth_signature->ttl = 0;
654
- $this->auth_signature->class = 'ANY';
655
-
656
- //
657
- // these values are pulled from the private key
658
- //
659
- $this->auth_signature->algorithm = $private->algorithm;
660
- $this->auth_signature->keytag = $private->keytag;
661
- $this->auth_signature->signname = $private->signname;
662
-
663
- //
664
- // these values are hard-coded for SIG0
665
- //
666
- $this->auth_signature->typecovered = 'SIG0';
667
- $this->auth_signature->labels = 0;
668
- $this->auth_signature->origttl = 0;
669
-
670
- //
671
- // generate the dates
672
- //
673
- $t = time();
674
-
675
- $this->auth_signature->sigincep = gmdate('YmdHis', $t);
676
- $this->auth_signature->sigexp = gmdate('YmdHis', $t + 500);
677
-
678
- //
679
- // store the private key in the SIG object for later.
680
- //
681
- $this->auth_signature->private_key = $private;
682
- }
683
-
684
- //
685
- // only RSA algorithms are supported for SIG(0)
686
- //
687
- switch($this->auth_signature->algorithm) {
688
- case Net_DNS2_Lookups::DNSSEC_ALGORITHM_RSAMD5:
689
- case Net_DNS2_Lookups::DNSSEC_ALGORITHM_RSASHA1:
690
- case Net_DNS2_Lookups::DNSSEC_ALGORITHM_RSASHA256:
691
- case Net_DNS2_Lookups::DNSSEC_ALGORITHM_RSASHA512:
692
- case Net_DNS2_Lookups::DNSSEC_ALGORITHM_DSA:
693
- break;
694
- default:
695
- throw new Net_DNS2_Exception(
696
- 'only asymmetric algorithms work with SIG(0)!',
697
- Net_DNS2_Lookups::E_OPENSSL_INV_ALGO
698
- );
699
- }
700
-
701
- return true;
702
- }
703
-
704
- /**
705
- * a simple function to determine if the RR type is cacheable
706
- *
707
- * @param string $_type the RR type string
708
- *
709
- * @return bool returns true/false if the RR type if cachable
710
- * @access public
711
- *
712
- */
713
- public function cacheable($_type)
714
- {
715
- switch($_type) {
716
- case 'AXFR':
717
- case 'OPT':
718
- return false;
719
- }
720
-
721
- return true;
722
- }
723
-
724
- /**
725
- * PHP doesn't support unsigned integers, but many of the RR's return
726
- * unsigned values (like SOA), so there is the possibility that the
727
- * value will overrun on 32bit systems, and you'll end up with a
728
- * negative value.
729
- *
730
- * 64bit systems are not affected, as their PHP_IN_MAX value should
731
- * be 64bit (ie 9223372036854775807)
732
- *
733
- * This function returns a negative integer value, as a string, with
734
- * the correct unsigned value.
735
- *
736
- * @param string $_int the unsigned integer value to check
737
- *
738
- * @return string returns the unsigned value as a string.
739
- * @access public
740
- *
741
- */
742
- public static function expandUint32($_int)
743
- {
744
- if ( ($_int < 0) && (PHP_INT_MAX == 2147483647) ) {
745
- return sprintf('%u', $_int);
746
- } else {
747
- return $_int;
748
- }
749
- }
750
-
751
- /**
752
- * returns true/false if the given address is a valid IPv4 address
753
- *
754
- * @param string $_address the IPv4 address to check
755
- *
756
- * @return boolean returns true/false if the address is IPv4 address
757
- * @access public
758
- *
759
- */
760
- public static function isIPv4($_address)
761
- {
762
- //
763
- // use filter_var() if it's available; it's faster than preg
764
- //
765
- if (extension_loaded('filter') == true) {
766
-
767
- if (filter_var($_address, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) == false) {
768
- return false;
769
- }
770
- } else {
771
-
772
- //
773
- // do the main check here;
774
- //
775
- if (inet_pton($_address) === false) {
776
- return false;
777
- }
778
-
779
- //
780
- // then make sure we're not a IPv6 address
781
- //
782
- if (preg_match('/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/', $_address) == 0) {
783
- return false;
784
- }
785
- }
786
-
787
- return true;
788
- }
789
-
790
- /**
791
- * returns true/false if the given address is a valid IPv6 address
792
- *
793
- * @param string $_address the IPv6 address to check
794
- *
795
- * @return boolean returns true/false if the address is IPv6 address
796
- * @access public
797
- *
798
- */
799
- public static function isIPv6($_address)
800
- {
801
- //
802
- // use filter_var() if it's available; it's faster than preg
803
- //
804
- if (extension_loaded('filter') == true) {
805
- if (filter_var($_address, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) == false) {
806
- return false;
807
- }
808
- } else {
809
-
810
- //
811
- // do the main check here
812
- //
813
- if (inet_pton($_address) === false) {
814
- return false;
815
- }
816
-
817
- //
818
- // then make sure it doesn't match a IPv4 address
819
- //
820
- if (preg_match('/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/', $_address) == 1) {
821
- return false;
822
- }
823
- }
824
-
825
- return true;
826
- }
827
-
828
- /**
829
- * formats the given IPv6 address as a fully expanded IPv6 address
830
- *
831
- * @param string $_address the IPv6 address to expand
832
- *
833
- * @return string the fully expanded IPv6 address
834
- * @access public
835
- *
836
- */
837
- public static function expandIPv6($_address)
838
- {
839
- $hex = unpack('H*hex', inet_pton($_address));
840
-
841
- return substr(preg_replace('/([A-f0-9]{4})/', "$1:", $hex['hex']), 0, -1);
842
- }
843
-
844
- /**
845
- * sends a standard Net_DNS2_Packet_Request packet
846
- *
847
- * @param Net_DNS2_Packet $request a Net_DNS2_Packet_Request object
848
- * @param boolean $use_tcp true/false if the function should
849
- * use TCP for the request
850
- *
851
- * @return Net_DNS2_Packet_Response
852
- * @throws Net_DNS2_Exception
853
- * @access protected
854
- *
855
- */
856
- protected function sendPacket(Net_DNS2_Packet $request, $use_tcp)
857
- {
858
- //
859
- // get the data from the packet
860
- //
861
- $data = $request->get();
862
- if (strlen($data) < Net_DNS2_Lookups::DNS_HEADER_SIZE) {
863
-
864
- throw new Net_DNS2_Exception(
865
- 'invalid or empty packet for sending!',
866
- Net_DNS2_Lookups::E_PACKET_INVALID,
867
- null,
868
- $request
869
- );
870
- }
871
-
872
- reset($this->nameservers);
873
-
874
- //
875
- // randomize the name server list if it's asked for
876
- //
877
- if ($this->ns_random == true) {
878
-
879
- shuffle($this->nameservers);
880
- }
881
-
882
- //
883
- // loop so we can handle server errors
884
- //
885
- $response = null;
886
- $ns = '';
887
-
888
- while (1) {
889
-
890
- //
891
- // grab the next DNS server
892
- //
893
- $ns = current($this->nameservers);
894
- next($this->nameservers);
895
-
896
- if ($ns === false) {
897
-
898
- if (is_null($this->last_exception) == false) {
899
-
900
- throw $this->last_exception;
901
- } else {
902
-
903
- throw new Net_DNS2_Exception(
904
- 'every name server provided has failed',
905
- Net_DNS2_Lookups::E_NS_FAILED
906
- );
907
- }
908
- }
909
-
910
- //
911
- // if the use TCP flag (force TCP) is set, or the packet is bigger than our
912
- // max allowed UDP size- which is either 512, or if this is DNSSEC request,
913
- // then whatever the configured dnssec_payload_size is.
914
- //
915
- $max_udp_size = Net_DNS2_Lookups::DNS_MAX_UDP_SIZE;
916
- if ($this->dnssec == true)
917
- {
918
- $max_udp_size = $this->dnssec_payload_size;
919
- }
920
-
921
- if ( ($use_tcp == true) || (strlen($data) > $max_udp_size) ) {
922
-
923
- try
924
- {
925
- $response = $this->sendTCPRequest($ns, $data, ($request->question[0]->qtype == 'AXFR') ? true : false);
926
-
927
- } catch(Net_DNS2_Exception $e) {
928
-
929
- $this->last_exception = $e;
930
- $this->last_exception_list[$ns] = $e;
931
-
932
- continue;
933
- }
934
-
935
- //
936
- // otherwise, send it using UDP
937
- //
938
- } else {
939
-
940
- try
941
- {
942
- $response = $this->sendUDPRequest($ns, $data);
943
-
944
- //
945
- // check the packet header for a trucated bit; if it was truncated,
946
- // then re-send the request as TCP.
947
- //
948
- if ($response->header->tc == 1) {
949
-
950
- $response = $this->sendTCPRequest($ns, $data);
951
- }
952
-
953
- } catch(Net_DNS2_Exception $e) {
954
-
955
- $this->last_exception = $e;
956
- $this->last_exception_list[$ns] = $e;
957
-
958
- continue;
959
- }
960
- }
961
-
962
- //
963
- // make sure header id's match between the request and response
964
- //
965
- if ($request->header->id != $response->header->id) {
966
-
967
- $this->last_exception = new Net_DNS2_Exception(
968
-
969
- 'invalid header: the request and response id do not match.',
970
- Net_DNS2_Lookups::E_HEADER_INVALID,
971
- null,
972
- $request,
973
- $response
974
- );
975
-
976
- $this->last_exception_list[$ns] = $this->last_exception;
977
- continue;
978
- }
979
-
980
- //
981
- // make sure the response is actually a response
982
- //
983
- // 0 = query, 1 = response
984
- //
985
- if ($response->header->qr != Net_DNS2_Lookups::QR_RESPONSE) {
986
-
987
- $this->last_exception = new Net_DNS2_Exception(
988
-
989
- 'invalid header: the response provided is not a response packet.',
990
- Net_DNS2_Lookups::E_HEADER_INVALID,
991
- null,
992
- $request,
993
- $response
994
- );
995
-
996
- $this->last_exception_list[$ns] = $this->last_exception;
997
- continue;
998
- }
999
-
1000
- //
1001
- // make sure the response code in the header is ok
1002
- //
1003
- if ($response->header->rcode != Net_DNS2_Lookups::RCODE_NOERROR) {
1004
-
1005
- $this->last_exception = new Net_DNS2_Exception(
1006
-
1007
- 'DNS request failed: ' .
1008
- Net_DNS2_Lookups::$result_code_messages[$response->header->rcode],
1009
- $response->header->rcode,
1010
- null,
1011
- $request,
1012
- $response
1013
- );
1014
-
1015
- $this->last_exception_list[$ns] = $this->last_exception;
1016
- continue;
1017
- }
1018
-
1019
- break;
1020
- }
1021
-
1022
- return $response;
1023
- }
1024
-
1025
- /**
1026
- * cleans up a failed socket and throws the given exception
1027
- *
1028
- * @param string $_proto the protocol of the socket
1029
- * @param string $_ns the name server to use for the request
1030
- * @param string $_error the error message to throw at the end of the function
1031
- *
1032
- * @throws Net_DNS2_Exception
1033
- * @access private
1034
- *
1035
- */
1036
- private function generateError($_proto, $_ns, $_error)
1037
- {
1038
- if (isset($this->sock[$_proto][$_ns]) == false)
1039
- {
1040
- throw new Net_DNS2_Exception('invalid socket referenced', Net_DNS2_Lookups::E_NS_INVALID_SOCKET);
1041
- }
1042
-
1043
- //
1044
- // grab the last error message off the socket
1045
- //
1046
- $last_error = $this->sock[$_proto][$_ns]->last_error;
1047
-
1048
- //
1049
- // remove it from the socket cache; this will call the destructor, which calls close() on the socket
1050
- //
1051
- unset($this->sock[$_proto][$_ns]);
1052
-
1053
- //
1054
- // throw the error provided
1055
- //
1056
- throw new Net_DNS2_Exception($last_error, $_error);
1057
- }
1058
-
1059
- /**
1060
- * sends a DNS request using TCP
1061
- *
1062
- * @param string $_ns the name server to use for the request
1063
- * @param string $_data the raw DNS packet data
1064
- * @param boolean $_axfr if this is a zone transfer request
1065
- *
1066
- * @return Net_DNS2_Packet_Response the reponse object
1067
- * @throws Net_DNS2_Exception
1068
- * @access private
1069
- *
1070
- */
1071
- private function sendTCPRequest($_ns, $_data, $_axfr = false)
1072
- {
1073
- //
1074
- // grab the start time
1075
- //
1076
- $start_time = microtime(true);
1077
-
1078
- //
1079
- // see if we already have an open socket from a previous request; if so, try to use
1080
- // that instead of opening a new one.
1081
- //
1082
- if ( (!isset($this->sock[Net_DNS2_Socket::SOCK_STREAM][$_ns]))
1083
- || (!($this->sock[Net_DNS2_Socket::SOCK_STREAM][$_ns] instanceof Net_DNS2_Socket))
1084
- ) {
1085
-
1086
- //
1087
- // create the socket object
1088
- //
1089
- $this->sock[Net_DNS2_Socket::SOCK_STREAM][$_ns] = new Net_DNS2_Socket(
1090
- Net_DNS2_Socket::SOCK_STREAM, $_ns, $this->dns_port, $this->timeout
1091
- );
1092
-
1093
- //
1094
- // if a local IP address / port is set, then add it
1095
- //
1096
- if (strlen($this->local_host) > 0) {
1097
-
1098
- $this->sock[Net_DNS2_Socket::SOCK_STREAM][$_ns]->bindAddress(
1099
- $this->local_host, $this->local_port
1100
- );
1101
- }
1102
-
1103
- //
1104
- // open the socket
1105
- //
1106
- if ($this->sock[Net_DNS2_Socket::SOCK_STREAM][$_ns]->open() === false) {
1107
-
1108
- $this->generateError(Net_DNS2_Socket::SOCK_STREAM, $_ns, Net_DNS2_Lookups::E_NS_SOCKET_FAILED);
1109
- }
1110
- }
1111
-
1112
- //
1113
- // write the data to the socket; if it fails, continue on
1114
- // the while loop
1115
- //
1116
- if ($this->sock[Net_DNS2_Socket::SOCK_STREAM][$_ns]->write($_data) === false) {
1117
-
1118
- $this->generateError(Net_DNS2_Socket::SOCK_STREAM, $_ns, Net_DNS2_Lookups::E_NS_SOCKET_FAILED);
1119
- }
1120
-
1121
- //
1122
- // read the content, using select to wait for a response
1123
- //
1124
- $size = 0;
1125
- $result = null;
1126
- $response = null;
1127
-
1128
- //
1129
- // handle zone transfer requests differently than other requests.
1130
- //
1131
- if ($_axfr == true) {
1132
-
1133
- $soa_count = 0;
1134
-
1135
- while (1) {
1136
-
1137
- //
1138
- // read the data off the socket
1139
- //
1140
- $result = $this->sock[Net_DNS2_Socket::SOCK_STREAM][$_ns]->read($size,
1141
- ($this->dnssec == true) ? $this->dnssec_payload_size : Net_DNS2_Lookups::DNS_MAX_UDP_SIZE);
1142
-
1143
- if ( ($result === false) || ($size < Net_DNS2_Lookups::DNS_HEADER_SIZE) ) {
1144
-
1145
- //
1146
- // if we get an error, then keeping this socket around for a future request, could cause
1147
- // an error- for example, https://github.com/mikepultz/netdns2/issues/61
1148
- //
1149
- // in this case, the connection was timing out, which once it did finally respond, left
1150
- // data on the socket, which could be captured on a subsequent request.
1151
- //
1152
- // since there's no way to "reset" a socket, the only thing we can do it close it.
1153
- //
1154
- $this->generateError(Net_DNS2_Socket::SOCK_STREAM, $_ns, Net_DNS2_Lookups::E_NS_SOCKET_FAILED);
1155
- }
1156
-
1157
- //
1158
- // parse the first chunk as a packet
1159
- //
1160
- $chunk = new Net_DNS2_Packet_Response($result, $size);
1161
-
1162
- //
1163
- // if this is the first packet, then clone it directly, then
1164
- // go through it to see if there are two SOA records
1165
- // (indicating that it's the only packet)
1166
- //
1167
- if (is_null($response) == true) {
1168
-
1169
- $response = clone $chunk;
1170
-
1171
- //
1172
- // look for a failed response; if the zone transfer
1173
- // failed, then we don't need to do anything else at this
1174
- // point, and we should just break out.
1175
- //
1176
- if ($response->header->rcode != Net_DNS2_Lookups::RCODE_NOERROR) {
1177
- break;
1178
- }
1179
-
1180
- //
1181
- // go through each answer
1182
- //
1183
- foreach ($response->answer as $index => $rr) {
1184
-
1185
- //
1186
- // count the SOA records
1187
- //
1188
- if ($rr->type == 'SOA') {
1189
- $soa_count++;
1190
- }
1191
- }
1192
-
1193
- //
1194
- // if we have 2 or more SOA records, then we're done;
1195
- // otherwise continue out so we read the rest of the
1196
- // packets off the socket
1197
- //
1198
- if ($soa_count >= 2) {
1199
- break;
1200
- } else {
1201
- continue;
1202
- }
1203
-
1204
- } else {
1205
-
1206
- //
1207
- // go through all these answers, and look for SOA records
1208
- //
1209
- foreach ($chunk->answer as $index => $rr) {
1210
-
1211
- //
1212
- // count the number of SOA records we find
1213
- //
1214
- if ($rr->type == 'SOA') {
1215
- $soa_count++;
1216
- }
1217
-
1218
- //
1219
- // add the records to a single response object
1220
- //
1221
- $response->answer[] = $rr;
1222
- }
1223
-
1224
- //
1225
- // if we've found the second SOA record, we're done
1226
- //
1227
- if ($soa_count >= 2) {
1228
- break;
1229
- }
1230
- }
1231
- }
1232
-
1233
- //
1234
- // everything other than a AXFR
1235
- //
1236
- } else {
1237
-
1238
- $result = $this->sock[Net_DNS2_Socket::SOCK_STREAM][$_ns]->read($size,
1239
- ($this->dnssec == true) ? $this->dnssec_payload_size : Net_DNS2_Lookups::DNS_MAX_UDP_SIZE);
1240
-
1241
- if ( ($result === false) || ($size < Net_DNS2_Lookups::DNS_HEADER_SIZE) ) {
1242
-
1243
- $this->generateError(Net_DNS2_Socket::SOCK_STREAM, $_ns, Net_DNS2_Lookups::E_NS_SOCKET_FAILED);
1244
- }
1245
-
1246
- //
1247
- // create the packet object
1248
- //
1249
- $response = new Net_DNS2_Packet_Response($result, $size);
1250
- }
1251
-
1252
- //
1253
- // store the query time
1254
- //
1255
- $response->response_time = microtime(true) - $start_time;
1256
-
1257
- //
1258
- // add the name server that the response came from to the response object,
1259
- // and the socket type that was used.
1260
- //
1261
- $response->answer_from = $_ns;
1262
- $response->answer_socket_type = Net_DNS2_Socket::SOCK_STREAM;
1263
-
1264
- //
1265
- // return the Net_DNS2_Packet_Response object
1266
- //
1267
- return $response;
1268
- }
1269
-
1270
- /**
1271
- * sends a DNS request using UDP
1272
- *
1273
- * @param string $_ns the name server to use for the request
1274
- * @param string $_data the raw DNS packet data
1275
- *
1276
- * @return Net_DNS2_Packet_Response the reponse object
1277
- * @throws Net_DNS2_Exception
1278
- * @access private
1279
- *
1280
- */
1281
- private function sendUDPRequest($_ns, $_data)
1282
- {
1283
- //
1284
- // grab the start time
1285
- //
1286
- $start_time = microtime(true);
1287
-
1288
- //
1289
- // see if we already have an open socket from a previous request; if so, try to use
1290
- // that instead of opening a new one.
1291
- //
1292
- if ( (!isset($this->sock[Net_DNS2_Socket::SOCK_DGRAM][$_ns]))
1293
- || (!($this->sock[Net_DNS2_Socket::SOCK_DGRAM][$_ns] instanceof Net_DNS2_Socket))
1294
- ) {
1295
-
1296
- //
1297
- // create the socket object
1298
- //
1299
- $this->sock[Net_DNS2_Socket::SOCK_DGRAM][$_ns] = new Net_DNS2_Socket(
1300
- Net_DNS2_Socket::SOCK_DGRAM, $_ns, $this->dns_port, $this->timeout
1301
- );
1302
-
1303
- //
1304
- // if a local IP address / port is set, then add it
1305
- //
1306
- if (strlen($this->local_host) > 0) {
1307
-
1308
- $this->sock[Net_DNS2_Socket::SOCK_DGRAM][$_ns]->bindAddress(
1309
- $this->local_host, $this->local_port
1310
- );
1311
- }
1312
-
1313
- //
1314
- // open the socket
1315
- //
1316
- if ($this->sock[Net_DNS2_Socket::SOCK_DGRAM][$_ns]->open() === false) {
1317
-
1318
- $this->generateError(Net_DNS2_Socket::SOCK_DGRAM, $_ns, Net_DNS2_Lookups::E_NS_SOCKET_FAILED);
1319
- }
1320
- }
1321
-
1322
- //
1323
- // write the data to the socket
1324
- //
1325
- if ($this->sock[Net_DNS2_Socket::SOCK_DGRAM][$_ns]->write($_data) === false) {
1326
-
1327
- $this->generateError(Net_DNS2_Socket::SOCK_DGRAM, $_ns, Net_DNS2_Lookups::E_NS_SOCKET_FAILED);
1328
- }
1329
-
1330
- //
1331
- // read the content, using select to wait for a response
1332
- //
1333
- $size = 0;
1334
-
1335
- $result = $this->sock[Net_DNS2_Socket::SOCK_DGRAM][$_ns]->read($size,
1336
- ($this->dnssec == true) ? $this->dnssec_payload_size : Net_DNS2_Lookups::DNS_MAX_UDP_SIZE);
1337
-
1338
- if (( $result === false) || ($size < Net_DNS2_Lookups::DNS_HEADER_SIZE)) {
1339
-
1340
- $this->generateError(Net_DNS2_Socket::SOCK_DGRAM, $_ns, Net_DNS2_Lookups::E_NS_SOCKET_FAILED);
1341
- }
1342
-
1343
- //
1344
- // create the packet object
1345
- //
1346
- $response = new Net_DNS2_Packet_Response($result, $size);
1347
-
1348
- //
1349
- // store the query time
1350
- //
1351
- $response->response_time = microtime(true) - $start_time;
1352
-
1353
- //
1354
- // add the name server that the response came from to the response object,
1355
- // and the socket type that was used.
1356
- //
1357
- $response->answer_from = $_ns;
1358
- $response->answer_socket_type = Net_DNS2_Socket::SOCK_DGRAM;
1359
-
1360
- //
1361
- // return the Net_DNS2_Packet_Response object
1362
- //
1363
- return $response;
1364
- }
1365
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/BitMap.php DELETED
@@ -1,206 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 0.6.0
17
- *
18
- */
19
-
20
- /**
21
- * a class to handle converting RR bitmaps to arrays and back; used on NSEC
22
- * and NSEC3 RR's
23
- *
24
- */
25
- class Net_DNS2_BitMap
26
- {
27
- /**
28
- * parses a RR bitmap field defined in RFC3845, into an array of RR names.
29
- *
30
- * Type Bit Map(s) Field = ( Window Block # | Bitmap Length | Bitmap ) +
31
- *
32
- * @param string $data a bitmap stringto parse
33
- *
34
- * @return array
35
- * @access public
36
- *
37
- */
38
- public static function bitMapToArray($data)
39
- {
40
- if (strlen($data) == 0) {
41
- return [];
42
- }
43
-
44
- $output = [];
45
- $offset = 0;
46
- $length = strlen($data);
47
-
48
- while ($offset < $length) {
49
-
50
- //
51
- // unpack the window and length values
52
- //
53
- $x = unpack('@' . $offset . '/Cwindow/Clength', $data);
54
- $offset += 2;
55
-
56
- //
57
- // copy out the bitmap value
58
- //
59
- $bitmap = unpack('C*', substr($data, $offset, $x['length']));
60
- $offset += $x['length'];
61
-
62
- //
63
- // I'm not sure if there's a better way of doing this, but PHP doesn't
64
- // have a 'B' flag for unpack()
65
- //
66
- $bitstr = '';
67
- foreach ($bitmap as $r) {
68
-
69
- $bitstr .= sprintf('%08b', $r);
70
- }
71
-
72
- $blen = strlen($bitstr);
73
- for ($i=0; $i<$blen; $i++) {
74
-
75
- if ($bitstr[$i] == '1') {
76
-
77
- $type = $x['window'] * 256 + $i;
78
-
79
- if (isset(Net_DNS2_Lookups::$rr_types_by_id[$type])) {
80
-
81
- $output[] = Net_DNS2_Lookups::$rr_types_by_id[$type];
82
- } else {
83
-
84
- $output[] = 'TYPE' . $type;
85
- }
86
- }
87
- }
88
- }
89
-
90
- return $output;
91
- }
92
-
93
- /**
94
- * builds a RR Bit map from an array of RR type names
95
- *
96
- * @param array $data a list of RR names
97
- *
98
- * @return string
99
- * @access public
100
- *
101
- */
102
- public static function arrayToBitMap(array $data)
103
- {
104
- if (count($data) == 0) {
105
- return '';
106
- }
107
-
108
- $current_window = 0;
109
-
110
- //
111
- // go through each RR
112
- //
113
- $max = 0;
114
- $bm = [];
115
-
116
- foreach ($data as $rr) {
117
-
118
- $rr = strtoupper($rr);
119
-
120
- //
121
- // get the type id for the RR
122
- //
123
- $type = @Net_DNS2_Lookups::$rr_types_by_name[$rr];
124
- if (isset($type)) {
125
-
126
- //
127
- // skip meta types or qtypes
128
- //
129
- if ( (isset(Net_DNS2_Lookups::$rr_qtypes_by_id[$type]))
130
- || (isset(Net_DNS2_Lookups::$rr_metatypes_by_id[$type]))
131
- ) {
132
- continue;
133
- }
134
-
135
- } else {
136
-
137
- //
138
- // if it's not found, then it must be defined as TYPE<id>, per
139
- // RFC3845 section 2.2, if it's not, we ignore it.
140
- //
141
- list($name, $type) = explode('TYPE', $rr);
142
- if (!isset($type)) {
143
-
144
- continue;
145
- }
146
- }
147
-
148
- //
149
- // build the current window
150
- //
151
- $current_window = (int)($type / 256);
152
-
153
- $val = $type - $current_window * 256.0;
154
- if ($val > $max) {
155
- $max = $val;
156
- }
157
-
158
- $bm[$current_window][$val] = 1;
159
- $bm[$current_window]['length'] = ceil(($max + 1) / 8);
160
- }
161
-
162
- $output = '';
163
-
164
- foreach ($bm as $window => $bitdata) {
165
-
166
- $bitstr = '';
167
-
168
- for ($i=0; $i<$bm[$window]['length'] * 8; $i++) {
169
- if (isset($bm[$window][$i])) {
170
- $bitstr .= '1';
171
- } else {
172
- $bitstr .= '0';
173
- }
174
- }
175
-
176
- $output .= pack('CC', $window, $bm[$window]['length']);
177
- $output .= pack('H*', self::bigBaseConvert($bitstr));
178
- }
179
-
180
- return $output;
181
- }
182
-
183
- /**
184
- * a base_convert that handles large numbers; forced to 2/16
185
- *
186
- * @param string $number a bit string
187
- *
188
- * @return string
189
- * @access public
190
- *
191
- */
192
- public static function bigBaseConvert($number)
193
- {
194
- $result = '';
195
-
196
- $bin = substr(chunk_split(strrev($number), 4, '-'), 0, -1);
197
- $temp = preg_split('[-]', $bin, -1, PREG_SPLIT_DELIM_CAPTURE);
198
-
199
- for ($i = count($temp)-1;$i >= 0;$i--) {
200
-
201
- $result = $result . base_convert(strrev($temp[$i]), 2, 16);
202
- }
203
-
204
- return strtoupper($result);
205
- }
206
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/Cache.php DELETED
@@ -1,263 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 1.1.0
17
- *
18
- */
19
-
20
- /**
21
- * A class to provide simple dns lookup caching.
22
- *
23
- */
24
- class Net_DNS2_Cache
25
- {
26
- /*
27
- * the filename of the cache file
28
- */
29
- protected $cache_file = '';
30
-
31
- /*
32
- * the local data store for the cache
33
- */
34
- protected $cache_data = [];
35
-
36
- /*
37
- * the size of the cache to use
38
- */
39
- protected $cache_size = 0;
40
-
41
- /*
42
- * the cache serializer
43
- */
44
- protected $cache_serializer;
45
-
46
- /*
47
- * an internal flag to make sure we don't load the cache content more
48
- * than once per instance.
49
- */
50
- protected $cache_opened = false;
51
-
52
- /**
53
- * returns true/false if the provided key is defined in the cache
54
- *
55
- * @param string $key the key to lookup in the local cache
56
- *
57
- * @return boolean
58
- * @access public
59
- *
60
- */
61
- public function has($key)
62
- {
63
- return isset($this->cache_data[$key]);
64
- }
65
-
66
- /**
67
- * returns the value for the given key
68
- *
69
- * @param string $key the key to lookup in the local cache
70
- *
71
- * @return mixed returns the cache data on sucess, false on error
72
- * @access public
73
- *
74
- */
75
- public function get($key)
76
- {
77
- if (isset($this->cache_data[$key])) {
78
-
79
- if ($this->cache_serializer == 'json') {
80
- return json_decode($this->cache_data[$key]['object']);
81
- } else {
82
- return unserialize($this->cache_data[$key]['object']);
83
- }
84
- } else {
85
-
86
- return false;
87
- }
88
- }
89
-
90
- /**
91
- * adds a new key/value pair to the cache
92
- *
93
- * @param string $key the key for the new cache entry
94
- * @param mixed $data the data to store in cache
95
- *
96
- * @return void
97
- * @access public
98
- *
99
- */
100
- public function put($key, $data)
101
- {
102
- $ttl = 86400 * 365;
103
-
104
- //
105
- // clear the rdata values
106
- //
107
- $data->rdata = '';
108
- $data->rdlength = 0;
109
-
110
- //
111
- // find the lowest TTL, and use that as the TTL for the whole cached
112
- // object. The downside to using one TTL for the whole object, is that
113
- // we'll invalidate entries before they actuall expire, causing a
114
- // real lookup to happen.
115
- //
116
- // The upside is that we don't need to require() each RR type in the
117
- // cache, so we can look at their individual TTL's on each run- we only
118
- // unserialize the actual RR object when it's get() from the cache.
119
- //
120
- foreach ($data->answer as $index => $rr) {
121
-
122
- if ($rr->ttl < $ttl) {
123
- $ttl = $rr->ttl;
124
- }
125
-
126
- $rr->rdata = '';
127
- $rr->rdlength = 0;
128
- }
129
- foreach ($data->authority as $index => $rr) {
130
-
131
- if ($rr->ttl < $ttl) {
132
- $ttl = $rr->ttl;
133
- }
134
-
135
- $rr->rdata = '';
136
- $rr->rdlength = 0;
137
- }
138
- foreach ($data->additional as $index => $rr) {
139
-
140
- if ($rr->ttl < $ttl) {
141
- $ttl = $rr->ttl;
142
- }
143
-
144
- $rr->rdata = '';
145
- $rr->rdlength = 0;
146
- }
147
-
148
- $this->cache_data[$key] = [
149
-
150
- 'cache_date' => time(),
151
- 'ttl' => $ttl
152
- ];
153
-
154
- if ($this->cache_serializer == 'json') {
155
- $this->cache_data[$key]['object'] = json_encode($data);
156
- } else {
157
- $this->cache_data[$key]['object'] = serialize($data);
158
- }
159
- }
160
-
161
- /**
162
- * runs a clean up process on the cache data
163
- *
164
- * @return void
165
- * @access protected
166
- *
167
- */
168
- protected function clean()
169
- {
170
- if (count($this->cache_data) > 0) {
171
-
172
- //
173
- // go through each entry and adjust their TTL, and remove entries that
174
- // have expired
175
- //
176
- $now = time();
177
-
178
- foreach ($this->cache_data as $key => $data) {
179
-
180
- $diff = $now - $data['cache_date'];
181
-
182
- if ($data['ttl'] <= $diff) {
183
-
184
- unset($this->cache_data[$key]);
185
- } else {
186
-
187
- $this->cache_data[$key]['ttl'] -= $diff;
188
- $this->cache_data[$key]['cache_date'] = $now;
189
- }
190
- }
191
- }
192
- }
193
-
194
- /**
195
- * runs a clean up process on the cache data
196
- *
197
- * @return mixed
198
- * @access protected
199
- *
200
- */
201
- protected function resize()
202
- {
203
- if (count($this->cache_data) > 0) {
204
-
205
- //
206
- // serialize the cache data
207
- //
208
- if ($this->cache_serializer == 'json') {
209
- $cache = json_encode($this->cache_data);
210
- } else {
211
- $cache = serialize($this->cache_data);
212
- }
213
-
214
- //
215
- // only do this part if the size allocated to the cache storage
216
- // is smaller than the actual cache data
217
- //
218
- if (strlen($cache) > $this->cache_size) {
219
-
220
- while (strlen($cache) > $this->cache_size) {
221
-
222
- //
223
- // go through the data, and remove the entries closed to
224
- // their expiration date.
225
- //
226
- $smallest_ttl = time();
227
- $smallest_key = null;
228
-
229
- foreach ($this->cache_data as $key => $data) {
230
-
231
- if ($data['ttl'] < $smallest_ttl) {
232
-
233
- $smallest_ttl = $data['ttl'];
234
- $smallest_key = $key;
235
- }
236
- }
237
-
238
- //
239
- // unset the key with the smallest TTL
240
- //
241
- unset($this->cache_data[$smallest_key]);
242
-
243
- //
244
- // re-serialize
245
- //
246
- if ($this->cache_serializer == 'json') {
247
- $cache = json_encode($this->cache_data);
248
- } else {
249
- $cache = serialize($this->cache_data);
250
- }
251
- }
252
- }
253
-
254
- if ( ($cache == 'a:0:{}') || ($cache == '{}') ) {
255
- return null;
256
- } else {
257
- return $cache;
258
- }
259
- }
260
-
261
- return null;
262
- }
263
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/Cache/File.php DELETED
@@ -1,199 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 1.1.0
17
- *
18
- */
19
-
20
- /**
21
- * File-based caching for the Net_DNS2_Cache class
22
- *
23
- */
24
- class Net_DNS2_Cache_File extends Net_DNS2_Cache
25
- {
26
- /**
27
- * open a cache object
28
- *
29
- * @param string $cache_file path to a file to use for cache storage
30
- * @param integer $size the size of the shared memory segment to create
31
- * @param string $serializer the name of the cache serialize to use
32
- *
33
- * @throws Net_DNS2_Exception
34
- * @access public
35
- * @return void
36
- *
37
- */
38
- public function open($cache_file, $size, $serializer)
39
- {
40
- $this->cache_size = $size;
41
- $this->cache_file = $cache_file;
42
- $this->cache_serializer = $serializer;
43
-
44
- //
45
- // check that the file exists first
46
- //
47
- if ( ($this->cache_opened == false)
48
- && (file_exists($this->cache_file) == true)
49
- && (filesize($this->cache_file) > 0)
50
- ) {
51
- //
52
- // open the file for reading
53
- //
54
- $fp = @fopen($this->cache_file, 'r');
55
- if ($fp !== false) {
56
-
57
- //
58
- // lock the file just in case
59
- //
60
- flock($fp, LOCK_EX);
61
-
62
- //
63
- // read the file contents
64
- //
65
- $data = fread($fp, filesize($this->cache_file));
66
-
67
- $decoded = null;
68
-
69
- if ($this->cache_serializer == 'json') {
70
-
71
- $decoded = json_decode($data, true);
72
- } else {
73
-
74
- $decoded = unserialize($data);
75
- }
76
-
77
- if (is_array($decoded) == true) {
78
-
79
- $this->cache_data = $decoded;
80
- } else {
81
-
82
- $this->cache_data = [];
83
- }
84
-
85
- //
86
- // unlock
87
- //
88
- flock($fp, LOCK_UN);
89
-
90
- //
91
- // close the file
92
- //
93
- fclose($fp);
94
-
95
- //
96
- // clean up the data
97
- //
98
- $this->clean();
99
-
100
- //
101
- // mark this so we don't read this contents more than once per instance.
102
- //
103
- $this->cache_opened = true;
104
- }
105
- }
106
- }
107
-
108
- /**
109
- * Destructor
110
- *
111
- * @access public
112
- *
113
- */
114
- public function __destruct()
115
- {
116
- //
117
- // if there's no cache file set, then there's nothing to do
118
- //
119
- if (strlen($this->cache_file) == 0) {
120
- return;
121
- }
122
-
123
- //
124
- // open the file for reading/writing
125
- //
126
- $fp = fopen($this->cache_file, 'a+');
127
- if ($fp !== false) {
128
-
129
- //
130
- // lock the file just in case
131
- //
132
- flock($fp, LOCK_EX);
133
-
134
- //
135
- // seek to the start of the file to read
136
- //
137
- fseek($fp, 0, SEEK_SET);
138
-
139
- //
140
- // read the file contents
141
- //
142
- $data = @fread($fp, filesize($this->cache_file));
143
- if ( ($data !== false) && (strlen($data) > 0) ) {
144
-
145
- //
146
- // unserialize and store the data
147
- //
148
- $c = $this->cache_data;
149
-
150
- $decoded = null;
151
-
152
- if ($this->cache_serializer == 'json') {
153
-
154
- $decoded = json_decode($data, true);
155
- } else {
156
-
157
- $decoded = unserialize($data);
158
- }
159
-
160
- if (is_array($decoded) == true) {
161
-
162
- $this->cache_data = array_merge($c, $decoded);
163
- }
164
- }
165
-
166
- //
167
- // trucate the file
168
- //
169
- ftruncate($fp, 0);
170
-
171
- //
172
- // clean the data
173
- //
174
- $this->clean();
175
-
176
- //
177
- // resize the data
178
- //
179
- $data = $this->resize();
180
- if (!is_null($data)) {
181
-
182
- //
183
- // write the file contents
184
- //
185
- fwrite($fp, $data);
186
- }
187
-
188
- //
189
- // unlock
190
- //
191
- flock($fp, LOCK_UN);
192
-
193
- //
194
- // close the file
195
- //
196
- fclose($fp);
197
- }
198
- }
199
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/Cache/Shm.php DELETED
@@ -1,270 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 1.1.0
17
- *
18
- */
19
-
20
- /**
21
- * Shared Memory-based caching for the Net_DNS2_Cache class
22
- *
23
- */
24
- class Net_DNS2_Cache_Shm extends Net_DNS2_Cache
25
- {
26
- /*
27
- * resource id of the shared memory cache
28
- */
29
- private $_cache_id = false;
30
-
31
- /*
32
- * the IPC key
33
- */
34
- private $_cache_file_tok = -1;
35
-
36
- /**
37
- * open a cache object
38
- *
39
- * @param string $cache_file path to a file to use for cache storage
40
- * @param integer $size the size of the shared memory segment to create
41
- * @param string $serializer the name of the cache serialize to use
42
- *
43
- * @throws Net_DNS2_Exception
44
- * @access public
45
- * @return void
46
- *
47
- */
48
- public function open($cache_file, $size, $serializer)
49
- {
50
- $this->cache_size = $size;
51
- $this->cache_file = $cache_file;
52
- $this->cache_serializer = $serializer;
53
-
54
- //
55
- // if we've already loaded the cache data, then just return right away
56
- //
57
- if ($this->cache_opened == true)
58
- {
59
- return;
60
- }
61
-
62
- //
63
- // make sure the file exists first
64
- //
65
- if (!file_exists($cache_file)) {
66
-
67
- if (file_put_contents($cache_file, '') === false) {
68
-
69
- throw new Net_DNS2_Exception(
70
- 'failed to create empty SHM file: ' . $cache_file,
71
- Net_DNS2_Lookups::E_CACHE_SHM_FILE
72
- );
73
- }
74
- }
75
-
76
- //
77
- // convert the filename to a IPC key
78
- //
79
- $this->_cache_file_tok = ftok($cache_file, 't');
80
- if ($this->_cache_file_tok == -1) {
81
-
82
- throw new Net_DNS2_Exception(
83
- 'failed on ftok() file: ' . $this->_cache_file_tok,
84
- Net_DNS2_Lookups::E_CACHE_SHM_FILE
85
- );
86
- }
87
-
88
- //
89
- // try to open an existing cache; if it doesn't exist, then there's no
90
- // cache, and nothing to do.
91
- //
92
- $this->_cache_id = @shmop_open($this->_cache_file_tok, 'w', 0, 0);
93
- if ($this->_cache_id !== false) {
94
-
95
- //
96
- // this returns the size allocated, and not the size used, but it's
97
- // still a good check to make sure there's space allocated.
98
- //
99
- $allocated = shmop_size($this->_cache_id);
100
- if ($allocated > 0) {
101
-
102
- //
103
- // read the data from the shared memory segment
104
- //
105
- $data = trim(shmop_read($this->_cache_id, 0, $allocated));
106
- if ( ($data !== false) && (strlen($data) > 0) ) {
107
-
108
- //
109
- // unserialize and store the data
110
- //
111
- $decoded = null;
112
-
113
- if ($this->cache_serializer == 'json') {
114
-
115
- $decoded = json_decode($data, true);
116
- } else {
117
-
118
- $decoded = unserialize($data);
119
- }
120
-
121
- if (is_array($decoded) == true) {
122
-
123
- $this->cache_data = $decoded;
124
- } else {
125
-
126
- $this->cache_data = [];
127
- }
128
-
129
- //
130
- // call clean to clean up old entries
131
- //
132
- $this->clean();
133
-
134
- //
135
- // mark the cache as loaded, so we don't load it more than once
136
- //
137
- $this->cache_opened = true;
138
- }
139
- }
140
- }
141
- }
142
-
143
- /**
144
- * Destructor
145
- *
146
- * @access public
147
- *
148
- */
149
- public function __destruct()
150
- {
151
- //
152
- // if there's no cache file set, then there's nothing to do
153
- //
154
- if (strlen($this->cache_file) == 0) {
155
- return;
156
- }
157
-
158
- $fp = fopen($this->cache_file, 'r');
159
- if ($fp !== false) {
160
-
161
- //
162
- // lock the file
163
- //
164
- flock($fp, LOCK_EX);
165
-
166
- //
167
- // check to see if we have an open shm segment
168
- //
169
- if ($this->_cache_id === false) {
170
-
171
- //
172
- // try opening it again, incase it was created by another
173
- // process in the mean time
174
- //
175
- $this->_cache_id = @shmop_open(
176
- $this->_cache_file_tok, 'w', 0, 0
177
- );
178
- if ($this->_cache_id === false) {
179
-
180
- //
181
- // otherwise, create it.
182
- //
183
- $this->_cache_id = @shmop_open(
184
- $this->_cache_file_tok, 'c', 0, $this->cache_size
185
- );
186
- }
187
- }
188
-
189
- //
190
- // get the size allocated to the segment
191
- //
192
- $allocated = shmop_size($this->_cache_id);
193
-
194
- //
195
- // read the contents
196
- //
197
- $data = trim(shmop_read($this->_cache_id, 0, $allocated));
198
-
199
- //
200
- // if there was some data
201
- //
202
- if ( ($data !== false) && (strlen($data) > 0) ) {
203
-
204
- //
205
- // unserialize and store the data
206
- //
207
- $c = $this->cache_data;
208
-
209
- $decoded = null;
210
-
211
- if ($this->cache_serializer == 'json') {
212
-
213
- $decoded = json_decode($data, true);
214
- } else {
215
-
216
- $decoded = unserialize($data);
217
- }
218
-
219
- if (is_array($decoded) == true) {
220
-
221
- $this->cache_data = array_merge($c, $decoded);
222
- }
223
- }
224
-
225
- //
226
- // delete the segment
227
- //
228
- shmop_delete($this->_cache_id);
229
-
230
- //
231
- // clean the data
232
- //
233
- $this->clean();
234
-
235
- //
236
- // clean up and write the data
237
- //
238
- $data = $this->resize();
239
- if (!is_null($data)) {
240
-
241
- //
242
- // re-create segment
243
- //
244
- $this->_cache_id = @shmop_open(
245
- $this->_cache_file_tok, 'c', 0644, $this->cache_size
246
- );
247
- if ($this->_cache_id === false) {
248
- return;
249
- }
250
-
251
- $o = shmop_write($this->_cache_id, $data, 0);
252
- }
253
-
254
- //
255
- // close the segment
256
- //
257
- shmop_close($this->_cache_id);
258
-
259
- //
260
- // unlock
261
- //
262
- flock($fp, LOCK_UN);
263
-
264
- //
265
- // close the file
266
- //
267
- fclose($fp);
268
- }
269
- }
270
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/Exception.php DELETED
@@ -1,96 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 0.6.0
17
- *
18
- */
19
-
20
- /**
21
- * Exception handler used by Net_DNS2
22
- *
23
- */
24
- class Net_DNS2_Exception extends Exception
25
- {
26
- private $_request;
27
- private $_response;
28
-
29
- /**
30
- * Constructor - overload the constructor so we can pass in the request
31
- * and response object (when it's available)
32
- *
33
- * @param string $message the exception message
34
- * @param int $code the exception code
35
- * @param object $previous the previous Exception object
36
- * @param object $request the Net_DNS2_Packet_Request object for this request
37
- * @param object $response the Net_DNS2_Packet_Response object for this request
38
- *
39
- * @access public
40
- *
41
- */
42
- public function __construct(
43
- $message = '',
44
- $code = 0,
45
- $previous = null,
46
- Net_DNS2_Packet_Request $request = null,
47
- Net_DNS2_Packet_Response $response = null
48
- ) {
49
- //
50
- // store the request/response objects (if passed)
51
- //
52
- $this->_request = $request;
53
- $this->_response = $response;
54
-
55
- //
56
- // call the parent constructor
57
- //
58
- // the "previous" argument was added in PHP 5.3.0
59
- //
60
- // https://code.google.com/p/netdns2/issues/detail?id=25
61
- //
62
- if (version_compare(PHP_VERSION, '5.3.0', '>=') == true) {
63
-
64
- parent::__construct($message, $code, $previous);
65
- } else {
66
-
67
- parent::__construct($message, $code);
68
- }
69
- }
70
-
71
- /**
72
- * returns the Net_DNS2_Packet_Request object (if available)
73
- *
74
- * @return Net_DNS2_Packet_Request object
75
- * @access public
76
- * @since function available since release 1.3.1
77
- *
78
- */
79
- public function getRequest()
80
- {
81
- return $this->_request;
82
- }
83
-
84
- /**
85
- * returns the Net_DNS2_Packet_Response object (if available)
86
- *
87
- * @return Net_DNS2_Packet_Response object
88
- * @access public
89
- * @since function available since release 1.3.1
90
- *
91
- */
92
- public function getResponse()
93
- {
94
- return $this->_response;
95
- }
96
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/Header.php DELETED
@@ -1,229 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 0.6.0
17
- *
18
- */
19
-
20
- /**
21
- * DNS Packet Header class
22
- *
23
- * This class handles parsing and constructing DNS Packet Headers as defined
24
- * by section 4.1.1 of RFC1035.
25
- *
26
- * DNS header format - RFC1035 section 4.1.1
27
- * DNS header format - RFC4035 section 3.2
28
- *
29
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
30
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
31
- * | ID |
32
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
33
- * |QR| Opcode |AA|TC|RD|RA| Z|AD|CD| RCODE |
34
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
35
- * | QDCOUNT |
36
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
37
- * | ANCOUNT |
38
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
39
- * | NSCOUNT |
40
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
41
- * | ARCOUNT |
42
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
43
- *
44
- */
45
- class Net_DNS2_Header
46
- {
47
- public $id; // 16 bit - identifier
48
- public $qr; // 1 bit - 0 = query, 1 = response
49
- public $opcode; // 4 bit - op code
50
- public $aa; // 1 bit - Authoritative Answer
51
- public $tc; // 1 bit - TrunCation
52
- public $rd; // 1 bit - Recursion Desired
53
- public $ra; // 1 bit - Recursion Available
54
- public $z; // 1 bit - Reserved
55
- public $ad; // 1 bit - Authentic Data (RFC4035)
56
- public $cd; // 1 bit - Checking Disabled (RFC4035)
57
- public $rcode; // 4 bit - Response code
58
- public $qdcount; // 16 bit - entries in the question section
59
- public $ancount; // 16 bit - resource records in the answer section
60
- public $nscount; // 16 bit - name server rr in the authority records section
61
- public $arcount; // 16 bit - rr's in the additional records section
62
-
63
- /**
64
- * Constructor - builds a new Net_DNS2_Header object
65
- *
66
- * @param mixed &$packet either a Net_DNS2_Packet object or null
67
- *
68
- * @throws Net_DNS2_Exception
69
- * @access public
70
- *
71
- */
72
- public function __construct(Net_DNS2_Packet &$packet = null)
73
- {
74
- if (!is_null($packet)) {
75
-
76
- $this->set($packet);
77
- } else {
78
-
79
- $this->id = $this->nextPacketId();
80
- $this->qr = Net_DNS2_Lookups::QR_QUERY;
81
- $this->opcode = Net_DNS2_Lookups::OPCODE_QUERY;
82
- $this->aa = 0;
83
- $this->tc = 0;
84
- $this->rd = 1;
85
- $this->ra = 0;
86
- $this->z = 0;
87
- $this->ad = 0;
88
- $this->cd = 0;
89
- $this->rcode = Net_DNS2_Lookups::RCODE_NOERROR;
90
- $this->qdcount = 1;
91
- $this->ancount = 0;
92
- $this->nscount = 0;
93
- $this->arcount = 0;
94
- }
95
- }
96
-
97
- /**
98
- * returns the next available packet id
99
- *
100
- * @return integer
101
- * @access public
102
- *
103
- */
104
- public function nextPacketId()
105
- {
106
- if (++Net_DNS2_Lookups::$next_packet_id > 65535) {
107
-
108
- Net_DNS2_Lookups::$next_packet_id = 1;
109
- }
110
-
111
- return Net_DNS2_Lookups::$next_packet_id;
112
- }
113
-
114
- /**
115
- * magic __toString() method to return the header as a string
116
- *
117
- * @return string
118
- * @access public
119
- *
120
- */
121
- public function __toString()
122
- {
123
- $output = ";;\n;; Header:\n";
124
-
125
- $output .= ";;\t id = " . $this->id . "\n";
126
- $output .= ";;\t qr = " . $this->qr . "\n";
127
- $output .= ";;\t opcode = " . $this->opcode . "\n";
128
- $output .= ";;\t aa = " . $this->aa . "\n";
129
- $output .= ";;\t tc = " . $this->tc . "\n";
130
- $output .= ";;\t rd = " . $this->rd . "\n";
131
- $output .= ";;\t ra = " . $this->ra . "\n";
132
- $output .= ";;\t z = " . $this->z . "\n";
133
- $output .= ";;\t ad = " . $this->ad . "\n";
134
- $output .= ";;\t cd = " . $this->cd . "\n";
135
- $output .= ";;\t rcode = " . $this->rcode . "\n";
136
- $output .= ";;\t qdcount = " . $this->qdcount . "\n";
137
- $output .= ";;\t ancount = " . $this->ancount . "\n";
138
- $output .= ";;\t nscount = " . $this->nscount . "\n";
139
- $output .= ";;\t arcount = " . $this->arcount . "\n";
140
-
141
- return $output;
142
- }
143
-
144
- /**
145
- * constructs a Net_DNS2_Header from a Net_DNS2_Packet object
146
- *
147
- * @param Net_DNS2_Packet &$packet Object
148
- *
149
- * @return boolean
150
- * @throws Net_DNS2_Exception
151
- * @access public
152
- *
153
- */
154
- public function set(Net_DNS2_Packet &$packet)
155
- {
156
- //
157
- // the header must be at least 12 bytes long.
158
- //
159
- if ($packet->rdlength < Net_DNS2_Lookups::DNS_HEADER_SIZE) {
160
-
161
- throw new Net_DNS2_Exception(
162
- 'invalid header data provided; too small',
163
- Net_DNS2_Lookups::E_HEADER_INVALID
164
- );
165
- }
166
-
167
- $offset = 0;
168
-
169
- //
170
- // parse the values
171
- //
172
- $this->id = ord($packet->rdata[$offset]) << 8 |
173
- ord($packet->rdata[++$offset]);
174
-
175
- ++$offset;
176
- $this->qr = (ord($packet->rdata[$offset]) >> 7) & 0x1;
177
- $this->opcode = (ord($packet->rdata[$offset]) >> 3) & 0xf;
178
- $this->aa = (ord($packet->rdata[$offset]) >> 2) & 0x1;
179
- $this->tc = (ord($packet->rdata[$offset]) >> 1) & 0x1;
180
- $this->rd = ord($packet->rdata[$offset]) & 0x1;
181
-
182
- ++$offset;
183
- $this->ra = (ord($packet->rdata[$offset]) >> 7) & 0x1;
184
- $this->z = (ord($packet->rdata[$offset]) >> 6) & 0x1;
185
- $this->ad = (ord($packet->rdata[$offset]) >> 5) & 0x1;
186
- $this->cd = (ord($packet->rdata[$offset]) >> 4) & 0x1;
187
- $this->rcode = ord($packet->rdata[$offset]) & 0xf;
188
-
189
- $this->qdcount = ord($packet->rdata[++$offset]) << 8 |
190
- ord($packet->rdata[++$offset]);
191
- $this->ancount = ord($packet->rdata[++$offset]) << 8 |
192
- ord($packet->rdata[++$offset]);
193
- $this->nscount = ord($packet->rdata[++$offset]) << 8 |
194
- ord($packet->rdata[++$offset]);
195
- $this->arcount = ord($packet->rdata[++$offset]) << 8 |
196
- ord($packet->rdata[++$offset]);
197
-
198
- //
199
- // increment the internal offset
200
- //
201
- $packet->offset += Net_DNS2_Lookups::DNS_HEADER_SIZE;
202
-
203
- return true;
204
- }
205
-
206
- /**
207
- * returns a binary packed DNS Header
208
- *
209
- * @param Net_DNS2_Packet &$packet Object
210
- *
211
- * @return string
212
- * @access public
213
- *
214
- */
215
- public function get(Net_DNS2_Packet &$packet)
216
- {
217
- $packet->offset += Net_DNS2_Lookups::DNS_HEADER_SIZE;
218
-
219
- return pack('n', $this->id) .
220
- chr(
221
- ($this->qr << 7) | ($this->opcode << 3) |
222
- ($this->aa << 2) | ($this->tc << 1) | ($this->rd)
223
- ) .
224
- chr(
225
- ($this->ra << 7) | ($this->ad << 5) | ($this->cd << 4) | $this->rcode
226
- ) .
227
- pack('n4', $this->qdcount, $this->ancount, $this->nscount, $this->arcount);
228
- }
229
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/Lookups.php DELETED
@@ -1,561 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 0.6.0
17
- *
18
- */
19
-
20
- //
21
- // initalize the packet id value
22
- //
23
- Net_DNS2_Lookups::$next_packet_id = mt_rand(0, 65535);
24
-
25
- //
26
- // build the reverse lookup tables; this is just so we don't have to
27
- // have duplicate static content laying around.
28
- //
29
- Net_DNS2_Lookups::$rr_types_by_id = array_flip(Net_DNS2_Lookups::$rr_types_by_name);
30
- Net_DNS2_Lookups::$classes_by_id = array_flip(Net_DNS2_Lookups::$classes_by_name);
31
- Net_DNS2_Lookups::$rr_types_class_to_id = array_flip(Net_DNS2_Lookups::$rr_types_id_to_class);
32
- Net_DNS2_Lookups::$algorithm_name_to_id = array_flip(Net_DNS2_Lookups::$algorithm_id_to_name);
33
- Net_DNS2_Lookups::$digest_name_to_id = array_flip(Net_DNS2_Lookups::$digest_id_to_name);
34
- Net_DNS2_Lookups::$rr_qtypes_by_id = array_flip(Net_DNS2_Lookups::$rr_qtypes_by_name);
35
- Net_DNS2_Lookups::$rr_metatypes_by_id = array_flip(Net_DNS2_Lookups::$rr_metatypes_by_name);
36
- Net_DNS2_Lookups::$protocol_by_id = array_flip(Net_DNS2_Lookups::$protocol_by_name);
37
-
38
- /**
39
- * This class provides simple lookups used througout the Net_DNS2 code
40
- *
41
- */
42
- class Net_DNS2_Lookups
43
- {
44
- /*
45
- * size (in bytes) of a header in a standard DNS packet
46
- */
47
- const DNS_HEADER_SIZE = 12;
48
-
49
- /*
50
- * max size of a UDP packet
51
- */
52
- const DNS_MAX_UDP_SIZE = 512;
53
-
54
- /*
55
- * Query/Response flag
56
- */
57
- const QR_QUERY = 0; // RFC 1035
58
- const QR_RESPONSE = 1; // RFC 1035
59
-
60
- /*
61
- * DNS Op Codes
62
- */
63
- const OPCODE_QUERY = 0; // RFC 1035
64
- const OPCODE_IQUERY = 1; // RFC 1035, RFC 3425
65
- const OPCODE_STATUS = 2; // RFC 1035
66
- const OPCODE_NOTIFY = 4; // RFC 1996
67
- const OPCODE_UPDATE = 5; // RFC 2136
68
- const OPCODE_DSO = 6; // RFC 8490
69
-
70
- /*
71
- * Resource Record Classes
72
- */
73
- const RR_CLASS_IN = 1; // RFC 1035
74
- const RR_CLASS_CH = 3; // RFC 1035
75
- const RR_CLASS_HS = 4; // RFC 1035
76
- const RR_CLASS_NONE = 254; // RFC 2136
77
- const RR_CLASS_ANY = 255; // RFC 1035
78
-
79
- /*
80
- * DNS Response Codes
81
- */
82
- const RCODE_NOERROR = 0; // RFC 1035
83
- const RCODE_FORMERR = 1; // RFC 1035
84
- const RCODE_SERVFAIL = 2; // RFC 1035
85
- const RCODE_NXDOMAIN = 3; // RFC 1035
86
- const RCODE_NOTIMP = 4; // RFC 1035
87
- const RCODE_REFUSED = 5; // RFC 1035
88
- const RCODE_YXDOMAIN = 6; // RFC 2136
89
- const RCODE_YXRRSET = 7; // RFC 2136
90
- const RCODE_NXRRSET = 8; // RFC 2136
91
- const RCODE_NOTAUTH = 9; // RFC 2136
92
- const RCODE_NOTZONE = 10; // RFC 2136
93
- const RCODE_DSOTYPENI = 11; // RFC 8490
94
-
95
- // 12-15 reserved
96
-
97
- const RCODE_BADSIG = 16; // RFC 2845
98
- const RCODE_BADVERS = 16; // RFC 6891
99
- const RCODE_BADKEY = 17; // RFC 2845
100
- const RCODE_BADTIME = 18; // RFC 2845
101
- const RCODE_BADMODE = 19; // RFC 2930
102
- const RCODE_BADNAME = 20; // RFC 2930
103
- const RCODE_BADALG = 21; // RFC 2930
104
- const RCODE_BADTRUNC = 22; // RFC 4635
105
- const RCODE_BADCOOKIE = 23; // RFC 7873
106
-
107
- /*
108
- * internal errors codes returned by the exceptions class
109
- */
110
- const E_NONE = 0;
111
- const E_DNS_FORMERR = self::RCODE_FORMERR;
112
- const E_DNS_SERVFAIL = self::RCODE_SERVFAIL;
113
- const E_DNS_NXDOMAIN = self::RCODE_NXDOMAIN;
114
- const E_DNS_NOTIMP = self::RCODE_NOTIMP;
115
- const E_DNS_REFUSED = self::RCODE_REFUSED;
116
- const E_DNS_YXDOMAIN = self::RCODE_YXDOMAIN;
117
- const E_DNS_YXRRSET = self::RCODE_YXRRSET;
118
- const E_DNS_NXRRSET = self::RCODE_NXRRSET;
119
- const E_DNS_NOTAUTH = self::RCODE_NOTAUTH;
120
- const E_DNS_NOTZONE = self::RCODE_NOTZONE;
121
-
122
- // 11-15 reserved
123
-
124
- const E_DNS_BADSIG = self::RCODE_BADSIG;
125
- const E_DNS_BADKEY = self::RCODE_BADKEY;
126
- const E_DNS_BADTIME = self::RCODE_BADTIME;
127
- const E_DNS_BADMODE = self::RCODE_BADMODE;
128
- const E_DNS_BADNAME = self::RCODE_BADNAME;
129
- const E_DNS_BADALG = self::RCODE_BADALG;
130
- const E_DNS_BADTRUNC = self::RCODE_BADTRUNC;
131
- const E_DNS_BADCOOKIE = self::RCODE_BADCOOKIE;
132
-
133
- // other error conditions
134
-
135
- const E_NS_INVALID_FILE = 200;
136
- const E_NS_INVALID_ENTRY = 201;
137
- const E_NS_FAILED = 202;
138
- const E_NS_SOCKET_FAILED = 203;
139
- const E_NS_INVALID_SOCKET = 204;
140
-
141
- const E_PACKET_INVALID = 300;
142
- const E_PARSE_ERROR = 301;
143
- const E_HEADER_INVALID = 302;
144
- const E_QUESTION_INVALID = 303;
145
- const E_RR_INVALID = 304;
146
-
147
- const E_OPENSSL_ERROR = 400;
148
- const E_OPENSSL_UNAVAIL = 401;
149
- const E_OPENSSL_INV_PKEY = 402;
150
- const E_OPENSSL_INV_ALGO = 403;
151
-
152
- const E_CACHE_UNSUPPORTED = 500;
153
- const E_CACHE_SHM_FILE = 501;
154
- const E_CACHE_SHM_UNAVAIL = 502;
155
-
156
- /*
157
- * EDNS0 Option Codes (OPT)
158
- */
159
- // 0 - Reserved
160
- const EDNS0_OPT_LLQ = 1;
161
- const EDNS0_OPT_UL = 2;
162
- const EDNS0_OPT_NSID = 3;
163
- // 4 - Reserved
164
- const EDNS0_OPT_DAU = 5;
165
- const EDNS0_OPT_DHU = 6;
166
- const EDNS0_OPT_N3U = 7;
167
- const EDNS0_OPT_CLIENT_SUBNET = 8;
168
- const EDNS0_OPT_EXPIRE = 9;
169
- const EDNS0_OPT_COOKIE = 10;
170
- const EDNS0_OPT_TCP_KEEPALIVE = 11;
171
- const EDNS0_OPT_PADDING = 12;
172
- const EDNS0_OPT_CHAIN = 13;
173
- const EDNS0_OPT_KEY_TAG = 14;
174
- // 15 - unsassigned
175
- const EDNS0_OPT_CLIENT_TAG = 16;
176
- const EDNS0_OPT_SERVER_TAG = 17;
177
- // 18-26945 - unassigned
178
- const EDNS0_OPT_DEVICEID = 26946;
179
-
180
- /*
181
- * DNSSEC Algorithms
182
- */
183
- const DNSSEC_ALGORITHM_RES = 0;
184
- const DNSSEC_ALGORITHM_RSAMD5 = 1;
185
- const DNSSEC_ALGORITHM_DH = 2;
186
- const DNSSEC_ALGORITHM_DSA = 3;
187
- const DNSSEC_ALGORITHM_ECC = 4;
188
- const DNSSEC_ALGORITHM_RSASHA1 = 5;
189
- const DNSSEC_ALGORITHM_DSANSEC3SHA1 = 6;
190
- const DSNSEC_ALGORITHM_RSASHA1NSEC3SHA1 = 7;
191
- const DNSSEC_ALGORITHM_RSASHA256 = 8;
192
- const DNSSEC_ALGORITHM_RSASHA512 = 10;
193
- const DNSSEC_ALGORITHM_ECCGOST = 12;
194
- const DNSSEC_ALGORITHM_ECDSAP256SHA256 = 13;
195
- const DNSSEC_ALGORITHM_ECDSAP384SHA384 = 14;
196
- const DNSSEC_ALGORITHM_ED25519 = 15;
197
- const DNSSEC_ALGORITHM_ED448 = 16;
198
- const DNSSEC_ALGORITHM_INDIRECT = 252;
199
- const DNSSEC_ALGORITHM_PRIVATEDNS = 253;
200
- const DNSSEC_ALGORITHM_PRIVATEOID = 254;
201
-
202
- /*
203
- * DNSSEC Digest Types
204
- */
205
- const DNSSEC_DIGEST_RES = 0;
206
- const DNSSEC_DIGEST_SHA1 = 1;
207
- const DNSSEC_DIGEST_SHA256 = 2;
208
- const DNSSEC_DIGEST_GOST = 3;
209
- const DNSSEC_DIGEST_SHA384 = 4;
210
-
211
- /*
212
- * The packet id used when sending requests
213
- */
214
- public static $next_packet_id;
215
-
216
- /*
217
- * Used to map resource record types to their id's, and back
218
- */
219
- public static $rr_types_by_id = [];
220
- public static $rr_types_by_name = [
221
-
222
- 'SIG0' => 0, // RFC 2931 pseudo type
223
- 'A' => 1, // RFC 1035
224
- 'NS' => 2, // RFC 1035
225
- 'MD' => 3, // RFC 1035 - obsolete, Not implemented
226
- 'MF' => 4, // RFC 1035 - obsolete, Not implemented
227
- 'CNAME' => 5, // RFC 1035
228
- 'SOA' => 6, // RFC 1035
229
- 'MB' => 7, // RFC 1035 - obsolete, Not implemented
230
- 'MG' => 8, // RFC 1035 - obsolete, Not implemented
231
- 'MR' => 9, // RFC 1035 - obsolete, Not implemented
232
- 'NULL' => 10, // RFC 1035 - obsolete, Not implemented
233
- 'WKS' => 11, // RFC 1035
234
- 'PTR' => 12, // RFC 1035
235
- 'HINFO' => 13, // RFC 1035
236
- 'MINFO' => 14, // RFC 1035 - obsolete, Not implemented
237
- 'MX' => 15, // RFC 1035
238
- 'TXT' => 16, // RFC 1035
239
- 'RP' => 17, // RFC 1183
240
- 'AFSDB' => 18, // RFC 1183
241
- 'X25' => 19, // RFC 1183
242
- 'ISDN' => 20, // RFC 1183
243
- 'RT' => 21, // RFC 1183
244
- 'NSAP' => 22, // RFC 1706
245
- 'NSAP_PTR' => 23, // RFC 1348 - obsolete, Not implemented
246
- 'SIG' => 24, // RFC 2535
247
- 'KEY' => 25, // RFC 2535, RFC 2930
248
- 'PX' => 26, // RFC 2163
249
- 'GPOS' => 27, // RFC 1712 - Not implemented
250
- 'AAAA' => 28, // RFC 3596
251
- 'LOC' => 29, // RFC 1876
252
- 'NXT' => 30, // RFC 2065, obsoleted by by RFC 3755
253
- 'EID' => 31, // [Patton][Patton1995]
254
- 'NIMLOC' => 32, // [Patton][Patton1995]
255
- 'SRV' => 33, // RFC 2782
256
- 'ATMA' => 34, // Windows only
257
- 'NAPTR' => 35, // RFC 2915
258
- 'KX' => 36, // RFC 2230
259
- 'CERT' => 37, // RFC 4398
260
- 'A6' => 38, // downgraded to experimental by RFC 3363
261
- 'DNAME' => 39, // RFC 2672
262
- 'SINK' => 40, // Not implemented
263
- 'OPT' => 41, // RFC 2671
264
- 'APL' => 42, // RFC 3123
265
- 'DS' => 43, // RFC 4034
266
- 'SSHFP' => 44, // RFC 4255
267
- 'IPSECKEY' => 45, // RFC 4025
268
- 'RRSIG' => 46, // RFC 4034
269
- 'NSEC' => 47, // RFC 4034
270
- 'DNSKEY' => 48, // RFC 4034
271
- 'DHCID' => 49, // RFC 4701
272
- 'NSEC3' => 50, // RFC 5155
273
- 'NSEC3PARAM' => 51, // RFC 5155
274
- 'TLSA' => 52, // RFC 6698
275
- 'SMIMEA' => 53, // RFC 8162
276
-
277
- // 54 unassigned
278
-
279
- 'HIP' => 55, // RFC 5205
280
- 'NINFO' => 56, // Not implemented
281
- 'RKEY' => 57, // Not implemented
282
- 'TALINK' => 58, //
283
- 'CDS' => 59, // RFC 7344
284
- 'CDNSKEY' => 60, // RFC 7344
285
- 'OPENPGPKEY' => 61, // RFC 7929
286
- 'CSYNC' => 62, // RFC 7477
287
- 'ZONEMD' => 63, // Not implemented yet
288
- 'SVCB' => 64, // Not implemented yet
289
- 'HTTPS' => 65, // Not implemented yet
290
-
291
- // 66 - 98 unassigned
292
-
293
- 'SPF' => 99, // RFC 4408
294
- 'UINFO' => 100, // no RFC, Not implemented
295
- 'UID' => 101, // no RFC, Not implemented
296
- 'GID' => 102, // no RFC, Not implemented
297
- 'UNSPEC' => 103, // no RFC, Not implemented
298
- 'NID' => 104, // RFC 6742
299
- 'L32' => 105, // RFC 6742
300
- 'L64' => 106, // RFC 6742
301
- 'LP' => 107, // RFC 6742
302
- 'EUI48' => 108, // RFC 7043
303
- 'EUI64' => 109, // RFC 7043
304
-
305
- // 110 - 248 unassigned
306
-
307
- 'TKEY' => 249, // RFC 2930
308
- 'TSIG' => 250, // RFC 2845
309
- 'IXFR' => 251, // RFC 1995 - only a full (AXFR) is supported
310
- 'AXFR' => 252, // RFC 1035
311
- 'MAILB' => 253, // RFC 883, Not implemented
312
- 'MAILA' => 254, // RFC 973, Not implemented
313
- 'ANY' => 255, // RFC 1035 - we support both 'ANY' and '*'
314
- 'URI' => 256, // RFC 7553
315
- 'CAA' => 257, // RFC 8659
316
- 'AVC' => 258, // Application Visibility and Control
317
- 'DOA' => 259, // Not implemented yet
318
- 'AMTRELAY' => 260, // RFC 8777
319
-
320
- // 261 - 32767 unassigned
321
-
322
- 'TA' => 32768, // same as DS
323
- 'DLV' => 32769, // RFC 4431
324
- 'TYPE65534' => 65534 // Private Bind record
325
- ];
326
-
327
- /*
328
- * Qtypes and Metatypes - defined in RFC2929 section 3.1
329
- */
330
- public static $rr_qtypes_by_id = [];
331
- public static $rr_qtypes_by_name = [
332
-
333
- 'IXFR' => 251, // RFC 1995 - only a full (AXFR) is supported
334
- 'AXFR' => 252, // RFC 1035
335
- 'MAILB' => 253, // RFC 883, Not implemented
336
- 'MAILA' => 254, // RFC 973, Not implemented
337
- 'ANY' => 255 // RFC 1035 - we support both 'ANY' and '*'
338
- ];
339
-
340
- public static $rr_metatypes_by_id = [];
341
- public static $rr_metatypes_by_name = [
342
-
343
- 'OPT' => 41, // RFC 2671
344
- 'TKEY' => 249, // RFC 2930
345
- 'TSIG' => 250 // RFC 2845
346
- ];
347
-
348
- /*
349
- * used to map resource record id's to RR class names
350
- */
351
- public static $rr_types_class_to_id = [];
352
- public static $rr_types_id_to_class = [
353
-
354
- 1 => 'Net_DNS2_RR_A',
355
- 2 => 'Net_DNS2_RR_NS',
356
- 5 => 'Net_DNS2_RR_CNAME',
357
- 6 => 'Net_DNS2_RR_SOA',
358
- 11 => 'Net_DNS2_RR_WKS',
359
- 12 => 'Net_DNS2_RR_PTR',
360
- 13 => 'Net_DNS2_RR_HINFO',
361
- 15 => 'Net_DNS2_RR_MX',
362
- 16 => 'Net_DNS2_RR_TXT',
363
- 17 => 'Net_DNS2_RR_RP',
364
- 18 => 'Net_DNS2_RR_AFSDB',
365
- 19 => 'Net_DNS2_RR_X25',
366
- 20 => 'Net_DNS2_RR_ISDN',
367
- 21 => 'Net_DNS2_RR_RT',
368
- 22 => 'Net_DNS2_RR_NSAP',
369
- 24 => 'Net_DNS2_RR_SIG',
370
- 25 => 'Net_DNS2_RR_KEY',
371
- 26 => 'Net_DNS2_RR_PX',
372
- 28 => 'Net_DNS2_RR_AAAA',
373
- 29 => 'Net_DNS2_RR_LOC',
374
- 31 => 'Net_DNS2_RR_EID',
375
- 32 => 'Net_DNS2_RR_NIMLOC',
376
- 33 => 'Net_DNS2_RR_SRV',
377
- 34 => 'Net_DNS2_RR_ATMA',
378
- 35 => 'Net_DNS2_RR_NAPTR',
379
- 36 => 'Net_DNS2_RR_KX',
380
- 37 => 'Net_DNS2_RR_CERT',
381
- 39 => 'Net_DNS2_RR_DNAME',
382
- 41 => 'Net_DNS2_RR_OPT',
383
- 42 => 'Net_DNS2_RR_APL',
384
- 43 => 'Net_DNS2_RR_DS',
385
- 44 => 'Net_DNS2_RR_SSHFP',
386
- 45 => 'Net_DNS2_RR_IPSECKEY',
387
- 46 => 'Net_DNS2_RR_RRSIG',
388
- 47 => 'Net_DNS2_RR_NSEC',
389
- 48 => 'Net_DNS2_RR_DNSKEY',
390
- 49 => 'Net_DNS2_RR_DHCID',
391
- 50 => 'Net_DNS2_RR_NSEC3',
392
- 51 => 'Net_DNS2_RR_NSEC3PARAM',
393
- 52 => 'Net_DNS2_RR_TLSA',
394
- 53 => 'Net_DNS2_RR_SMIMEA',
395
- 55 => 'Net_DNS2_RR_HIP',
396
- 58 => 'Net_DNS2_RR_TALINK',
397
- 59 => 'Net_DNS2_RR_CDS',
398
- 60 => 'Net_DNS2_RR_CDNSKEY',
399
- 61 => 'Net_DNS2_RR_OPENPGPKEY',
400
- 62 => 'Net_DNS2_RR_CSYNC',
401
- 99 => 'Net_DNS2_RR_SPF',
402
- 104 => 'Net_DNS2_RR_NID',
403
- 105 => 'Net_DNS2_RR_L32',
404
- 106 => 'Net_DNS2_RR_L64',
405
- 107 => 'Net_DNS2_RR_LP',
406
- 108 => 'Net_DNS2_RR_EUI48',
407
- 109 => 'Net_DNS2_RR_EUI64',
408
-
409
- 249 => 'Net_DNS2_RR_TKEY',
410
- 250 => 'Net_DNS2_RR_TSIG',
411
-
412
- // 251 - IXFR - handled as a full zone transfer (252)
413
- // 252 - AXFR - handled as a function call
414
-
415
- 255 => 'Net_DNS2_RR_ANY',
416
- 256 => 'Net_DNS2_RR_URI',
417
- 257 => 'Net_DNS2_RR_CAA',
418
- 258 => 'Net_DNS2_RR_AVC',
419
- 260 => 'Net_DNS2_RR_AMTRELAY',
420
- 32768 => 'Net_DNS2_RR_TA',
421
- 32769 => 'Net_DNS2_RR_DLV',
422
- 65534 => 'Net_DNS2_RR_TYPE65534'
423
- ];
424
-
425
- /*
426
- * used to map resource record class names to their id's, and back
427
- */
428
- public static $classes_by_id = [];
429
- public static $classes_by_name = [
430
-
431
- 'IN' => self::RR_CLASS_IN, // RFC 1035
432
- 'CH' => self::RR_CLASS_CH, // RFC 1035
433
- 'HS' => self::RR_CLASS_HS, // RFC 1035
434
- 'NONE' => self::RR_CLASS_NONE, // RFC 2136
435
- 'ANY' => self::RR_CLASS_ANY // RFC 1035
436
- ];
437
-
438
- /*
439
- * maps response codes to error messages
440
- */
441
- public static $result_code_messages = [
442
-
443
- self::RCODE_NOERROR => 'The request completed successfully.',
444
- self::RCODE_FORMERR => 'The name server was unable to interpret the query.',
445
- self::RCODE_SERVFAIL => 'The name server was unable to process this query due to a problem with the name server.',
446
- self::RCODE_NXDOMAIN => 'The domain name referenced in the query does not exist.',
447
- self::RCODE_NOTIMP => 'The name server does not support the requested kind of query.',
448
- self::RCODE_REFUSED => 'The name server refuses to perform the specified operation for policy reasons.',
449
- self::RCODE_YXDOMAIN => 'Name Exists when it should not.',
450
- self::RCODE_YXRRSET => 'RR Set Exists when it should not.',
451
- self::RCODE_NXRRSET => 'RR Set that should exist does not.',
452
- self::RCODE_NOTAUTH => 'Server Not Authoritative for zone.',
453
- self::RCODE_NOTZONE => 'Name not contained in zone.',
454
-
455
- self::RCODE_BADSIG => 'TSIG Signature Failure.',
456
- self::RCODE_BADKEY => 'Key not recognized.',
457
- self::RCODE_BADTIME => 'Signature out of time window.',
458
- self::RCODE_BADMODE => 'Bad TKEY Mode.',
459
- self::RCODE_BADNAME => 'Duplicate key name.',
460
- self::RCODE_BADALG => 'Algorithm not supported.',
461
- self::RCODE_BADTRUNC => 'Bad truncation.'
462
- ];
463
-
464
- /*
465
- * maps DNS SEC alrorithms to their mnemonics
466
- */
467
- public static $algorithm_name_to_id = [];
468
- public static $algorithm_id_to_name = [
469
-
470
- self::DNSSEC_ALGORITHM_RES => 'RES',
471
- self::DNSSEC_ALGORITHM_RSAMD5 => 'RSAMD5',
472
- self::DNSSEC_ALGORITHM_DH => 'DH',
473
- self::DNSSEC_ALGORITHM_DSA => 'DSA',
474
- self::DNSSEC_ALGORITHM_ECC => 'ECC',
475
- self::DNSSEC_ALGORITHM_RSASHA1 => 'RSASHA1',
476
- self::DNSSEC_ALGORITHM_DSANSEC3SHA1 => 'DSA-NSEC3-SHA1',
477
- self::DSNSEC_ALGORITHM_RSASHA1NSEC3SHA1 => 'RSASHA1-NSEC3-SHA1',
478
- self::DNSSEC_ALGORITHM_RSASHA256 => 'RSASHA256',
479
- self::DNSSEC_ALGORITHM_RSASHA512 => 'RSASHA512',
480
- self::DNSSEC_ALGORITHM_ECCGOST => 'ECC-GOST',
481
- self::DNSSEC_ALGORITHM_ECDSAP256SHA256 => 'ECDSAP256SHA256',
482
- self::DNSSEC_ALGORITHM_ECDSAP384SHA384 => 'ECDSAP384SHA384',
483
- self::DNSSEC_ALGORITHM_ED25519 => 'ED25519',
484
- self::DNSSEC_ALGORITHM_ED448 => 'ED448',
485
- self::DNSSEC_ALGORITHM_INDIRECT => 'INDIRECT',
486
- self::DNSSEC_ALGORITHM_PRIVATEDNS => 'PRIVATEDNS',
487
- self::DNSSEC_ALGORITHM_PRIVATEOID => 'PRIVATEOID'
488
- ];
489
-
490
- /*
491
- * maps DNSSEC digest types to their mnemonics
492
- */
493
- public static $digest_name_to_id = [];
494
- public static $digest_id_to_name = [
495
-
496
- self::DNSSEC_DIGEST_RES => 'RES',
497
- self::DNSSEC_DIGEST_SHA1 => 'SHA-1',
498
- self::DNSSEC_DIGEST_SHA256 => 'SHA-256',
499
- self::DNSSEC_DIGEST_GOST => 'GOST-R-34.11-94',
500
- self::DNSSEC_DIGEST_SHA384 => 'SHA-384'
501
- ];
502
-
503
- /*
504
- * Protocols names - RFC 1010
505
- */
506
- public static $protocol_by_id = [];
507
- public static $protocol_by_name = [
508
-
509
- 'ICMP' => 1,
510
- 'IGMP' => 2,
511
- 'GGP' => 3,
512
- 'ST' => 5,
513
- 'TCP' => 6,
514
- 'UCL' => 7,
515
- 'EGP' => 8,
516
- 'IGP' => 9,
517
- 'BBN-RCC-MON' => 10,
518
- 'NVP-II' => 11,
519
- 'PUP' => 12,
520
- 'ARGUS' => 13,
521
- 'EMCON' => 14,
522
- 'XNET' => 15,
523
- 'CHAOS' => 16,
524
- 'UDP' => 17,
525
- 'MUX' => 18,
526
- 'DCN-MEAS' => 19,
527
- 'HMP' => 20,
528
- 'PRM' => 21,
529
- 'XNS-IDP' => 22,
530
- 'TRUNK-1' => 23,
531
- 'TRUNK-2' => 24,
532
- 'LEAF-1' => 25,
533
- 'LEAF-2' => 26,
534
- 'RDP' => 27,
535
- 'IRTP' => 28,
536
- 'ISO-TP4' => 29,
537
- 'NETBLT' => 30,
538
- 'MFE-NSP' => 31,
539
- 'MERIT-INP' => 32,
540
- 'SEP' => 33,
541
- // 34 - 60 - Unassigned
542
- // 61 - any host internal protocol
543
- 'CFTP' => 62,
544
- // 63 - any local network
545
- 'SAT-EXPAK' => 64,
546
- 'MIT-SUBNET' => 65,
547
- 'RVD' => 66,
548
- 'IPPC' => 67,
549
- // 68 - any distributed file system
550
- 'SAT-MON' => 69,
551
- // 70 - Unassigned
552
- 'IPCV' => 71,
553
- // 72 - 75 - Unassigned
554
- 'BR-SAT-MON' => 76,
555
- // 77 - Unassigned
556
- 'WB-MON' => 78,
557
- 'WB-EXPAK' => 79
558
- // 80 - 254 - Unassigned
559
- // 255 - Reserved
560
- ];
561
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/Notifier.php DELETED
@@ -1,220 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 0.6.0
17
- *
18
- */
19
-
20
- /**
21
- * The main dynamic DNS notifier class.
22
- *
23
- * This class provices functions to handle DNS notify requests as defined by RFC 1996.
24
- *
25
- * This is separate from the Net_DNS2_Resolver class, as while the underlying
26
- * protocol is the same, the functionality is completely different.
27
- *
28
- * Generally, query (recursive) lookups are done against caching server, while
29
- * notify requests are done against authoratative servers.
30
- *
31
- */
32
- class Net_DNS2_Notifier extends Net_DNS2
33
- {
34
- /*
35
- * a Net_DNS2_Packet_Request object used for the notify request
36
- */
37
- private $_packet;
38
-
39
- /**
40
- * Constructor - builds a new Net_DNS2_Notifier objected used for doing
41
- * DNS notification for a changed zone
42
- *
43
- * @param string $zone the domain name to use for DNS updates
44
- * @param mixed $options an array of config options or null
45
- *
46
- * @throws Net_DNS2_Exception
47
- * @access public
48
- *
49
- */
50
- public function __construct($zone, array $options = null)
51
- {
52
- parent::__construct($options);
53
-
54
- //
55
- // create the packet
56
- //
57
- $this->_packet = new Net_DNS2_Packet_Request(
58
- strtolower(trim($zone, " \n\r\t.")), 'SOA', 'IN'
59
- );
60
-
61
- //
62
- // make sure the opcode on the packet is set to NOTIFY
63
- //
64
- $this->_packet->header->opcode = Net_DNS2_Lookups::OPCODE_NOTIFY;
65
- }
66
-
67
- /**
68
- * checks that the given name matches the name for the zone we're notifying
69
- *
70
- * @param string $name The name to be checked.
71
- *
72
- * @return boolean
73
- * @throws Net_DNS2_Exception
74
- * @access private
75
- *
76
- */
77
- private function _checkName($name)
78
- {
79
- if (!preg_match('/' . $this->_packet->question[0]->qname . '$/', $name)) {
80
-
81
- throw new Net_DNS2_Exception(
82
- 'name provided (' . $name . ') does not match zone name (' .
83
- $this->_packet->question[0]->qname . ')',
84
- Net_DNS2_Lookups::E_PACKET_INVALID
85
- );
86
- }
87
-
88
- return true;
89
- }
90
-
91
- /**
92
- * 3.7 - Add RR to notify
93
- *
94
- * @param Net_DNS2_RR $rr the Net_DNS2_RR object to be sent in the notify message
95
- *
96
- * @return boolean
97
- * @throws Net_DNS2_Exception
98
- * @access public
99
- *
100
- */
101
- public function add(Net_DNS2_RR $rr)
102
- {
103
- $this->_checkName($rr->name);
104
- //
105
- // add the RR to the "notify" section
106
- //
107
- if (!in_array($rr, $this->_packet->answer)) {
108
- $this->_packet->answer[] = $rr;
109
- }
110
- return true;
111
- }
112
-
113
- /**
114
- * add a signature to the request for authentication
115
- *
116
- * @param string $keyname the key name to use for the TSIG RR
117
- * @param string $signature the key to sign the request.
118
- *
119
- * @return boolean
120
- * @access public
121
- * @see Net_DNS2::signTSIG()
122
- * @deprecated function deprecated in 1.1.0
123
- *
124
- */
125
- public function signature($keyname, $signature, $algorithm = Net_DNS2_RR_TSIG::HMAC_MD5)
126
- {
127
- return $this->signTSIG($keyname, $signature, $algorithm);
128
- }
129
-
130
- /**
131
- * returns the current internal packet object.
132
- *
133
- * @return Net_DNS2_Packet_Request
134
- * @access public
135
- #
136
- */
137
- public function packet()
138
- {
139
- //
140
- // take a copy
141
- //
142
- $p = $this->_packet;
143
-
144
- //
145
- // check for an authentication method; either TSIG or SIG
146
- //
147
- if ( ($this->auth_signature instanceof Net_DNS2_RR_TSIG)
148
- || ($this->auth_signature instanceof Net_DNS2_RR_SIG)
149
- ) {
150
- $p->additional[] = $this->auth_signature;
151
- }
152
-
153
- //
154
- // update the counts
155
- //
156
- $p->header->qdcount = count($p->question);
157
- $p->header->ancount = count($p->answer);
158
- $p->header->nscount = count($p->authority);
159
- $p->header->arcount = count($p->additional);
160
-
161
- return $p;
162
- }
163
-
164
- /**
165
- * executes the notify request
166
- *
167
- * @param Net_DNS2_Packet_Response &$response ref to the response object
168
- *
169
- * @return boolean
170
- * @throws Net_DNS2_Exception
171
- * @access public
172
- *
173
- */
174
- public function notify(&$response = null)
175
- {
176
- //
177
- // check for an authentication method; either TSIG or SIG
178
- //
179
- if ( ($this->auth_signature instanceof Net_DNS2_RR_TSIG)
180
- || ($this->auth_signature instanceof Net_DNS2_RR_SIG)
181
- ) {
182
- $this->_packet->additional[] = $this->auth_signature;
183
- }
184
-
185
- //
186
- // update the counts
187
- //
188
- $this->_packet->header->qdcount = count($this->_packet->question);
189
- $this->_packet->header->ancount = count($this->_packet->answer);
190
- $this->_packet->header->nscount = count($this->_packet->authority);
191
- $this->_packet->header->arcount = count($this->_packet->additional);
192
-
193
- //
194
- // make sure we have some data to send
195
- //
196
- if ($this->_packet->header->qdcount == 0) {
197
- throw new Net_DNS2_Exception(
198
- 'empty headers- nothing to send!',
199
- Net_DNS2_Lookups::E_PACKET_INVALID
200
- );
201
- }
202
-
203
- //
204
- // send the packet and get back the response
205
- //
206
- $response = $this->sendPacket($this->_packet, $this->use_tcp);
207
-
208
- //
209
- // clear the internal packet so if we make another request, we don't have
210
- // old data being sent.
211
- //
212
- $this->_packet->reset();
213
-
214
- //
215
- // for notifies, we just need to know it worked- we don't actualy need to
216
- // return the response object
217
- //
218
- return true;
219
- }
220
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/Packet.php DELETED
@@ -1,401 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 0.6.0
17
- *
18
- * This file contains code based off the Net::DNS Perl module by Michael Fuhr.
19
- *
20
- * This is the copyright notice from the PERL Net::DNS module:
21
- *
22
- * Copyright (c) 1997-2000 Michael Fuhr. All rights reserved. This program is
23
- * free software; you can redistribute it and/or modify it under the same terms
24
- * as Perl itself.
25
- *
26
- */
27
-
28
- /**
29
- * This is the base class that holds a standard DNS packet.
30
- *
31
- * The Net_DNS2_Packet_Request and Net_DNS2_Packet_Response classes extend this
32
- * class.
33
- *
34
- */
35
- class Net_DNS2_Packet
36
- {
37
- /*
38
- * the full binary data and length for this packet
39
- */
40
- public $rdata;
41
- public $rdlength;
42
-
43
- /*
44
- * the offset pointer used when building/parsing packets
45
- */
46
- public $offset = 0;
47
-
48
- /*
49
- * Net_DNS2_Header object with the DNS packet header
50
- */
51
- public $header;
52
-
53
- /*
54
- * array of Net_DNS2_Question objects
55
- *
56
- * used as "zone" for updates per RFC2136
57
- *
58
- */
59
- public $question = [];
60
-
61
- /*
62
- * array of Net_DNS2_RR Objects for Answers
63
- *
64
- * used as "prerequisite" for updates per RFC2136
65
- *
66
- */
67
- public $answer = [];
68
-
69
- /*
70
- * array of Net_DNS2_RR Objects for Authority
71
- *
72
- * used as "update" for updates per RFC2136
73
- *
74
- */
75
- public $authority = [];
76
-
77
- /*
78
- * array of Net_DNS2_RR Objects for Addtitional
79
- */
80
- public $additional = [];
81
-
82
- /*
83
- * array of compressed labeles
84
- */
85
- private $_compressed = [];
86
-
87
- /**
88
- * magic __toString() method to return the Net_DNS2_Packet as a string
89
- *
90
- * @return string
91
- * @access public
92
- *
93
- */
94
- public function __toString()
95
- {
96
- $output = $this->header->__toString();
97
-
98
- foreach ($this->question as $x) {
99
-
100
- $output .= $x->__toString() . "\n";
101
- }
102
- foreach ($this->answer as $x) {
103
-
104
- $output .= $x->__toString() . "\n";
105
- }
106
- foreach ($this->authority as $x) {
107
-
108
- $output .= $x->__toString() . "\n";
109
- }
110
- foreach ($this->additional as $x) {
111
-
112
- $output .= $x->__toString() . "\n";
113
- }
114
-
115
- return $output;
116
- }
117
-
118
- /**
119
- * returns a full binary DNS packet
120
- *
121
- * @return string
122
- * @throws Net_DNS2_Exception
123
- * @access public
124
- *
125
- */
126
- public function get()
127
- {
128
- $data = $this->header->get($this);
129
-
130
- foreach ($this->question as $x) {
131
-
132
- $data .= $x->get($this);
133
- }
134
- foreach ($this->answer as $x) {
135
-
136
- $data .= $x->get($this);
137
- }
138
- foreach ($this->authority as $x) {
139
-
140
- $data .= $x->get($this);
141
- }
142
- foreach ($this->additional as $x) {
143
-
144
- $data .= $x->get($this);
145
- }
146
-
147
- return $data;
148
- }
149
-
150
- /**
151
- * applies a standard DNS name compression on the given name/offset
152
- *
153
- * This logic was based on the Net::DNS::Packet::dn_comp() function
154
- * by Michanel Fuhr
155
- *
156
- * @param string $name the name to be compressed
157
- * @param integer &$offset the offset into the given packet object
158
- *
159
- * @return string
160
- * @access public
161
- *
162
- */
163
- public function compress($name, &$offset)
164
- {
165
- //
166
- // we're using preg_split() rather than explode() so that we can use the negative lookbehind,
167
- // to catch cases where we have escaped dots in strings.
168
- //
169
- // there's only a few cases like this- the rname in SOA for example
170
- //
171
- $names = str_replace('\.', '.', preg_split('/(?<!\\\)\./', $name));
172
- $compname = '';
173
-
174
- while (!empty($names)) {
175
-
176
- $dname = join('.', $names);
177
-
178
- if (isset($this->_compressed[$dname])) {
179
-
180
- $compname .= pack('n', 0xc000 | $this->_compressed[$dname]);
181
- $offset += 2;
182
-
183
- break;
184
- }
185
-
186
- $this->_compressed[$dname] = $offset;
187
-
188
- $first = array_shift($names);
189
-
190
- $length = strlen($first);
191
- if ($length <= 0) {
192
- continue;
193
- }
194
-
195
- //
196
- // truncate see RFC1035 2.3.1
197
- //
198
- if ($length > 63) {
199
-
200
- $length = 63;
201
- $first = substr($first, 0, $length);
202
- }
203
-
204
- $compname .= pack('Ca*', $length, $first);
205
- $offset += $length + 1;
206
- }
207
-
208
- if (empty($names)) {
209
-
210
- $compname .= pack('C', 0);
211
- $offset++;
212
- }
213
-
214
- return $compname;
215
- }
216
-
217
- /**
218
- * applies a standard DNS name compression on the given name/offset
219
- *
220
- * This logic was based on the Net::DNS::Packet::dn_comp() function
221
- * by Michanel Fuhr
222
- *
223
- * @param string $name the name to be compressed
224
- *
225
- * @return string
226
- * @access public
227
- *
228
- */
229
- public static function pack($name)
230
- {
231
- $offset = 0;
232
- $names = explode('.', $name);
233
- $compname = '';
234
-
235
- while (!empty($names)) {
236
-
237
- $first = array_shift($names);
238
- $length = strlen($first);
239
-
240
- $compname .= pack('Ca*', $length, $first);
241
- $offset += $length + 1;
242
- }
243
-
244
- $compname .= "\0";
245
- $offset++;
246
-
247
- return $compname;
248
- }
249
-
250
- /**
251
- * expands the domain name stored at a given offset in a DNS Packet
252
- *
253
- * This logic was based on the Net::DNS::Packet::dn_expand() function
254
- * by Michanel Fuhr
255
- *
256
- * @param Net_DNS2_Packet &$packet the DNS packet to look in for the domain name
257
- * @param integer &$offset the offset into the given packet object
258
- * @param boolean $escape_dot_literals if we should escape periods in names
259
- *
260
- * @return mixed either the domain name or null if it's not found.
261
- * @access public
262
- *
263
- */
264
- public static function expand(Net_DNS2_Packet &$packet, &$offset, $escape_dot_literals = false)
265
- {
266
- $name = '';
267
-
268
- while (1) {
269
- if ($packet->rdlength < ($offset + 1)) {
270
- return null;
271
- }
272
-
273
- $xlen = ord($packet->rdata[$offset]);
274
- if ($xlen == 0) {
275
-
276
- ++$offset;
277
- break;
278
-
279
- } else if (($xlen & 0xc0) == 0xc0) {
280
- if ($packet->rdlength < ($offset + 2)) {
281
-
282
- return null;
283
- }
284
-
285
- $ptr = ord($packet->rdata[$offset]) << 8 | ord($packet->rdata[$offset+1]);
286
- $ptr = $ptr & 0x3fff;
287
-
288
- $name2 = Net_DNS2_Packet::expand($packet, $ptr);
289
- if (is_null($name2)) {
290
-
291
- return null;
292
- }
293
-
294
- $name .= $name2;
295
- $offset += 2;
296
-
297
- break;
298
- } else {
299
- ++$offset;
300
-
301
- if ($packet->rdlength < ($offset + $xlen)) {
302
-
303
- return null;
304
- }
305
-
306
- $elem = '';
307
- $elem = substr($packet->rdata, $offset, $xlen);
308
-
309
- //
310
- // escape literal dots in certain cases (SOA rname)
311
- //
312
- if ( ($escape_dot_literals == true) && (strpos($elem, '.') !== false) ) {
313
-
314
- $elem = str_replace('.', '\.', $elem);
315
- }
316
-
317
- $name .= $elem . '.';
318
- $offset += $xlen;
319
- }
320
- }
321
-
322
- return trim($name, '.');
323
- }
324
-
325
- /**
326
- * parses a domain label from a DNS Packet at the given offset
327
- *
328
- * @param Net_DNS2_Packet &$packet the DNS packet to look in for the domain name
329
- * @param integer &$offset the offset into the given packet object
330
- *
331
- * @return mixed either the domain name or null if it's not found.
332
- * @access public
333
- *
334
- */
335
- public static function label(Net_DNS2_Packet &$packet, &$offset)
336
- {
337
- $name = '';
338
-
339
- if ($packet->rdlength < ($offset + 1)) {
340
-
341
- return null;
342
- }
343
-
344
- $xlen = ord($packet->rdata[$offset]);
345
- ++$offset;
346
-
347
- if (($xlen + $offset) > $packet->rdlength) {
348
-
349
- $name = substr($packet->rdata, $offset);
350
- $offset = $packet->rdlength;
351
- } else {
352
-
353
- $name = substr($packet->rdata, $offset, $xlen);
354
- $offset += $xlen;
355
- }
356
-
357
- return $name;
358
- }
359
-
360
- /**
361
- * copies the contents of the given packet, to the local packet object. this
362
- * function intentionally ignores some of the packet data.
363
- *
364
- * @param Net_DNS2_Packet $packet the DNS packet to copy the data from
365
- *
366
- * @return boolean
367
- * @access public
368
- *
369
- */
370
- public function copy(Net_DNS2_Packet $packet)
371
- {
372
- $this->header = $packet->header;
373
- $this->question = $packet->question;
374
- $this->answer = $packet->answer;
375
- $this->authority = $packet->authority;
376
- $this->additional = $packet->additional;
377
-
378
- return true;
379
- }
380
-
381
- /**
382
- * resets the values in the current packet object
383
- *
384
- * @return boolean
385
- * @access public
386
- *
387
- */
388
- public function reset()
389
- {
390
- $this->header->id = $this->header->nextPacketId();
391
- $this->rdata = '';
392
- $this->rdlength = 0;
393
- $this->offset = 0;
394
- $this->answer = [];
395
- $this->authority = [];
396
- $this->additional = [];
397
- $this->_compressed = [];
398
-
399
- return true;
400
- }
401
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/Packet/Request.php DELETED
@@ -1,168 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 0.6.0
17
- *
18
- */
19
-
20
- /**
21
- * This class handles building new DNS request packets; packets used for DNS
22
- * queries and updates.
23
- *
24
- */
25
- class Net_DNS2_Packet_Request extends Net_DNS2_Packet
26
- {
27
- /**
28
- * Constructor - builds a new Net_DNS2_Packet_Request object
29
- *
30
- * @param string $name the domain name for the packet
31
- * @param string $type the DNS RR type for the packet
32
- * @param string $class the DNS class for the packet
33
- *
34
- * @throws Net_DNS2_Exception
35
- * @access public
36
- *
37
- */
38
- public function __construct($name, $type = null, $class = null)
39
- {
40
- $this->set($name, $type, $class);
41
- }
42
-
43
- /**
44
- * builds a new Net_DNS2_Packet_Request object
45
- *
46
- * @param string $name the domain name for the packet
47
- * @param string $type the DNS RR type for the packet
48
- * @param string $class the DNS class for the packet
49
- *
50
- * @return boolean
51
- * @throws Net_DNS2_Exception
52
- * @access public
53
- *
54
- */
55
- public function set($name, $type = 'A', $class = 'IN')
56
- {
57
- //
58
- // generate a new header
59
- //
60
- $this->header = new Net_DNS2_Header;
61
-
62
- //
63
- // add a new question
64
- //
65
- $q = new Net_DNS2_Question();
66
-
67
- //
68
- // allow queries directly to . for the root name servers
69
- //
70
- if ($name != '.') {
71
- $name = trim(strtolower($name), " \t\n\r\0\x0B.");
72
- }
73
-
74
- $type = strtoupper(trim($type));
75
- $class = strtoupper(trim($class));
76
-
77
- //
78
- // check that the input string has some data in it
79
- //
80
- if (empty($name)) {
81
-
82
- throw new Net_DNS2_Exception(
83
- 'empty query string provided',
84
- Net_DNS2_Lookups::E_PACKET_INVALID
85
- );
86
- }
87
-
88
- //
89
- // if the type is "*", rename it to "ANY"- both are acceptable.
90
- //
91
- if ($type == '*') {
92
-
93
- $type = 'ANY';
94
- }
95
-
96
- //
97
- // check that the type and class are valid
98
- //
99
- if ( (!isset(Net_DNS2_Lookups::$rr_types_by_name[$type]))
100
- || (!isset(Net_DNS2_Lookups::$classes_by_name[$class]))
101
- ) {
102
- throw new Net_DNS2_Exception(
103
- 'invalid type (' . $type . ') or class (' . $class . ') specified.',
104
- Net_DNS2_Lookups::E_PACKET_INVALID
105
- );
106
- }
107
-
108
- if ($type == 'PTR') {
109
-
110
- //
111
- // if it's a PTR request for an IP address, then make sure we tack on
112
- // the arpa domain.
113
- //
114
- // there are other types of PTR requests, so if an IP adress doesn't match,
115
- // then just let it flow through and assume it's a hostname
116
- //
117
- if (Net_DNS2::isIPv4($name) == true) {
118
-
119
- //
120
- // IPv4
121
- //
122
- $name = implode('.', array_reverse(explode('.', $name)));
123
- $name .= '.in-addr.arpa';
124
-
125
- } else if (Net_DNS2::isIPv6($name) == true) {
126
-
127
- //
128
- // IPv6
129
- //
130
- $e = Net_DNS2::expandIPv6($name);
131
- if ($e !== false) {
132
-
133
- $name = implode(
134
- '.', array_reverse(str_split(str_replace(':', '', $e)))
135
- );
136
-
137
- $name .= '.ip6.arpa';
138
-
139
- } else {
140
-
141
- throw new Net_DNS2_Exception(
142
- 'unsupported PTR value: ' . $name,
143
- Net_DNS2_Lookups::E_PACKET_INVALID
144
- );
145
- }
146
- }
147
- }
148
-
149
- //
150
- // store the data
151
- //
152
- $q->qname = $name;
153
- $q->qtype = $type;
154
- $q->qclass = $class;
155
-
156
- $this->question[] = $q;
157
-
158
- //
159
- // the answer, authority and additional are empty; they can be modified
160
- // after the request is created for UPDATE requests if needed.
161
- //
162
- $this->answer = [];
163
- $this->authority = [];
164
- $this->additional = [];
165
-
166
- return true;
167
- }
168
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/Packet/Response.php DELETED
@@ -1,145 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 0.6.0
17
- *
18
- */
19
-
20
- /**
21
- * This class handles building new DNS response packets; it parses binary packed
22
- * packets that come off the wire
23
- *
24
- */
25
- class Net_DNS2_Packet_Response extends Net_DNS2_Packet
26
- {
27
- /*
28
- * The name servers that this response came from
29
- */
30
- public $answer_from;
31
-
32
- /*
33
- * The socket type the answer came from (TCP/UDP)
34
- */
35
- public $answer_socket_type;
36
-
37
- /*
38
- * The query response time in microseconds
39
- */
40
- public $response_time = 0;
41
-
42
- /**
43
- * Constructor - builds a new Net_DNS2_Packet_Response object
44
- *
45
- * @param string $data binary DNS packet
46
- * @param integer $size the length of the DNS packet
47
- *
48
- * @throws Net_DNS2_Exception
49
- * @access public
50
- *
51
- */
52
- public function __construct($data, $size)
53
- {
54
- $this->set($data, $size);
55
- }
56
-
57
- /**
58
- * builds a new Net_DNS2_Packet_Response object
59
- *
60
- * @param string $data binary DNS packet
61
- * @param integer $size the length of the DNS packet
62
- *
63
- * @return boolean
64
- * @throws Net_DNS2_Exception
65
- * @access public
66
- *
67
- */
68
- public function set($data, $size)
69
- {
70
- //
71
- // store the full packet
72
- //
73
- $this->rdata = $data;
74
- $this->rdlength = $size;
75
-
76
- //
77
- // parse the header
78
- //
79
- // we don't bother checking the size earlier, because the first thing the
80
- // header class does, is check the size and throw and exception if it's
81
- // invalid.
82
- //
83
- $this->header = new Net_DNS2_Header($this);
84
-
85
- //
86
- // if the truncation bit is set, then just return right here, because the
87
- // rest of the packet is probably empty; and there's no point in processing
88
- // anything else.
89
- //
90
- // we also don't need to worry about checking to see if the the header is
91
- // null or not, since the Net_DNS2_Header() constructor will throw an
92
- // exception if the packet is invalid.
93
- //
94
- if ($this->header->tc == 1) {
95
-
96
- return false;
97
- }
98
-
99
- //
100
- // parse the questions
101
- //
102
- for ($x = 0; $x < $this->header->qdcount; ++$x) {
103
-
104
- $this->question[$x] = new Net_DNS2_Question($this);
105
- }
106
-
107
- //
108
- // parse the answers
109
- //
110
- for ($x = 0; $x < $this->header->ancount; ++$x) {
111
-
112
- $o = Net_DNS2_RR::parse($this);
113
- if (!is_null($o)) {
114
-
115
- $this->answer[] = $o;
116
- }
117
- }
118
-
119
- //
120
- // parse the authority section
121
- //
122
- for ($x = 0; $x < $this->header->nscount; ++$x) {
123
-
124
- $o = Net_DNS2_RR::parse($this);
125
- if (!is_null($o)) {
126
-
127
- $this->authority[] = $o;
128
- }
129
- }
130
-
131
- //
132
- // parse the additional section
133
- //
134
- for ($x = 0; $x < $this->header->arcount; ++$x) {
135
-
136
- $o = Net_DNS2_RR::parse($this);
137
- if (!is_null($o)) {
138
-
139
- $this->additional[] = $o;
140
- }
141
- }
142
-
143
- return true;
144
- }
145
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/PrivateKey.php DELETED
@@ -1,377 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 1.1.0
17
- *
18
- */
19
-
20
- /**
21
- * SSL Private Key container class
22
- *
23
- */
24
- class Net_DNS2_PrivateKey
25
- {
26
- /*
27
- * the filename that was loaded; stored for reference
28
- */
29
- public $filename;
30
-
31
- /*
32
- * the keytag for the signature
33
- */
34
- public $keytag;
35
-
36
- /*
37
- * the sign name for the signature
38
- */
39
- public $signname;
40
-
41
- /*
42
- * the algorithm used for the signature
43
- */
44
- public $algorithm;
45
-
46
- /*
47
- * the key format of the signature
48
- */
49
- public $key_format;
50
-
51
- /*
52
- * the openssl private key id
53
- */
54
- public $instance;
55
-
56
- /*
57
- * RSA: modulus
58
- */
59
- private $_modulus;
60
-
61
- /*
62
- * RSA: public exponent
63
- */
64
- private $_public_exponent;
65
-
66
- /*
67
- * RSA: rivate exponent
68
- */
69
- private $_private_exponent;
70
-
71
- /*
72
- * RSA: prime1
73
- */
74
- private $_prime1;
75
-
76
- /*
77
- * RSA: prime2
78
- */
79
- private $_prime2;
80
-
81
- /*
82
- * RSA: exponent 1
83
- */
84
- private $_exponent1;
85
-
86
- /*
87
- * RSA: exponent 2
88
- */
89
- private $_exponent2;
90
-
91
- /*
92
- * RSA: coefficient
93
- */
94
- private $_coefficient;
95
-
96
- /*
97
- * DSA: prime
98
- */
99
- public $prime;
100
-
101
- /*
102
- * DSA: subprime
103
- */
104
- public $subprime;
105
-
106
- /*
107
- * DSA: base
108
- */
109
- public $base;
110
-
111
- /*
112
- * DSA: private value
113
- */
114
- public $private_value;
115
-
116
- /*
117
- * DSA: public value
118
- */
119
- public $public_value;
120
-
121
- /**
122
- * Constructor - base constructor the private key container class
123
- *
124
- * @param string $file path to a private-key file to parse and load
125
- *
126
- * @throws Net_DNS2_Exception
127
- * @access public
128
- *
129
- */
130
- public function __construct($file = null)
131
- {
132
- if (isset($file)) {
133
- $this->parseFile($file);
134
- }
135
- }
136
-
137
- /**
138
- * parses a private key file generated by dnssec-keygen
139
- *
140
- * @param string $file path to a private-key file to parse and load
141
- *
142
- * @return boolean
143
- * @throws Net_DNS2_Exception
144
- * @access public
145
- *
146
- */
147
- public function parseFile($file)
148
- {
149
- //
150
- // check for OpenSSL
151
- //
152
- if (extension_loaded('openssl') === false) {
153
-
154
- throw new Net_DNS2_Exception(
155
- 'the OpenSSL extension is required to use parse private key.',
156
- Net_DNS2_Lookups::E_OPENSSL_UNAVAIL
157
- );
158
- }
159
-
160
- //
161
- // check to make sure the file exists
162
- //
163
- if (is_readable($file) == false) {
164
-
165
- throw new Net_DNS2_Exception(
166
- 'invalid private key file: ' . $file,
167
- Net_DNS2_Lookups::E_OPENSSL_INV_PKEY
168
- );
169
- }
170
-
171
- //
172
- // get the base filename, and parse it for the local value
173
- //
174
- $keyname = basename($file);
175
- if (strlen($keyname) == 0) {
176
-
177
- throw new Net_DNS2_Exception(
178
- 'failed to get basename() for: ' . $file,
179
- Net_DNS2_Lookups::E_OPENSSL_INV_PKEY
180
- );
181
- }
182
-
183
- //
184
- // parse the keyname
185
- //
186
- if (preg_match("/K(.*)\.\+(\d{3})\+(\d*)\.private/", $keyname, $matches)) {
187
-
188
- $this->signname = $matches[1];
189
- $this->algorithm = intval($matches[2]);
190
- $this->keytag = intval($matches[3]);
191
-
192
- } else {
193
-
194
- throw new Net_DNS2_Exception(
195
- 'file ' . $keyname . ' does not look like a private key file!',
196
- Net_DNS2_Lookups::E_OPENSSL_INV_PKEY
197
- );
198
- }
199
-
200
- //
201
- // read all the data from the
202
- //
203
- $data = file($file, FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES);
204
- if (count($data) == 0) {
205
-
206
- throw new Net_DNS2_Exception(
207
- 'file ' . $keyname . ' is empty!',
208
- Net_DNS2_Lookups::E_OPENSSL_INV_PKEY
209
- );
210
- }
211
-
212
- foreach ($data as $line) {
213
-
214
- list($key, $value) = explode(':', $line);
215
-
216
- $key = trim($key);
217
- $value = trim($value);
218
-
219
- switch(strtolower($key)) {
220
-
221
- case 'private-key-format':
222
- $this->key_format = $value;
223
- break;
224
-
225
- case 'algorithm':
226
- if ($this->algorithm != $value) {
227
- throw new Net_DNS2_Exception(
228
- 'Algorithm mis-match! filename is ' . $this->algorithm .
229
- ', contents say ' . $value,
230
- Net_DNS2_Lookups::E_OPENSSL_INV_ALGO
231
- );
232
- }
233
- break;
234
-
235
- //
236
- // RSA
237
- //
238
- case 'modulus':
239
- $this->_modulus = $value;
240
- break;
241
-
242
- case 'publicexponent':
243
- $this->_public_exponent = $value;
244
- break;
245
-
246
- case 'privateexponent':
247
- $this->_private_exponent = $value;
248
- break;
249
-
250
- case 'prime1':
251
- $this->_prime1 = $value;
252
- break;
253
-
254
- case 'prime2':
255
- $this->_prime2 = $value;
256
- break;
257
-
258
- case 'exponent1':
259
- $this->_exponent1 = $value;
260
- break;
261
-
262
- case 'exponent2':
263
- $this->_exponent2 = $value;
264
- break;
265
-
266
- case 'coefficient':
267
- $this->_coefficient = $value;
268
- break;
269
-
270
- //
271
- // DSA - this won't work in PHP until the OpenSSL extension is better
272
- //
273
- case 'prime(p)':
274
- $this->prime = $value;
275
- break;
276
-
277
- case 'subprime(q)':
278
- $this->subprime = $value;
279
- break;
280
-
281
- case 'base(g)':
282
- $this->base = $value;
283
- break;
284
-
285
- case 'private_value(x)':
286
- $this->private_value = $value;
287
- break;
288
-
289
- case 'public_value(y)':
290
- $this->public_value = $value;
291
- break;
292
-
293
- default:
294
- throw new Net_DNS2_Exception(
295
- 'unknown private key data: ' . $key . ': ' . $value,
296
- Net_DNS2_Lookups::E_OPENSSL_INV_PKEY
297
- );
298
- }
299
- }
300
-
301
- //
302
- // generate the private key
303
- //
304
- $args = [];
305
-
306
- switch($this->algorithm) {
307
-
308
- //
309
- // RSA
310
- //
311
- case Net_DNS2_Lookups::DNSSEC_ALGORITHM_RSAMD5:
312
- case Net_DNS2_Lookups::DNSSEC_ALGORITHM_RSASHA1:
313
- case Net_DNS2_Lookups::DNSSEC_ALGORITHM_RSASHA256:
314
- case Net_DNS2_Lookups::DNSSEC_ALGORITHM_RSASHA512:
315
-
316
- $args = [
317
-
318
- 'rsa' => [
319
-
320
- 'n' => base64_decode($this->_modulus),
321
- 'e' => base64_decode($this->_public_exponent),
322
- 'd' => base64_decode($this->_private_exponent),
323
- 'p' => base64_decode($this->_prime1),
324
- 'q' => base64_decode($this->_prime2),
325
- 'dmp1' => base64_decode($this->_exponent1),
326
- 'dmq1' => base64_decode($this->_exponent2),
327
- 'iqmp' => base64_decode($this->_coefficient)
328
- ]
329
- ];
330
-
331
- break;
332
-
333
- //
334
- // DSA - this won't work in PHP until the OpenSSL extension is better
335
- //
336
- case Net_DNS2_Lookups::DNSSEC_ALGORITHM_DSA:
337
-
338
- $args = [
339
-
340
- 'dsa' => [
341
-
342
- 'p' => base64_decode($this->prime),
343
- 'q' => base64_decode($this->subprime),
344
- 'g' => base64_decode($this->base),
345
- 'priv_key' => base64_decode($this->private_value),
346
- 'pub_key' => base64_decode($this->public_value)
347
- ]
348
- ];
349
-
350
- break;
351
-
352
- default:
353
- throw new Net_DNS2_Exception(
354
- 'we only currently support RSAMD5 and RSASHA1 encryption.',
355
- Net_DNS2_Lookups::E_OPENSSL_INV_PKEY
356
- );
357
- }
358
-
359
- //
360
- // generate and store the key
361
- //
362
- $this->instance = openssl_pkey_new($args);
363
- if ($this->instance === false) {
364
- throw new Net_DNS2_Exception(
365
- openssl_error_string(),
366
- Net_DNS2_Lookups::E_OPENSSL_ERROR
367
- );
368
- }
369
-
370
- //
371
- // store the filename incase we need it for something
372
- //
373
- $this->filename = $file;
374
-
375
- return true;
376
- }
377
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/Question.php DELETED
@@ -1,196 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 0.6.0
17
- *
18
- */
19
-
20
- /**
21
- * This class handles parsing and constructing the question sectino of DNS
22
- * packets.
23
- *
24
- * This is referred to as the "zone" for update per RFC2136
25
- *
26
- * DNS question format - RFC1035 section 4.1.2
27
- *
28
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
29
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
30
- * | |
31
- * / QNAME /
32
- * / /
33
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
34
- * | QTYPE |
35
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
36
- * | QCLASS |
37
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
38
- *
39
- */
40
- class Net_DNS2_Question
41
- {
42
- /*
43
- * The name of the question
44
- *
45
- * referred to as "zname" for updates per RFC2136
46
- *
47
- */
48
- public $qname;
49
-
50
- /*
51
- * The RR type for the questino
52
- *
53
- * referred to as "ztype" for updates per RFC2136
54
- *
55
- */
56
- public $qtype;
57
-
58
- /*
59
- * The RR class for the questino
60
- *
61
- * referred to as "zclass" for updates per RFC2136
62
- *
63
- */
64
- public $qclass;
65
-
66
- /**
67
- * Constructor - builds a new Net_DNS2_Question object
68
- *
69
- * @param mixed &$packet either a Net_DNS2_Packet object, or null to
70
- * build an empty object
71
- *
72
- * @throws Net_DNS2_Exception
73
- * @access public
74
- *
75
- */
76
- public function __construct(Net_DNS2_Packet &$packet = null)
77
- {
78
- if (!is_null($packet)) {
79
-
80
- $this->set($packet);
81
- } else {
82
-
83
- $this->qname = '';
84
- $this->qtype = 'A';
85
- $this->qclass = 'IN';
86
- }
87
- }
88
-
89
- /**
90
- * magic __toString() function to return the Net_DNS2_Question object as a string
91
- *
92
- * @return string
93
- * @access public
94
- *
95
- */
96
- public function __toString()
97
- {
98
- return ";;\n;; Question:\n;;\t " . $this->qname . '. ' .
99
- $this->qtype . ' ' . $this->qclass . "\n";
100
- }
101
-
102
- /**
103
- * builds a new Net_DNS2_Header object from a Net_DNS2_Packet object
104
- *
105
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet object
106
- *
107
- * @return boolean
108
- * @throws Net_DNS2_Exception
109
- * @access public
110
- *
111
- */
112
- public function set(Net_DNS2_Packet &$packet)
113
- {
114
- //
115
- // expand the name
116
- //
117
- $this->qname = $packet->expand($packet, $packet->offset);
118
- if ($packet->rdlength < ($packet->offset + 4)) {
119
-
120
- throw new Net_DNS2_Exception(
121
- 'invalid question section: to small',
122
- Net_DNS2_Lookups::E_QUESTION_INVALID
123
- );
124
- }
125
-
126
- //
127
- // unpack the type and class
128
- //
129
- $type = ord($packet->rdata[$packet->offset++]) << 8 |
130
- ord($packet->rdata[$packet->offset++]);
131
- $class = ord($packet->rdata[$packet->offset++]) << 8 |
132
- ord($packet->rdata[$packet->offset++]);
133
-
134
- //
135
- // validate it
136
- //
137
- $type_name = Net_DNS2_Lookups::$rr_types_by_id[$type];
138
- $class_name = Net_DNS2_Lookups::$classes_by_id[$class];
139
-
140
- if ( (!isset($type_name)) || (!isset($class_name)) ) {
141
-
142
- throw new Net_DNS2_Exception(
143
- 'invalid question section: invalid type (' . $type .
144
- ') or class (' . $class . ') specified.',
145
- Net_DNS2_Lookups::E_QUESTION_INVALID
146
- );
147
- }
148
-
149
- //
150
- // store it
151
- //
152
- $this->qtype = $type_name;
153
- $this->qclass = $class_name;
154
-
155
- return true;
156
- }
157
-
158
- /**
159
- * returns a binary packed Net_DNS2_Question object
160
- *
161
- * @param Net_DNS2_Packet &$packet the Net_DNS2_Packet object this question is
162
- * part of. This needs to be passed in so that
163
- * the compressed qname value can be packed in
164
- * with the names of the other parts of the
165
- * packet.
166
- *
167
- * @return string
168
- * @throws Net_DNS2_Exception
169
- * @access public
170
- *
171
- */
172
- public function get(Net_DNS2_Packet &$packet)
173
- {
174
- //
175
- // validate the type and class
176
- //
177
- $type = Net_DNS2_Lookups::$rr_types_by_name[$this->qtype];
178
- $class = Net_DNS2_Lookups::$classes_by_name[$this->qclass];
179
-
180
- if ( (!isset($type)) || (!isset($class)) ) {
181
-
182
- throw new Net_DNS2_Exception(
183
- 'invalid question section: invalid type (' . $this->qtype .
184
- ') or class (' . $this->qclass . ') specified.',
185
- Net_DNS2_Lookups::E_QUESTION_INVALID
186
- );
187
- }
188
-
189
- $data = $packet->compress($this->qname, $packet->offset);
190
-
191
- $data .= chr($type >> 8) . chr($type) . chr($class >> 8) . chr($class);
192
- $packet->offset += 4;
193
-
194
- return $data;
195
- }
196
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR.php DELETED
@@ -1,616 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 0.6.0
17
- *
18
- */
19
-
20
- /**
21
- * This is the base class for DNS Resource Records
22
- *
23
- * Each resource record type (defined in RR/*.php) extends this class for
24
- * base functionality.
25
- *
26
- * This class handles parsing and constructing the common parts of the DNS
27
- * resource records, while the RR specific functionality is handled in each
28
- * child class.
29
- *
30
- * DNS resource record format - RFC1035 section 4.1.3
31
- *
32
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
33
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
34
- * | |
35
- * / /
36
- * / NAME /
37
- * | |
38
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
39
- * | TYPE |
40
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
41
- * | CLASS |
42
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
43
- * | TTL |
44
- * | |
45
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
46
- * | RDLENGTH |
47
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
48
- * / RDATA /
49
- * / /
50
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
51
- *
52
- */
53
- abstract class Net_DNS2_RR
54
- {
55
- /*
56
- * The name of the resource record
57
- */
58
- public $name;
59
-
60
- /*
61
- * The resource record type
62
- */
63
- public $type;
64
-
65
- /*
66
- * The resouce record class
67
- */
68
- public $class;
69
-
70
- /*
71
- * The time to live for this resource record
72
- */
73
- public $ttl;
74
-
75
- /*
76
- * The length of the rdata field
77
- */
78
- public $rdlength;
79
-
80
- /*
81
- * The resource record specific data as a packed binary string
82
- */
83
- public $rdata;
84
-
85
- /**
86
- * abstract definition - method to return a RR as a string; not to
87
- * be confused with the __toString() magic method.
88
- *
89
- * @return string
90
- * @access protected
91
- *
92
- */
93
- abstract protected function rrToString();
94
-
95
- /**
96
- * abstract definition - parses a RR from a standard DNS config line
97
- *
98
- * @param array $rdata a string split line of values for the rdata
99
- *
100
- * @return boolean
101
- * @access protected
102
- *
103
- */
104
- abstract protected function rrFromString(array $rdata);
105
-
106
- /**
107
- * abstract definition - sets a Net_DNS2_RR from a Net_DNS2_Packet object
108
- *
109
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
110
- *
111
- * @return boolean
112
- * @access protected
113
- *
114
- */
115
- abstract protected function rrSet(Net_DNS2_Packet &$packet);
116
-
117
- /**
118
- * abstract definition - returns a binary packet DNS RR object
119
- *
120
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
121
- * compressed names
122
- *
123
- * @return mixed either returns a binary packed string or
124
- * null on failure
125
- * @access protected
126
- *
127
- */
128
- abstract protected function rrGet(Net_DNS2_Packet &$packet);
129
-
130
- /**
131
- * Constructor - builds a new Net_DNS2_RR object
132
- *
133
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet or null to create
134
- * an empty object
135
- * @param array $rr an array with RR parse values or null to
136
- * create an empty object
137
- *
138
- * @throws Net_DNS2_Exception
139
- * @access public
140
- *
141
- */
142
- public function __construct(Net_DNS2_Packet &$packet = null, array $rr = null)
143
- {
144
- if ( (!is_null($packet)) && (!is_null($rr)) ) {
145
-
146
- if ($this->set($packet, $rr) == false) {
147
-
148
- throw new Net_DNS2_Exception(
149
- 'failed to generate resource record',
150
- Net_DNS2_Lookups::E_RR_INVALID
151
- );
152
- }
153
- } else {
154
-
155
- $class = Net_DNS2_Lookups::$rr_types_class_to_id[get_class($this)];
156
- if (isset($class)) {
157
-
158
- $this->type = Net_DNS2_Lookups::$rr_types_by_id[$class];
159
- }
160
-
161
- $this->class = 'IN';
162
- $this->ttl = 86400;
163
- }
164
- }
165
-
166
- /**
167
- * magic __toString() method to return the Net_DNS2_RR object object as a string
168
- *
169
- * @return string
170
- * @access public
171
- *
172
- */
173
- public function __toString()
174
- {
175
- return $this->name . '. ' . $this->ttl . ' ' . $this->class .
176
- ' ' . $this->type . ' ' . $this->rrToString();
177
- }
178
-
179
- /**
180
- * return the same data as __toString(), but as an array, so each value can be
181
- * used without having to parse the string.
182
- *
183
- * @return array
184
- * @access public
185
- *
186
- */
187
- public function asArray()
188
- {
189
- return [
190
-
191
- 'name' => $this->name,
192
- 'ttl' => $this->ttl,
193
- 'class' => $this->class,
194
- 'type' => $this->type,
195
- 'rdata' => $this->rrToString()
196
- ];
197
- }
198
-
199
- /**
200
- * return a formatted string; if a string has spaces in it, then return
201
- * it with double quotes around it, otherwise, return it as it was passed in.
202
- *
203
- * @param string $string the string to format
204
- *
205
- * @return string
206
- * @access protected
207
- *
208
- */
209
- protected function formatString($string)
210
- {
211
- return '"' . str_replace('"', '\"', trim($string, '"')) . '"';
212
- }
213
-
214
- /**
215
- * builds an array of strings from an array of chunks of text split by spaces
216
- *
217
- * @param array $chunks an array of chunks of text split by spaces
218
- *
219
- * @return array
220
- * @access protected
221
- *
222
- */
223
- protected function buildString(array $chunks)
224
- {
225
- $data = [];
226
- $c = 0;
227
- $in = false;
228
-
229
- foreach ($chunks as $r) {
230
-
231
- $r = trim($r);
232
- if (strlen($r) == 0) {
233
- continue;
234
- }
235
-
236
- if ( ($r[0] == '"')
237
- && ($r[strlen($r) - 1] == '"')
238
- && ($r[strlen($r) - 2] != '\\')
239
- ) {
240
-
241
- $data[$c] = $r;
242
- ++$c;
243
- $in = false;
244
-
245
- } else if ($r[0] == '"') {
246
-
247
- $data[$c] = $r;
248
- $in = true;
249
-
250
- } else if ( ($r[strlen($r) - 1] == '"')
251
- && ($r[strlen($r) - 2] != '\\')
252
- ) {
253
-
254
- $data[$c] .= ' ' . $r;
255
- ++$c;
256
- $in = false;
257
-
258
- } else {
259
-
260
- if ($in == true) {
261
- $data[$c] .= ' ' . $r;
262
- } else {
263
- $data[$c++] = $r;
264
- }
265
- }
266
- }
267
-
268
- foreach ($data as $index => $string) {
269
-
270
- $data[$index] = str_replace('\"', '"', trim($string, '"'));
271
- }
272
-
273
- return $data;
274
- }
275
-
276
- /**
277
- * builds a new Net_DNS2_RR object
278
- *
279
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet or null to create
280
- * an empty object
281
- * @param array $rr an array with RR parse values or null to
282
- * create an empty object
283
- *
284
- * @return boolean
285
- * @throws Net_DNS2_Exception
286
- * @access public
287
- *
288
- */
289
- public function set(Net_DNS2_Packet &$packet, array $rr)
290
- {
291
- $this->name = $rr['name'];
292
- $this->type = Net_DNS2_Lookups::$rr_types_by_id[$rr['type']];
293
-
294
- //
295
- // for RR OPT (41), the class value includes the requestors UDP payload size,
296
- // and not a class value
297
- //
298
- if ($this->type == 'OPT') {
299
- $this->class = $rr['class'];
300
- } else {
301
- $this->class = Net_DNS2_Lookups::$classes_by_id[$rr['class']];
302
- }
303
-
304
- $this->ttl = $rr['ttl'];
305
- $this->rdlength = $rr['rdlength'];
306
- $this->rdata = substr($packet->rdata, $packet->offset, $rr['rdlength']);
307
-
308
- return $this->rrSet($packet);
309
- }
310
-
311
- /**
312
- * returns a binary packed DNS RR object
313
- *
314
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet used for
315
- * compressing names
316
- *
317
- * @return string
318
- * @throws Net_DNS2_Exception
319
- * @access public
320
- *
321
- */
322
- public function get(Net_DNS2_Packet &$packet)
323
- {
324
- $data = '';
325
- $rdata = '';
326
-
327
- //
328
- // pack the name
329
- //
330
- $data = $packet->compress($this->name, $packet->offset);
331
-
332
- //
333
- // pack the main values
334
- //
335
- if ($this->type == 'OPT') {
336
-
337
- //
338
- // pre-build the TTL value
339
- //
340
- $this->preBuild();
341
-
342
- //
343
- // the class value is different for OPT types
344
- //
345
- $data .= pack(
346
- 'nnN',
347
- Net_DNS2_Lookups::$rr_types_by_name[$this->type],
348
- $this->class,
349
- $this->ttl
350
- );
351
- } else {
352
-
353
- $data .= pack(
354
- 'nnN',
355
- Net_DNS2_Lookups::$rr_types_by_name[$this->type],
356
- Net_DNS2_Lookups::$classes_by_name[$this->class],
357
- $this->ttl
358
- );
359
- }
360
-
361
- //
362
- // increase the offset, and allow for the rdlength
363
- //
364
- $packet->offset += 10;
365
-
366
- //
367
- // get the RR specific details
368
- //
369
- if ($this->rdlength != -1) {
370
-
371
- $rdata = $this->rrGet($packet);
372
- }
373
-
374
- //
375
- // add the RR
376
- //
377
- $data .= pack('n', strlen($rdata)) . $rdata;
378
-
379
- return $data;
380
- }
381
-
382
- /**
383
- * parses a binary packet, and returns the appropriate Net_DNS2_RR object,
384
- * based on the RR type of the binary content.
385
- *
386
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet used for
387
- * decompressing names
388
- *
389
- * @return mixed returns a new Net_DNS2_RR_* object for
390
- * the given RR
391
- * @throws Net_DNS2_Exception
392
- * @access public
393
- *
394
- */
395
- public static function parse(Net_DNS2_Packet &$packet)
396
- {
397
- $object = [];
398
-
399
- //
400
- // expand the name
401
- //
402
- $object['name'] = $packet->expand($packet, $packet->offset);
403
- if (is_null($object['name'])) {
404
-
405
- throw new Net_DNS2_Exception(
406
- 'failed to parse resource record: failed to expand name.',
407
- Net_DNS2_Lookups::E_PARSE_ERROR
408
- );
409
- }
410
- if ($packet->rdlength < ($packet->offset + 10)) {
411
-
412
- throw new Net_DNS2_Exception(
413
- 'failed to parse resource record: packet too small.',
414
- Net_DNS2_Lookups::E_PARSE_ERROR
415
- );
416
- }
417
-
418
- //
419
- // unpack the RR details
420
- //
421
- $object['type'] = ord($packet->rdata[$packet->offset++]) << 8 |
422
- ord($packet->rdata[$packet->offset++]);
423
- $object['class'] = ord($packet->rdata[$packet->offset++]) << 8 |
424
- ord($packet->rdata[$packet->offset++]);
425
-
426
- $object['ttl'] = ord($packet->rdata[$packet->offset++]) << 24 |
427
- ord($packet->rdata[$packet->offset++]) << 16 |
428
- ord($packet->rdata[$packet->offset++]) << 8 |
429
- ord($packet->rdata[$packet->offset++]);
430
-
431
- $object['rdlength'] = ord($packet->rdata[$packet->offset++]) << 8 |
432
- ord($packet->rdata[$packet->offset++]);
433
-
434
- if ($packet->rdlength < ($packet->offset + $object['rdlength'])) {
435
- return null;
436
- }
437
-
438
- //
439
- // lookup the class to use
440
- //
441
- $o = null;
442
- $class = Net_DNS2_Lookups::$rr_types_id_to_class[$object['type']];
443
-
444
- if (isset($class)) {
445
-
446
- $o = new $class($packet, $object);
447
- if ($o) {
448
-
449
- $packet->offset += $object['rdlength'];
450
- }
451
- } else {
452
-
453
- throw new Net_DNS2_Exception(
454
- 'un-implemented resource record type: ' . $object['type'],
455
- Net_DNS2_Lookups::E_RR_INVALID
456
- );
457
- }
458
-
459
- return $o;
460
- }
461
-
462
- /**
463
- * cleans up some RR data
464
- *
465
- * @param string $data the text string to clean
466
- *
467
- * @return string returns the cleaned string
468
- *
469
- * @access public
470
- *
471
- */
472
- public function cleanString($data)
473
- {
474
- return strtolower(rtrim($data, '.'));
475
- }
476
-
477
- /**
478
- * parses a standard RR format lines, as defined by rfc1035 (kinda)
479
- *
480
- * In our implementation, the domain *must* be specified- format must be
481
- *
482
- * <name> [<ttl>] [<class>] <type> <rdata>
483
- * or
484
- * <name> [<class>] [<ttl>] <type> <rdata>
485
- *
486
- * name, title, class and type are parsed by this function, rdata is passed
487
- * to the RR specific classes for parsing.
488
- *
489
- * @param string $line a standard DNS config line
490
- *
491
- * @return mixed returns a new Net_DNS2_RR_* object for the given RR
492
- * @throws Net_DNS2_Exception
493
- * @access public
494
- *
495
- */
496
- public static function fromString($line)
497
- {
498
- if (strlen($line) == 0) {
499
- throw new Net_DNS2_Exception(
500
- 'empty config line provided.',
501
- Net_DNS2_Lookups::E_PARSE_ERROR
502
- );
503
- }
504
-
505
- $name = '';
506
- $type = '';
507
- $class = 'IN';
508
- $ttl = 86400;
509
-
510
- //
511
- // split the line by spaces
512
- //
513
- $values = preg_split('/[\s]+/', $line);
514
- if (count($values) < 3) {
515
-
516
- throw new Net_DNS2_Exception(
517
- 'failed to parse config: minimum of name, type and rdata required.',
518
- Net_DNS2_Lookups::E_PARSE_ERROR
519
- );
520
- }
521
-
522
- //
523
- // assume the first value is the name
524
- //
525
- $name = trim(strtolower(array_shift($values)), '.');
526
-
527
- //
528
- // The next value is either a TTL, Class or Type
529
- //
530
- foreach ($values as $value) {
531
-
532
- switch(true) {
533
- case is_numeric($value):
534
-
535
- $ttl = array_shift($values);
536
- break;
537
-
538
- //
539
- // this is here because of a bug in is_numeric() in certain versions of
540
- // PHP on windows.
541
- //
542
- case ($value === 0):
543
-
544
- $ttl = array_shift($values);
545
- break;
546
-
547
- case isset(Net_DNS2_Lookups::$classes_by_name[strtoupper($value)]):
548
-
549
- $class = strtoupper(array_shift($values));
550
- break;
551
-
552
- case isset(Net_DNS2_Lookups::$rr_types_by_name[strtoupper($value)]):
553
-
554
- $type = strtoupper(array_shift($values));
555
- break 2;
556
- break;
557
-
558
- default:
559
-
560
- throw new Net_DNS2_Exception(
561
- 'invalid config line provided: unknown file: ' . $value,
562
- Net_DNS2_Lookups::E_PARSE_ERROR
563
- );
564
- }
565
- }
566
-
567
- //
568
- // lookup the class to use
569
- //
570
- $o = null;
571
- $class_name = Net_DNS2_Lookups::$rr_types_id_to_class[
572
- Net_DNS2_Lookups::$rr_types_by_name[$type]
573
- ];
574
-
575
- if (isset($class_name)) {
576
-
577
- $o = new $class_name;
578
- if (!is_null($o)) {
579
-
580
- //
581
- // set the parsed values
582
- //
583
- $o->name = $name;
584
- $o->class = $class;
585
- $o->ttl = $ttl;
586
-
587
- //
588
- // parse the rdata
589
- //
590
- if ($o->rrFromString($values) === false) {
591
-
592
- throw new Net_DNS2_Exception(
593
- 'failed to parse rdata for config: ' . $line,
594
- Net_DNS2_Lookups::E_PARSE_ERROR
595
- );
596
- }
597
-
598
- } else {
599
-
600
- throw new Net_DNS2_Exception(
601
- 'failed to create new RR record for type: ' . $type,
602
- Net_DNS2_Lookups::E_RR_INVALID
603
- );
604
- }
605
-
606
- } else {
607
-
608
- throw new Net_DNS2_Exception(
609
- 'un-implemented resource record type: '. $type,
610
- Net_DNS2_Lookups::E_RR_INVALID
611
- );
612
- }
613
-
614
- return $o;
615
- }
616
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/A.php DELETED
@@ -1,108 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 0.6.0
17
- *
18
- */
19
-
20
- /**
21
- * A Resource Record - RFC1035 section 3.4.1
22
- *
23
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
24
- * | ADDRESS |
25
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
26
- *
27
- */
28
- class Net_DNS2_RR_A extends Net_DNS2_RR
29
- {
30
- /*
31
- * The IPv4 address in quad-dotted notation
32
- */
33
- public $address;
34
-
35
- /**
36
- * method to return the rdata portion of the packet as a string
37
- *
38
- * @return string
39
- * @access protected
40
- *
41
- */
42
- protected function rrToString()
43
- {
44
- return $this->address;
45
- }
46
-
47
- /**
48
- * parses the rdata portion from a standard DNS config line
49
- *
50
- * @param array $rdata a string split line of values for the rdata
51
- *
52
- * @return boolean
53
- * @access protected
54
- *
55
- */
56
- protected function rrFromString(array $rdata)
57
- {
58
- $value = array_shift($rdata);
59
-
60
- if (Net_DNS2::isIPv4($value) == true) {
61
-
62
- $this->address = $value;
63
- return true;
64
- }
65
-
66
- return false;
67
- }
68
-
69
- /**
70
- * parses the rdata of the Net_DNS2_Packet object
71
- *
72
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
73
- *
74
- * @return boolean
75
- * @access protected
76
- *
77
- */
78
- protected function rrSet(Net_DNS2_Packet &$packet)
79
- {
80
- if ($this->rdlength > 0) {
81
-
82
- $this->address = inet_ntop($this->rdata);
83
- if ($this->address !== false) {
84
-
85
- return true;
86
- }
87
- }
88
-
89
- return false;
90
- }
91
-
92
- /**
93
- * returns the rdata portion of the DNS packet
94
- *
95
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
96
- * compressed names
97
- *
98
- * @return mixed either returns a binary packed
99
- * string or null on failure
100
- * @access protected
101
- *
102
- */
103
- protected function rrGet(Net_DNS2_Packet &$packet)
104
- {
105
- $packet->offset += 4;
106
- return inet_pton($this->address);
107
- }
108
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/AAAA.php DELETED
@@ -1,129 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 0.6.0
17
- *
18
- */
19
-
20
- /**
21
- * A Resource Record - RFC1035 section 3.4.1
22
- *
23
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
24
- * | |
25
- * | |
26
- * | |
27
- * | ADDRESS |
28
- * | |
29
- * | (128 bit) |
30
- * | |
31
- * | |
32
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
33
- *
34
- */
35
- class Net_DNS2_RR_AAAA extends Net_DNS2_RR
36
- {
37
- /*
38
- * the IPv6 address in the preferred hexadecimal values of the eight
39
- * 16-bit pieces
40
- * per RFC1884
41
- *
42
- */
43
- public $address;
44
-
45
- /**
46
- * method to return the rdata portion of the packet as a string
47
- *
48
- * @return string
49
- * @access protected
50
- *
51
- */
52
- protected function rrToString()
53
- {
54
- return $this->address;
55
- }
56
-
57
- /**
58
- * parses the rdata portion from a standard DNS config line
59
- *
60
- * @param array $rdata a string split line of values for the rdata
61
- *
62
- * @return boolean
63
- * @access protected
64
- *
65
- */
66
- protected function rrFromString(array $rdata)
67
- {
68
- //
69
- // expand out compressed formats
70
- //
71
- $value = array_shift($rdata);
72
- if (Net_DNS2::isIPv6($value) == true) {
73
-
74
- $this->address = $value;
75
- return true;
76
- }
77
-
78
- return false;
79
- }
80
-
81
- /**
82
- * parses the rdata of the Net_DNS2_Packet object
83
- *
84
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
85
- *
86
- * @return boolean
87
- * @access protected
88
- *
89
- */
90
- protected function rrSet(Net_DNS2_Packet &$packet)
91
- {
92
- //
93
- // must be 8 x 16bit chunks, or 16 x 8bit
94
- //
95
- if ($this->rdlength == 16) {
96
-
97
- //
98
- // PHP's inet_ntop returns IPv6 addresses in their compressed form,
99
- // but we want to keep with the preferred standard, so we'll parse
100
- // it manually.
101
- //
102
- $x = unpack('n8', $this->rdata);
103
- if (count($x) == 8) {
104
-
105
- $this->address = vsprintf('%x:%x:%x:%x:%x:%x:%x:%x', $x);
106
- return true;
107
- }
108
- }
109
-
110
- return false;
111
- }
112
-
113
- /**
114
- * returns the rdata portion of the DNS packet
115
- *
116
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
117
- * compressed names
118
- *
119
- * @return mixed either returns a binary packed
120
- * string or null on failure
121
- * @access protected
122
- *
123
- */
124
- protected function rrGet(Net_DNS2_Packet &$packet)
125
- {
126
- $packet->offset += 16;
127
- return inet_pton($this->address);
128
- }
129
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/AFSDB.php DELETED
@@ -1,126 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 0.6.0
17
- *
18
- */
19
-
20
- /**
21
- * AFSDB Resource Record - RFC1183 section 1
22
- *
23
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
24
- * | SUBTYPE |
25
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
26
- * / HOSTNAME /
27
- * / /
28
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
29
- *
30
- */
31
- class Net_DNS2_RR_AFSDB extends Net_DNS2_RR
32
- {
33
- /*
34
- * The AFSDB sub type
35
- */
36
- public $subtype;
37
-
38
- /*
39
- * The AFSDB hostname
40
- */
41
- public $hostname;
42
-
43
- /**
44
- * method to return the rdata portion of the packet as a string
45
- *
46
- * @return string
47
- * @access protected
48
- *
49
- */
50
- protected function rrToString()
51
- {
52
- return $this->subtype . ' ' . $this->cleanString($this->hostname) . '.';
53
- }
54
-
55
- /**
56
- * parses the rdata portion from a standard DNS config line
57
- *
58
- * @param array $rdata a string split line of values for the rdata
59
- *
60
- * @return boolean
61
- * @access protected
62
- *
63
- */
64
- protected function rrFromString(array $rdata)
65
- {
66
- $this->subtype = array_shift($rdata);
67
- $this->hostname = $this->cleanString(array_shift($rdata));
68
-
69
- return true;
70
- }
71
-
72
- /**
73
- * parses the rdata of the Net_DNS2_Packet object
74
- *
75
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
76
- *
77
- * @return boolean
78
- * @access protected
79
- *
80
- */
81
- protected function rrSet(Net_DNS2_Packet &$packet)
82
- {
83
- if ($this->rdlength > 0) {
84
-
85
- //
86
- // unpack the subtype
87
- //
88
- $x = unpack('nsubtype', $this->rdata);
89
-
90
- $this->subtype = $x['subtype'];
91
- $offset = $packet->offset + 2;
92
-
93
- $this->hostname = Net_DNS2_Packet::expand($packet, $offset);
94
-
95
- return true;
96
- }
97
-
98
- return false;
99
- }
100
-
101
- /**
102
- * returns the rdata portion of the DNS packet
103
- *
104
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
105
- * compressed names
106
- *
107
- * @return mixed either returns a binary packed
108
- * string or null on failure
109
- * @access protected
110
- *
111
- */
112
- protected function rrGet(Net_DNS2_Packet &$packet)
113
- {
114
- if (strlen($this->hostname) > 0) {
115
-
116
- $data = pack('n', $this->subtype);
117
- $packet->offset += 2;
118
-
119
- $data .= $packet->compress($this->hostname, $packet->offset);
120
-
121
- return $data;
122
- }
123
-
124
- return null;
125
- }
126
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/AMTRELAY.php DELETED
@@ -1,259 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 1.4.5
17
- *
18
- */
19
-
20
- /**
21
- * AMTRELAY Resource Record - RFC8777 section 4.2
22
- *
23
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
24
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
25
- * | precedence |D| type | |
26
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +
27
- * ~ relay ~
28
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
29
- *
30
- */
31
- class Net_DNS2_RR_AMTRELAY extends Net_DNS2_RR
32
- {
33
- /*
34
- * type definitions that match the "type" field below
35
- */
36
- const AMTRELAY_TYPE_NONE = 0;
37
- const AMTRELAY_TYPE_IPV4 = 1;
38
- const AMTRELAY_TYPE_IPV6 = 2;
39
- const AMTRELAY_TYPE_DOMAIN = 3;
40
-
41
- /*
42
- * the precedence for this record
43
- */
44
- public $precedence;
45
-
46
- /*
47
- * "Discovery Optional" flag
48
- */
49
- public $discovery;
50
-
51
- /*
52
- * The type field indicates the format of the information that is stored in the relay field.
53
- */
54
- public $relay_type;
55
-
56
- /*
57
- * The relay field is the address or domain name of the AMT relay.
58
- */
59
- public $relay;
60
-
61
- /**
62
- * method to return the rdata portion of the packet as a string
63
- *
64
- * @return string
65
- * @access protected
66
- *
67
- */
68
- protected function rrToString()
69
- {
70
- $out = $this->precedence . ' ' . $this->discovery . ' ' . $this->relay_type . ' ' . $this->relay;
71
-
72
- //
73
- // 4.3.1 - If the relay type field is 0, the relay field MUST be ".".
74
- //
75
- if ( ($this->relay_type == self::AMTRELAY_TYPE_NONE) || ($this->relay_type == self::AMTRELAY_TYPE_DOMAIN) )
76
- {
77
- $out .= '.';
78
- }
79
-
80
- return $out;
81
- }
82
-
83
- /**
84
- * parses the rdata portion from a standard DNS config line
85
- *
86
- * @param array $rdata a string split line of values for the rdata
87
- *
88
- * @return boolean
89
- * @access protected
90
- *
91
- */
92
- protected function rrFromString(array $rdata)
93
- {
94
- //
95
- // extract the values from the array
96
- //
97
- $this->precedence = array_shift($rdata);
98
- $this->discovery = array_shift($rdata);
99
- $this->relay_type = array_shift($rdata);
100
- $this->relay = trim(strtolower(trim(array_shift($rdata))), '.');
101
-
102
- //
103
- // if there's anything else other than 0 in the discovery value, then force it to one, so
104
- // that it effectively is either "true" or "false".
105
- //
106
- if ($this->discovery != 0) {
107
- $this->discovery = 1;
108
- }
109
-
110
- //
111
- // validate the type & relay values
112
- //
113
- switch($this->relay_type) {
114
- case self::AMTRELAY_TYPE_NONE:
115
- $this->relay = '';
116
- break;
117
-
118
- case self::AMTRELAY_TYPE_IPV4:
119
- if (Net_DNS2::isIPv4($this->relay) == false) {
120
- return false;
121
- }
122
- break;
123
-
124
- case self::AMTRELAY_TYPE_IPV6:
125
- if (Net_DNS2::isIPv6($this->relay) == false) {
126
- return false;
127
- }
128
- break;
129
-
130
- case self::AMTRELAY_TYPE_DOMAIN:
131
- ; // do nothing
132
- break;
133
-
134
- default:
135
-
136
- //
137
- // invalid type value
138
- //
139
- return false;
140
-
141
- }
142
-
143
- return true;
144
- }
145
-
146
- /**
147
- * parses the rdata of the Net_DNS2_Packet object
148
- *
149
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
150
- *
151
- * @return boolean
152
- * @access protected
153
- *
154
- */
155
- protected function rrSet(Net_DNS2_Packet &$packet)
156
- {
157
- if ($this->rdlength > 0) {
158
-
159
- //
160
- // parse off the first two octets
161
- //
162
- $x = unpack('Cprecedence/Csecond', $this->rdata);
163
-
164
- $this->precedence = $x['precedence'];
165
- $this->discovery = ($x['second'] >> 7) & 0x1;
166
- $this->relay_type = $x['second'] & 0xf;
167
-
168
- $offset = 2;
169
-
170
- //
171
- // parse the relay value based on the type
172
- //
173
- switch($this->relay_type) {
174
- case self::AMTRELAY_TYPE_NONE:
175
- $this->relay = '';
176
- break;
177
-
178
- case self::AMTRELAY_TYPE_IPV4:
179
- $this->relay = inet_ntop(substr($this->rdata, $offset, 4));
180
- break;
181
-
182
- case self::AMTRELAY_TYPE_IPV6:
183
-
184
- //
185
- // PHP's inet_ntop returns IPv6 addresses in their compressed form, but we want to keep
186
- // with the preferred standard, so we'll parse it manually.
187
- //
188
- $ip = unpack('n8', substr($this->rdata, $offset, 16));
189
- if (count($ip) == 8) {
190
- $this->relay = vsprintf('%x:%x:%x:%x:%x:%x:%x:%x', $ip);
191
- } else
192
- {
193
- return false;
194
- }
195
- break;
196
-
197
- case self::AMTRELAY_TYPE_DOMAIN:
198
- $doffset = $packet->offset + $offset;
199
- $this->relay = Net_DNS2_Packet::label($packet, $doffset);
200
-
201
- break;
202
-
203
- default:
204
- //
205
- // invalid type value
206
- //
207
- return false;
208
- }
209
-
210
- return true;
211
- }
212
-
213
- return false;
214
- }
215
-
216
- /**
217
- * returns the rdata portion of the DNS packet
218
- *
219
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
220
- * compressed names
221
- *
222
- * @return mixed either returns a binary packed
223
- * string or null on failure
224
- * @access protected
225
- *
226
- */
227
- protected function rrGet(Net_DNS2_Packet &$packet)
228
- {
229
- //
230
- // pack the precedence, discovery, and type
231
- //
232
- $data = pack('CC', $this->precedence, ($this->discovery << 7) | $this->relay_type);
233
-
234
- //
235
- // add the relay data based on the type
236
- //
237
- switch($this->relay_type) {
238
- case self::AMTRELAY_TYPE_NONE:
239
- ; // add nothing
240
- break;
241
-
242
- case self::AMTRELAY_TYPE_IPV4:
243
- case self::AMTRELAY_TYPE_IPV6:
244
- $data .= inet_pton($this->relay);
245
- break;
246
-
247
- case self::AMTRELAY_TYPE_DOMAIN:
248
- $data .= pack('Ca*', strlen($this->relay), $this->relay);
249
- break;
250
-
251
- default:
252
- return null;
253
- }
254
-
255
- $packet->offset += strlen($data);
256
-
257
- return $data;
258
- }
259
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/ANY.php DELETED
@@ -1,81 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 0.6.0
17
- *
18
- */
19
-
20
- /**
21
- * This is only used for generating an empty ANY RR.
22
- *
23
- */
24
- class Net_DNS2_RR_ANY extends Net_DNS2_RR
25
- {
26
- /**
27
- * method to return the rdata portion of the packet as a string
28
- *
29
- * @return string
30
- * @access protected
31
- *
32
- */
33
- protected function rrToString()
34
- {
35
- return '';
36
- }
37
-
38
- /**
39
- * parses the rdata portion from a standard DNS config line
40
- *
41
- * @param array $rdata a string split line of values for the rdata
42
- *
43
- * @return boolean
44
- * @access protected
45
- *
46
- */
47
- protected function rrFromString(array $rdata)
48
- {
49
- return true;
50
- }
51
-
52
- /**
53
- * parses the rdata of the Net_DNS2_Packet object
54
- *
55
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
56
- *
57
- * @return boolean
58
- * @access protected
59
- *
60
- */
61
- protected function rrSet(Net_DNS2_Packet &$packet)
62
- {
63
- return true;
64
- }
65
-
66
- /**
67
- * returns the rdata portion of the DNS packet
68
- *
69
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
70
- * compressed names
71
- *
72
- * @return mixed either returns a binary packed
73
- * string or null on failure
74
- * @access protected
75
- *
76
- */
77
- protected function rrGet(Net_DNS2_Packet &$packet)
78
- {
79
- return '';
80
- }
81
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/APL.php DELETED
@@ -1,295 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 1.0.0
17
- *
18
- */
19
-
20
- /**
21
- * APL Resource Record - RFC3123
22
- *
23
- * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
24
- * | ADDRESSFAMILY |
25
- * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
26
- * | PREFIX | N | AFDLENGTH |
27
- * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
28
- * / AFDPART /
29
- * | |
30
- * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
31
- *
32
- */
33
- class Net_DNS2_RR_APL extends Net_DNS2_RR
34
- {
35
- /*
36
- * a list of all the address prefix list items
37
- */
38
- public $apl_items = [];
39
-
40
- /**
41
- * method to return the rdata portion of the packet as a string
42
- *
43
- * @return string
44
- * @access protected
45
- *
46
- */
47
- protected function rrToString()
48
- {
49
- $out = '';
50
-
51
- foreach ($this->apl_items as $item) {
52
-
53
- if ($item['n'] == 1) {
54
-
55
- $out .= '!';
56
- }
57
-
58
- $out .= $item['address_family'] . ':' .
59
- $item['afd_part'] . '/' . $item['prefix'] . ' ';
60
- }
61
-
62
- return trim($out);
63
- }
64
-
65
- /**
66
- * parses the rdata portion from a standard DNS config line
67
- *
68
- * @param array $rdata a string split line of values for the rdata
69
- *
70
- * @return boolean
71
- * @access protected
72
- *
73
- */
74
- protected function rrFromString(array $rdata)
75
- {
76
- foreach ($rdata as $item) {
77
-
78
- if (preg_match('/^(!?)([1|2])\:([^\/]*)\/([0-9]{1,3})$/', $item, $m)) {
79
-
80
- $i = [
81
-
82
- 'address_family' => $m[2],
83
- 'prefix' => $m[4],
84
- 'n' => ($m[1] == '!') ? 1 : 0,
85
- 'afd_part' => strtolower($m[3])
86
- ];
87
-
88
- $address = $this->_trimZeros(
89
- $i['address_family'], $i['afd_part']
90
- );
91
-
92
- $i['afd_length'] = count(explode('.', $address));
93
-
94
- $this->apl_items[] = $i;
95
- }
96
- }
97
-
98
- return true;
99
- }
100
-
101
- /**
102
- * parses the rdata of the Net_DNS2_Packet object
103
- *
104
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
105
- *
106
- * @return boolean
107
- * @access protected
108
- *
109
- */
110
- protected function rrSet(Net_DNS2_Packet &$packet)
111
- {
112
- if ($this->rdlength > 0) {
113
-
114
- $offset = 0;
115
-
116
- while ($offset < $this->rdlength) {
117
-
118
- //
119
- // unpack the family, prefix, negate and length values
120
- //
121
- $x = unpack(
122
- 'naddress_family/Cprefix/Cextra', substr($this->rdata, $offset)
123
- );
124
-
125
- $item = [
126
-
127
- 'address_family' => $x['address_family'],
128
- 'prefix' => $x['prefix'],
129
- 'n' => ($x['extra'] >> 7) & 0x1,
130
- 'afd_length' => $x['extra'] & 0xf
131
- ];
132
-
133
- switch($item['address_family']) {
134
-
135
- case 1:
136
- $r = unpack(
137
- 'C*', substr($this->rdata, $offset + 4, $item['afd_length'])
138
- );
139
- if (count($r) < 4) {
140
-
141
- for ($c=count($r)+1; $c<4+1; $c++) {
142
-
143
- $r[$c] = 0;
144
- }
145
- }
146
-
147
- $item['afd_part'] = implode('.', $r);
148
-
149
- break;
150
- case 2:
151
- $r = unpack(
152
- 'C*', substr($this->rdata, $offset + 4, $item['afd_length'])
153
- );
154
- if (count($r) < 8) {
155
-
156
- for ($c=count($r)+1; $c<8+1; $c++) {
157
-
158
- $r[$c] = 0;
159
- }
160
- }
161
-
162
- $item['afd_part'] = sprintf(
163
- '%x:%x:%x:%x:%x:%x:%x:%x',
164
- $r[1], $r[2], $r[3], $r[4], $r[5], $r[6], $r[7], $r[8]
165
- );
166
-
167
- break;
168
- default:
169
- return false;
170
- }
171
-
172
- $this->apl_items[] = $item;
173
-
174
- $offset += 4 + $item['afd_length'];
175
- }
176
-
177
- return true;
178
- }
179
-
180
- return false;
181
- }
182
-
183
- /**
184
- * returns the rdata portion of the DNS packet
185
- *
186
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
187
- * compressed names
188
- *
189
- * @return mixed either returns a binary packed
190
- * string or null on failure
191
- * @access protected
192
- *
193
- */
194
- protected function rrGet(Net_DNS2_Packet &$packet)
195
- {
196
- if (count($this->apl_items) > 0) {
197
-
198
- $data = '';
199
-
200
- foreach ($this->apl_items as $item) {
201
-
202
- //
203
- // pack the address_family and prefix values
204
- //
205
- $data .= pack(
206
- 'nCC',
207
- $item['address_family'],
208
- $item['prefix'],
209
- ($item['n'] << 7) | $item['afd_length']
210
- );
211
-
212
- switch($item['address_family']) {
213
- case 1:
214
- $address = explode(
215
- '.',
216
- $this->_trimZeros($item['address_family'], $item['afd_part'])
217
- );
218
-
219
- foreach ($address as $b) {
220
- $data .= chr($b);
221
- }
222
- break;
223
- case 2:
224
- $address = explode(
225
- ':',
226
- $this->_trimZeros($item['address_family'], $item['afd_part'])
227
- );
228
-
229
- foreach ($address as $b) {
230
- $data .= pack('H', $b);
231
- }
232
- break;
233
- default:
234
- return null;
235
- }
236
- }
237
-
238
- $packet->offset += strlen($data);
239
-
240
- return $data;
241
- }
242
-
243
- return null;
244
- }
245
-
246
- /**
247
- * returns an IP address with the right-hand zero's trimmed
248
- *
249
- * @param integer $family the IP address family from the rdata
250
- * @param string $address the IP address
251
- *
252
- * @return string the trimmed IP addresss.
253
- *
254
- * @access private
255
- *
256
- */
257
- private function _trimZeros($family, $address)
258
- {
259
- $a = [];
260
-
261
- switch($family) {
262
- case 1:
263
- $a = array_reverse(explode('.', $address));
264
- break;
265
- case 2:
266
- $a = array_reverse(explode(':', $address));
267
- break;
268
- default:
269
- return '';
270
- }
271
-
272
- foreach ($a as $value) {
273
-
274
- if ($value === '0') {
275
-
276
- array_shift($a);
277
- }
278
- }
279
-
280
- $out = '';
281
-
282
- switch($family) {
283
- case 1:
284
- $out = implode('.', array_reverse($a));
285
- break;
286
- case 2:
287
- $out = implode(':', array_reverse($a));
288
- break;
289
- default:
290
- return '';
291
- }
292
-
293
- return $out;
294
- }
295
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/ATMA.php DELETED
@@ -1,162 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 1.1.0
17
- *
18
- */
19
-
20
- /**
21
- * ATMA Resource Record
22
- *
23
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
24
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
25
- * | FORMAT | |
26
- * | +--+--+--+--+--+--+--+--+
27
- * / ADDRESS /
28
- * | |
29
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
30
- *
31
- */
32
- class Net_DNS2_RR_ATMA extends Net_DNS2_RR
33
- {
34
- /*
35
- * One octet that indicates the format of ADDRESS. The two possible values
36
- * for FORMAT are value 0 indicating ATM End System Address (AESA) format
37
- * and value 1 indicating E.164 format
38
- */
39
- public $format;
40
-
41
- /*
42
- * The IPv4 address in quad-dotted notation
43
- */
44
- public $address;
45
-
46
- /**
47
- * method to return the rdata portion of the packet as a string
48
- *
49
- * @return string
50
- * @access protected
51
- *
52
- */
53
- protected function rrToString()
54
- {
55
- return $this->address;
56
- }
57
-
58
- /**
59
- * parses the rdata portion from a standard DNS config line
60
- *
61
- * @param array $rdata a string split line of values for the rdata
62
- *
63
- * @return boolean
64
- * @access protected
65
- *
66
- */
67
- protected function rrFromString(array $rdata)
68
- {
69
- $value = array_shift($rdata);
70
-
71
- if (ctype_xdigit($value) == true) {
72
-
73
- $this->format = 0;
74
- $this->address = $value;
75
-
76
- } else if (is_numeric($value) == true) {
77
-
78
- $this->format = 1;
79
- $this->address = $value;
80
-
81
- } else {
82
-
83
- return false;
84
- }
85
-
86
- return true;
87
- }
88
-
89
- /**
90
- * parses the rdata of the Net_DNS2_Packet object
91
- *
92
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
93
- *
94
- * @return boolean
95
- * @access protected
96
- *
97
- */
98
- protected function rrSet(Net_DNS2_Packet &$packet)
99
- {
100
- if ($this->rdlength > 0) {
101
-
102
- //
103
- // unpack the format
104
- //
105
- $x = unpack('Cformat/N*address', $this->rdata);
106
-
107
- $this->format = $x['format'];
108
-
109
- if ($this->format == 0) {
110
-
111
- $a = unpack('@1/H*address', $this->rdata);
112
-
113
- $this->address = $a['address'];
114
-
115
- } else if ($this->format == 1) {
116
-
117
- $this->address = substr($this->rdata, 1, $this->rdlength - 1);
118
-
119
- } else {
120
-
121
- return false;
122
- }
123
-
124
- return true;
125
- }
126
-
127
- return false;
128
- }
129
-
130
- /**
131
- * returns the rdata portion of the DNS packet
132
- *
133
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
134
- * compressed names
135
- *
136
- * @return mixed either returns a binary packed
137
- * string or null on failure
138
- * @access protected
139
- *
140
- */
141
- protected function rrGet(Net_DNS2_Packet &$packet)
142
- {
143
- $data = chr($this->format);
144
-
145
- if ($this->format == 0) {
146
-
147
- $data .= pack('H*', $this->address);
148
-
149
- } else if ($this->format == 1) {
150
-
151
- $data .= $this->address;
152
-
153
- } else {
154
-
155
- return null;
156
- }
157
-
158
- $packet->offset += strlen($data);
159
-
160
- return $data;
161
- }
162
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/AVC.php DELETED
@@ -1,27 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 1.4.2
17
- *
18
- */
19
-
20
- /**
21
- * The AVC RR is implemented exactly like the TXT record, so
22
- * for now we just extend the TXT RR and use it.
23
- *
24
- */
25
- class Net_DNS2_RR_AVC extends Net_DNS2_RR_TXT
26
- {
27
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/CAA.php DELETED
@@ -1,138 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 1.2.0
17
- *
18
- */
19
-
20
- /**
21
- * CAA Resource Record - http://tools.ietf.org/html/draft-ietf-pkix-caa-03
22
- *
23
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
24
- * | FLAGS | TAG LENGTH |
25
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
26
- * / TAG /
27
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
28
- * / DATA /
29
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
30
- *
31
- */
32
- class Net_DNS2_RR_CAA extends Net_DNS2_RR
33
- {
34
- /*
35
- * The critcal flag
36
- */
37
- public $flags;
38
-
39
- /*
40
- * The property identifier
41
- */
42
- public $tag;
43
-
44
- /*
45
- * The property value
46
- */
47
- public $value;
48
-
49
- /**
50
- * method to return the rdata portion of the packet as a string
51
- *
52
- * @return string
53
- * @access protected
54
- *
55
- */
56
- protected function rrToString()
57
- {
58
- return $this->flags . ' ' . $this->tag . ' "' .
59
- trim($this->cleanString($this->value), '"') . '"';
60
- }
61
-
62
- /**
63
- * parses the rdata portion from a standard DNS config line
64
- *
65
- * @param array $rdata a string split line of values for the rdata
66
- *
67
- * @return boolean
68
- * @access protected
69
- *
70
- */
71
- protected function rrFromString(array $rdata)
72
- {
73
- $this->flags = array_shift($rdata);
74
- $this->tag = array_shift($rdata);
75
-
76
- $this->value = trim($this->cleanString(implode(' ', $rdata)), '"');
77
-
78
- return true;
79
- }
80
-
81
- /**
82
- * parses the rdata of the Net_DNS2_Packet object
83
- *
84
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
85
- *
86
- * @return boolean
87
- * @access protected
88
- *
89
- */
90
- protected function rrSet(Net_DNS2_Packet &$packet)
91
- {
92
- if ($this->rdlength > 0) {
93
-
94
- //
95
- // unpack the flags and tag length
96
- //
97
- $x = unpack('Cflags/Ctag_length', $this->rdata);
98
-
99
- $this->flags = $x['flags'];
100
- $offset = 2;
101
-
102
- $this->tag = substr($this->rdata, $offset, $x['tag_length']);
103
- $offset += $x['tag_length'];
104
-
105
- $this->value = substr($this->rdata, $offset);
106
-
107
- return true;
108
- }
109
-
110
- return false;
111
- }
112
-
113
- /**
114
- * returns the rdata portion of the DNS packet
115
- *
116
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
117
- * compressed names
118
- *
119
- * @return mixed either returns a binary packed
120
- * string or null on failure
121
- * @access protected
122
- *
123
- */
124
- protected function rrGet(Net_DNS2_Packet &$packet)
125
- {
126
- if (strlen($this->value) > 0) {
127
-
128
- $data = chr($this->flags);
129
- $data .= chr(strlen($this->tag)) . $this->tag . $this->value;
130
-
131
- $packet->offset += strlen($data);
132
-
133
- return $data;
134
- }
135
-
136
- return null;
137
- }
138
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/CDNSKEY.php DELETED
@@ -1,29 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 1.4.0
17
- *
18
- */
19
-
20
- /**
21
- * The CDNSKEY RR is implemented exactly like the DNSKEY record, so
22
- * for now we just extend the DNSKEY RR and use it.
23
- *
24
- * http://www.rfc-editor.org/rfc/rfc7344.txt
25
- *
26
- */
27
- class Net_DNS2_RR_CDNSKEY extends Net_DNS2_RR_DNSKEY
28
- {
29
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/CDS.php DELETED
@@ -1,29 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 1.2.0
17
- *
18
- */
19
-
20
- /**
21
- * The CDS RR is implemented exactly like the DS record, so
22
- * for now we just extend the DS RR and use it.
23
- *
24
- * http://www.rfc-editor.org/rfc/rfc7344.txt
25
- *
26
- */
27
- class Net_DNS2_RR_CDS extends Net_DNS2_RR_DS
28
- {
29
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/CERT.php DELETED
@@ -1,243 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 0.6.0
17
- *
18
- */
19
-
20
- /**
21
- * CERT Resource Record - RFC4398 section 2
22
- *
23
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
24
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
25
- * | format | key tag |
26
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
27
- * | algorithm | /
28
- * +---------------+ certificate or CRL /
29
- * / /
30
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-|
31
- *
32
- */
33
- class Net_DNS2_RR_CERT extends Net_DNS2_RR
34
- {
35
- /*
36
- * format's allowed for certificates
37
- */
38
- const CERT_FORMAT_RES = 0;
39
- const CERT_FORMAT_PKIX = 1;
40
- const CERT_FORMAT_SPKI = 2;
41
- const CERT_FORMAT_PGP = 3;
42
- const CERT_FORMAT_IPKIX = 4;
43
- const CERT_FORMAT_ISPKI = 5;
44
- const CERT_FORMAT_IPGP = 6;
45
- const CERT_FORMAT_ACPKIX = 7;
46
- const CERT_FORMAT_IACPKIX = 8;
47
- const CERT_FORMAT_URI = 253;
48
- const CERT_FORMAT_OID = 254;
49
-
50
- public $cert_format_name_to_id = [];
51
- public $cert_format_id_to_name = [
52
-
53
- self::CERT_FORMAT_RES => 'Reserved',
54
- self::CERT_FORMAT_PKIX => 'PKIX',
55
- self::CERT_FORMAT_SPKI => 'SPKI',
56
- self::CERT_FORMAT_PGP => 'PGP',
57
- self::CERT_FORMAT_IPKIX => 'IPKIX',
58
- self::CERT_FORMAT_ISPKI => 'ISPKI',
59
- self::CERT_FORMAT_IPGP => 'IPGP',
60
- self::CERT_FORMAT_ACPKIX => 'ACPKIX',
61
- self::CERT_FORMAT_IACPKIX => 'IACPKIX',
62
- self::CERT_FORMAT_URI => 'URI',
63
- self::CERT_FORMAT_OID => 'OID'
64
- ];
65
-
66
- /*
67
- * certificate format
68
- */
69
- public $format;
70
-
71
- /*
72
- * key tag
73
- */
74
- public $keytag;
75
-
76
- /*
77
- * The algorithm used for the CERt
78
- */
79
- public $algorithm;
80
-
81
- /*
82
- * certificate
83
- */
84
- public $certificate;
85
-
86
- /**
87
- * we have our own constructor so that we can load our certificate
88
- * information for parsing.
89
- *
90
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
91
- * @param array $rr a array with parsed RR values
92
- *
93
- * @return
94
- *
95
- */
96
- public function __construct(Net_DNS2_Packet &$packet = null, array $rr = null)
97
- {
98
- parent::__construct($packet, $rr);
99
-
100
- //
101
- // load the lookup values
102
- //
103
- $this->cert_format_name_to_id = array_flip($this->cert_format_id_to_name);
104
- }
105
-
106
- /**
107
- * method to return the rdata portion of the packet as a string
108
- *
109
- * @return string
110
- * @access protected
111
- *
112
- */
113
- protected function rrToString()
114
- {
115
- return $this->format . ' ' . $this->keytag . ' ' . $this->algorithm .
116
- ' ' . base64_encode($this->certificate);
117
- }
118
-
119
- /**
120
- * parses the rdata portion from a standard DNS config line
121
- *
122
- * @param array $rdata a string split line of values for the rdata
123
- *
124
- * @return boolean
125
- * @access protected
126
- *
127
- */
128
- protected function rrFromString(array $rdata)
129
- {
130
- //
131
- // load and check the format; can be an int, or a mnemonic symbol
132
- //
133
- $this->format = array_shift($rdata);
134
- if (!is_numeric($this->format)) {
135
-
136
- $mnemonic = strtoupper(trim($this->format));
137
- if (!isset($this->cert_format_name_to_id[$mnemonic])) {
138
-
139
- return false;
140
- }
141
-
142
- $this->format = $this->cert_format_name_to_id[$mnemonic];
143
- } else {
144
-
145
- if (!isset($this->cert_format_id_to_name[$this->format])) {
146
-
147
- return false;
148
- }
149
- }
150
-
151
- $this->keytag = array_shift($rdata);
152
-
153
- //
154
- // parse and check the algorithm; can be an int, or a mnemonic symbol
155
- //
156
- $this->algorithm = array_shift($rdata);
157
- if (!is_numeric($this->algorithm)) {
158
-
159
- $mnemonic = strtoupper(trim($this->algorithm));
160
- if (!isset(Net_DNS2_Lookups::$algorithm_name_to_id[$mnemonic])) {
161
-
162
- return false;
163
- }
164
-
165
- $this->algorithm = Net_DNS2_Lookups::$algorithm_name_to_id[
166
- $mnemonic
167
- ];
168
- } else {
169
-
170
- if (!isset(Net_DNS2_Lookups::$algorithm_id_to_name[$this->algorithm])) {
171
- return false;
172
- }
173
- }
174
-
175
- //
176
- // parse and base64 decode the certificate
177
- //
178
- // certificates MUST be provided base64 encoded, if not, everything will
179
- // be broken after this point, as we assume it's base64 encoded.
180
- //
181
- $this->certificate = base64_decode(implode(' ', $rdata));
182
-
183
- return true;
184
- }
185
-
186
- /**
187
- * parses the rdata of the Net_DNS2_Packet object
188
- *
189
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
190
- *
191
- * @return boolean
192
- * @access protected
193
- *
194
- */
195
- protected function rrSet(Net_DNS2_Packet &$packet)
196
- {
197
- if ($this->rdlength > 0) {
198
-
199
- //
200
- // unpack the format, keytag and algorithm
201
- //
202
- $x = unpack('nformat/nkeytag/Calgorithm', $this->rdata);
203
-
204
- $this->format = $x['format'];
205
- $this->keytag = $x['keytag'];
206
- $this->algorithm = $x['algorithm'];
207
-
208
- //
209
- // copy the certificate
210
- //
211
- $this->certificate = substr($this->rdata, 5, $this->rdlength - 5);
212
-
213
- return true;
214
- }
215
-
216
- return false;
217
- }
218
-
219
- /**
220
- * returns the rdata portion of the DNS packet
221
- *
222
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
223
- * compressed names
224
- *
225
- * @return mixed either returns a binary packed
226
- * string or null on failure
227
- * @access protected
228
- *
229
- */
230
- protected function rrGet(Net_DNS2_Packet &$packet)
231
- {
232
- if (strlen($this->certificate) > 0) {
233
-
234
- $data = pack('nnC', $this->format, $this->keytag, $this->algorithm) . $this->certificate;
235
-
236
- $packet->offset += strlen($data);
237
-
238
- return $data;
239
- }
240
-
241
- return null;
242
- }
243
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/CNAME.php DELETED
@@ -1,105 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 0.6.0
17
- *
18
- */
19
-
20
- /**
21
- * CNAME Resource Record - RFC1035 section 3.3.1
22
- *
23
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
24
- * / CNAME /
25
- * / /
26
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
27
- *
28
- */
29
- class Net_DNS2_RR_CNAME extends Net_DNS2_RR
30
- {
31
- /*
32
- * The canonical name
33
- */
34
- public $cname;
35
-
36
- /**
37
- * method to return the rdata portion of the packet as a string
38
- *
39
- * @return string
40
- * @access protected
41
- *
42
- */
43
- protected function rrToString()
44
- {
45
- return $this->cleanString($this->cname) . '.';
46
- }
47
-
48
- /**
49
- * parses the rdata portion from a standard DNS config line
50
- *
51
- * @param array $rdata a string split line of values for the rdata
52
- *
53
- * @return boolean
54
- * @access protected
55
- *
56
- */
57
- protected function rrFromString(array $rdata)
58
- {
59
- $this->cname = $this->cleanString(array_shift($rdata));
60
- return true;
61
- }
62
-
63
- /**
64
- * parses the rdata of the Net_DNS2_Packet object
65
- *
66
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
67
- *
68
- * @return boolean
69
- * @access protected
70
- *
71
- */
72
- protected function rrSet(Net_DNS2_Packet &$packet)
73
- {
74
- if ($this->rdlength > 0) {
75
-
76
- $offset = $packet->offset;
77
- $this->cname = Net_DNS2_Packet::expand($packet, $offset);
78
-
79
- return true;
80
- }
81
-
82
- return false;
83
- }
84
-
85
- /**
86
- * returns the rdata portion of the DNS packet
87
- *
88
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
89
- * compressed names
90
- *
91
- * @return mixed either returns a binary packed
92
- * string or null on failure
93
- * @access protected
94
- *
95
- */
96
- protected function rrGet(Net_DNS2_Packet &$packet)
97
- {
98
- if (strlen($this->cname) > 0) {
99
-
100
- return $packet->compress($this->cname, $packet->offset);
101
- }
102
-
103
- return null;
104
- }
105
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/CSYNC.php DELETED
@@ -1,155 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 1.4.1
17
- *
18
- */
19
-
20
- /**
21
- * CSYNC Resource Record - RFC 7477 seciond 2.1.1
22
- *
23
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
24
- * | SOA Serial |
25
- * | |
26
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
27
- * | Flags |
28
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
29
- * / Type Bit Map /
30
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
31
- *
32
- */
33
- class Net_DNS2_RR_CSYNC extends Net_DNS2_RR
34
- {
35
- /*
36
- * serial number
37
- */
38
- public $serial;
39
-
40
- /*
41
- * flags
42
- */
43
- public $flags;
44
-
45
- /*
46
- * array of RR type names
47
- */
48
- public $type_bit_maps = [];
49
-
50
- /**
51
- * method to return the rdata portion of the packet as a string
52
- *
53
- * @return string
54
- * @access protected
55
- *
56
- */
57
- protected function rrToString()
58
- {
59
- $out = $this->serial . ' ' . $this->flags;
60
-
61
- //
62
- // show the RR's
63
- //
64
- foreach ($this->type_bit_maps as $rr) {
65
-
66
- $out .= ' ' . strtoupper($rr);
67
- }
68
-
69
- return $out;
70
- }
71
-
72
- /**
73
- * parses the rdata portion from a standard DNS config line
74
- *
75
- * @param array $rdata a string split line of values for the rdata
76
- *
77
- * @return boolean
78
- * @access protected
79
- *
80
- */
81
- protected function rrFromString(array $rdata)
82
- {
83
- $this->serial = array_shift($rdata);
84
- $this->flags = array_shift($rdata);
85
-
86
- $this->type_bit_maps = $rdata;
87
-
88
- return true;
89
- }
90
-
91
- /**
92
- * parses the rdata of the Net_DNS2_Packet object
93
- *
94
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
95
- *
96
- * @return boolean
97
- * @access protected
98
- *
99
- */
100
- protected function rrSet(Net_DNS2_Packet &$packet)
101
- {
102
- if ($this->rdlength > 0) {
103
-
104
- //
105
- // unpack the serial and flags values
106
- //
107
- $x = unpack('@' . $packet->offset . '/Nserial/nflags', $packet->rdata);
108
-
109
- $this->serial = Net_DNS2::expandUint32($x['serial']);
110
- $this->flags = $x['flags'];
111
-
112
- //
113
- // parse out the RR bitmap
114
- //
115
- $this->type_bit_maps = Net_DNS2_BitMap::bitMapToArray(
116
- substr($this->rdata, 6)
117
- );
118
-
119
- return true;
120
- }
121
-
122
- return false;
123
- }
124
-
125
- /**
126
- * returns the rdata portion of the DNS packet
127
- *
128
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
129
- * compressed names
130
- *
131
- * @return mixed either returns a binary packed
132
- * string or null on failure
133
- * @access protected
134
- *
135
- */
136
- protected function rrGet(Net_DNS2_Packet &$packet)
137
- {
138
- //
139
- // pack the serial and flags values
140
- //
141
- $data = pack('Nn', $this->serial, $this->flags);
142
-
143
- //
144
- // convert the array of RR names to a type bitmap
145
- //
146
- $data .= Net_DNS2_BitMap::arrayToBitMap($this->type_bit_maps);
147
-
148
- //
149
- // advance the offset
150
- //
151
- $packet->offset += strlen($data);
152
-
153
- return $data;
154
- }
155
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/DHCID.php DELETED
@@ -1,159 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 0.6.0
17
- *
18
- */
19
-
20
- /**
21
- * DHCID Resource Record - RFC4701 section 3.1
22
- *
23
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
24
- * | ID Type Code |
25
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
26
- * | Digest Type | /
27
- * +--+--+--+--+--+--+--+--+ /
28
- * / /
29
- * / Digest /
30
- * / /
31
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
32
- *
33
- */
34
- class Net_DNS2_RR_DHCID extends Net_DNS2_RR
35
- {
36
- /*
37
- * Identifier type
38
- */
39
- public $id_type;
40
-
41
- /*
42
- * Digest Type
43
- */
44
- public $digest_type;
45
-
46
- /*
47
- * The digest
48
- */
49
- public $digest;
50
-
51
-
52
- /**
53
- * method to return the rdata portion of the packet as a string
54
- *
55
- * @return string
56
- * @access protected
57
- *
58
- */
59
- protected function rrToString()
60
- {
61
- $out = pack('nC', $this->id_type, $this->digest_type);
62
- $out .= base64_decode($this->digest);
63
-
64
- return base64_encode($out);
65
- }
66
-
67
- /**
68
- * parses the rdata portion from a standard DNS config line
69
- *
70
- * @param array $rdata a string split line of values for the rdata
71
- *
72
- * @return boolean
73
- * @access protected
74
- *
75
- */
76
- protected function rrFromString(array $rdata)
77
- {
78
- $data = base64_decode(array_shift($rdata));
79
- if (strlen($data) > 0) {
80
-
81
- //
82
- // unpack the id type and digest type
83
- //
84
- $x = unpack('nid_type/Cdigest_type', $data);
85
-
86
- $this->id_type = $x['id_type'];
87
- $this->digest_type = $x['digest_type'];
88
-
89
- //
90
- // copy out the digest
91
- //
92
- $this->digest = base64_encode(substr($data, 3, strlen($data) - 3));
93
-
94
- return true;
95
- }
96
-
97
- return false;
98
- }
99
-
100
- /**
101
- * parses the rdata of the Net_DNS2_Packet object
102
- *
103
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
104
- *
105
- * @return boolean
106
- * @access protected
107
- *
108
- */
109
- protected function rrSet(Net_DNS2_Packet &$packet)
110
- {
111
- if ($this->rdlength > 0) {
112
-
113
- //
114
- // unpack the id type and digest type
115
- //
116
- $x = unpack('nid_type/Cdigest_type', $this->rdata);
117
-
118
- $this->id_type = $x['id_type'];
119
- $this->digest_type = $x['digest_type'];
120
-
121
- //
122
- // copy out the digest
123
- //
124
- $this->digest = base64_encode(
125
- substr($this->rdata, 3, $this->rdlength - 3)
126
- );
127
-
128
- return true;
129
- }
130
-
131
- return false;
132
- }
133
-
134
- /**
135
- * returns the rdata portion of the DNS packet
136
- *
137
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
138
- * compressed names
139
- *
140
- * @return mixed either returns a binary packed
141
- * string or null on failure
142
- * @access protected
143
- *
144
- */
145
- protected function rrGet(Net_DNS2_Packet &$packet)
146
- {
147
- if (strlen($this->digest) > 0) {
148
-
149
- $data = pack('nC', $this->id_type, $this->digest_type) .
150
- base64_decode($this->digest);
151
-
152
- $packet->offset += strlen($data);
153
-
154
- return $data;
155
- }
156
-
157
- return null;
158
- }
159
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/DLV.php DELETED
@@ -1,27 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 0.6.0
17
- *
18
- */
19
-
20
- /**
21
- * The DLV RR is implemented exactly like the DS RR; so we just extend that
22
- * class, and use all of it's methods
23
- *
24
- */
25
- class Net_DNS2_RR_DLV extends Net_DNS2_RR_DS
26
- {
27
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/DNAME.php DELETED
@@ -1,105 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 0.6.0
17
- *
18
- */
19
-
20
- /**
21
- * DNAME Resource Record - RFC2672 section 3
22
- *
23
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
24
- * / DNAME /
25
- * / /
26
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
27
- *
28
- */
29
- class Net_DNS2_RR_DNAME extends Net_DNS2_RR
30
- {
31
- /*
32
- * The target name
33
- */
34
- public $dname;
35
-
36
- /**
37
- * method to return the rdata portion of the packet as a string
38
- *
39
- * @return string
40
- * @access protected
41
- *
42
- */
43
- protected function rrToString()
44
- {
45
- return $this->cleanString($this->dname) . '.';
46
- }
47
-
48
- /**
49
- * parses the rdata portion from a standard DNS config line
50
- *
51
- * @param array $rdata a string split line of values for the rdata
52
- *
53
- * @return boolean
54
- * @access protected
55
- *
56
- */
57
- protected function rrFromString(array $rdata)
58
- {
59
- $this->dname = $this->cleanString(array_shift($rdata));
60
- return true;
61
- }
62
-
63
- /**
64
- * parses the rdata of the Net_DNS2_Packet object
65
- *
66
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
67
- *
68
- * @return boolean
69
- * @access protected
70
- *
71
- */
72
- protected function rrSet(Net_DNS2_Packet &$packet)
73
- {
74
- if ($this->rdlength > 0) {
75
-
76
- $offset = $packet->offset;
77
- $this->dname = Net_DNS2_Packet::expand($packet, $offset);
78
-
79
- return true;
80
- }
81
-
82
- return false;
83
- }
84
-
85
- /**
86
- * returns the rdata portion of the DNS packet
87
- *
88
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
89
- * compressed names
90
- *
91
- * @return mixed either returns a binary packed
92
- * string or null on failure
93
- * @access protected
94
- *
95
- */
96
- protected function rrGet(Net_DNS2_Packet &$packet)
97
- {
98
- if (strlen($this->dname) > 0) {
99
-
100
- return $packet->compress($this->dname, $packet->offset);
101
- }
102
-
103
- return null;
104
- }
105
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/DNSKEY.php DELETED
@@ -1,150 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 0.6.0
17
- *
18
- */
19
-
20
- /**
21
- * DNSKEY Resource Record - RFC4034 sction 2.1
22
- *
23
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
24
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
25
- * | Flags | Protocol | Algorithm |
26
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
27
- * / /
28
- * / Public Key /
29
- * / /
30
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
31
- *
32
- */
33
- class Net_DNS2_RR_DNSKEY extends Net_DNS2_RR
34
- {
35
- /*
36
- * flags
37
- */
38
- public $flags;
39
-
40
- /*
41
- * protocol
42
- */
43
- public $protocol;
44
-
45
- /*
46
- * algorithm used
47
- */
48
- public $algorithm;
49
-
50
- /*
51
- * the public key
52
- */
53
- public $key;
54
-
55
- /**
56
- * method to return the rdata portion of the packet as a string
57
- *
58
- * @return string
59
- * @access protected
60
- *
61
- */
62
- protected function rrToString()
63
- {
64
- return $this->flags . ' ' . $this->protocol . ' ' .
65
- $this->algorithm . ' ' . $this->key;
66
- }
67
-
68
- /**
69
- * parses the rdata portion from a standard DNS config line
70
- *
71
- * @param array $rdata a string split line of values for the rdata
72
- *
73
- * @return boolean
74
- * @access protected
75
- *
76
- */
77
- protected function rrFromString(array $rdata)
78
- {
79
- $this->flags = array_shift($rdata);
80
- $this->protocol = array_shift($rdata);
81
- $this->algorithm = array_shift($rdata);
82
- $this->key = implode(' ', $rdata);
83
-
84
- return true;
85
- }
86
-
87
- /**
88
- * parses the rdata of the Net_DNS2_Packet object
89
- *
90
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
91
- *
92
- * @return boolean
93
- * @access protected
94
- *
95
- */
96
- protected function rrSet(Net_DNS2_Packet &$packet)
97
- {
98
- if ($this->rdlength > 0) {
99
-
100
- //
101
- // unpack the flags, protocol and algorithm
102
- //
103
- $x = unpack('nflags/Cprotocol/Calgorithm', $this->rdata);
104
-
105
- //
106
- // TODO: right now we're just displaying what's in DNS; we really
107
- // should be parsing bit 7 and bit 15 of the flags field, and store
108
- // those separately.
109
- //
110
- // right now the DNSSEC implementation is really just for display,
111
- // we don't validate or handle any of the keys
112
- //
113
- $this->flags = $x['flags'];
114
- $this->protocol = $x['protocol'];
115
- $this->algorithm = $x['algorithm'];
116
-
117
- $this->key = base64_encode(substr($this->rdata, 4));
118
-
119
- return true;
120
- }
121
-
122
- return false;
123
- }
124
-
125
- /**
126
- * returns the rdata portion of the DNS packet
127
- *
128
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
129
- * compressed names
130
- *
131
- * @return mixed either returns a binary packed
132
- * string or null on failure
133
- * @access protected
134
- *
135
- */
136
- protected function rrGet(Net_DNS2_Packet &$packet)
137
- {
138
- if (strlen($this->key) > 0) {
139
-
140
- $data = pack('nCC', $this->flags, $this->protocol, $this->algorithm);
141
- $data .= base64_decode($this->key);
142
-
143
- $packet->offset += strlen($data);
144
-
145
- return $data;
146
- }
147
-
148
- return null;
149
- }
150
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/DS.php DELETED
@@ -1,139 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 0.6.0
17
- *
18
- */
19
-
20
- /**
21
- * DS Resource Record - RFC4034 sction 5.1
22
- *
23
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
24
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
25
- * | Key Tag | Algorithm | Digest Type |
26
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
27
- * / /
28
- * / Digest /
29
- * / /
30
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
31
- *
32
- */
33
- class Net_DNS2_RR_DS extends Net_DNS2_RR
34
- {
35
- /*
36
- * key tag
37
- */
38
- public $keytag;
39
-
40
- /*
41
- * algorithm number
42
- */
43
- public $algorithm;
44
-
45
- /*
46
- * algorithm used to construct the digest
47
- */
48
- public $digesttype;
49
-
50
- /*
51
- * the digest data
52
- */
53
- public $digest;
54
-
55
- /**
56
- * method to return the rdata portion of the packet as a string
57
- *
58
- * @return string
59
- * @access protected
60
- *
61
- */
62
- protected function rrToString()
63
- {
64
- return $this->keytag . ' ' . $this->algorithm . ' ' . $this->digesttype . ' ' . $this->digest;
65
- }
66
-
67
- /**
68
- * parses the rdata portion from a standard DNS config line
69
- *
70
- * @param array $rdata a string split line of values for the rdata
71
- *
72
- * @return boolean
73
- * @access protected
74
- *
75
- */
76
- protected function rrFromString(array $rdata)
77
- {
78
- $this->keytag = array_shift($rdata);
79
- $this->algorithm = array_shift($rdata);
80
- $this->digesttype = array_shift($rdata);
81
- $this->digest = implode('', $rdata);
82
-
83
- return true;
84
- }
85
-
86
- /**
87
- * parses the rdata of the Net_DNS2_Packet object
88
- *
89
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
90
- *
91
- * @return boolean
92
- * @access protected
93
- *
94
- */
95
- protected function rrSet(Net_DNS2_Packet &$packet)
96
- {
97
- if ($this->rdlength > 0) {
98
-
99
- //
100
- // unpack the keytag, algorithm and digesttype
101
- //
102
- $x = unpack('nkeytag/Calgorithm/Cdigesttype/H*digest', $this->rdata);
103
-
104
- $this->keytag = $x['keytag'];
105
- $this->algorithm = $x['algorithm'];
106
- $this->digesttype = $x['digesttype'];
107
- $this->digest = $x['digest'];
108
-
109
- return true;
110
- }
111
-
112
- return false;
113
- }
114
-
115
- /**
116
- * returns the rdata portion of the DNS packet
117
- *
118
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
119
- * compressed names
120
- *
121
- * @return mixed either returns a binary packed
122
- * string or null on failure
123
- * @access protected
124
- *
125
- */
126
- protected function rrGet(Net_DNS2_Packet &$packet)
127
- {
128
- if (strlen($this->digest) > 0) {
129
-
130
- $data = pack('nCCH*', $this->keytag, $this->algorithm, $this->digesttype, $this->digest);
131
-
132
- $packet->offset += strlen($data);
133
-
134
- return $data;
135
- }
136
-
137
- return null;
138
- }
139
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/EID.php DELETED
@@ -1,82 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 0.6.0
17
- *
18
- */
19
-
20
- /**
21
- * EID Resource Record - undefined; the rdata is simply used as-is in it's
22
- * binary format, so not process has to be done.
23
- *
24
- */
25
- class Net_DNS2_RR_EID extends Net_DNS2_RR
26
- {
27
- /**
28
- * method to return the rdata portion of the packet as a string
29
- *
30
- * @return string
31
- * @access protected
32
- *
33
- */
34
- protected function rrToString()
35
- {
36
- return '';
37
- }
38
-
39
- /**
40
- * parses the rdata portion from a standard DNS config line
41
- *
42
- * @param array $rdata a string split line of values for the rdata
43
- *
44
- * @return boolean
45
- * @access protected
46
- *
47
- */
48
- protected function rrFromString(array $rdata)
49
- {
50
- return true;
51
- }
52
-
53
- /**
54
- * parses the rdata of the Net_DNS2_Packet object
55
- *
56
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
57
- *
58
- * @return boolean
59
- * @access protected
60
- *
61
- */
62
- protected function rrSet(Net_DNS2_Packet &$packet)
63
- {
64
- return true;
65
- }
66
-
67
- /**
68
- * returns the rdata portion of the DNS packet
69
- *
70
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
71
- * compressed names
72
- *
73
- * @return mixed either returns a binary packed
74
- * string or null on failure
75
- * @access protected
76
- *
77
- */
78
- protected function rrGet(Net_DNS2_Packet &$packet)
79
- {
80
- return $this->rdata;
81
- }
82
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/EUI48.php DELETED
@@ -1,139 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 1.3.2
17
- *
18
- */
19
-
20
- /**
21
- * EUI48 Resource Record - RFC7043 section 3.1
22
- *
23
- * 0 1 2 3
24
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
25
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
26
- * | EUI-48 Address |
27
- * | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
28
- * | |
29
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
30
- *
31
- */
32
- class Net_DNS2_RR_EUI48 extends Net_DNS2_RR
33
- {
34
- /*
35
- * The EUI48 address, in hex format
36
- */
37
- public $address;
38
-
39
- /**
40
- * method to return the rdata portion of the packet as a string
41
- *
42
- * @return string
43
- * @access protected
44
- *
45
- */
46
- protected function rrToString()
47
- {
48
- return $this->address;
49
- }
50
-
51
- /**
52
- * parses the rdata portion from a standard DNS config line
53
- *
54
- * @param array $rdata a string split line of values for the rdata
55
- *
56
- * @return boolean
57
- * @access protected
58
- *
59
- */
60
- protected function rrFromString(array $rdata)
61
- {
62
- $value = array_shift($rdata);
63
-
64
- //
65
- // re: RFC 7043, the field must be represented as six two-digit hex numbers
66
- // separated by hyphens.
67
- //
68
- $a = explode('-', $value);
69
- if (count($a) != 6) {
70
-
71
- return false;
72
- }
73
-
74
- //
75
- // make sure they're all hex values
76
- //
77
- foreach ($a as $i) {
78
- if (ctype_xdigit($i) == false) {
79
- return false;
80
- }
81
- }
82
-
83
- //
84
- // store it
85
- //
86
- $this->address = strtolower($value);
87
-
88
- return true;
89
- }
90
-
91
- /**
92
- * parses the rdata of the Net_DNS2_Packet object
93
- *
94
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
95
- *
96
- * @return boolean
97
- * @access protected
98
- *
99
- */
100
- protected function rrSet(Net_DNS2_Packet &$packet)
101
- {
102
- if ($this->rdlength > 0) {
103
-
104
- $x = unpack('C6', $this->rdata);
105
- if (count($x) == 6) {
106
-
107
- $this->address = vsprintf('%02x-%02x-%02x-%02x-%02x-%02x', $x);
108
- return true;
109
- }
110
- }
111
-
112
- return false;
113
- }
114
-
115
- /**
116
- * returns the rdata portion of the DNS packet
117
- *
118
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
119
- * compressed names
120
- *
121
- * @return mixed either returns a binary packed
122
- * string or null on failure
123
- * @access protected
124
- *
125
- */
126
- protected function rrGet(Net_DNS2_Packet &$packet)
127
- {
128
- $data = '';
129
-
130
- $a = explode('-', $this->address);
131
- foreach ($a as $b) {
132
-
133
- $data .= chr(hexdec($b));
134
- }
135
-
136
- $packet->offset += 6;
137
- return $data;
138
- }
139
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/EUI64.php DELETED
@@ -1,140 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 1.3.2
17
- *
18
- */
19
-
20
- /**
21
- * EUI64 Resource Record - RFC7043 section 4.1
22
- *
23
- * 0 1 2 3
24
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
25
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
26
- * | EUI-64 Address |
27
- * | |
28
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
29
- *
30
- */
31
- class Net_DNS2_RR_EUI64 extends Net_DNS2_RR
32
- {
33
- /*
34
- * The EUI64 address, in hex format
35
- */
36
- public $address;
37
-
38
- /**
39
- * method to return the rdata portion of the packet as a string
40
- *
41
- * @return string
42
- * @access protected
43
- *
44
- */
45
- protected function rrToString()
46
- {
47
- return $this->address;
48
- }
49
-
50
- /**
51
- * parses the rdata portion from a standard DNS config line
52
- *
53
- * @param array $rdata a string split line of values for the rdata
54
- *
55
- * @return boolean
56
- * @access protected
57
- *
58
- */
59
- protected function rrFromString(array $rdata)
60
- {
61
- $value = array_shift($rdata);
62
-
63
- //
64
- // re: RFC 7043, the field must be represented as 8 two-digit hex numbers
65
- // separated by hyphens.
66
- //
67
- $a = explode('-', $value);
68
- if (count($a) != 8) {
69
-
70
- return false;
71
- }
72
-
73
- //
74
- // make sure they're all hex values
75
- //
76
- foreach ($a as $i) {
77
- if (ctype_xdigit($i) == false) {
78
- return false;
79
- }
80
- }
81
-
82
- //
83
- // store it
84
- //
85
- $this->address = strtolower($value);
86
-
87
- return true;
88
- }
89
-
90
- /**
91
- * parses the rdata of the Net_DNS2_Packet object
92
- *
93
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
94
- *
95
- * @return boolean
96
- * @access protected
97
- *
98
- */
99
- protected function rrSet(Net_DNS2_Packet &$packet)
100
- {
101
- if ($this->rdlength > 0) {
102
-
103
- $x = unpack('C8', $this->rdata);
104
- if (count($x) == 8) {
105
-
106
- $this->address = vsprintf(
107
- '%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x', $x
108
- );
109
- return true;
110
- }
111
- }
112
-
113
- return false;
114
- }
115
-
116
- /**
117
- * returns the rdata portion of the DNS packet
118
- *
119
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
120
- * compressed names
121
- *
122
- * @return mixed either returns a binary packed
123
- * string or null on failure
124
- * @access protected
125
- *
126
- */
127
- protected function rrGet(Net_DNS2_Packet &$packet)
128
- {
129
- $data = '';
130
-
131
- $a = explode('-', $this->address);
132
- foreach ($a as $b) {
133
-
134
- $data .= chr(hexdec($b));
135
- }
136
-
137
- $packet->offset += 8;
138
- return $data;
139
- }
140
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/HINFO.php DELETED
@@ -1,125 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 0.6.0
17
- *
18
- */
19
-
20
- /**
21
- * HINFO Resource Record - RFC1035 section 3.3.2
22
- *
23
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
24
- * / CPU /
25
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
26
- * / OS /
27
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
28
- *
29
- */
30
- class Net_DNS2_RR_HINFO extends Net_DNS2_RR
31
- {
32
- /*
33
- * computer informatino
34
- */
35
- public $cpu;
36
-
37
- /*
38
- * operataing system
39
- */
40
- public $os;
41
-
42
- /**
43
- * method to return the rdata portion of the packet as a string
44
- *
45
- * @return string
46
- * @access protected
47
- *
48
- */
49
- protected function rrToString()
50
- {
51
- return $this->formatString($this->cpu) . ' ' . $this->formatString($this->os);
52
- }
53
-
54
- /**
55
- * parses the rdata portion from a standard DNS config line
56
- *
57
- * @param array $rdata a string split line of values for the rdata
58
- *
59
- * @return boolean
60
- * @access protected
61
- *
62
- */
63
- protected function rrFromString(array $rdata)
64
- {
65
- $data = $this->buildString($rdata);
66
- if (count($data) == 2) {
67
-
68
- $this->cpu = trim($data[0], '"');
69
- $this->os = trim($data[1], '"');
70
-
71
- return true;
72
- }
73
-
74
- return false;
75
- }
76
-
77
- /**
78
- * parses the rdata of the Net_DNS2_Packet object
79
- *
80
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
81
- *
82
- * @return boolean
83
- * @access protected
84
- *
85
- */
86
- protected function rrSet(Net_DNS2_Packet &$packet)
87
- {
88
- if ($this->rdlength > 0) {
89
-
90
- $offset = $packet->offset;
91
-
92
- $this->cpu = Net_DNS2_Packet::label($packet, $offset);
93
- $this->os = Net_DNS2_Packet::label($packet, $offset);
94
-
95
- return true;
96
- }
97
-
98
- return false;
99
- }
100
-
101
- /**
102
- * returns the rdata portion of the DNS packet
103
- *
104
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
105
- * compressed names
106
- *
107
- * @return mixed either returns a binary packed
108
- * string or null on failure
109
- * @access protected
110
- *
111
- */
112
- protected function rrGet(Net_DNS2_Packet &$packet)
113
- {
114
- if (strlen($this->cpu) > 0) {
115
-
116
- $data = pack('Ca*Ca*', strlen($this->cpu), $this->cpu, strlen($this->os), $this->os);
117
-
118
- $packet->offset += strlen($data);
119
-
120
- return $data;
121
- }
122
-
123
- return null;
124
- }
125
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/HIP.php DELETED
@@ -1,239 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 1.0.0
17
- *
18
- */
19
-
20
- /**
21
- * HIP Resource Record - RFC5205 section 5
22
- *
23
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
24
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
25
- * | HIT length | PK algorithm | PK length |
26
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
27
- * | |
28
- * ~ HIT ~
29
- * | |
30
- * + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
31
- * | | |
32
- * +-+-+-+-+-+-+-+-+-+-+-+ +
33
- * | Public Key |
34
- * ~ ~
35
- * | |
36
- * + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
37
- * | | |
38
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +
39
- * | |
40
- * ~ Rendezvous Servers ~
41
- * | |
42
- * + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
43
- * | |
44
- * +-+-+-+-+-+-+-+
45
- *
46
- */
47
- class Net_DNS2_RR_HIP extends Net_DNS2_RR
48
- {
49
- /*
50
- * The length of the HIT field
51
- */
52
- public $hit_length;
53
-
54
- /*
55
- * the public key cryptographic algorithm
56
- */
57
- public $pk_algorithm;
58
-
59
- /*
60
- * the length of the public key field
61
- */
62
- public $pk_length;
63
-
64
- /*
65
- * The HIT is stored as a binary value in network byte order.
66
- */
67
- public $hit;
68
-
69
- /*
70
- * The public key
71
- */
72
- public $public_key;
73
-
74
- /*
75
- * a list of rendezvous servers
76
- */
77
- public $rendezvous_servers = [];
78
-
79
- /**
80
- * method to return the rdata portion of the packet as a string
81
- *
82
- * @return string
83
- * @access protected
84
- *
85
- */
86
- protected function rrToString()
87
- {
88
- $out = $this->pk_algorithm . ' ' .
89
- $this->hit . ' ' . $this->public_key . ' ';
90
-
91
- foreach ($this->rendezvous_servers as $index => $server) {
92
-
93
- $out .= $server . '. ';
94
- }
95
-
96
- return trim($out);
97
- }
98
-
99
- /**
100
- * parses the rdata portion from a standard DNS config line
101
- *
102
- * @param array $rdata a string split line of values for the rdata
103
- *
104
- * @return boolean
105
- * @access protected
106
- *
107
- */
108
- protected function rrFromString(array $rdata)
109
- {
110
- $this->pk_algorithm = array_shift($rdata);
111
- $this->hit = strtoupper(array_shift($rdata));
112
- $this->public_key = array_shift($rdata);
113
-
114
- //
115
- // anything left on the array, must be one or more rendezevous servers. add
116
- // them and strip off the trailing dot
117
- //
118
- if (count($rdata) > 0) {
119
-
120
- $this->rendezvous_servers = preg_replace('/\.$/', '', $rdata);
121
- }
122
-
123
- //
124
- // store the lengths;
125
- //
126
- $this->hit_length = strlen(pack('H*', $this->hit));
127
- $this->pk_length = strlen(base64_decode($this->public_key));
128
-
129
- return true;
130
- }
131
-
132
- /**
133
- * parses the rdata of the Net_DNS2_Packet object
134
- *
135
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
136
- *
137
- * @return boolean
138
- * @access protected
139
- *
140
- */
141
- protected function rrSet(Net_DNS2_Packet &$packet)
142
- {
143
- if ($this->rdlength > 0) {
144
-
145
- //
146
- // unpack the algorithm and length values
147
- //
148
- $x = unpack('Chit_length/Cpk_algorithm/npk_length', $this->rdata);
149
-
150
- $this->hit_length = $x['hit_length'];
151
- $this->pk_algorithm = $x['pk_algorithm'];
152
- $this->pk_length = $x['pk_length'];
153
-
154
- $offset = 4;
155
-
156
- //
157
- // copy out the HIT value
158
- //
159
- $hit = unpack('H*', substr($this->rdata, $offset, $this->hit_length));
160
-
161
- $this->hit = strtoupper($hit[1]);
162
- $offset += $this->hit_length;
163
-
164
- //
165
- // copy out the public key
166
- //
167
- $this->public_key = base64_encode(
168
- substr($this->rdata, $offset, $this->pk_length)
169
- );
170
- $offset += $this->pk_length;
171
-
172
- //
173
- // copy out any possible rendezvous servers
174
- //
175
- $offset = $packet->offset + $offset;
176
-
177
- while ( ($offset - $packet->offset) < $this->rdlength) {
178
-
179
- $this->rendezvous_servers[] = Net_DNS2_Packet::expand(
180
- $packet, $offset
181
- );
182
- }
183
-
184
- return true;
185
- }
186
-
187
- return false;
188
- }
189
-
190
- /**
191
- * returns the rdata portion of the DNS packet
192
- *
193
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
194
- * compressed names
195
- *
196
- * @return mixed either returns a binary packed
197
- * string or null on failure
198
- * @access protected
199
- *
200
- */
201
- protected function rrGet(Net_DNS2_Packet &$packet)
202
- {
203
- if ( (strlen($this->hit) > 0) && (strlen($this->public_key) > 0) ) {
204
-
205
- //
206
- // pack the length, algorithm and HIT values
207
- //
208
- $data = pack(
209
- 'CCnH*',
210
- $this->hit_length,
211
- $this->pk_algorithm,
212
- $this->pk_length,
213
- $this->hit
214
- );
215
-
216
- //
217
- // add the public key
218
- //
219
- $data .= base64_decode($this->public_key);
220
-
221
- //
222
- // add the offset
223
- //
224
- $packet->offset += strlen($data);
225
-
226
- //
227
- // add each rendezvous server
228
- //
229
- foreach ($this->rendezvous_servers as $index => $server) {
230
-
231
- $data .= $packet->compress($server, $packet->offset);
232
- }
233
-
234
- return $data;
235
- }
236
-
237
- return null;
238
- }
239
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/IPSECKEY.php DELETED
@@ -1,338 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 0.6.0
17
- *
18
- */
19
-
20
- /**
21
- * IPSECKEY Resource Record - RFC4025 section 2.1
22
- *
23
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
24
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
25
- * | precedence | gateway type | algorithm | gateway |
26
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-------------+ +
27
- * ~ gateway ~
28
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
29
- * | /
30
- * / public key /
31
- * / /
32
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-|
33
- *
34
- */
35
- class Net_DNS2_RR_IPSECKEY extends Net_DNS2_RR
36
- {
37
- const GATEWAY_TYPE_NONE = 0;
38
- const GATEWAY_TYPE_IPV4 = 1;
39
- const GATEWAY_TYPE_IPV6 = 2;
40
- const GATEWAY_TYPE_DOMAIN = 3;
41
-
42
- const ALGORITHM_NONE = 0;
43
- const ALGORITHM_DSA = 1;
44
- const ALGORITHM_RSA = 2;
45
-
46
- /*
47
- * Precedence (used the same was as a preference field)
48
- */
49
- public $precedence;
50
-
51
- /*
52
- * Gateway type - specifies the format of the gataway information
53
- * This can be either:
54
- *
55
- * 0 No Gateway
56
- * 1 IPv4 address
57
- * 2 IPV6 address
58
- * 3 wire-encoded domain name (not compressed)
59
- *
60
- */
61
- public $gateway_type;
62
-
63
- /*
64
- * The algorithm used
65
- *
66
- * This can be:
67
- *
68
- * 0 No key is present
69
- * 1 DSA key is present
70
- * 2 RSA key is present
71
- *
72
- */
73
- public $algorithm;
74
-
75
- /*
76
- * The gatway information
77
- */
78
- public $gateway;
79
-
80
- /*
81
- * the public key
82
- */
83
- public $key;
84
-
85
- /**
86
- * method to return the rdata portion of the packet as a string
87
- *
88
- * @return string
89
- * @access protected
90
- *
91
- */
92
- protected function rrToString()
93
- {
94
- $out = $this->precedence . ' ' . $this->gateway_type . ' ' .
95
- $this->algorithm . ' ';
96
-
97
- switch($this->gateway_type) {
98
- case self::GATEWAY_TYPE_NONE:
99
- $out .= '. ';
100
- break;
101
-
102
- case self::GATEWAY_TYPE_IPV4:
103
- case self::GATEWAY_TYPE_IPV6:
104
- $out .= $this->gateway . ' ';
105
- break;
106
-
107
- case self::GATEWAY_TYPE_DOMAIN:
108
- $out .= $this->gateway . '. ';
109
- break;
110
- }
111
-
112
- $out .= $this->key;
113
- return $out;
114
- }
115
-
116
- /**
117
- * parses the rdata portion from a standard DNS config line
118
- *
119
- * @param array $rdata a string split line of values for the rdata
120
- *
121
- * @return boolean
122
- * @access protected
123
- *
124
- */
125
- protected function rrFromString(array $rdata)
126
- {
127
- //
128
- // load the data
129
- //
130
- $precedence = array_shift($rdata);
131
- $gateway_type = array_shift($rdata);
132
- $algorithm = array_shift($rdata);
133
- $gateway = trim(strtolower(trim(array_shift($rdata))), '.');
134
- $key = array_shift($rdata);
135
-
136
- //
137
- // validate it
138
- //
139
- switch($gateway_type) {
140
- case self::GATEWAY_TYPE_NONE:
141
- $gateway = '';
142
- break;
143
-
144
- case self::GATEWAY_TYPE_IPV4:
145
- if (Net_DNS2::isIPv4($gateway) == false) {
146
- return false;
147
- }
148
- break;
149
-
150
- case self::GATEWAY_TYPE_IPV6:
151
- if (Net_DNS2::isIPv6($gateway) == false) {
152
- return false;
153
- }
154
- break;
155
-
156
- case self::GATEWAY_TYPE_DOMAIN:
157
- ; // do nothing
158
- break;
159
-
160
- default:
161
- return false;
162
- }
163
-
164
- //
165
- // check the algorithm and key
166
- //
167
- switch($algorithm) {
168
- case self::ALGORITHM_NONE:
169
- $key = '';
170
- break;
171
-
172
- case self::ALGORITHM_DSA:
173
- case self::ALGORITHM_RSA:
174
- ; // do nothing
175
- break;
176
-
177
- default:
178
- return false;
179
- }
180
-
181
- //
182
- // store the values
183
- //
184
- $this->precedence = $precedence;
185
- $this->gateway_type = $gateway_type;
186
- $this->algorithm = $algorithm;
187
- $this->gateway = $gateway;
188
- $this->key = $key;
189
-
190
- return true;
191
- }
192
-
193
- /**
194
- * parses the rdata of the Net_DNS2_Packet object
195
- *
196
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
197
- *
198
- * @return boolean
199
- * @access protected
200
- *
201
- */
202
- protected function rrSet(Net_DNS2_Packet &$packet)
203
- {
204
- if ($this->rdlength > 0) {
205
-
206
- //
207
- // parse off the precedence, gateway type and algorithm
208
- //
209
- $x = unpack('Cprecedence/Cgateway_type/Calgorithm', $this->rdata);
210
-
211
- $this->precedence = $x['precedence'];
212
- $this->gateway_type = $x['gateway_type'];
213
- $this->algorithm = $x['algorithm'];
214
-
215
- $offset = 3;
216
-
217
- //
218
- // extract the gatway based on the type
219
- //
220
- switch($this->gateway_type) {
221
- case self::GATEWAY_TYPE_NONE:
222
- $this->gateway = '';
223
- break;
224
-
225
- case self::GATEWAY_TYPE_IPV4:
226
- $this->gateway = inet_ntop(substr($this->rdata, $offset, 4));
227
- $offset += 4;
228
- break;
229
-
230
- case self::GATEWAY_TYPE_IPV6:
231
- $ip = unpack('n8', substr($this->rdata, $offset, 16));
232
- if (count($ip) == 8) {
233
-
234
- $this->gateway = vsprintf('%x:%x:%x:%x:%x:%x:%x:%x', $ip);
235
- $offset += 16;
236
- } else {
237
-
238
- return false;
239
- }
240
- break;
241
-
242
- case self::GATEWAY_TYPE_DOMAIN:
243
-
244
- $doffset = $offset + $packet->offset;
245
- $this->gateway = Net_DNS2_Packet::expand($packet, $doffset);
246
- $offset = ($doffset - $packet->offset);
247
- break;
248
-
249
- default:
250
- return false;
251
- }
252
-
253
- //
254
- // extract the key
255
- //
256
- switch($this->algorithm) {
257
- case self::ALGORITHM_NONE:
258
- $this->key = '';
259
- break;
260
-
261
- case self::ALGORITHM_DSA:
262
- case self::ALGORITHM_RSA:
263
- $this->key = base64_encode(substr($this->rdata, $offset));
264
- break;
265
-
266
- default:
267
- return false;
268
- }
269
-
270
- return true;
271
- }
272
-
273
- return false;
274
- }
275
-
276
- /**
277
- * returns the rdata portion of the DNS packet
278
- *
279
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
280
- * compressed names
281
- *
282
- * @return mixed either returns a binary packed
283
- * string or null on failure
284
- * @access protected
285
- *
286
- */
287
- protected function rrGet(Net_DNS2_Packet &$packet)
288
- {
289
- //
290
- // pack the precedence, gateway type and algorithm
291
- //
292
- $data = pack(
293
- 'CCC', $this->precedence, $this->gateway_type, $this->algorithm
294
- );
295
-
296
- //
297
- // add the gateway based on the type
298
- //
299
- switch($this->gateway_type) {
300
- case self::GATEWAY_TYPE_NONE:
301
- ; // add nothing
302
- break;
303
-
304
- case self::GATEWAY_TYPE_IPV4:
305
- case self::GATEWAY_TYPE_IPV6:
306
- $data .= inet_pton($this->gateway);
307
- break;
308
-
309
- case self::GATEWAY_TYPE_DOMAIN:
310
- $data .= chr(strlen($this->gateway)) . $this->gateway;
311
- break;
312
-
313
- default:
314
- return null;
315
- }
316
-
317
- //
318
- // add the key if there's one specified
319
- //
320
- switch($this->algorithm) {
321
- case self::ALGORITHM_NONE:
322
- ; // add nothing
323
- break;
324
-
325
- case self::ALGORITHM_DSA:
326
- case self::ALGORITHM_RSA:
327
- $data .= base64_decode($this->key);
328
- break;
329
-
330
- default:
331
- return null;
332
- }
333
-
334
- $packet->offset += strlen($data);
335
-
336
- return $data;
337
- }
338
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/ISDN.php DELETED
@@ -1,142 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 0.6.0
17
- *
18
- */
19
-
20
- /**
21
- * ISDN Resource Record - RFC1183 section 3.2
22
- *
23
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
24
- * / ISDN-address /
25
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
26
- * / SA /
27
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
28
- *
29
- */
30
- class Net_DNS2_RR_ISDN extends Net_DNS2_RR
31
- {
32
- /*
33
- * ISDN Number
34
- */
35
- public $isdnaddress;
36
-
37
- /*
38
- * Sub-Address
39
- */
40
- public $sa;
41
-
42
- /**
43
- * method to return the rdata portion of the packet as a string
44
- *
45
- * @return string
46
- * @access protected
47
- *
48
- */
49
- protected function rrToString()
50
- {
51
- return $this->formatString($this->isdnaddress) . ' ' .
52
- $this->formatString($this->sa);
53
- }
54
-
55
- /**
56
- * parses the rdata portion from a standard DNS config line
57
- *
58
- * @param array $rdata a string split line of values for the rdata
59
- *
60
- * @return boolean
61
- * @access protected
62
- *
63
- */
64
- protected function rrFromString(array $rdata)
65
- {
66
- $data = $this->buildString($rdata);
67
- if (count($data) >= 1) {
68
-
69
- $this->isdnaddress = $data[0];
70
- if (isset($data[1])) {
71
-
72
- $this->sa = $data[1];
73
- }
74
-
75
- return true;
76
- }
77
-
78
- return false;
79
- }
80
-
81
- /**
82
- * parses the rdata of the Net_DNS2_Packet object
83
- *
84
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
85
- *
86
- * @return boolean
87
- * @access protected
88
- *
89
- */
90
- protected function rrSet(Net_DNS2_Packet &$packet)
91
- {
92
- if ($this->rdlength > 0) {
93
-
94
- $this->isdnaddress = Net_DNS2_Packet::label($packet, $packet->offset);
95
-
96
- //
97
- // look for a SA (sub address) - it's optional
98
- //
99
- if ( (strlen($this->isdnaddress) + 1) < $this->rdlength) {
100
-
101
- $this->sa = Net_DNS2_Packet::label($packet, $packet->offset);
102
- } else {
103
-
104
- $this->sa = '';
105
- }
106
-
107
- return true;
108
- }
109
-
110
- return false;
111
- }
112
-
113
- /**
114
- * returns the rdata portion of the DNS packet
115
- *
116
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
117
- * compressed names
118
- *
119
- * @return mixed either returns a binary packed
120
- * string or null on failure
121
- * @access protected
122
- *
123
- */
124
- protected function rrGet(Net_DNS2_Packet &$packet)
125
- {
126
- if (strlen($this->isdnaddress) > 0) {
127
-
128
- $data = chr(strlen($this->isdnaddress)) . $this->isdnaddress;
129
- if (!empty($this->sa)) {
130
-
131
- $data .= chr(strlen($this->sa));
132
- $data .= $this->sa;
133
- }
134
-
135
- $packet->offset += strlen($data);
136
-
137
- return $data;
138
- }
139
-
140
- return null;
141
- }
142
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/KEY.php DELETED
@@ -1,37 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 0.6.0
17
- *
18
- */
19
-
20
- /**
21
- * the KEY RR is implemented the same as the DNSKEY RR, the only difference
22
- * is how the flags data is parsed.
23
- *
24
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
25
- * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
26
- * | A/C | Z | XT| Z | Z | NAMTYP| Z | Z | Z | Z | SIG |
27
- * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
28
- *
29
- * DNSKEY only uses bits 7 and 15
30
- *
31
- * We're not doing anything with these flags right now, so duplicating the
32
- * class like this is fine.
33
- *
34
- */
35
- class Net_DNS2_RR_KEY extends Net_DNS2_RR_DNSKEY
36
- {
37
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/KX.php DELETED
@@ -1,131 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 0.6.0
17
- *
18
- */
19
-
20
- /**
21
- * KX Resource Record - RFC2230 section 3.1
22
- *
23
- * This class is almost identical to MX, except that the the exchanger
24
- * domain is not compressed, it's added as a label
25
- *
26
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
27
- * | PREFERENCE |
28
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
29
- * / EXCHANGER /
30
- * / /
31
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
32
- *
33
- */
34
- class Net_DNS2_RR_KX extends Net_DNS2_RR
35
- {
36
- /*
37
- * the preference for this mail exchanger
38
- */
39
- public $preference;
40
-
41
- /*
42
- * the hostname of the mail exchanger
43
- */
44
- public $exchange;
45
-
46
- /**
47
- * method to return the rdata portion of the packet as a string
48
- *
49
- * @return string
50
- * @access protected
51
- *
52
- */
53
- protected function rrToString()
54
- {
55
- return $this->preference . ' ' . $this->cleanString($this->exchange) . '.';
56
- }
57
-
58
- /**
59
- * parses the rdata portion from a standard DNS config line
60
- *
61
- * @param array $rdata a string split line of values for the rdata
62
- *
63
- * @return boolean
64
- * @access protected
65
- *
66
- */
67
- protected function rrFromString(array $rdata)
68
- {
69
- $this->preference = array_shift($rdata);
70
- $this->exchange = $this->cleanString(array_shift($rdata));
71
-
72
- return true;
73
- }
74
-
75
- /**
76
- * parses the rdata of the Net_DNS2_Packet object
77
- *
78
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
79
- *
80
- * @return boolean
81
- * @access protected
82
- *
83
- */
84
- protected function rrSet(Net_DNS2_Packet &$packet)
85
- {
86
- if ($this->rdlength > 0) {
87
-
88
- //
89
- // parse the preference
90
- //
91
- $x = unpack('npreference', $this->rdata);
92
- $this->preference = $x['preference'];
93
-
94
- //
95
- // get the exchange entry server)
96
- //
97
- $offset = $packet->offset + 2;
98
- $this->exchange = Net_DNS2_Packet::label($packet, $offset);
99
-
100
- return true;
101
- }
102
-
103
- return false;
104
- }
105
-
106
- /**
107
- * returns the rdata portion of the DNS packet
108
- *
109
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
110
- * compressed names
111
- *
112
- * @return mixed either returns a binary packed
113
- * string or null on failure
114
- * @access protected
115
- *
116
- */
117
- protected function rrGet(Net_DNS2_Packet &$packet)
118
- {
119
- if (strlen($this->exchange) > 0) {
120
-
121
- $data = pack('nC', $this->preference, strlen($this->exchange)) .
122
- $this->exchange;
123
-
124
- $packet->offset += strlen($data);
125
-
126
- return $data;
127
- }
128
-
129
- return null;
130
- }
131
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/L32.php DELETED
@@ -1,132 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 1.3.1
17
- *
18
- */
19
-
20
- /**
21
- * L32 Resource Record - RFC6742 section 2.2
22
- *
23
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
24
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
25
- * | Preference | Locator32 (16 MSBs) |
26
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
27
- * | Locator32 (16 LSBs) |
28
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
29
- *
30
- */
31
- class Net_DNS2_RR_L32 extends Net_DNS2_RR
32
- {
33
- /*
34
- * The preference
35
- */
36
- public $preference;
37
-
38
- /*
39
- * The locator32 field
40
- */
41
- public $locator32;
42
-
43
- /**
44
- * method to return the rdata portion of the packet as a string
45
- *
46
- * @return string
47
- * @access protected
48
- *
49
- */
50
- protected function rrToString()
51
- {
52
- return $this->preference . ' ' . $this->locator32;
53
- }
54
-
55
- /**
56
- * parses the rdata portion from a standard DNS config line
57
- *
58
- * @param array $rdata a string split line of values for the rdata
59
- *
60
- * @return boolean
61
- * @access protected
62
- *
63
- */
64
- protected function rrFromString(array $rdata)
65
- {
66
- $this->preference = array_shift($rdata);
67
- $this->locator32 = array_shift($rdata);
68
-
69
- return true;
70
- }
71
-
72
- /**
73
- * parses the rdata of the Net_DNS2_Packet object
74
- *
75
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
76
- *
77
- * @return boolean
78
- * @access protected
79
- *
80
- */
81
- protected function rrSet(Net_DNS2_Packet &$packet)
82
- {
83
- if ($this->rdlength > 0) {
84
-
85
- //
86
- // unpack the values
87
- //
88
- $x = unpack('npreference/C4locator', $this->rdata);
89
-
90
- $this->preference = $x['preference'];
91
-
92
- //
93
- // build the locator value
94
- //
95
- $this->locator32 = $x['locator1'] . '.' . $x['locator2'] . '.' .
96
- $x['locator3'] . '.' . $x['locator4'];
97
-
98
- return true;
99
- }
100
-
101
- return false;
102
- }
103
-
104
- /**
105
- * returns the rdata portion of the DNS packet
106
- *
107
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
108
- * compressed names
109
- *
110
- * @return mixed either returns a binary packed
111
- * string or null on failure
112
- * @access protected
113
- *
114
- */
115
- protected function rrGet(Net_DNS2_Packet &$packet)
116
- {
117
- if (strlen($this->locator32) > 0) {
118
-
119
- //
120
- // break out the locator value
121
- //
122
- $n = explode('.', $this->locator32);
123
-
124
- //
125
- // pack the data
126
- //
127
- return pack('nC4', $this->preference, $n[0], $n[1], $n[2], $n[3]);
128
- }
129
-
130
- return null;
131
- }
132
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/L64.php DELETED
@@ -1,139 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 1.3.1
17
- *
18
- */
19
-
20
- /**
21
- * L64 Resource Record - RFC6742 section 2.3
22
- *
23
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
24
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
25
- * | Preference | |
26
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +
27
- * | Locator64 |
28
- * + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
29
- * | |
30
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
31
- *
32
- */
33
- class Net_DNS2_RR_L64 extends Net_DNS2_RR
34
- {
35
- /*
36
- * The preference
37
- */
38
- public $preference;
39
-
40
- /*
41
- * The locator64 field
42
- */
43
- public $locator64;
44
-
45
- /**
46
- * method to return the rdata portion of the packet as a string
47
- *
48
- * @return string
49
- * @access protected
50
- *
51
- */
52
- protected function rrToString()
53
- {
54
- return $this->preference . ' ' . $this->locator64;
55
- }
56
-
57
- /**
58
- * parses the rdata portion from a standard DNS config line
59
- *
60
- * @param array $rdata a string split line of values for the rdata
61
- *
62
- * @return boolean
63
- * @access protected
64
- *
65
- */
66
- protected function rrFromString(array $rdata)
67
- {
68
- $this->preference = array_shift($rdata);
69
- $this->locator64 = array_shift($rdata);
70
-
71
- return true;
72
- }
73
-
74
- /**
75
- * parses the rdata of the Net_DNS2_Packet object
76
- *
77
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
78
- *
79
- * @return boolean
80
- * @access protected
81
- *
82
- */
83
- protected function rrSet(Net_DNS2_Packet &$packet)
84
- {
85
- if ($this->rdlength > 0) {
86
-
87
- //
88
- // unpack the values
89
- //
90
- $x = unpack('npreference/n4locator', $this->rdata);
91
-
92
- $this->preference = $x['preference'];
93
-
94
- //
95
- // build the locator64
96
- //
97
- $this->locator64 = dechex($x['locator1']) . ':' .
98
- dechex($x['locator2']) . ':' .
99
- dechex($x['locator3']) . ':' .
100
- dechex($x['locator4']);
101
-
102
- return true;
103
- }
104
-
105
- return false;
106
- }
107
-
108
- /**
109
- * returns the rdata portion of the DNS packet
110
- *
111
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
112
- * compressed names
113
- *
114
- * @return mixed either returns a binary packed
115
- * string or null on failure
116
- * @access protected
117
- *
118
- */
119
- protected function rrGet(Net_DNS2_Packet &$packet)
120
- {
121
- if (strlen($this->locator64) > 0) {
122
-
123
- //
124
- // break out the locator64
125
- //
126
- $n = explode(':', $this->locator64);
127
-
128
- //
129
- // pack the data
130
- //
131
- return pack(
132
- 'n5', $this->preference, hexdec($n[0]), hexdec($n[1]),
133
- hexdec($n[2]), hexdec($n[3])
134
- );
135
- }
136
-
137
- return null;
138
- }
139
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/LOC.php DELETED
@@ -1,392 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 0.6.0
17
- *
18
- */
19
-
20
- /**
21
- * LOC Resource Record - RFC1876 section 2
22
- *
23
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
24
- * | VERSION | SIZE |
25
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
26
- * | HORIZ PRE | VERT PRE |
27
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
28
- * | LATITUDE |
29
- * | |
30
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
31
- * | LONGITUDE |
32
- * | |
33
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
34
- * | ALTITUDE |
35
- * | |
36
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
37
- *
38
- */
39
- class Net_DNS2_RR_LOC extends Net_DNS2_RR
40
- {
41
- /*
42
- * the LOC version- should only ever be 0
43
- */
44
- public $version;
45
-
46
- /*
47
- * The diameter of a sphere enclosing the described entity
48
- */
49
- public $size;
50
-
51
- /*
52
- * The horizontal precision of the data
53
- */
54
- public $horiz_pre;
55
-
56
- /*
57
- * The vertical precision of the data
58
- */
59
- public $vert_pre;
60
-
61
- /*
62
- * The latitude - stored in decimal degrees
63
- */
64
- public $latitude;
65
-
66
- /*
67
- * The longitude - stored in decimal degrees
68
- */
69
- public $longitude;
70
-
71
- /*
72
- * The altitude - stored in decimal
73
- */
74
- public $altitude;
75
-
76
- /*
77
- * used for quick power-of-ten lookups
78
- */
79
- private $_powerOfTen = [ 1, 10, 100, 1000, 10000, 100000,
80
- 1000000,10000000,100000000,1000000000 ];
81
-
82
- /*
83
- * some conversion values
84
- */
85
- const CONV_SEC = 1000;
86
- const CONV_MIN = 60000;
87
- const CONV_DEG = 3600000;
88
-
89
- const REFERENCE_ALT = 10000000;
90
- const REFERENCE_LATLON = 2147483648;
91
-
92
- /**
93
- * method to return the rdata portion of the packet as a string
94
- *
95
- * @return string
96
- * @access protected
97
- *
98
- */
99
- protected function rrToString()
100
- {
101
- if ($this->version == 0) {
102
-
103
- return $this->_d2Dms($this->latitude, 'LAT') . ' ' .
104
- $this->_d2Dms($this->longitude, 'LNG') . ' ' .
105
- sprintf('%.2fm', $this->altitude) . ' ' .
106
- sprintf('%.2fm', $this->size) . ' ' .
107
- sprintf('%.2fm', $this->horiz_pre) . ' ' .
108
- sprintf('%.2fm', $this->vert_pre);
109
- }
110
-
111
- return '';
112
- }
113
-
114
- /**
115
- * parses the rdata portion from a standard DNS config line
116
- *
117
- * @param array $rdata a string split line of values for the rdata
118
- *
119
- * @return boolean
120
- * @access protected
121
- *
122
- */
123
- protected function rrFromString(array $rdata)
124
- {
125
- //
126
- // format as defined by RFC1876 section 3
127
- //
128
- // d1 [m1 [s1]] {"N"|"S"} d2 [m2 [s2]] {"E"|"W"} alt["m"]
129
- // [siz["m"] [hp["m"] [vp["m"]]]]
130
- //
131
- $res = preg_match(
132
- '/^(\d+) \s+((\d+) \s+)?(([\d.]+) \s+)?(N|S) \s+(\d+) ' .
133
- '\s+((\d+) \s+)?(([\d.]+) \s+)?(E|W) \s+(-?[\d.]+) m?(\s+ ' .
134
- '([\d.]+) m?)?(\s+ ([\d.]+) m?)?(\s+ ([\d.]+) m?)?/ix',
135
- implode(' ', $rdata), $x
136
- );
137
-
138
- if ($res) {
139
-
140
- //
141
- // latitude
142
- //
143
- $latdeg = $x[1];
144
- $latmin = (isset($x[3])) ? $x[3] : 0;
145
- $latsec = (isset($x[5])) ? $x[5] : 0;
146
- $lathem = strtoupper($x[6]);
147
-
148
- $this->latitude = $this->_dms2d($latdeg, $latmin, $latsec, $lathem);
149
-
150
- //
151
- // longitude
152
- //
153
- $londeg = $x[7];
154
- $lonmin = (isset($x[9])) ? $x[9] : 0;
155
- $lonsec = (isset($x[11])) ? $x[11] : 0;
156
- $lonhem = strtoupper($x[12]);
157
-
158
- $this->longitude = $this->_dms2d($londeg, $lonmin, $lonsec, $lonhem);
159
-
160
- //
161
- // the rest of teh values
162
- //
163
- $version = 0;
164
-
165
- $this->size = (isset($x[15])) ? $x[15] : 1;
166
- $this->horiz_pre = ((isset($x[17])) ? $x[17] : 10000);
167
- $this->vert_pre = ((isset($x[19])) ? $x[19] : 10);
168
- $this->altitude = $x[13];
169
-
170
- return true;
171
- }
172
-
173
- return false;
174
- }
175
-
176
- /**
177
- * parses the rdata of the Net_DNS2_Packet object
178
- *
179
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
180
- *
181
- * @return boolean
182
- * @access protected
183
- *
184
- */
185
- protected function rrSet(Net_DNS2_Packet &$packet)
186
- {
187
- if ($this->rdlength > 0) {
188
-
189
- //
190
- // unpack all the values
191
- //
192
- $x = unpack(
193
- 'Cver/Csize/Choriz_pre/Cvert_pre/Nlatitude/Nlongitude/Naltitude',
194
- $this->rdata
195
- );
196
-
197
- //
198
- // version must be 0 per RFC 1876 section 2
199
- //
200
- $this->version = $x['ver'];
201
- if ($this->version == 0) {
202
-
203
- $this->size = $this->_precsizeNtoA($x['size']);
204
- $this->horiz_pre = $this->_precsizeNtoA($x['horiz_pre']);
205
- $this->vert_pre = $this->_precsizeNtoA($x['vert_pre']);
206
-
207
- //
208
- // convert the latitude and longitude to degress in decimal
209
- //
210
- if ($x['latitude'] < 0) {
211
-
212
- $this->latitude = ($x['latitude'] +
213
- self::REFERENCE_LATLON) / self::CONV_DEG;
214
- } else {
215
-
216
- $this->latitude = ($x['latitude'] -
217
- self::REFERENCE_LATLON) / self::CONV_DEG;
218
- }
219
-
220
- if ($x['longitude'] < 0) {
221
-
222
- $this->longitude = ($x['longitude'] +
223
- self::REFERENCE_LATLON) / self::CONV_DEG;
224
- } else {
225
-
226
- $this->longitude = ($x['longitude'] -
227
- self::REFERENCE_LATLON) / self::CONV_DEG;
228
- }
229
-
230
- //
231
- // convert down the altitude
232
- //
233
- $this->altitude = ($x['altitude'] - self::REFERENCE_ALT) / 100;
234
-
235
- return true;
236
-
237
- } else {
238
-
239
- return false;
240
- }
241
-
242
- return true;
243
- }
244
-
245
- return false;
246
- }
247
-
248
- /**
249
- * returns the rdata portion of the DNS packet
250
- *
251
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
252
- * compressed names
253
- *
254
- * @return mixed either returns a binary packed
255
- * string or null on failure
256
- * @access protected
257
- *
258
- */
259
- protected function rrGet(Net_DNS2_Packet &$packet)
260
- {
261
- if ($this->version == 0) {
262
-
263
- $lat = 0;
264
- $lng = 0;
265
-
266
- if ($this->latitude < 0) {
267
-
268
- $lat = ($this->latitude * self::CONV_DEG) - self::REFERENCE_LATLON;
269
- } else {
270
-
271
- $lat = ($this->latitude * self::CONV_DEG) + self::REFERENCE_LATLON;
272
- }
273
-
274
- if ($this->longitude < 0) {
275
-
276
- $lng = ($this->longitude * self::CONV_DEG) - self::REFERENCE_LATLON;
277
- } else {
278
-
279
- $lng = ($this->longitude * self::CONV_DEG) + self::REFERENCE_LATLON;
280
- }
281
-
282
- $packet->offset += 16;
283
-
284
- return pack(
285
- 'CCCCNNN',
286
- $this->version,
287
- $this->_precsizeAtoN($this->size),
288
- $this->_precsizeAtoN($this->horiz_pre),
289
- $this->_precsizeAtoN($this->vert_pre),
290
- $lat, $lng,
291
- ($this->altitude * 100) + self::REFERENCE_ALT
292
- );
293
- }
294
-
295
- return null;
296
- }
297
-
298
- /**
299
- * takes an XeY precision/size value, returns a string representation.
300
- * shamlessly stolen from RFC1876 Appendix A
301
- *
302
- * @param integer $prec the value to convert
303
- *
304
- * @return string
305
- * @access private
306
- *
307
- */
308
- private function _precsizeNtoA($prec)
309
- {
310
- $mantissa = (($prec >> 4) & 0x0f) % 10;
311
- $exponent = (($prec >> 0) & 0x0f) % 10;
312
-
313
- return $mantissa * $this->_powerOfTen[$exponent];
314
- }
315
-
316
- /**
317
- * converts ascii size/precision X * 10**Y(cm) to 0xXY.
318
- * shamlessly stolen from RFC1876 Appendix A
319
- *
320
- * @param string $prec the value to convert
321
- *
322
- * @return integer
323
- * @access private
324
- *
325
- */
326
- private function _precsizeAtoN($prec)
327
- {
328
- $exponent = 0;
329
- while ($prec >= 10) {
330
-
331
- $prec /= 10;
332
- ++$exponent;
333
- }
334
-
335
- return ($prec << 4) | ($exponent & 0x0f);
336
- }
337
-
338
- /**
339
- * convert lat/lng in deg/min/sec/hem to decimal value
340
- *
341
- * @param integer $deg the degree value
342
- * @param integer $min the minutes value
343
- * @param integer $sec the seconds value
344
- * @param string $hem the hemisphere (N/E/S/W)
345
- *
346
- * @return float the decinmal value
347
- * @access private
348
- *
349
- */
350
- private function _dms2d($deg, $min, $sec, $hem)
351
- {
352
- $deg = $deg - 0;
353
- $min = $min - 0;
354
-
355
- $sign = ($hem == 'W' || $hem == 'S') ? -1 : 1;
356
- return ((($sec/60+$min)/60)+$deg) * $sign;
357
- }
358
-
359
- /**
360
- * convert lat/lng in decimal to deg/min/sec/hem
361
- *
362
- * @param float $data the decimal value
363
- * @param string $latlng either LAT or LNG so we can determine the HEM value
364
- *
365
- * @return string
366
- * @access private
367
- *
368
- */
369
- private function _d2Dms($data, $latlng)
370
- {
371
- $deg = 0;
372
- $min = 0;
373
- $sec = 0;
374
- $msec = 0;
375
- $hem = '';
376
-
377
- if ($latlng == 'LAT') {
378
- $hem = ($data > 0) ? 'N' : 'S';
379
- } else {
380
- $hem = ($data > 0) ? 'E' : 'W';
381
- }
382
-
383
- $data = abs($data);
384
-
385
- $deg = (int)$data;
386
- $min = (int)(($data - $deg) * 60);
387
- $sec = (int)(((($data - $deg) * 60) - $min) * 60);
388
- $msec = round((((((($data - $deg) * 60) - $min) * 60) - $sec) * 1000));
389
-
390
- return sprintf('%d %02d %02d.%03d %s', $deg, $min, $sec, round($msec), $hem);
391
- }
392
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/LP.php DELETED
@@ -1,129 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 1.3.1
17
- *
18
- */
19
-
20
- /**
21
- * LP Resource Record - RFC6742 section 2.4
22
- *
23
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
24
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
25
- * | Preference | /
26
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ /
27
- * / /
28
- * / FQDN /
29
- * / /
30
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
31
- *
32
- */
33
- class Net_DNS2_RR_LP extends Net_DNS2_RR
34
- {
35
- /*
36
- * The preference
37
- */
38
- public $preference;
39
-
40
- /*
41
- * The fdqn field
42
- */
43
- public $fqdn;
44
-
45
- /**
46
- * method to return the rdata portion of the packet as a string
47
- *
48
- * @return string
49
- * @access protected
50
- *
51
- */
52
- protected function rrToString()
53
- {
54
- return $this->preference . ' ' . $this->fqdn . '.';
55
- }
56
-
57
- /**
58
- * parses the rdata portion from a standard DNS config line
59
- *
60
- * @param array $rdata a string split line of values for the rdata
61
- *
62
- * @return boolean
63
- * @access protected
64
- *
65
- */
66
- protected function rrFromString(array $rdata)
67
- {
68
- $this->preference = array_shift($rdata);
69
- $this->fqdn = trim(array_shift($rdata), '.');
70
-
71
- return true;
72
- }
73
-
74
- /**
75
- * parses the rdata of the Net_DNS2_Packet object
76
- *
77
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
78
- *
79
- * @return boolean
80
- * @access protected
81
- *
82
- */
83
- protected function rrSet(Net_DNS2_Packet &$packet)
84
- {
85
- if ($this->rdlength > 0) {
86
-
87
- //
88
- // parse the preference
89
- //
90
- $x = unpack('npreference', $this->rdata);
91
- $this->preference = $x['preference'];
92
- $offset = $packet->offset + 2;
93
-
94
- //
95
- // get the hostname
96
- //
97
- $this->fqdn = Net_DNS2_Packet::expand($packet, $offset);
98
-
99
- return true;
100
- }
101
-
102
- return false;
103
- }
104
-
105
- /**
106
- * returns the rdata portion of the DNS packet
107
- *
108
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
109
- * compressed names
110
- *
111
- * @return mixed either returns a binary packed
112
- * string or null on failure
113
- * @access protected
114
- *
115
- */
116
- protected function rrGet(Net_DNS2_Packet &$packet)
117
- {
118
- if (strlen($this->fqdn) > 0) {
119
-
120
- $data = pack('n', $this->preference);
121
- $packet->offset += 2;
122
-
123
- $data .= $packet->compress($this->fqdn, $packet->offset);
124
- return $data;
125
- }
126
-
127
- return null;
128
- }
129
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/MX.php DELETED
@@ -1,127 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 0.6.0
17
- *
18
- */
19
-
20
- /**
21
- * MX Resource Record - RFC1035 section 3.3.9
22
- *
23
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
24
- * | PREFERENCE |
25
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
26
- * / EXCHANGE /
27
- * / /
28
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
29
- *
30
- */
31
- class Net_DNS2_RR_MX extends Net_DNS2_RR
32
- {
33
- /*
34
- * the preference for this mail exchanger
35
- */
36
- public $preference;
37
-
38
- /*
39
- * the hostname of the mail exchanger
40
- */
41
- public $exchange;
42
-
43
- /**
44
- * method to return the rdata portion of the packet as a string
45
- *
46
- * @return string
47
- * @access protected
48
- *
49
- */
50
- protected function rrToString()
51
- {
52
- return $this->preference . ' ' . $this->cleanString($this->exchange) . '.';
53
- }
54
-
55
- /**
56
- * parses the rdata portion from a standard DNS config line
57
- *
58
- * @param array $rdata a string split line of values for the rdata
59
- *
60
- * @return boolean
61
- * @access protected
62
- *
63
- */
64
- protected function rrFromString(array $rdata)
65
- {
66
- $this->preference = array_shift($rdata);
67
- $this->exchange = $this->cleanString(array_shift($rdata));
68
-
69
- return true;
70
- }
71
-
72
- /**
73
- * parses the rdata of the Net_DNS2_Packet object
74
- *
75
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
76
- *
77
- * @return boolean
78
- * @access protected
79
- *
80
- */
81
- protected function rrSet(Net_DNS2_Packet &$packet)
82
- {
83
- if ($this->rdlength > 0) {
84
-
85
- //
86
- // parse the preference
87
- //
88
- $x = unpack('npreference', $this->rdata);
89
- $this->preference = $x['preference'];
90
-
91
- //
92
- // get the exchange entry server)
93
- //
94
- $offset = $packet->offset + 2;
95
- $this->exchange = Net_DNS2_Packet::expand($packet, $offset);
96
-
97
- return true;
98
- }
99
-
100
- return false;
101
- }
102
-
103
- /**
104
- * returns the rdata portion of the DNS packet
105
- *
106
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
107
- * compressed names
108
- *
109
- * @return mixed either returns a binary packed
110
- * string or null on failure
111
- * @access protected
112
- *
113
- */
114
- protected function rrGet(Net_DNS2_Packet &$packet)
115
- {
116
- if (strlen($this->exchange) > 0) {
117
-
118
- $data = pack('n', $this->preference);
119
- $packet->offset += 2;
120
-
121
- $data .= $packet->compress($this->exchange, $packet->offset);
122
- return $data;
123
- }
124
-
125
- return null;
126
- }
127
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/NAPTR.php DELETED
@@ -1,183 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 0.6.0
17
- *
18
- */
19
-
20
- /**
21
- * NAPTR Resource Record - RFC2915
22
- *
23
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
24
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
25
- * | ORDER |
26
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
27
- * | PREFERENCE |
28
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
29
- * / FLAGS /
30
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
31
- * / SERVICES /
32
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
33
- * / REGEXP /
34
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
35
- * / REPLACEMENT /
36
- * / /
37
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
38
- *
39
- */
40
- class Net_DNS2_RR_NAPTR extends Net_DNS2_RR
41
- {
42
- /*
43
- * the order in which the NAPTR records MUST be processed
44
- */
45
- public $order;
46
-
47
- /*
48
- * specifies the order in which NAPTR records with equal "order"
49
- * values SHOULD be processed
50
- */
51
- public $preference;
52
-
53
- /*
54
- * rewrite flags
55
- */
56
- public $flags;
57
-
58
- /*
59
- * Specifies the service(s) available down this rewrite path
60
- */
61
- public $services;
62
-
63
- /*
64
- * regular expression
65
- */
66
- public $regexp;
67
-
68
- /*
69
- * The next NAME to query for NAPTR, SRV, or address records
70
- * depending on the value of the flags field
71
- */
72
- public $replacement;
73
-
74
- /**
75
- * method to return the rdata portion of the packet as a string
76
- *
77
- * @return string
78
- * @access protected
79
- *
80
- */
81
- protected function rrToString()
82
- {
83
- return $this->order . ' ' . $this->preference . ' ' .
84
- $this->formatString($this->flags) . ' ' .
85
- $this->formatString($this->services) . ' ' .
86
- $this->formatString($this->regexp) . ' ' .
87
- $this->cleanString($this->replacement) . '.';
88
- }
89
-
90
- /**
91
- * parses the rdata portion from a standard DNS config line
92
- *
93
- * @param array $rdata a string split line of values for the rdata
94
- *
95
- * @return boolean
96
- * @access protected
97
- *
98
- */
99
- protected function rrFromString(array $rdata)
100
- {
101
- $this->order = array_shift($rdata);
102
- $this->preference = array_shift($rdata);
103
-
104
- $data = $this->buildString($rdata);
105
- if (count($data) == 4) {
106
-
107
- $this->flags = $data[0];
108
- $this->services = $data[1];
109
- $this->regexp = $data[2];
110
- $this->replacement = $this->cleanString($data[3]);
111
-
112
- return true;
113
- }
114
-
115
- return false;
116
- }
117
-
118
- /**
119
- * parses the rdata of the Net_DNS2_Packet object
120
- *
121
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
122
- *
123
- * @return boolean
124
- * @access protected
125
- *
126
- */
127
- protected function rrSet(Net_DNS2_Packet &$packet)
128
- {
129
- if ($this->rdlength > 0) {
130
-
131
- //
132
- // unpack the order and preference
133
- //
134
- $x = unpack('norder/npreference', $this->rdata);
135
-
136
- $this->order = $x['order'];
137
- $this->preference = $x['preference'];
138
-
139
- $offset = $packet->offset + 4;
140
-
141
- $this->flags = Net_DNS2_Packet::label($packet, $offset);
142
- $this->services = Net_DNS2_Packet::label($packet, $offset);
143
- $this->regexp = Net_DNS2_Packet::label($packet, $offset);
144
-
145
- $this->replacement = Net_DNS2_Packet::expand($packet, $offset);
146
-
147
- return true;
148
- }
149
-
150
- return false;
151
- }
152
-
153
- /**
154
- * returns the rdata portion of the DNS packet
155
- *
156
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
157
- * compressed names
158
- *
159
- * @return mixed either returns a binary packed
160
- * string or null on failure
161
- * @access protected
162
- *
163
- */
164
- protected function rrGet(Net_DNS2_Packet &$packet)
165
- {
166
- if ( (isset($this->order)) && (strlen($this->services) > 0) ) {
167
-
168
- $data = pack('nn', $this->order, $this->preference);
169
-
170
- $data .= chr(strlen($this->flags)) . $this->flags;
171
- $data .= chr(strlen($this->services)) . $this->services;
172
- $data .= chr(strlen($this->regexp)) . $this->regexp;
173
-
174
- $packet->offset += strlen($data);
175
-
176
- $data .= $packet->compress($this->replacement, $packet->offset);
177
-
178
- return $data;
179
- }
180
-
181
- return null;
182
- }
183
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/NID.php DELETED
@@ -1,139 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 1.3.1
17
- *
18
- */
19
-
20
- /**
21
- * NID Resource Record - RFC6742 section 2.1
22
- *
23
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
24
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
25
- * | Preference | |
26
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +
27
- * | NodeID |
28
- * + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
29
- * | |
30
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
31
- *
32
- */
33
- class Net_DNS2_RR_NID extends Net_DNS2_RR
34
- {
35
- /*
36
- * The preference
37
- */
38
- public $preference;
39
-
40
- /*
41
- * The node ID field
42
- */
43
- public $nodeid;
44
-
45
- /**
46
- * method to return the rdata portion of the packet as a string
47
- *
48
- * @return string
49
- * @access protected
50
- *
51
- */
52
- protected function rrToString()
53
- {
54
- return $this->preference . ' ' . $this->nodeid;
55
- }
56
-
57
- /**
58
- * parses the rdata portion from a standard DNS config line
59
- *
60
- * @param array $rdata a string split line of values for the rdata
61
- *
62
- * @return boolean
63
- * @access protected
64
- *
65
- */
66
- protected function rrFromString(array $rdata)
67
- {
68
- $this->preference = array_shift($rdata);
69
- $this->nodeid = array_shift($rdata);
70
-
71
- return true;
72
- }
73
-
74
- /**
75
- * parses the rdata of the Net_DNS2_Packet object
76
- *
77
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
78
- *
79
- * @return boolean
80
- * @access protected
81
- *
82
- */
83
- protected function rrSet(Net_DNS2_Packet &$packet)
84
- {
85
- if ($this->rdlength > 0) {
86
-
87
- //
88
- // unpack the values
89
- //
90
- $x = unpack('npreference/n4nodeid', $this->rdata);
91
-
92
- $this->preference = $x['preference'];
93
-
94
- //
95
- // build the node id
96
- //
97
- $this->nodeid = dechex($x['nodeid1']) . ':' .
98
- dechex($x['nodeid2']) . ':' .
99
- dechex($x['nodeid3']) . ':' .
100
- dechex($x['nodeid4']);
101
-
102
- return true;
103
- }
104
-
105
- return false;
106
- }
107
-
108
- /**
109
- * returns the rdata portion of the DNS packet
110
- *
111
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
112
- * compressed names
113
- *
114
- * @return mixed either returns a binary packed
115
- * string or null on failure
116
- * @access protected
117
- *
118
- */
119
- protected function rrGet(Net_DNS2_Packet &$packet)
120
- {
121
- if (strlen($this->nodeid) > 0) {
122
-
123
- //
124
- // break out the node id
125
- //
126
- $n = explode(':', $this->nodeid);
127
-
128
- //
129
- // pack the data
130
- //
131
- return pack(
132
- 'n5', $this->preference, hexdec($n[0]), hexdec($n[1]),
133
- hexdec($n[2]), hexdec($n[3])
134
- );
135
- }
136
-
137
- return null;
138
- }
139
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/NIMLOC.php DELETED
@@ -1,82 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 0.6.0
17
- *
18
- */
19
-
20
- /**
21
- * NIMLOC Resource Record - undefined; the rdata is simply used as-is in it's
22
- * binary format, so not process has to be done.
23
- *
24
- */
25
- class Net_DNS2_RR_NIMLOC extends Net_DNS2_RR
26
- {
27
- /**
28
- * method to return the rdata portion of the packet as a string
29
- *
30
- * @return string
31
- * @access protected
32
- *
33
- */
34
- protected function rrToString()
35
- {
36
- return '';
37
- }
38
-
39
- /**
40
- * parses the rdata portion from a standard DNS config line
41
- *
42
- * @param array $rdata a string split line of values for the rdata
43
- *
44
- * @return boolean
45
- * @access protected
46
- *
47
- */
48
- protected function rrFromString(array $rdata)
49
- {
50
- return true;
51
- }
52
-
53
- /**
54
- * parses the rdata of the Net_DNS2_Packet object
55
- *
56
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
57
- *
58
- * @return boolean
59
- * @access protected
60
- *
61
- */
62
- protected function rrSet(Net_DNS2_Packet &$packet)
63
- {
64
- return true;
65
- }
66
-
67
- /**
68
- * returns the rdata portion of the DNS packet
69
- *
70
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
71
- * compressed names
72
- *
73
- * @return mixed either returns a binary packed
74
- * string or null on failure
75
- * @access protected
76
- *
77
- */
78
- protected function rrGet(Net_DNS2_Packet &$packet)
79
- {
80
- return $this->rdata;
81
- }
82
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/NS.php DELETED
@@ -1,105 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 0.6.0
17
- *
18
- */
19
-
20
- /**
21
- * NS Resource Record - RFC1035 section 3.3.11
22
- *
23
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
24
- * / NSDNAME /
25
- * / /
26
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
27
- *
28
- */
29
- class Net_DNS2_RR_NS extends Net_DNS2_RR
30
- {
31
- /*
32
- * the hostname of the DNS server
33
- */
34
- public $nsdname;
35
-
36
- /**
37
- * method to return the rdata portion of the packet as a string
38
- *
39
- * @return string
40
- * @access protected
41
- *
42
- */
43
- protected function rrToString()
44
- {
45
- return $this->cleanString($this->nsdname) . '.';
46
- }
47
-
48
- /**
49
- * parses the rdata portion from a standard DNS config line
50
- *
51
- * @param array $rdata a string split line of values for the rdata
52
- *
53
- * @return boolean
54
- * @access protected
55
- *
56
- */
57
- protected function rrFromString(array $rdata)
58
- {
59
- $this->nsdname = $this->cleanString(array_shift($rdata));
60
- return true;
61
- }
62
-
63
- /**
64
- * parses the rdata of the Net_DNS2_Packet object
65
- *
66
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
67
- *
68
- * @return boolean
69
- * @access protected
70
- *
71
- */
72
- protected function rrSet(Net_DNS2_Packet &$packet)
73
- {
74
- if ($this->rdlength > 0) {
75
-
76
- $offset = $packet->offset;
77
- $this->nsdname = Net_DNS2_Packet::expand($packet, $offset);
78
-
79
- return true;
80
- }
81
-
82
- return false;
83
- }
84
-
85
- /**
86
- * returns the rdata portion of the DNS packet
87
- *
88
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
89
- * compressed names
90
- *
91
- * @return mixed either returns a binary packed
92
- * string or null on failure
93
- * @access protected
94
- *
95
- */
96
- protected function rrGet(Net_DNS2_Packet &$packet)
97
- {
98
- if (strlen($this->nsdname) > 0) {
99
-
100
- return $packet->compress($this->nsdname, $packet->offset);
101
- }
102
-
103
- return null;
104
- }
105
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/NSAP.php DELETED
@@ -1,214 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 0.6.0
17
- *
18
- */
19
-
20
- /**
21
- * NSAP Resource Record - RFC1706
22
- *
23
- * |--------------|
24
- * | <-- IDP --> |
25
- * |--------------|-------------------------------------|
26
- * | AFI | IDI | <-- DSP --> |
27
- * |-----|--------|-------------------------------------|
28
- * | 47 | 0005 | DFI | AA |Rsvd | RD |Area | ID |Sel |
29
- * |-----|--------|-----|----|-----|----|-----|----|----|
30
- * octets | 1 | 2 | 1 | 3 | 2 | 2 | 2 | 6 | 1 |
31
- * |-----|--------|-----|----|-----|----|-----|----|----|
32
- *
33
- */
34
- class Net_DNS2_RR_NSAP extends Net_DNS2_RR
35
- {
36
- public $afi;
37
- public $idi;
38
- public $dfi;
39
- public $aa;
40
- public $rsvd;
41
- public $rd;
42
- public $area;
43
- public $id;
44
- public $sel;
45
-
46
- /**
47
- * method to return the rdata portion of the packet as a string
48
- *
49
- * @return string
50
- * @access protected
51
- *
52
- */
53
- protected function rrToString()
54
- {
55
- return $this->cleanString($this->afi) . '.' .
56
- $this->cleanString($this->idi) . '.' .
57
- $this->cleanString($this->dfi) . '.' .
58
- $this->cleanString($this->aa) . '.' .
59
- $this->cleanString($this->rsvd) . '.' .
60
- $this->cleanString($this->rd) . '.' .
61
- $this->cleanString($this->area) . '.' .
62
- $this->cleanString($this->id) . '.' .
63
- $this->sel;
64
- }
65
-
66
- /**
67
- * parses the rdata portion from a standard DNS config line
68
- *
69
- * @param array $rdata a string split line of values for the rdata
70
- *
71
- * @return boolean
72
- * @access protected
73
- *
74
- */
75
- protected function rrFromString(array $rdata)
76
- {
77
- $data = strtolower(trim(array_shift($rdata)));
78
-
79
- //
80
- // there is no real standard for format, so we can't rely on the fact that
81
- // the value will come in with periods separating the values- so strip
82
- // them out if they're included, and parse without them.
83
- //
84
- $data = str_replace([ '.', '0x' ], '', $data);
85
-
86
- //
87
- // unpack it as ascii characters
88
- //
89
- $x = unpack('A2afi/A4idi/A2dfi/A6aa/A4rsvd/A4rd/A4area/A12id/A2sel', $data);
90
-
91
- //
92
- // make sure the afi value is 47
93
- //
94
- if ($x['afi'] == '47') {
95
-
96
- $this->afi = '0x' . $x['afi'];
97
- $this->idi = $x['idi'];
98
- $this->dfi = $x['dfi'];
99
- $this->aa = $x['aa'];
100
- $this->rsvd = $x['rsvd'];
101
- $this->rd = $x['rd'];
102
- $this->area = $x['area'];
103
- $this->id = $x['id'];
104
- $this->sel = $x['sel'];
105
-
106
- return true;
107
- }
108
-
109
- return false;
110
- }
111
-
112
- /**
113
- * parses the rdata of the Net_DNS2_Packet object
114
- *
115
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
116
- *
117
- * @return boolean
118
- * @access protected
119
- *
120
- */
121
- protected function rrSet(Net_DNS2_Packet &$packet)
122
- {
123
- if ($this->rdlength == 20) {
124
-
125
- //
126
- // get the AFI value
127
- //
128
- $this->afi = dechex(ord($this->rdata[0]));
129
-
130
- //
131
- // we only support AFI 47- there arent' any others defined.
132
- //
133
- if ($this->afi == '47') {
134
-
135
- //
136
- // unpack the rest of the values
137
- //
138
- $x = unpack(
139
- 'Cafi/nidi/Cdfi/C3aa/nrsvd/nrd/narea/Nidh/nidl/Csel',
140
- $this->rdata
141
- );
142
-
143
- $this->afi = sprintf('0x%02x', $x['afi']);
144
- $this->idi = sprintf('%04x', $x['idi']);
145
- $this->dfi = sprintf('%02x', $x['dfi']);
146
- $this->aa = sprintf(
147
- '%06x', $x['aa1'] << 16 | $x['aa2'] << 8 | $x['aa3']
148
- );
149
- $this->rsvd = sprintf('%04x', $x['rsvd']);
150
- $this->rd = sprintf('%04x', $x['rd']);
151
- $this->area = sprintf('%04x', $x['area']);
152
- $this->id = sprintf('%08x', $x['idh']) .
153
- sprintf('%04x', $x['idl']);
154
- $this->sel = sprintf('%02x', $x['sel']);
155
-
156
- return true;
157
- }
158
- }
159
-
160
- return false;
161
- }
162
-
163
- /**
164
- * returns the rdata portion of the DNS packet
165
- *
166
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
167
- * compressed names
168
- *
169
- * @return mixed either returns a binary packed
170
- * string or null on failure
171
- * @access protected
172
- *
173
- */
174
- protected function rrGet(Net_DNS2_Packet &$packet)
175
- {
176
- if ($this->afi == '0x47') {
177
-
178
- //
179
- // build the aa field
180
- //
181
- $aa = unpack('A2x/A2y/A2z', $this->aa);
182
-
183
- //
184
- // build the id field
185
- //
186
- $id = unpack('A8a/A4b', $this->id);
187
-
188
- //
189
- $data = pack(
190
- 'CnCCCCnnnNnC',
191
- hexdec($this->afi),
192
- hexdec($this->idi),
193
- hexdec($this->dfi),
194
- hexdec($aa['x']),
195
- hexdec($aa['y']),
196
- hexdec($aa['z']),
197
- hexdec($this->rsvd),
198
- hexdec($this->rd),
199
- hexdec($this->area),
200
- hexdec($id['a']),
201
- hexdec($id['b']),
202
- hexdec($this->sel)
203
- );
204
-
205
- if (strlen($data) == 20) {
206
-
207
- $packet->offset += 20;
208
- return $data;
209
- }
210
- }
211
-
212
- return null;
213
- }
214
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/NSEC.php DELETED
@@ -1,136 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 0.6.0
17
- *
18
- */
19
-
20
- /**
21
- * NSEC Resource Record - RFC3845 section 2.1
22
- *
23
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
24
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
25
- * / Next Domain Name /
26
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
27
- * / List of Type Bit Map(s) /
28
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
29
- *
30
- */
31
- class Net_DNS2_RR_NSEC extends Net_DNS2_RR
32
- {
33
- /*
34
- * The next owner name
35
- */
36
- public $next_domain_name;
37
-
38
- /*
39
- * identifies the RRset types that exist at the NSEC RR's owner name.
40
- */
41
- public $type_bit_maps = [];
42
-
43
- /**
44
- * method to return the rdata portion of the packet as a string
45
- *
46
- * @return string
47
- * @access protected
48
- *
49
- */
50
- protected function rrToString()
51
- {
52
- $data = $this->cleanString($this->next_domain_name) . '.';
53
-
54
- foreach ($this->type_bit_maps as $rr) {
55
-
56
- $data .= ' ' . $rr;
57
- }
58
-
59
- return $data;
60
- }
61
-
62
- /**
63
- * parses the rdata portion from a standard DNS config line
64
- *
65
- * @param array $rdata a string split line of values for the rdata
66
- *
67
- * @return boolean
68
- * @access protected
69
- *
70
- */
71
- protected function rrFromString(array $rdata)
72
- {
73
- $this->next_domain_name = $this->cleanString(array_shift($rdata));
74
- $this->type_bit_maps = $rdata;
75
-
76
- return true;
77
- }
78
-
79
- /**
80
- * parses the rdata of the Net_DNS2_Packet object
81
- *
82
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
83
- *
84
- * @return boolean
85
- * @access protected
86
- *
87
- */
88
- protected function rrSet(Net_DNS2_Packet &$packet)
89
- {
90
- if ($this->rdlength > 0) {
91
-
92
- //
93
- // expand the next domain name
94
- //
95
- $offset = $packet->offset;
96
- $this->next_domain_name = Net_DNS2_Packet::expand($packet, $offset);
97
-
98
- //
99
- // parse out the RR's from the bitmap
100
- //
101
- $this->type_bit_maps = Net_DNS2_BitMap::bitMapToArray(
102
- substr($this->rdata, $offset - $packet->offset)
103
- );
104
-
105
- return true;
106
- }
107
-
108
- return false;
109
- }
110
-
111
- /**
112
- * returns the rdata portion of the DNS packet
113
- *
114
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
115
- * compressed names
116
- *
117
- * @return mixed either returns a binary packed
118
- * string or null on failure
119
- * @access protected
120
- *
121
- */
122
- protected function rrGet(Net_DNS2_Packet &$packet)
123
- {
124
- if (strlen($this->next_domain_name) > 0) {
125
-
126
- $data = $packet->compress($this->next_domain_name, $packet->offset);
127
- $bitmap = Net_DNS2_BitMap::arrayToBitMap($this->type_bit_maps);
128
-
129
- $packet->offset += strlen($bitmap);
130
-
131
- return $data . $bitmap;
132
- }
133
-
134
- return null;
135
- }
136
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/NSEC3.php DELETED
@@ -1,262 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 0.6.0
17
- *
18
- */
19
-
20
- /**
21
- * NSEC3 Resource Record - RFC5155 section 3.2
22
- *
23
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
24
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
25
- * | Hash Alg. | Flags | Iterations |
26
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
27
- * | Salt Length | Salt /
28
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
29
- * | Hash Length | Next Hashed Owner Name /
30
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
31
- * / Type Bit Maps /
32
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
33
- *
34
- */
35
- class Net_DNS2_RR_NSEC3 extends Net_DNS2_RR
36
- {
37
- /*
38
- * Algorithm to use
39
- */
40
- public $algorithm;
41
-
42
- /*
43
- * flags
44
- */
45
- public $flags;
46
-
47
- /*
48
- * defines the number of additional times the hash is performed.
49
- */
50
- public $iterations;
51
-
52
- /*
53
- * the length of the salt- not displayed
54
- */
55
- public $salt_length;
56
-
57
- /*
58
- * the salt
59
- */
60
- public $salt;
61
-
62
- /*
63
- * the length of the hash value
64
- */
65
- public $hash_length;
66
-
67
- /*
68
- * the hashed value of the owner name
69
- */
70
- public $hashed_owner_name;
71
-
72
- /*
73
- * array of RR type names
74
- */
75
- public $type_bit_maps = [];
76
-
77
- /**
78
- * method to return the rdata portion of the packet as a string
79
- *
80
- * @return string
81
- * @access protected
82
- *
83
- */
84
- protected function rrToString()
85
- {
86
- $out = $this->algorithm . ' ' . $this->flags . ' ' . $this->iterations . ' ';
87
-
88
- //
89
- // per RFC5155, the salt_length value isn't displayed, and if the salt
90
- // is empty, the salt is displayed as '-'
91
- //
92
- if ($this->salt_length > 0) {
93
-
94
- $out .= $this->salt;
95
- } else {
96
-
97
- $out .= '-';
98
- }
99
-
100
- //
101
- // per RFC5255 the hash length isn't shown
102
- //
103
- $out .= ' ' . $this->hashed_owner_name;
104
-
105
- //
106
- // show the RR's
107
- //
108
- foreach ($this->type_bit_maps as $rr) {
109
-
110
- $out .= ' ' . strtoupper($rr);
111
- }
112
-
113
- return $out;
114
- }
115
-
116
- /**
117
- * parses the rdata portion from a standard DNS config line
118
- *
119
- * @param array $rdata a string split line of values for the rdata
120
- *
121
- * @return boolean
122
- * @access protected
123
- *
124
- */
125
- protected function rrFromString(array $rdata)
126
- {
127
- $this->algorithm = array_shift($rdata);
128
- $this->flags = array_shift($rdata);
129
- $this->iterations = array_shift($rdata);
130
-
131
- //
132
- // an empty salt is represented as '-' per RFC5155 section 3.3
133
- //
134
- $salt = array_shift($rdata);
135
- if ($salt == '-') {
136
-
137
- $this->salt_length = 0;
138
- $this->salt = '';
139
- } else {
140
-
141
- $this->salt_length = strlen(pack('H*', $salt));
142
- $this->salt = strtoupper($salt);
143
- }
144
-
145
- $this->hashed_owner_name = array_shift($rdata);
146
- $this->hash_length = strlen(base64_decode($this->hashed_owner_name));
147
-
148
- $this->type_bit_maps = $rdata;
149
-
150
- return true;
151
- }
152
-
153
- /**
154
- * parses the rdata of the Net_DNS2_Packet object
155
- *
156
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
157
- *
158
- * @return boolean
159
- * @access protected
160
- *
161
- */
162
- protected function rrSet(Net_DNS2_Packet &$packet)
163
- {
164
- if ($this->rdlength > 0) {
165
-
166
- //
167
- // unpack the first values
168
- //
169
- $x = unpack('Calgorithm/Cflags/niterations/Csalt_length', $this->rdata);
170
-
171
- $this->algorithm = $x['algorithm'];
172
- $this->flags = $x['flags'];
173
- $this->iterations = $x['iterations'];
174
- $this->salt_length = $x['salt_length'];
175
-
176
- $offset = 5;
177
-
178
- if ($this->salt_length > 0) {
179
-
180
- $x = unpack('H*', substr($this->rdata, $offset, $this->salt_length));
181
- $this->salt = strtoupper($x[1]);
182
- $offset += $this->salt_length;
183
- }
184
-
185
- //
186
- // unpack the hash length
187
- //
188
- $x = unpack('@' . $offset . '/Chash_length', $this->rdata);
189
- $offset++;
190
-
191
- //
192
- // copy out the hash
193
- //
194
- $this->hash_length = $x['hash_length'];
195
- if ($this->hash_length > 0) {
196
-
197
- $this->hashed_owner_name = base64_encode(
198
- substr($this->rdata, $offset, $this->hash_length)
199
- );
200
- $offset += $this->hash_length;
201
- }
202
-
203
- //
204
- // parse out the RR bitmap
205
- //
206
- $this->type_bit_maps = Net_DNS2_BitMap::bitMapToArray(
207
- substr($this->rdata, $offset)
208
- );
209
-
210
- return true;
211
- }
212
-
213
- return false;
214
- }
215
-
216
- /**
217
- * returns the rdata portion of the DNS packet
218
- *
219
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
220
- * compressed names
221
- *
222
- * @return mixed either returns a binary packed
223
- * string or null on failure
224
- * @access protected
225
- *
226
- */
227
- protected function rrGet(Net_DNS2_Packet &$packet)
228
- {
229
- //
230
- // pull the salt and build the length
231
- //
232
- $salt = pack('H*', $this->salt);
233
- $this->salt_length = strlen($salt);
234
-
235
- //
236
- // pack the algorithm, flags, iterations and salt length
237
- //
238
- $data = pack(
239
- 'CCnC',
240
- $this->algorithm, $this->flags, $this->iterations, $this->salt_length
241
- );
242
- $data .= $salt;
243
-
244
- //
245
- // add the hash length and hash
246
- //
247
- $data .= chr($this->hash_length);
248
- if ($this->hash_length > 0) {
249
-
250
- $data .= base64_decode($this->hashed_owner_name);
251
- }
252
-
253
- //
254
- // conver the array of RR names to a type bitmap
255
- //
256
- $data .= Net_DNS2_BitMap::arrayToBitMap($this->type_bit_maps);
257
-
258
- $packet->offset += strlen($data);
259
-
260
- return $data;
261
- }
262
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/NSEC3PARAM.php DELETED
@@ -1,172 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 0.6.0
17
- *
18
- */
19
-
20
- /**
21
- * NSEC3PARAM Resource Record - RFC5155 section 4.2
22
- *
23
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
24
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
25
- * | Hash Alg. | Flags | Iterations |
26
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
27
- * | Salt Length | Salt /
28
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
29
- *
30
- */
31
- class Net_DNS2_RR_NSEC3PARAM extends Net_DNS2_RR
32
- {
33
- /*
34
- * Algorithm to use
35
- *
36
- * TODO: same as the NSEC3
37
- */
38
- public $algorithm;
39
-
40
- /*
41
- * flags
42
- */
43
- public $flags;
44
-
45
- /*
46
- * defines the number of additional times the hash is performed.
47
- */
48
- public $iterations;
49
-
50
- /*
51
- * the length of the salt- not displayed
52
- */
53
- public $salt_length;
54
-
55
- /*
56
- * the salt
57
- */
58
- public $salt;
59
-
60
- /**
61
- * method to return the rdata portion of the packet as a string
62
- *
63
- * @return string
64
- * @access protected
65
- *
66
- */
67
- protected function rrToString()
68
- {
69
- $out = $this->algorithm . ' ' . $this->flags . ' ' . $this->iterations . ' ';
70
-
71
- //
72
- // per RFC5155, the salt_length value isn't displayed, and if the salt
73
- // is empty, the salt is displayed as "-"
74
- //
75
- if ($this->salt_length > 0) {
76
-
77
- $out .= $this->salt;
78
- } else {
79
-
80
- $out .= '-';
81
- }
82
-
83
- return $out;
84
- }
85
-
86
- /**
87
- * parses the rdata portion from a standard DNS config line
88
- *
89
- * @param array $rdata a string split line of values for the rdata
90
- *
91
- * @return boolean
92
- * @access protected
93
- *
94
- */
95
- protected function rrFromString(array $rdata)
96
- {
97
- $this->algorithm = array_shift($rdata);
98
- $this->flags = array_shift($rdata);
99
- $this->iterations = array_shift($rdata);
100
-
101
- $salt = array_shift($rdata);
102
- if ($salt == '-') {
103
-
104
- $this->salt_length = 0;
105
- $this->salt = '';
106
- } else {
107
-
108
- $this->salt_length = strlen(pack('H*', $salt));
109
- $this->salt = strtoupper($salt);
110
- }
111
-
112
- return true;
113
- }
114
-
115
- /**
116
- * parses the rdata of the Net_DNS2_Packet object
117
- *
118
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
119
- *
120
- * @return boolean
121
- * @access protected
122
- *
123
- */
124
- protected function rrSet(Net_DNS2_Packet &$packet)
125
- {
126
- if ($this->rdlength > 0) {
127
-
128
- $x = unpack('Calgorithm/Cflags/niterations/Csalt_length', $this->rdata);
129
-
130
- $this->algorithm = $x['algorithm'];
131
- $this->flags = $x['flags'];
132
- $this->iterations = $x['iterations'];
133
- $this->salt_length = $x['salt_length'];
134
-
135
- if ($this->salt_length > 0) {
136
-
137
- $x = unpack('H*', substr($this->rdata, 5, $this->salt_length));
138
- $this->salt = strtoupper($x[1]);
139
- }
140
-
141
- return true;
142
- }
143
-
144
- return false;
145
- }
146
-
147
- /**
148
- * returns the rdata portion of the DNS packet
149
- *
150
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
151
- * compressed names
152
- *
153
- * @return mixed either returns a binary packed
154
- * string or null on failure
155
- * @access protected
156
- *
157
- */
158
- protected function rrGet(Net_DNS2_Packet &$packet)
159
- {
160
- $salt = pack('H*', $this->salt);
161
- $this->salt_length = strlen($salt);
162
-
163
- $data = pack(
164
- 'CCnC',
165
- $this->algorithm, $this->flags, $this->iterations, $this->salt_length
166
- ) . $salt;
167
-
168
- $packet->offset += strlen($data);
169
-
170
- return $data;
171
- }
172
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/OPENPGPKEY.php DELETED
@@ -1,111 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 1.4.0
17
- *
18
- */
19
-
20
- /**
21
- * OPENPGPKEY Resource Record - https://tools.ietf.org/html/draft-ietf-dane-openpgpkey-01
22
- *
23
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
24
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
25
- * / /
26
- * / OpenPGP Public KeyRing /
27
- * / /
28
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
29
- *
30
- */
31
- class Net_DNS2_RR_OPENPGPKEY extends Net_DNS2_RR
32
- {
33
- /*
34
- * the public key
35
- */
36
- public $key;
37
-
38
- /**
39
- * method to return the rdata portion of the packet as a string
40
- *
41
- * @return string
42
- * @access protected
43
- *
44
- */
45
- protected function rrToString()
46
- {
47
- return $this->key;
48
- }
49
-
50
- /**
51
- * parses the rdata portion from a standard DNS config line
52
- *
53
- * @param array $rdata a string split line of values for the rdata
54
- *
55
- * @return boolean
56
- * @access protected
57
- *
58
- */
59
- protected function rrFromString(array $rdata)
60
- {
61
- $this->key = array_shift($rdata);
62
-
63
- return true;
64
- }
65
-
66
- /**
67
- * parses the rdata of the Net_DNS2_Packet object
68
- *
69
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
70
- *
71
- * @return boolean
72
- * @access protected
73
- *
74
- */
75
- protected function rrSet(Net_DNS2_Packet &$packet)
76
- {
77
- if ($this->rdlength > 0) {
78
-
79
- $this->key = base64_encode(substr($this->rdata, 0, $this->rdlength));
80
-
81
- return true;
82
- }
83
-
84
- return false;
85
- }
86
-
87
- /**
88
- * returns the rdata portion of the DNS packet
89
- *
90
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
91
- * compressed names
92
- *
93
- * @return mixed either returns a binary packed
94
- * string or null on failure
95
- * @access protected
96
- *
97
- */
98
- protected function rrGet(Net_DNS2_Packet &$packet)
99
- {
100
- if (strlen($this->key) > 0) {
101
-
102
- $data = base64_decode($this->key);
103
-
104
- $packet->offset += strlen($data);
105
-
106
- return $data;
107
- }
108
-
109
- return null;
110
- }
111
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/OPT.php DELETED
@@ -1,244 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 1.0.0
17
- *
18
- */
19
-
20
- /**
21
- * OPT Resource Record - RFC2929 section 3.1
22
- *
23
- * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
24
- * | OPTION-CODE |
25
- * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
26
- * | OPTION-LENGTH |
27
- * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
28
- * | |
29
- * / OPTION-DATA /
30
- * / /
31
- * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
32
- *
33
- */
34
- class Net_DNS2_RR_OPT extends Net_DNS2_RR
35
- {
36
- /*
37
- * option code - assigned by IANA
38
- */
39
- public $option_code;
40
-
41
- /*
42
- * the length of the option data
43
- */
44
- public $option_length;
45
-
46
- /*
47
- * the option data
48
- */
49
- public $option_data;
50
-
51
- /*
52
- * the extended response code stored in the TTL
53
- */
54
- public $extended_rcode;
55
-
56
- /*
57
- * the implementation level
58
- */
59
- public $version;
60
-
61
- /*
62
- * the DO bit used for DNSSEC - RFC3225
63
- */
64
- public $do;
65
-
66
- /*
67
- * the extended flags
68
- */
69
- public $z;
70
-
71
- /**
72
- * Constructor - builds a new Net_DNS2_RR_OPT object; normally you wouldn't call
73
- * this directly, but OPT RR's are a little different
74
- *
75
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet or null to create
76
- * an empty object
77
- * @param array $rr an array with RR parse values or null to
78
- * create an empty object
79
- *
80
- * @throws Net_DNS2_Exception
81
- * @access public
82
- *
83
- */
84
- public function __construct(Net_DNS2_Packet &$packet = null, array $rr = null)
85
- {
86
- //
87
- // this is for when we're manually building an OPT RR object; we aren't
88
- // passing in binary data to parse, we just want a clean/empty object.
89
- //
90
- $this->type = 'OPT';
91
- $this->rdlength = 0;
92
-
93
- $this->option_length = 0;
94
- $this->extended_rcode = 0;
95
- $this->version = 0;
96
- $this->do = 0;
97
- $this->z = 0;
98
-
99
- //
100
- // everthing else gets passed through to the parent.
101
- //
102
- if ( (!is_null($packet)) && (!is_null($rr)) ) {
103
-
104
- parent::__construct($packet, $rr);
105
- }
106
- }
107
-
108
- /**
109
- * method to return the rdata portion of the packet as a string. There is no
110
- * defintion for returning an OPT RR by string- this is just here to validate
111
- * the binary parsing / building routines.
112
- *
113
- * @return string
114
- * @access protected
115
- *
116
- */
117
- protected function rrToString()
118
- {
119
- return $this->option_code . ' ' . $this->option_data;
120
- }
121
-
122
- /**
123
- * parses the rdata portion from a standard DNS config line. There is no
124
- * definition for parsing a OPT RR by string- this is just here to validate
125
- * the binary parsing / building routines.
126
- *
127
- * @param array $rdata a string split line of values for the rdata
128
- *
129
- * @return boolean
130
- * @access protected
131
- *
132
- */
133
- protected function rrFromString(array $rdata)
134
- {
135
- $this->option_code = array_shift($rdata);
136
- $this->option_data = array_shift($rdata);
137
- $this->option_length = strlen($this->option_data);
138
-
139
- $x = unpack('Cextended/Cversion/Cdo/Cz', pack('N', $this->ttl));
140
-
141
- $this->extended_rcode = $x['extended'];
142
- $this->version = $x['version'];
143
- $this->do = ($x['do'] >> 7);
144
- $this->z = $x['z'];
145
-
146
- return true;
147
- }
148
-
149
- /**
150
- * parses the rdata of the Net_DNS2_Packet object
151
- *
152
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
153
- *
154
- * @return boolean
155
- * @access protected
156
- *
157
- */
158
- protected function rrSet(Net_DNS2_Packet &$packet)
159
- {
160
- //
161
- // parse out the TTL value
162
- //
163
- $x = unpack('Cextended/Cversion/Cdo/Cz', pack('N', $this->ttl));
164
-
165
- $this->extended_rcode = $x['extended'];
166
- $this->version = $x['version'];
167
- $this->do = ($x['do'] >> 7);
168
- $this->z = $x['z'];
169
-
170
- //
171
- // parse the data, if there is any
172
- //
173
- if ($this->rdlength > 0) {
174
-
175
- //
176
- // unpack the code and length
177
- //
178
- $x = unpack('noption_code/noption_length', $this->rdata);
179
-
180
- $this->option_code = $x['option_code'];
181
- $this->option_length = $x['option_length'];
182
-
183
- //
184
- // copy out the data based on the length
185
- //
186
- $this->option_data = substr($this->rdata, 4);
187
- }
188
-
189
- return true;
190
- }
191
-
192
- /**
193
- * pre-builds the TTL value for this record; we needed to separate this out
194
- * from the rrGet() function, as the logic in the Net_DNS2_RR packs the TTL
195
- * value before it builds the rdata value.
196
- *
197
- * @return void
198
- * @access protected
199
- *
200
- */
201
- protected function preBuild()
202
- {
203
- //
204
- // build the TTL value based on the local values
205
- //
206
- $ttl = unpack(
207
- 'N',
208
- pack('CCCC', $this->extended_rcode, $this->version, ($this->do << 7), 0)
209
- );
210
-
211
- $this->ttl = $ttl[1];
212
-
213
- return;
214
- }
215
-
216
- /**
217
- * returns the rdata portion of the DNS packet
218
- *
219
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
220
- * compressed names
221
- *
222
- * @return mixed either returns a binary packed
223
- * string or null on failure
224
- * @access protected
225
- *
226
- */
227
- protected function rrGet(Net_DNS2_Packet &$packet)
228
- {
229
- //
230
- // if there is an option code, then pack that data too
231
- //
232
- if ($this->option_code) {
233
-
234
- $data = pack('nn', $this->option_code, $this->option_length) .
235
- $this->option_data;
236
-
237
- $packet->offset += strlen($data);
238
-
239
- return $data;
240
- }
241
-
242
- return null;
243
- }
244
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/PTR.php DELETED
@@ -1,104 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 0.6.0
17
- *
18
- */
19
-
20
- /**
21
- * PTR Resource Record - RFC1035 section 3.3.12
22
- *
23
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
24
- * / PTRDNAME /
25
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
26
- *
27
- */
28
- class Net_DNS2_RR_PTR extends Net_DNS2_RR
29
- {
30
- /*
31
- * the hostname of the PTR entry
32
- */
33
- public $ptrdname;
34
-
35
- /**
36
- * method to return the rdata portion of the packet as a string
37
- *
38
- * @return string
39
- * @access protected
40
- *
41
- */
42
- protected function rrToString()
43
- {
44
- return rtrim($this->ptrdname, '.') . '.';
45
- }
46
-
47
- /**
48
- * parses the rdata portion from a standard DNS config line
49
- *
50
- * @param array $rdata a string split line of values for the rdata
51
- *
52
- * @return boolean
53
- * @access protected
54
- *
55
- */
56
- protected function rrFromString(array $rdata)
57
- {
58
- $this->ptrdname = rtrim(implode(' ', $rdata), '.');
59
- return true;
60
- }
61
-
62
- /**
63
- * parses the rdata of the Net_DNS2_Packet object
64
- *
65
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
66
- *
67
- * @return boolean
68
- * @access protected
69
- *
70
- */
71
- protected function rrSet(Net_DNS2_Packet &$packet)
72
- {
73
- if ($this->rdlength > 0) {
74
-
75
- $offset = $packet->offset;
76
- $this->ptrdname = Net_DNS2_Packet::expand($packet, $offset);
77
-
78
- return true;
79
- }
80
-
81
- return false;
82
- }
83
-
84
- /**
85
- * returns the rdata portion of the DNS packet
86
- *
87
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
88
- * compressed names
89
- *
90
- * @return mixed either returns a binary packed
91
- * string or null on failure
92
- * @access protected
93
- *
94
- */
95
- protected function rrGet(Net_DNS2_Packet &$packet)
96
- {
97
- if (strlen($this->ptrdname) > 0) {
98
-
99
- return $packet->compress($this->ptrdname, $packet->offset);
100
- }
101
-
102
- return null;
103
- }
104
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/PX.php DELETED
@@ -1,138 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 0.6.0
17
- *
18
- */
19
-
20
- /**
21
- * PX Resource Record - RFC2163 section 4
22
- *
23
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
24
- * | PREFERENCE |
25
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
26
- * / MAP822 /
27
- * / /
28
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
29
- * / MAPX400 /
30
- * / /
31
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--
32
- *
33
- */
34
- class Net_DNS2_RR_PX extends Net_DNS2_RR
35
- {
36
- /*
37
- * preference
38
- */
39
- public $preference;
40
-
41
- /*
42
- * the RFC822 part of the MCGAM
43
- */
44
- public $map822;
45
-
46
- /*
47
- * the X.400 part of the MCGAM
48
- */
49
- public $mapx400;
50
-
51
- /**
52
- * method to return the rdata portion of the packet as a string
53
- *
54
- * @return string
55
- * @access protected
56
- *
57
- */
58
- protected function rrToString()
59
- {
60
- return $this->preference . ' ' . $this->cleanString($this->map822) . '. ' .
61
- $this->cleanString($this->mapx400) . '.';
62
- }
63
-
64
- /**
65
- * parses the rdata portion from a standard DNS config line
66
- *
67
- * @param array $rdata a string split line of values for the rdata
68
- *
69
- * @return boolean
70
- * @access protected
71
- *
72
- */
73
- protected function rrFromString(array $rdata)
74
- {
75
- $this->preference = $rdata[0];
76
- $this->map822 = $this->cleanString($rdata[1]);
77
- $this->mapx400 = $this->cleanString($rdata[2]);
78
-
79
- return true;
80
- }
81
-
82
- /**
83
- * parses the rdata of the Net_DNS2_Packet object
84
- *
85
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
86
- *
87
- * @return boolean
88
- * @access protected
89
- *
90
- */
91
- protected function rrSet(Net_DNS2_Packet &$packet)
92
- {
93
- if ($this->rdlength > 0) {
94
-
95
- //
96
- // parse the preference
97
- //
98
- $x = unpack('npreference', $this->rdata);
99
- $this->preference = $x['preference'];
100
-
101
- $offset = $packet->offset + 2;
102
-
103
- $this->map822 = Net_DNS2_Packet::expand($packet, $offset);
104
- $this->mapx400 = Net_DNS2_Packet::expand($packet, $offset);
105
-
106
- return true;
107
- }
108
-
109
- return false;
110
- }
111
-
112
- /**
113
- * returns the rdata portion of the DNS packet
114
- *
115
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
116
- * compressed names
117
- *
118
- * @return mixed either returns a binary packed
119
- * string or null on failure
120
- * @access protected
121
- *
122
- */
123
- protected function rrGet(Net_DNS2_Packet &$packet)
124
- {
125
- if (strlen($this->map822) > 0) {
126
-
127
- $data = pack('n', $this->preference);
128
- $packet->offset += 2;
129
-
130
- $data .= $packet->compress($this->map822, $packet->offset);
131
- $data .= $packet->compress($this->mapx400, $packet->offset);
132
-
133
- return $data;
134
- }
135
-
136
- return null;
137
- }
138
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/RP.php DELETED
@@ -1,118 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 0.6.0
17
- *
18
- */
19
-
20
- /**
21
- * RP Resource Record - RFC1183 section 2.2
22
- *
23
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
24
- * / mboxdname /
25
- * / /
26
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
27
- * / txtdname /
28
- * / /
29
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
30
- *
31
- */
32
- class Net_DNS2_RR_RP extends Net_DNS2_RR
33
- {
34
- /*
35
- * mailbox for the responsible person
36
- */
37
- public $mboxdname;
38
-
39
- /*
40
- * is a domain name for which TXT RR's exists
41
- */
42
- public $txtdname;
43
-
44
- /**
45
- * method to return the rdata portion of the packet as a string
46
- *
47
- * @return string
48
- * @access protected
49
- *
50
- */
51
- protected function rrToString()
52
- {
53
- return $this->cleanString($this->mboxdname) . '. ' . $this->cleanString($this->txtdname) . '.';
54
- }
55
-
56
- /**
57
- * parses the rdata portion from a standard DNS config line
58
- *
59
- * @param array $rdata a string split line of values for the rdata
60
- *
61
- * @return boolean
62
- * @access protected
63
- *
64
- */
65
- protected function rrFromString(array $rdata)
66
- {
67
- $this->mboxdname = $this->cleanString($rdata[0]);
68
- $this->txtdname = $this->cleanString($rdata[1]);
69
-
70
- return true;
71
- }
72
-
73
- /**
74
- * parses the rdata of the Net_DNS2_Packet object
75
- *
76
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
77
- *
78
- * @return boolean
79
- * @access protected
80
- *
81
- */
82
- protected function rrSet(Net_DNS2_Packet &$packet)
83
- {
84
- if ($this->rdlength > 0) {
85
-
86
- $offset = $packet->offset;
87
-
88
- $this->mboxdname = Net_DNS2_Packet::expand($packet, $offset, true);
89
- $this->txtdname = Net_DNS2_Packet::expand($packet, $offset);
90
-
91
- return true;
92
- }
93
-
94
- return false;
95
- }
96
-
97
- /**
98
- * returns the rdata portion of the DNS packet
99
- *
100
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
101
- * compressed names
102
- *
103
- * @return mixed either returns a binary packed
104
- * string or null on failure
105
- * @access protected
106
- *
107
- */
108
- protected function rrGet(Net_DNS2_Packet &$packet)
109
- {
110
- if (strlen($this->mboxdname) > 0) {
111
-
112
- return $packet->compress($this->mboxdname, $packet->offset) .
113
- $packet->compress($this->txtdname, $packet->offset);
114
- }
115
-
116
- return null;
117
- }
118
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/RRSIG.php DELETED
@@ -1,280 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 0.6.0
17
- *
18
- * This file contains code based off the Net::DNS::SEC Perl module by Olaf M. Kolkman
19
- *
20
- * This is the copyright notice from the PERL Net::DNS::SEC module:
21
- *
22
- * Copyright (c) 2001 - 2005 RIPE NCC. Author Olaf M. Kolkman
23
- * Copyright (c) 2007 - 2008 NLnet Labs. Author Olaf M. Kolkman
24
- * <olaf@net-dns.org>
25
- *
26
- * All Rights Reserved
27
- *
28
- * Permission to use, copy, modify, and distribute this software and its
29
- * documentation for any purpose and without fee is hereby granted,
30
- * provided that the above copyright notice appear in all copies and that
31
- * both that copyright notice and this permission notice appear in
32
- * supporting documentation, and that the name of the author not be
33
- * used in advertising or publicity pertaining to distribution of the
34
- * software without specific, written prior permission.
35
- *
36
- * THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
37
- * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS; IN NO EVENT SHALL
38
- * AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
39
- * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
40
- * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
41
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
42
- *
43
- */
44
-
45
- /**
46
- * RRSIG Resource Record - RFC4034 sction 3.1
47
- *
48
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
49
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
50
- * | Type Covered | Algorithm | Labels |
51
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
52
- * | Original TTL |
53
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
54
- * | Signature Expiration |
55
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
56
- * | Signature Inception |
57
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
58
- * | Key Tag | /
59
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Signer's Name /
60
- * / /
61
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
62
- * / /
63
- * / Signature /
64
- * / /
65
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
66
- *
67
- */
68
- class Net_DNS2_RR_RRSIG extends Net_DNS2_RR
69
- {
70
- /*
71
- * the RR type covered by this signature
72
- */
73
- public $typecovered;
74
-
75
- /*
76
- * the algorithm used for the signature
77
- */
78
- public $algorithm;
79
-
80
- /*
81
- * the number of labels in the name
82
- */
83
- public $labels;
84
-
85
- /*
86
- * the original TTL
87
- */
88
- public $origttl;
89
-
90
- /*
91
- * the signature expiration
92
- */
93
- public $sigexp;
94
-
95
- /*
96
- * the inception of the signature
97
- */
98
- public $sigincep;
99
-
100
- /*
101
- * the keytag used
102
- */
103
- public $keytag;
104
-
105
- /*
106
- * the signer's name
107
- */
108
- public $signname;
109
-
110
- /*
111
- * the signature
112
- */
113
- public $signature;
114
-
115
- /**
116
- * method to return the rdata portion of the packet as a string
117
- *
118
- * @return string
119
- * @access protected
120
- *
121
- */
122
- protected function rrToString()
123
- {
124
- return $this->typecovered . ' ' . $this->algorithm . ' ' .
125
- $this->labels . ' ' . $this->origttl . ' ' .
126
- $this->sigexp . ' ' . $this->sigincep . ' ' .
127
- $this->keytag . ' ' . $this->cleanString($this->signname) . '. ' .
128
- $this->signature;
129
- }
130
-
131
- /**
132
- * parses the rdata portion from a standard DNS config line
133
- *
134
- * @param array $rdata a string split line of values for the rdata
135
- *
136
- * @return boolean
137
- * @access protected
138
- *
139
- */
140
- protected function rrFromString(array $rdata)
141
- {
142
- $this->typecovered = strtoupper(array_shift($rdata));
143
- $this->algorithm = array_shift($rdata);
144
- $this->labels = array_shift($rdata);
145
- $this->origttl = array_shift($rdata);
146
- $this->sigexp = array_shift($rdata);
147
- $this->sigincep = array_shift($rdata);
148
- $this->keytag = array_shift($rdata);
149
- $this->signname = $this->cleanString(array_shift($rdata));
150
-
151
- foreach ($rdata as $line) {
152
-
153
- $this->signature .= $line;
154
- }
155
-
156
- $this->signature = trim($this->signature);
157
-
158
- return true;
159
- }
160
-
161
- /**
162
- * parses the rdata of the Net_DNS2_Packet object
163
- *
164
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
165
- *
166
- * @return boolean
167
- * @access protected
168
- *
169
- */
170
- protected function rrSet(Net_DNS2_Packet &$packet)
171
- {
172
- if ($this->rdlength > 0) {
173
-
174
- //
175
- // unpack
176
- //
177
- $x = unpack(
178
- 'ntc/Calgorithm/Clabels/Norigttl/Nsigexp/Nsigincep/nkeytag',
179
- $this->rdata
180
- );
181
-
182
- $this->typecovered = Net_DNS2_Lookups::$rr_types_by_id[$x['tc']];
183
- $this->algorithm = $x['algorithm'];
184
- $this->labels = $x['labels'];
185
- $this->origttl = Net_DNS2::expandUint32($x['origttl']);
186
-
187
- //
188
- // the dates are in GM time
189
- //
190
- $this->sigexp = gmdate('YmdHis', $x['sigexp']);
191
- $this->sigincep = gmdate('YmdHis', $x['sigincep']);
192
-
193
- //
194
- // get the keytag
195
- //
196
- $this->keytag = $x['keytag'];
197
-
198
- //
199
- // get teh signers name and signature
200
- //
201
- $offset = $packet->offset + 18;
202
- $sigoffset = $offset;
203
-
204
- $this->signname = strtolower(
205
- Net_DNS2_Packet::expand($packet, $sigoffset)
206
- );
207
- $this->signature = base64_encode(
208
- substr($this->rdata, 18 + ($sigoffset - $offset))
209
- );
210
-
211
- return true;
212
- }
213
-
214
- return false;
215
- }
216
-
217
- /**
218
- * returns the rdata portion of the DNS packet
219
- *
220
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
221
- * compressed names
222
- *
223
- * @return mixed either returns a binary packed
224
- * string or null on failure
225
- * @access protected
226
- *
227
- */
228
- protected function rrGet(Net_DNS2_Packet &$packet)
229
- {
230
- if (strlen($this->signature) > 0) {
231
-
232
- //
233
- // parse the values out of the dates
234
- //
235
- preg_match(
236
- '/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/', $this->sigexp, $e
237
- );
238
- preg_match(
239
- '/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/', $this->sigincep, $i
240
- );
241
-
242
- //
243
- // pack the value
244
- //
245
- $data = pack(
246
- 'nCCNNNn',
247
- Net_DNS2_Lookups::$rr_types_by_name[$this->typecovered],
248
- $this->algorithm,
249
- $this->labels,
250
- $this->origttl,
251
- gmmktime($e[4], $e[5], $e[6], $e[2], $e[3], $e[1]),
252
- gmmktime($i[4], $i[5], $i[6], $i[2], $i[3], $i[1]),
253
- $this->keytag
254
- );
255
-
256
- //
257
- // the signer name is special; it's not allowed to be compressed
258
- // (see section 3.1.7)
259
- //
260
- $names = explode('.', strtolower($this->signname));
261
- foreach ($names as $name) {
262
-
263
- $data .= chr(strlen($name));
264
- $data .= $name;
265
- }
266
- $data .= "\0";
267
-
268
- //
269
- // add the signature
270
- //
271
- $data .= base64_decode($this->signature);
272
-
273
- $packet->offset += strlen($data);
274
-
275
- return $data;
276
- }
277
-
278
- return null;
279
- }
280
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/RT.php DELETED
@@ -1,127 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 0.6.0
17
- *
18
- */
19
-
20
- /**
21
- * RT Resource Record - RFC1183 section 3.3
22
- *
23
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
24
- * | preference |
25
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
26
- * / intermediate-host /
27
- * / /
28
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
29
- *
30
- */
31
- class Net_DNS2_RR_RT extends Net_DNS2_RR
32
- {
33
- /*
34
- * the preference of this route
35
- */
36
- public $preference;
37
-
38
- /*
39
- * host which will servce as an intermediate in reaching the owner host
40
- */
41
- public $intermediatehost;
42
-
43
- /**
44
- * method to return the rdata portion of the packet as a string
45
- *
46
- * @return string
47
- * @access protected
48
- *
49
- */
50
- protected function rrToString()
51
- {
52
- return $this->preference . ' ' .
53
- $this->cleanString($this->intermediatehost) . '.';
54
- }
55
-
56
- /**
57
- * parses the rdata portion from a standard DNS config line
58
- *
59
- * @param array $rdata a string split line of values for the rdata
60
- *
61
- * @return boolean
62
- * @access protected
63
- *
64
- */
65
- protected function rrFromString(array $rdata)
66
- {
67
- $this->preference = $rdata[0];
68
- $this->intermediatehost = $this->cleanString($rdata[1]);
69
-
70
- return true;
71
- }
72
-
73
- /**
74
- * parses the rdata of the Net_DNS2_Packet object
75
- *
76
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
77
- *
78
- * @return boolean
79
- * @access protected
80
- *
81
- */
82
- protected function rrSet(Net_DNS2_Packet &$packet)
83
- {
84
- if ($this->rdlength > 0) {
85
-
86
- //
87
- // unpack the preference
88
- //
89
- $x = unpack('npreference', $this->rdata);
90
-
91
- $this->preference = $x['preference'];
92
- $offset = $packet->offset + 2;
93
-
94
- $this->intermediatehost = Net_DNS2_Packet::expand($packet, $offset);
95
-
96
- return true;
97
- }
98
-
99
- return false;
100
- }
101
-
102
- /**
103
- * returns the rdata portion of the DNS packet
104
- *
105
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
106
- * compressed names
107
- *
108
- * @return mixed either returns a binary packed
109
- * string or null on failure
110
- * @access protected
111
- *
112
- */
113
- protected function rrGet(Net_DNS2_Packet &$packet)
114
- {
115
- if (strlen($this->intermediatehost) > 0) {
116
-
117
- $data = pack('n', $this->preference);
118
- $packet->offset += 2;
119
-
120
- $data .= $packet->compress($this->intermediatehost, $packet->offset);
121
-
122
- return $data;
123
- }
124
-
125
- return null;
126
- }
127
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/SIG.php DELETED
@@ -1,410 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 0.6.0
17
- *
18
- * This file contains code based off the Net::DNS::SEC Perl module by Olaf M. Kolkman
19
- *
20
- * This is the copyright notice from the PERL Net::DNS::SEC module:
21
- *
22
- * Copyright (c) 2001 - 2005 RIPE NCC. Author Olaf M. Kolkman
23
- * Copyright (c) 2007 - 2008 NLnet Labs. Author Olaf M. Kolkman
24
- * <olaf@net-dns.org>
25
- *
26
- * All Rights Reserved
27
- *
28
- * Permission to use, copy, modify, and distribute this software and its
29
- * documentation for any purpose and without fee is hereby granted,
30
- * provided that the above copyright notice appear in all copies and that
31
- * both that copyright notice and this permission notice appear in
32
- * supporting documentation, and that the name of the author not be
33
- * used in advertising or publicity pertaining to distribution of the
34
- * software without specific, written prior permission.
35
- *
36
- * THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
37
- * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS; IN NO EVENT SHALL
38
- * AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
39
- * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
40
- * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
41
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
42
- *
43
- */
44
-
45
- /**
46
- * SIG Resource Record - RFC2535 section 4.1
47
- *
48
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
49
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
50
- * | Type Covered | Algorithm | Labels |
51
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
52
- * | Original TTL |
53
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
54
- * | Signature Expiration |
55
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
56
- * | Signature Inception |
57
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
58
- * | Key Tag | /
59
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Signer's Name /
60
- * / /
61
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
62
- * / /
63
- * / Signature /
64
- * / /
65
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
66
- *
67
- */
68
- class Net_DNS2_RR_SIG extends Net_DNS2_RR
69
- {
70
- /*
71
- * and instance of a Net_DNS2_PrivateKey object
72
- */
73
- public $private_key = null;
74
-
75
- /*
76
- * the RR type covered by this signature
77
- */
78
- public $typecovered;
79
-
80
- /*
81
- * the algorithm used for the signature
82
- */
83
- public $algorithm;
84
-
85
- /*
86
- * the number of labels in the name
87
- */
88
- public $labels;
89
-
90
- /*
91
- * the original TTL
92
- */
93
- public $origttl;
94
-
95
- /*
96
- * the signature expiration
97
- */
98
- public $sigexp;
99
-
100
- /*
101
- * the inception of the signature
102
- */
103
- public $sigincep;
104
-
105
- /*
106
- * the keytag used
107
- */
108
- public $keytag;
109
-
110
- /*
111
- * the signer's name
112
- */
113
- public $signname;
114
-
115
- /*
116
- * the signature
117
- */
118
- public $signature;
119
-
120
- /**
121
- * method to return the rdata portion of the packet as a string
122
- *
123
- * @return string
124
- * @access protected
125
- *
126
- */
127
- protected function rrToString()
128
- {
129
- return $this->typecovered . ' ' . $this->algorithm . ' ' .
130
- $this->labels . ' ' . $this->origttl . ' ' .
131
- $this->sigexp . ' ' . $this->sigincep . ' ' .
132
- $this->keytag . ' ' . $this->cleanString($this->signname) . '. ' .
133
- $this->signature;
134
- }
135
-
136
- /**
137
- * parses the rdata portion from a standard DNS config line
138
- *
139
- * @param array $rdata a string split line of values for the rdata
140
- *
141
- * @return boolean
142
- * @access protected
143
- *
144
- */
145
- protected function rrFromString(array $rdata)
146
- {
147
- $this->typecovered = strtoupper(array_shift($rdata));
148
- $this->algorithm = array_shift($rdata);
149
- $this->labels = array_shift($rdata);
150
- $this->origttl = array_shift($rdata);
151
- $this->sigexp = array_shift($rdata);
152
- $this->sigincep = array_shift($rdata);
153
- $this->keytag = array_shift($rdata);
154
- $this->signname = $this->cleanString(array_shift($rdata));
155
-
156
- foreach ($rdata as $line) {
157
-
158
- $this->signature .= $line;
159
- }
160
-
161
- $this->signature = trim($this->signature);
162
-
163
- return true;
164
- }
165
-
166
- /**
167
- * parses the rdata of the Net_DNS2_Packet object
168
- *
169
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
170
- *
171
- * @return boolean
172
- * @access protected
173
- *
174
- */
175
- protected function rrSet(Net_DNS2_Packet &$packet)
176
- {
177
- if ($this->rdlength > 0) {
178
-
179
- //
180
- // unpack
181
- //
182
- $x = unpack(
183
- 'ntc/Calgorithm/Clabels/Norigttl/Nsigexp/Nsigincep/nkeytag',
184
- $this->rdata
185
- );
186
-
187
- $this->typecovered = Net_DNS2_Lookups::$rr_types_by_id[$x['tc']];
188
- $this->algorithm = $x['algorithm'];
189
- $this->labels = $x['labels'];
190
- $this->origttl = Net_DNS2::expandUint32($x['origttl']);
191
-
192
- //
193
- // the dates are in GM time
194
- //
195
- $this->sigexp = gmdate('YmdHis', $x['sigexp']);
196
- $this->sigincep = gmdate('YmdHis', $x['sigincep']);
197
-
198
- //
199
- // get the keytag
200
- //
201
- $this->keytag = $x['keytag'];
202
-
203
- //
204
- // get teh signers name and signature
205
- //
206
- $offset = $packet->offset + 18;
207
- $sigoffset = $offset;
208
-
209
- $this->signname = strtolower(
210
- Net_DNS2_Packet::expand($packet, $sigoffset)
211
- );
212
- $this->signature = base64_encode(
213
- substr($this->rdata, 18 + ($sigoffset - $offset))
214
- );
215
-
216
- return true;
217
- }
218
-
219
- return false;
220
- }
221
-
222
- /**
223
- * returns the rdata portion of the DNS packet
224
- *
225
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
226
- * compressed names
227
- *
228
- * @return mixed either returns a binary packed
229
- * string or null on failure
230
- * @access protected
231
- *
232
- */
233
- protected function rrGet(Net_DNS2_Packet &$packet)
234
- {
235
- //
236
- // parse the values out of the dates
237
- //
238
- preg_match(
239
- '/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/', $this->sigexp, $e
240
- );
241
- preg_match(
242
- '/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/', $this->sigincep, $i
243
- );
244
-
245
- //
246
- // pack the value
247
- //
248
- $data = pack(
249
- 'nCCNNNn',
250
- Net_DNS2_Lookups::$rr_types_by_name[$this->typecovered],
251
- $this->algorithm,
252
- $this->labels,
253
- $this->origttl,
254
- gmmktime($e[4], $e[5], $e[6], $e[2], $e[3], $e[1]),
255
- gmmktime($i[4], $i[5], $i[6], $i[2], $i[3], $i[1]),
256
- $this->keytag
257
- );
258
-
259
- //
260
- // the signer name is special; it's not allowed to be compressed
261
- // (see section 3.1.7)
262
- //
263
- $names = explode('.', strtolower($this->signname));
264
- foreach ($names as $name) {
265
-
266
- $data .= chr(strlen($name));
267
- $data .= $name;
268
- }
269
-
270
- $data .= chr('0');
271
-
272
- //
273
- // if the signature is empty, and $this->private_key is an instance of a
274
- // private key object, and we have access to openssl, then assume this
275
- // is a SIG(0), and generate a new signature
276
- //
277
- if ( (strlen($this->signature) == 0)
278
- && ($this->private_key instanceof Net_DNS2_PrivateKey)
279
- && (extension_loaded('openssl') === true)
280
- ) {
281
-
282
- //
283
- // create a new packet for the signature-
284
- //
285
- $new_packet = new Net_DNS2_Packet_Request('example.com', 'SOA', 'IN');
286
-
287
- //
288
- // copy the packet data over
289
- //
290
- $new_packet->copy($packet);
291
-
292
- //
293
- // remove the SIG object from the additional list
294
- //
295
- array_pop($new_packet->additional);
296
- $new_packet->header->arcount = count($new_packet->additional);
297
-
298
- //
299
- // copy out the data
300
- //
301
- $sigdata = $data . $new_packet->get();
302
-
303
- //
304
- // based on the algorithm
305
- //
306
- $algorithm = 0;
307
-
308
- switch($this->algorithm) {
309
-
310
- //
311
- // MD5
312
- //
313
- case Net_DNS2_Lookups::DNSSEC_ALGORITHM_RSAMD5:
314
-
315
- $algorithm = OPENSSL_ALGO_MD5;
316
- break;
317
-
318
- //
319
- // SHA1
320
- //
321
- case Net_DNS2_Lookups::DNSSEC_ALGORITHM_RSASHA1:
322
-
323
- $algorithm = OPENSSL_ALGO_SHA1;
324
- break;
325
-
326
- //
327
- // SHA256 (PHP 5.4.8 or higher)
328
- //
329
- case Net_DNS2_Lookups::DNSSEC_ALGORITHM_RSASHA256:
330
-
331
- if (version_compare(PHP_VERSION, '5.4.8', '<') == true) {
332
-
333
- throw new Net_DNS2_Exception(
334
- 'SHA256 support is only available in PHP >= 5.4.8',
335
- Net_DNS2_Lookups::E_OPENSSL_INV_ALGO
336
- );
337
- }
338
-
339
- $algorithm = OPENSSL_ALGO_SHA256;
340
- break;
341
-
342
- //
343
- // SHA512 (PHP 5.4.8 or higher)
344
- //
345
- case Net_DNS2_Lookups::DNSSEC_ALGORITHM_RSASHA512:
346
-
347
- if (version_compare(PHP_VERSION, '5.4.8', '<') == true) {
348
-
349
- throw new Net_DNS2_Exception(
350
- 'SHA512 support is only available in PHP >= 5.4.8',
351
- Net_DNS2_Lookups::E_OPENSSL_INV_ALGO
352
- );
353
- }
354
-
355
- $algorithm = OPENSSL_ALGO_SHA512;
356
- break;
357
-
358
- //
359
- // unsupported at the moment
360
- //
361
- case Net_DNS2_Lookups::DNSSEC_ALGORITHM_DSA:
362
- case Net_DNS2_Lookups::DSNSEC_ALGORITHM_RSASHA1NSEC3SHA1:
363
- case Net_DNS2_Lookups::DNSSEC_ALGORITHM_DSANSEC3SHA1:
364
- default:
365
- throw new Net_DNS2_Exception(
366
- 'invalid or unsupported algorithm',
367
- Net_DNS2_Lookups::E_OPENSSL_INV_ALGO
368
- );
369
- break;
370
- }
371
-
372
- //
373
- // sign the data
374
- //
375
- if (openssl_sign($sigdata, $this->signature, $this->private_key->instance, $algorithm) == false) {
376
-
377
- throw new Net_DNS2_Exception(
378
- openssl_error_string(),
379
- Net_DNS2_Lookups::E_OPENSSL_ERROR
380
- );
381
- }
382
-
383
- //
384
- // build the signature value based
385
- //
386
- switch($this->algorithm) {
387
-
388
- //
389
- // RSA- add it directly
390
- //
391
- case Net_DNS2_Lookups::DNSSEC_ALGORITHM_RSAMD5:
392
- case Net_DNS2_Lookups::DNSSEC_ALGORITHM_RSASHA1:
393
- case Net_DNS2_Lookups::DNSSEC_ALGORITHM_RSASHA256:
394
- case Net_DNS2_Lookups::DNSSEC_ALGORITHM_RSASHA512:
395
-
396
- $this->signature = base64_encode($this->signature);
397
- break;
398
- }
399
- }
400
-
401
- //
402
- // add the signature
403
- //
404
- $data .= base64_decode($this->signature);
405
-
406
- $packet->offset += strlen($data);
407
-
408
- return $data;
409
- }
410
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/SMIMEA.php DELETED
@@ -1,27 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 1.4.2
17
- *
18
- */
19
-
20
- /**
21
- * The SMIMEA RR is implemented exactly like the TLSA record, so
22
- * for now we just extend the TLSA RR and use it.
23
- *
24
- */
25
- class Net_DNS2_RR_SMIMEA extends Net_DNS2_RR_TLSA
26
- {
27
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/SOA.php DELETED
@@ -1,192 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 0.6.0
17
- *
18
- */
19
-
20
- /**
21
- * SOA Resource Record - RFC1035 section 3.3.13
22
- *
23
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
24
- * / MNAME /
25
- * / /
26
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
27
- * / RNAME /
28
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
29
- * | SERIAL |
30
- * | |
31
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
32
- * | REFRESH |
33
- * | |
34
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
35
- * | RETRY |
36
- * | |
37
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
38
- * | EXPIRE |
39
- * | |
40
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
41
- * | MINIMUM |
42
- * | |
43
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
44
- *
45
- */
46
- class Net_DNS2_RR_SOA extends Net_DNS2_RR
47
- {
48
- /*
49
- * The master DNS server
50
- */
51
- public $mname;
52
-
53
- /*
54
- * mailbox of the responsible person
55
- */
56
- public $rname;
57
-
58
- /*
59
- * serial number
60
- */
61
- public $serial;
62
-
63
- /*
64
- * refresh time
65
- */
66
- public $refresh;
67
-
68
- /*
69
- * retry interval
70
- */
71
- public $retry;
72
-
73
- /*
74
- * expire time
75
- */
76
- public $expire;
77
-
78
- /*
79
- * minimum TTL for any RR in this zone
80
- */
81
- public $minimum;
82
-
83
- /**
84
- * method to return the rdata portion of the packet as a string
85
- *
86
- * @return string
87
- * @access protected
88
- *
89
- */
90
- protected function rrToString()
91
- {
92
- return $this->cleanString($this->mname) . '. ' .
93
- $this->cleanString($this->rname) . '. ' .
94
- $this->serial . ' ' . $this->refresh . ' ' . $this->retry . ' ' .
95
- $this->expire . ' ' . $this->minimum;
96
- }
97
-
98
- /**
99
- * parses the rdata portion from a standard DNS config line
100
- *
101
- * @param array $rdata a string split line of values for the rdata
102
- *
103
- * @return boolean
104
- * @access protected
105
- *
106
- */
107
- protected function rrFromString(array $rdata)
108
- {
109
- $this->mname = $this->cleanString($rdata[0]);
110
- $this->rname = $this->cleanString($rdata[1]);
111
-
112
- $this->serial = $rdata[2];
113
- $this->refresh = $rdata[3];
114
- $this->retry = $rdata[4];
115
- $this->expire = $rdata[5];
116
- $this->minimum = $rdata[6];
117
-
118
- return true;
119
- }
120
-
121
- /**
122
- * parses the rdata of the Net_DNS2_Packet object
123
- *
124
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
125
- *
126
- * @return boolean
127
- * @access protected
128
- *
129
- */
130
- protected function rrSet(Net_DNS2_Packet &$packet)
131
- {
132
- if ($this->rdlength > 0) {
133
-
134
- //
135
- // parse the
136
- //
137
- $offset = $packet->offset;
138
-
139
- $this->mname = Net_DNS2_Packet::expand($packet, $offset);
140
- $this->rname = Net_DNS2_Packet::expand($packet, $offset, true);
141
-
142
- //
143
- // get the SOA values
144
- //
145
- $x = unpack(
146
- '@' . $offset . '/Nserial/Nrefresh/Nretry/Nexpire/Nminimum/',
147
- $packet->rdata
148
- );
149
-
150
- $this->serial = Net_DNS2::expandUint32($x['serial']);
151
- $this->refresh = Net_DNS2::expandUint32($x['refresh']);
152
- $this->retry = Net_DNS2::expandUint32($x['retry']);
153
- $this->expire = Net_DNS2::expandUint32($x['expire']);
154
- $this->minimum = Net_DNS2::expandUint32($x['minimum']);
155
-
156
- return true;
157
- }
158
-
159
- return false;
160
- }
161
-
162
- /**
163
- * returns the rdata portion of the DNS packet
164
- *
165
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
166
- * compressed names
167
- *
168
- * @return mixed either returns a binary packed
169
- * string or null on failure
170
- * @access protected
171
- *
172
- */
173
- protected function rrGet(Net_DNS2_Packet &$packet)
174
- {
175
- if (strlen($this->mname) > 0) {
176
-
177
- $data = $packet->compress($this->mname, $packet->offset);
178
- $data .= $packet->compress($this->rname, $packet->offset);
179
-
180
- $data .= pack(
181
- 'N5', $this->serial, $this->refresh, $this->retry,
182
- $this->expire, $this->minimum
183
- );
184
-
185
- $packet->offset += 20;
186
-
187
- return $data;
188
- }
189
-
190
- return null;
191
- }
192
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/SPF.php DELETED
@@ -1,27 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 0.6.0
17
- *
18
- */
19
-
20
- /**
21
- * The SPF RR is implemented exactly like the TXT record, so
22
- * for now we just extend the TXT RR and use it.
23
- *
24
- */
25
- class Net_DNS2_RR_SPF extends Net_DNS2_RR_TXT
26
- {
27
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/SRV.php DELETED
@@ -1,145 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 0.6.0
17
- *
18
- */
19
-
20
- /**
21
- * SRV Resource Record - RFC2782
22
- *
23
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
24
- * | PRIORITY |
25
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
26
- * | WEIGHT |
27
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
28
- * | PORT |
29
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
30
- * / TARGET /
31
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
32
- *
33
- */
34
- class Net_DNS2_RR_SRV extends Net_DNS2_RR
35
- {
36
- /*
37
- * The priority of this target host.
38
- */
39
- public $priority;
40
-
41
- /*
42
- * a relative weight for entries with the same priority
43
- */
44
- public $weight;
45
-
46
- /*
47
- * The port on this target host of this service.
48
- */
49
- public $port;
50
-
51
- /*
52
- * The domain name of the target host
53
- */
54
- public $target;
55
-
56
- /**
57
- * method to return the rdata portion of the packet as a string
58
- *
59
- * @return string
60
- * @access protected
61
- *
62
- */
63
- protected function rrToString()
64
- {
65
- return $this->priority . ' ' . $this->weight . ' ' .
66
- $this->port . ' ' . $this->cleanString($this->target) . '.';
67
- }
68
-
69
- /**
70
- * parses the rdata portion from a standard DNS config line
71
- *
72
- * @param array $rdata a string split line of values for the rdata
73
- *
74
- * @return boolean
75
- * @access protected
76
- *
77
- */
78
- protected function rrFromString(array $rdata)
79
- {
80
- $this->priority = $rdata[0];
81
- $this->weight = $rdata[1];
82
- $this->port = $rdata[2];
83
-
84
- $this->target = $this->cleanString($rdata[3]);
85
-
86
- return true;
87
- }
88
-
89
- /**
90
- * parses the rdata of the Net_DNS2_Packet object
91
- *
92
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
93
- *
94
- * @return boolean
95
- * @access protected
96
- *
97
- */
98
- protected function rrSet(Net_DNS2_Packet &$packet)
99
- {
100
- if ($this->rdlength > 0) {
101
-
102
- //
103
- // unpack the priority, weight and port
104
- //
105
- $x = unpack('npriority/nweight/nport', $this->rdata);
106
-
107
- $this->priority = $x['priority'];
108
- $this->weight = $x['weight'];
109
- $this->port = $x['port'];
110
-
111
- $offset = $packet->offset + 6;
112
- $this->target = Net_DNS2_Packet::expand($packet, $offset);
113
-
114
- return true;
115
- }
116
-
117
- return false;
118
- }
119
-
120
- /**
121
- * returns the rdata portion of the DNS packet
122
- *
123
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
124
- * compressed names
125
- *
126
- * @return mixed either returns a binary packed
127
- * string or null on failure
128
- * @access protected
129
- *
130
- */
131
- protected function rrGet(Net_DNS2_Packet &$packet)
132
- {
133
- if (strlen($this->target) > 0) {
134
-
135
- $data = pack('nnn', $this->priority, $this->weight, $this->port);
136
- $packet->offset += 6;
137
-
138
- $data .= $packet->compress($this->target, $packet->offset);
139
-
140
- return $data;
141
- }
142
-
143
- return null;
144
- }
145
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/SSHFP.php DELETED
@@ -1,205 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 0.6.0
17
- *
18
- */
19
-
20
- /**
21
- * SSHFP Resource Record - RFC4255 section 3.1
22
- *
23
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
24
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
25
- * | algorithm | fp type | /
26
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ /
27
- * / /
28
- * / fingerprint /
29
- * / /
30
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
31
- *
32
- */
33
- class Net_DNS2_RR_SSHFP extends Net_DNS2_RR
34
- {
35
- /*
36
- * the algorithm used
37
- */
38
- public $algorithm;
39
-
40
- /*
41
- * The finger print type
42
- */
43
- public $fp_type;
44
-
45
- /*
46
- * the finger print data
47
- */
48
- public $fingerprint;
49
-
50
- /*
51
- * Algorithms
52
- */
53
- const SSHFP_ALGORITHM_RES = 0;
54
- const SSHFP_ALGORITHM_RSA = 1;
55
- const SSHFP_ALGORITHM_DSS = 2;
56
- const SSHFP_ALGORITHM_ECDSA = 3;
57
- const SSHFP_ALGORITHM_ED25519 = 4;
58
-
59
- /*
60
- * Fingerprint Types
61
- */
62
- const SSHFP_FPTYPE_RES = 0;
63
- const SSHFP_FPTYPE_SHA1 = 1;
64
- const SSHFP_FPTYPE_SHA256 = 2;
65
-
66
-
67
- /**
68
- * method to return the rdata portion of the packet as a string
69
- *
70
- * @return string
71
- * @access protected
72
- *
73
- */
74
- protected function rrToString()
75
- {
76
- return $this->algorithm . ' ' . $this->fp_type . ' ' . $this->fingerprint;
77
- }
78
-
79
- /**
80
- * parses the rdata portion from a standard DNS config line
81
- *
82
- * @param array $rdata a string split line of values for the rdata
83
- *
84
- * @return boolean
85
- * @access protected
86
- *
87
- */
88
- protected function rrFromString(array $rdata)
89
- {
90
- //
91
- // "The use of mnemonics instead of numbers is not allowed."
92
- //
93
- // RFC4255 section 3.2
94
- //
95
- $algorithm = array_shift($rdata);
96
- $fp_type = array_shift($rdata);
97
- $fingerprint = strtolower(implode('', $rdata));
98
-
99
- //
100
- // There are only two algorithm's defined
101
- //
102
- if ( ($algorithm != self::SSHFP_ALGORITHM_RSA)
103
- && ($algorithm != self::SSHFP_ALGORITHM_DSS)
104
- && ($algorithm != self::SSHFP_ALGORITHM_ECDSA)
105
- && ($algorithm != self::SSHFP_ALGORITHM_ED25519)
106
- ) {
107
- return false;
108
- }
109
-
110
- //
111
- // there are only two fingerprints defined
112
- //
113
- if ( ($fp_type != self::SSHFP_FPTYPE_SHA1)
114
- && ($fp_type != self::SSHFP_FPTYPE_SHA256)
115
- ) {
116
- return false;
117
- }
118
-
119
- $this->algorithm = $algorithm;
120
- $this->fp_type = $fp_type;
121
- $this->fingerprint = $fingerprint;
122
-
123
- return true;
124
- }
125
-
126
- /**
127
- * parses the rdata of the Net_DNS2_Packet object
128
- *
129
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
130
- *
131
- * @return boolean
132
- * @access protected
133
- *
134
- */
135
- protected function rrSet(Net_DNS2_Packet &$packet)
136
- {
137
- if ($this->rdlength > 0) {
138
-
139
- //
140
- // unpack the algorithm and finger print type
141
- //
142
- $x = unpack('Calgorithm/Cfp_type', $this->rdata);
143
-
144
- $this->algorithm = $x['algorithm'];
145
- $this->fp_type = $x['fp_type'];
146
-
147
- //
148
- // There are only three algorithm's defined
149
- //
150
- if ( ($this->algorithm != self::SSHFP_ALGORITHM_RSA)
151
- && ($this->algorithm != self::SSHFP_ALGORITHM_DSS)
152
- && ($this->algorithm != self::SSHFP_ALGORITHM_ECDSA)
153
- && ($this->algorithm != self::SSHFP_ALGORITHM_ED25519)
154
- ) {
155
- return false;
156
- }
157
-
158
- //
159
- // there are only two fingerprints defined
160
- //
161
- if ( ($this->fp_type != self::SSHFP_FPTYPE_SHA1)
162
- && ($this->fp_type != self::SSHFP_FPTYPE_SHA256)
163
- ) {
164
- return false;
165
- }
166
-
167
- //
168
- // parse the finger print; this assumes SHA-1
169
- //
170
- $fp = unpack('H*a', substr($this->rdata, 2));
171
- $this->fingerprint = strtolower($fp['a']);
172
-
173
- return true;
174
- }
175
-
176
- return false;
177
- }
178
-
179
- /**
180
- * returns the rdata portion of the DNS packet
181
- *
182
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
183
- * compressed names
184
- *
185
- * @return mixed either returns a binary packed
186
- * string or null on failure
187
- * @access protected
188
- *
189
- */
190
- protected function rrGet(Net_DNS2_Packet &$packet)
191
- {
192
- if (strlen($this->fingerprint) > 0) {
193
-
194
- $data = pack(
195
- 'CCH*', $this->algorithm, $this->fp_type, $this->fingerprint
196
- );
197
-
198
- $packet->offset += strlen($data);
199
-
200
- return $data;
201
- }
202
-
203
- return null;
204
- }
205
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/TA.php DELETED
@@ -1,27 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 1.2.0
17
- *
18
- */
19
-
20
- /**
21
- * The TA RR is implemented exactly like the DS record, so
22
- * for now we just extend the DS RR and use it.
23
- *
24
- */
25
- class Net_DNS2_RR_TA extends Net_DNS2_RR_DS
26
- {
27
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/TALINK.php DELETED
@@ -1,121 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * @category Networking
9
- * @package Net_DNS2
10
- * @author Mike Pultz <mike@mikepultz.com>
11
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
12
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
13
- * @link https://netdns2.com/
14
- * @since File available since Release 1.2.0
15
- *
16
- */
17
-
18
- /**
19
- * TALINK Resource Record - DNSSEC Trust Anchor
20
- *
21
- * http://tools.ietf.org/id/draft-ietf-dnsop-dnssec-trust-history-00.txt
22
- *
23
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
24
- * / PREVIOUS /
25
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
26
- * / NEXT /
27
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
28
- *
29
- */
30
- class Net_DNS2_RR_TALINK extends Net_DNS2_RR
31
- {
32
- /*
33
- * the previous domain name
34
- */
35
- public $previous;
36
-
37
- /*
38
- * the next domain name
39
- */
40
- public $next;
41
-
42
- /**
43
- * method to return the rdata portion of the packet as a string
44
- *
45
- * @return string
46
- * @access protected
47
- *
48
- */
49
- protected function rrToString()
50
- {
51
- return $this->cleanString($this->previous) . '. ' .
52
- $this->cleanString($this->next) . '.';
53
- }
54
-
55
- /**
56
- * parses the rdata portion from a standard DNS config line
57
- *
58
- * @param array $rdata a string split line of values for the rdata
59
- *
60
- * @return boolean
61
- * @access protected
62
- *
63
- */
64
- protected function rrFromString(array $rdata)
65
- {
66
- $this->previous = $this->cleanString($rdata[0]);
67
- $this->next = $this->cleanString($rdata[1]);
68
-
69
- return true;
70
- }
71
-
72
- /**
73
- * parses the rdata of the Net_DNS2_Packet object
74
- *
75
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
76
- *
77
- * @return boolean
78
- * @access protected
79
- *
80
- */
81
- protected function rrSet(Net_DNS2_Packet &$packet)
82
- {
83
- if ($this->rdlength > 0) {
84
-
85
- $offset = $packet->offset;
86
-
87
- $this->previous = Net_DNS2_Packet::label($packet, $offset);
88
- $this->next = Net_DNS2_Packet::label($packet, $offset);
89
-
90
- return true;
91
- }
92
-
93
- return false;
94
- }
95
-
96
- /**
97
- * returns the rdata portion of the DNS packet
98
- *
99
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
100
- * compressed names
101
- *
102
- * @return mixed either returns a binary packed
103
- * string or null on failure
104
- * @access protected
105
- *
106
- */
107
- protected function rrGet(Net_DNS2_Packet &$packet)
108
- {
109
- if ( (strlen($this->previous) > 0) || (strlen($this->next) > 0) ) {
110
-
111
- $data = chr(strlen($this->previous)) . $this->previous .
112
- chr(strlen($this->next)) . $this->next;
113
-
114
- $packet->offset += strlen($data);
115
-
116
- return $data;
117
- }
118
-
119
- return null;
120
- }
121
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/TKEY.php DELETED
@@ -1,259 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 0.6.0
17
- *
18
- */
19
-
20
- /**
21
- * TKEY Resource Record - RFC 2930 section 2
22
- *
23
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
24
- * / ALGORITHM /
25
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
26
- * | INCEPTION |
27
- * | |
28
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
29
- * | EXPIRATION |
30
- * | |
31
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
32
- * | MODE |
33
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
34
- * | ERROR |
35
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
36
- * | KEY SIZE |
37
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
38
- * / KEY DATA /
39
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
40
- * | OTHER SIZE |
41
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
42
- * / OTHER DATA /
43
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
44
- *
45
- */
46
- class Net_DNS2_RR_TKEY extends Net_DNS2_RR
47
- {
48
- public $algorithm;
49
- public $inception;
50
- public $expiration;
51
- public $mode;
52
- public $error;
53
- public $key_size;
54
- public $key_data;
55
- public $other_size;
56
- public $other_data;
57
-
58
- /*
59
- * TSIG Modes
60
- */
61
- const TSIG_MODE_RES = 0;
62
- const TSIG_MODE_SERV_ASSIGN = 1;
63
- const TSIG_MODE_DH = 2;
64
- const TSIG_MODE_GSS_API = 3;
65
- const TSIG_MODE_RESV_ASSIGN = 4;
66
- const TSIG_MODE_KEY_DELE = 5;
67
-
68
- /*
69
- * map the mod id's to names so we can validate
70
- */
71
- public $tsgi_mode_id_to_name = [
72
-
73
- self::TSIG_MODE_RES => 'Reserved',
74
- self::TSIG_MODE_SERV_ASSIGN => 'Server Assignment',
75
- self::TSIG_MODE_DH => 'Diffie-Hellman',
76
- self::TSIG_MODE_GSS_API => 'GSS-API',
77
- self::TSIG_MODE_RESV_ASSIGN => 'Resolver Assignment',
78
- self::TSIG_MODE_KEY_DELE => 'Key Deletion'
79
- ];
80
-
81
- /**
82
- * method to return the rdata portion of the packet as a string
83
- *
84
- * @return string
85
- * @access protected
86
- *
87
- */
88
- protected function rrToString()
89
- {
90
- $out = $this->cleanString($this->algorithm) . '. ' . $this->mode;
91
- if ($this->key_size > 0) {
92
-
93
- $out .= ' ' . trim($this->key_data, '.') . '.';
94
- } else {
95
-
96
- $out .= ' .';
97
- }
98
-
99
- return $out;
100
- }
101
-
102
- /**
103
- * parses the rdata portion from a standard DNS config line
104
- *
105
- * @param array $rdata a string split line of values for the rdata
106
- *
107
- * @return boolean
108
- * @access protected
109
- *
110
- */
111
- protected function rrFromString(array $rdata)
112
- {
113
- //
114
- // data passed in is assumed: <algorithm> <mode> <key>
115
- //
116
- $this->algorithm = $this->cleanString(array_shift($rdata));
117
- $this->mode = array_shift($rdata);
118
- $this->key_data = trim(array_shift($rdata), '.');
119
-
120
- //
121
- // the rest of the data is set manually
122
- //
123
- $this->inception = time();
124
- $this->expiration = time() + 86400; // 1 day
125
- $this->error = 0;
126
- $this->key_size = strlen($this->key_data);
127
- $this->other_size = 0;
128
- $this->other_data = '';
129
-
130
- return true;
131
- }
132
-
133
- /**
134
- * parses the rdata of the Net_DNS2_Packet object
135
- *
136
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
137
- *
138
- * @return boolean
139
- * @access protected
140
- *
141
- */
142
- protected function rrSet(Net_DNS2_Packet &$packet)
143
- {
144
- if ($this->rdlength > 0) {
145
-
146
- //
147
- // expand the algorithm
148
- //
149
- $offset = $packet->offset;
150
- $this->algorithm = Net_DNS2_Packet::expand($packet, $offset);
151
-
152
- //
153
- // unpack inception, expiration, mode, error and key size
154
- //
155
- $x = unpack(
156
- '@' . $offset . '/Ninception/Nexpiration/nmode/nerror/nkey_size',
157
- $packet->rdata
158
- );
159
-
160
- $this->inception = Net_DNS2::expandUint32($x['inception']);
161
- $this->expiration = Net_DNS2::expandUint32($x['expiration']);
162
- $this->mode = $x['mode'];
163
- $this->error = $x['error'];
164
- $this->key_size = $x['key_size'];
165
-
166
- $offset += 14;
167
-
168
- //
169
- // if key_size > 0, then copy out the key
170
- //
171
- if ($this->key_size > 0) {
172
-
173
- $this->key_data = substr($packet->rdata, $offset, $this->key_size);
174
- $offset += $this->key_size;
175
- }
176
-
177
- //
178
- // unpack the other length
179
- //
180
- $x = unpack('@' . $offset . '/nother_size', $packet->rdata);
181
-
182
- $this->other_size = $x['other_size'];
183
- $offset += 2;
184
-
185
- //
186
- // if other_size > 0, then copy out the data
187
- //
188
- if ($this->other_size > 0) {
189
-
190
- $this->other_data = substr(
191
- $packet->rdata, $offset, $this->other_size
192
- );
193
- }
194
-
195
- return true;
196
- }
197
-
198
- return false;
199
- }
200
-
201
- /**
202
- * returns the rdata portion of the DNS packet
203
- *
204
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
205
- * compressed names
206
- *
207
- * @return mixed either returns a binary packed
208
- * string or null on failure
209
- * @access protected
210
- *
211
- */
212
- protected function rrGet(Net_DNS2_Packet &$packet)
213
- {
214
- if (strlen($this->algorithm) > 0) {
215
-
216
- //
217
- // make sure the size values are correct
218
- //
219
- $this->key_size = strlen($this->key_data);
220
- $this->other_size = strlen($this->other_data);
221
-
222
- //
223
- // add the algorithm without compression
224
- //
225
- $data = Net_DNS2_Packet::pack($this->algorithm);
226
-
227
- //
228
- // pack in the inception, expiration, mode, error and key size
229
- //
230
- $data .= pack(
231
- 'NNnnn', $this->inception, $this->expiration,
232
- $this->mode, 0, $this->key_size
233
- );
234
-
235
- //
236
- // if the key_size > 0, then add the key
237
- //
238
- if ($this->key_size > 0) {
239
-
240
- $data .= $this->key_data;
241
- }
242
-
243
- //
244
- // pack in the other size
245
- //
246
- $data .= pack('n', $this->other_size);
247
- if ($this->other_size > 0) {
248
-
249
- $data .= $this->other_data;
250
- }
251
-
252
- $packet->offset += strlen($data);
253
-
254
- return $data;
255
- }
256
-
257
- return null;
258
- }
259
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/TLSA.php DELETED
@@ -1,146 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 1.2.5
17
- *
18
- */
19
-
20
- /**
21
- * TLSA Resource Record - RFC 6698
22
- *
23
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
24
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
25
- * | Cert. Usage | Selector | Matching Type | /
26
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ /
27
- * / /
28
- * / Certificate Association Data /
29
- * / /
30
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
31
- *
32
- */
33
- class Net_DNS2_RR_TLSA extends Net_DNS2_RR
34
- {
35
- /*
36
- * The Certificate Usage Field
37
- */
38
- public $cert_usage;
39
-
40
- /*
41
- * The Selector Field
42
- */
43
- public $selector;
44
-
45
- /*
46
- * The Matching Type Field
47
- */
48
- public $matching_type;
49
-
50
- /*
51
- * The Certificate Association Data Field
52
- */
53
- public $certificate;
54
-
55
- /**
56
- * method to return the rdata portion of the packet as a string
57
- *
58
- * @return string
59
- * @access protected
60
- *
61
- */
62
- protected function rrToString()
63
- {
64
- return $this->cert_usage . ' ' . $this->selector . ' ' .
65
- $this->matching_type . ' ' . base64_encode($this->certificate);
66
- }
67
-
68
- /**
69
- * parses the rdata portion from a standard DNS config line
70
- *
71
- * @param array $rdata a string split line of values for the rdata
72
- *
73
- * @return boolean
74
- * @access protected
75
- *
76
- */
77
- protected function rrFromString(array $rdata)
78
- {
79
- $this->cert_usage = array_shift($rdata);
80
- $this->selector = array_shift($rdata);
81
- $this->matching_type = array_shift($rdata);
82
- $this->certificate = base64_decode(implode('', $rdata));
83
-
84
- return true;
85
- }
86
-
87
- /**
88
- * parses the rdata of the Net_DNS2_Packet object
89
- *
90
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
91
- *
92
- * @return boolean
93
- * @access protected
94
- *
95
- */
96
- protected function rrSet(Net_DNS2_Packet &$packet)
97
- {
98
- if ($this->rdlength > 0) {
99
-
100
- //
101
- // unpack the format, keytag and algorithm
102
- //
103
- $x = unpack('Cusage/Cselector/Ctype', $this->rdata);
104
-
105
- $this->cert_usage = $x['usage'];
106
- $this->selector = $x['selector'];
107
- $this->matching_type = $x['type'];
108
-
109
- //
110
- // copy the certificate
111
- //
112
- $this->certificate = substr($this->rdata, 3, $this->rdlength - 3);
113
-
114
- return true;
115
- }
116
-
117
- return false;
118
- }
119
-
120
- /**
121
- * returns the rdata portion of the DNS packet
122
- *
123
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
124
- * compressed names
125
- *
126
- * @return mixed either returns a binary packed
127
- * string or null on failure
128
- * @access protected
129
- *
130
- */
131
- protected function rrGet(Net_DNS2_Packet &$packet)
132
- {
133
- if (strlen($this->certificate) > 0) {
134
-
135
- $data = pack(
136
- 'CCC', $this->cert_usage, $this->selector, $this->matching_type
137
- ) . $this->certificate;
138
-
139
- $packet->offset += strlen($data);
140
-
141
- return $data;
142
- }
143
-
144
- return null;
145
- }
146
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/TSIG.php DELETED
@@ -1,456 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 0.6.0
17
- *
18
- */
19
-
20
- /**
21
- * TSIG Resource Record - RFC 2845
22
- *
23
- * 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
24
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
25
- * / algorithm /
26
- * / /
27
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
28
- * | time signed |
29
- * | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
30
- * | | fudge |
31
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
32
- * | mac size | /
33
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ /
34
- * / mac /
35
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
36
- * | original id | error |
37
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
38
- * | other length | /
39
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ /
40
- * / other data /
41
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
42
- *
43
- */
44
- class Net_DNS2_RR_TSIG extends Net_DNS2_RR
45
- {
46
- /*
47
- * TSIG Algorithm Identifiers
48
- */
49
- const HMAC_MD5 = 'hmac-md5.sig-alg.reg.int'; // RFC 2845, required
50
- const GSS_TSIG = 'gss-tsig'; // unsupported, optional
51
- const HMAC_SHA1 = 'hmac-sha1'; // RFC 4635, required
52
- const HMAC_SHA224 = 'hmac-sha224'; // RFC 4635, optional
53
- const HMAC_SHA256 = 'hmac-sha256'; // RFC 4635, required
54
- const HMAC_SHA384 = 'hmac-sha384'; // RFC 4635, optional
55
- const HMAC_SHA512 = 'hmac-sha512'; // RFC 4635, optional
56
-
57
- /*
58
- * the map of hash values to names
59
- */
60
- public static $hash_algorithms = [
61
-
62
- self::HMAC_MD5 => 'md5',
63
- self::HMAC_SHA1 => 'sha1',
64
- self::HMAC_SHA224 => 'sha224',
65
- self::HMAC_SHA256 => 'sha256',
66
- self::HMAC_SHA384 => 'sha384',
67
- self::HMAC_SHA512 => 'sha512'
68
- ];
69
-
70
- /*
71
- * algorithm used; only supports HMAC-MD5
72
- */
73
- public $algorithm;
74
-
75
- /*
76
- * The time it was signed
77
- */
78
- public $time_signed;
79
-
80
- /*
81
- * fudge- allowed offset from the time signed
82
- */
83
- public $fudge;
84
-
85
- /*
86
- * size of the digest
87
- */
88
- public $mac_size;
89
-
90
- /*
91
- * the digest data
92
- */
93
- public $mac;
94
-
95
- /*
96
- * the original id of the request
97
- */
98
- public $original_id;
99
-
100
- /*
101
- * additional error code
102
- */
103
- public $error;
104
-
105
- /*
106
- * length of the "other" data, should only ever be 0 when there is
107
- * no error, or 6 when there is the error RCODE_BADTIME
108
- */
109
- public $other_length;
110
-
111
- /*
112
- * the other data; should only ever be a timestamp when there is the
113
- * error RCODE_BADTIME
114
- */
115
- public $other_data;
116
-
117
- /*
118
- * the key to use for signing - passed in, not included in the rdata
119
- */
120
- public $key;
121
-
122
- /**
123
- * method to return the rdata portion of the packet as a string
124
- *
125
- * @return string
126
- * @access protected
127
- *
128
- */
129
- protected function rrToString()
130
- {
131
- $out = $this->cleanString($this->algorithm) . '. ' .
132
- $this->time_signed . ' ' .
133
- $this->fudge . ' ' . $this->mac_size . ' ' .
134
- base64_encode($this->mac) . ' ' . $this->original_id . ' ' .
135
- $this->error . ' '. $this->other_length;
136
-
137
- if ($this->other_length > 0) {
138
-
139
- $out .= ' ' . $this->other_data;
140
- }
141
-
142
- return $out;
143
- }
144
-
145
- /**
146
- * parses the rdata portion from a standard DNS config line
147
- *
148
- * @param array $rdata a string split line of values for the rdata
149
- *
150
- * @return boolean
151
- * @access protected
152
- *
153
- */
154
- protected function rrFromString(array $rdata)
155
- {
156
- //
157
- // the only value passed in is the key-
158
- //
159
- // this assumes it's passed in base64 encoded.
160
- //
161
- $this->key = preg_replace('/\s+/', '', array_shift($rdata));
162
-
163
- //
164
- // the rest of the data is set to default
165
- //
166
- $this->algorithm = self::HMAC_MD5;
167
- $this->time_signed = time();
168
- $this->fudge = 300;
169
- $this->mac_size = 0;
170
- $this->mac = '';
171
- $this->original_id = 0;
172
- $this->error = 0;
173
- $this->other_length = 0;
174
- $this->other_data = '';
175
-
176
- //
177
- // per RFC 2845 section 2.3
178
- //
179
- $this->class = 'ANY';
180
- $this->ttl = 0;
181
-
182
- return true;
183
- }
184
-
185
- /**
186
- * parses the rdata of the Net_DNS2_Packet object
187
- *
188
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
189
- *
190
- * @return boolean
191
- * @access protected
192
- *
193
- */
194
- protected function rrSet(Net_DNS2_Packet &$packet)
195
- {
196
- if ($this->rdlength > 0) {
197
-
198
- //
199
- // expand the algorithm
200
- //
201
- $newoffset = $packet->offset;
202
- $this->algorithm = Net_DNS2_Packet::expand($packet, $newoffset);
203
- $offset = $newoffset - $packet->offset;
204
-
205
- //
206
- // unpack time, fudge and mac_size
207
- //
208
- $x = unpack(
209
- '@' . $offset . '/ntime_high/Ntime_low/nfudge/nmac_size',
210
- $this->rdata
211
- );
212
-
213
- $this->time_signed = Net_DNS2::expandUint32($x['time_low']);
214
- $this->fudge = $x['fudge'];
215
- $this->mac_size = $x['mac_size'];
216
-
217
- $offset += 10;
218
-
219
- //
220
- // copy out the mac
221
- //
222
- if ($this->mac_size > 0) {
223
-
224
- $this->mac = substr($this->rdata, $offset, $this->mac_size);
225
- $offset += $this->mac_size;
226
- }
227
-
228
- //
229
- // unpack the original id, error, and other_length values
230
- //
231
- $x = unpack(
232
- '@' . $offset . '/noriginal_id/nerror/nother_length',
233
- $this->rdata
234
- );
235
-
236
- $this->original_id = $x['original_id'];
237
- $this->error = $x['error'];
238
- $this->other_length = $x['other_length'];
239
-
240
- //
241
- // the only time there is actually any "other data", is when there's
242
- // a BADTIME error code.
243
- //
244
- // The other length should be 6, and the other data field includes the
245
- // servers current time - per RFC 2845 section 4.5.2
246
- //
247
- if ($this->error == Net_DNS2_Lookups::RCODE_BADTIME) {
248
-
249
- if ($this->other_length != 6) {
250
-
251
- return false;
252
- }
253
-
254
- //
255
- // other data is a 48bit timestamp
256
- //
257
- $x = unpack(
258
- 'nhigh/nlow',
259
- substr($this->rdata, $offset + 6, $this->other_length)
260
- );
261
- $this->other_data = $x['low'];
262
- }
263
-
264
- return true;
265
- }
266
-
267
- return false;
268
- }
269
-
270
- /**
271
- * returns the rdata portion of the DNS packet
272
- *
273
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
274
- * compressed names
275
- *
276
- * @return mixed either returns a binary packed
277
- * string or null on failure
278
- * @access protected
279
- *
280
- */
281
- protected function rrGet(Net_DNS2_Packet &$packet)
282
- {
283
- if (strlen($this->key) > 0) {
284
-
285
- //
286
- // create a new packet for the signature-
287
- //
288
- $new_packet = new Net_DNS2_Packet_Request('example.com', 'SOA', 'IN');
289
-
290
- //
291
- // copy the packet data over
292
- //
293
- $new_packet->copy($packet);
294
-
295
- //
296
- // remove the TSIG object from the additional list
297
- //
298
- array_pop($new_packet->additional);
299
- $new_packet->header->arcount = count($new_packet->additional);
300
-
301
- //
302
- // copy out the data
303
- //
304
- $sig_data = $new_packet->get();
305
-
306
- //
307
- // add the name without compressing
308
- //
309
- $sig_data .= Net_DNS2_Packet::pack($this->name);
310
-
311
- //
312
- // add the class and TTL
313
- //
314
- $sig_data .= pack(
315
- 'nN', Net_DNS2_Lookups::$classes_by_name[$this->class], $this->ttl
316
- );
317
-
318
- //
319
- // add the algorithm name without compression
320
- //
321
- $sig_data .= Net_DNS2_Packet::pack(strtolower($this->algorithm));
322
-
323
- //
324
- // add the rest of the values
325
- //
326
- $sig_data .= pack(
327
- 'nNnnn', 0, $this->time_signed, $this->fudge,
328
- $this->error, $this->other_length
329
- );
330
- if ($this->other_length > 0) {
331
-
332
- $sig_data .= pack('nN', 0, $this->other_data);
333
- }
334
-
335
- //
336
- // sign the data
337
- //
338
- $this->mac = $this->_signHMAC(
339
- $sig_data, base64_decode($this->key), $this->algorithm
340
- );
341
- $this->mac_size = strlen($this->mac);
342
-
343
- //
344
- // compress the algorithm
345
- //
346
- $data = Net_DNS2_Packet::pack(strtolower($this->algorithm));
347
-
348
- //
349
- // pack the time, fudge and mac size
350
- //
351
- $data .= pack(
352
- 'nNnn', 0, $this->time_signed, $this->fudge, $this->mac_size
353
- );
354
- $data .= $this->mac;
355
-
356
- //
357
- // check the error and other_length
358
- //
359
- if ($this->error == Net_DNS2_Lookups::RCODE_BADTIME) {
360
-
361
- $this->other_length = strlen($this->other_data);
362
- if ($this->other_length != 6) {
363
-
364
- return null;
365
- }
366
- } else {
367
-
368
- $this->other_length = 0;
369
- $this->other_data = '';
370
- }
371
-
372
- //
373
- // pack the id, error and other_length
374
- //
375
- $data .= pack(
376
- 'nnn', $packet->header->id, $this->error, $this->other_length
377
- );
378
- if ($this->other_length > 0) {
379
-
380
- $data .= pack('nN', 0, $this->other_data);
381
- }
382
-
383
- $packet->offset += strlen($data);
384
-
385
- return $data;
386
- }
387
-
388
- return null;
389
- }
390
-
391
- /**
392
- * signs the given data with the given key, and returns the result
393
- *
394
- * @param string $data the data to sign
395
- * @param string $key key to use for signing
396
- * @param string $algorithm the algorithm to use; defaults to MD5
397
- *
398
- * @return string the signed digest
399
- * @throws Net_DNS2_Exception
400
- * @access private
401
- *
402
- */
403
- private function _signHMAC($data, $key = null, $algorithm = self::HMAC_MD5)
404
- {
405
- //
406
- // use the hash extension; this is included by default in >= 5.1.2 which
407
- // is our dependent version anyway- so it's easy to switch to it.
408
- //
409
- if (extension_loaded('hash')) {
410
-
411
- if (!isset(self::$hash_algorithms[$algorithm])) {
412
-
413
- throw new Net_DNS2_Exception(
414
- 'invalid or unsupported algorithm',
415
- Net_DNS2_Lookups::E_PARSE_ERROR
416
- );
417
- }
418
-
419
- return hash_hmac(self::$hash_algorithms[$algorithm], $data, $key, true);
420
- }
421
-
422
- //
423
- // if the hash extension isn't loaded, and they selected something other
424
- // than MD5, throw an exception
425
- //
426
- if ($algorithm != self::HMAC_MD5) {
427
-
428
- throw new Net_DNS2_Exception(
429
- 'only HMAC-MD5 supported. please install the php-extension ' .
430
- '"hash" in order to use the sha-family',
431
- Net_DNS2_Lookups::E_PARSE_ERROR
432
- );
433
- }
434
-
435
- //
436
- // otherwise, do it ourselves
437
- //
438
- if (is_null($key)) {
439
-
440
- return pack('H*', md5($data));
441
- }
442
-
443
- $key = str_pad($key, 64, chr(0x00));
444
- if (strlen($key) > 64) {
445
-
446
- $key = pack('H*', md5($key));
447
- }
448
-
449
- $k_ipad = $key ^ str_repeat(chr(0x36), 64);
450
- $k_opad = $key ^ str_repeat(chr(0x5c), 64);
451
-
452
- return $this->_signHMAC(
453
- $k_opad . pack('H*', md5($k_ipad . $data)), null, $algorithm
454
- );
455
- }
456
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/TXT.php DELETED
@@ -1,129 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 0.6.0
17
- *
18
- */
19
-
20
- /**
21
- * TXT Resource Record - RFC1035 section 3.3.14
22
- *
23
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
24
- * / TXT-DATA /
25
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
26
- *
27
- */
28
- class Net_DNS2_RR_TXT extends Net_DNS2_RR
29
- {
30
- /*
31
- * an array of the text strings
32
- */
33
- public $text = [];
34
-
35
- /**
36
- * method to return the rdata portion of the packet as a string
37
- *
38
- * @return string
39
- * @access protected
40
- *
41
- */
42
- protected function rrToString()
43
- {
44
- if (count($this->text) == 0) {
45
- return '""';
46
- }
47
-
48
- $data = '';
49
-
50
- foreach ($this->text as $t) {
51
-
52
- $data .= $this->formatString($t) . ' ';
53
- }
54
-
55
- return trim($data);
56
- }
57
-
58
- /**
59
- * parses the rdata portion from a standard DNS config line
60
- *
61
- * @param array $rdata a string split line of values for the rdata
62
- *
63
- * @return boolean
64
- * @access protected
65
- *
66
- */
67
- protected function rrFromString(array $rdata)
68
- {
69
- $data = $this->buildString($rdata);
70
- if (count($data) > 0) {
71
-
72
- $this->text = $data;
73
- }
74
-
75
- return true;
76
- }
77
-
78
- /**
79
- * parses the rdata of the Net_DNS2_Packet object
80
- *
81
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
82
- *
83
- * @return boolean
84
- * @access protected
85
- *
86
- */
87
- protected function rrSet(Net_DNS2_Packet &$packet)
88
- {
89
- if ($this->rdlength > 0) {
90
-
91
- $length = $packet->offset + $this->rdlength;
92
- $offset = $packet->offset;
93
-
94
- while ($length > $offset) {
95
-
96
- $this->text[] = Net_DNS2_Packet::label($packet, $offset);
97
- }
98
-
99
- return true;
100
- }
101
-
102
- return false;
103
- }
104
-
105
- /**
106
- * returns the rdata portion of the DNS packet
107
- *
108
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
109
- * compressed names
110
- *
111
- * @return mixed either returns a binary packed
112
- * string or null on failure
113
- * @access protected
114
- *
115
- */
116
- protected function rrGet(Net_DNS2_Packet &$packet)
117
- {
118
- $data = null;
119
-
120
- foreach ($this->text as $t) {
121
-
122
- $data .= chr(strlen($t)) . $t;
123
- }
124
-
125
- $packet->offset += strlen($data);
126
-
127
- return $data;
128
- }
129
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/TYPE65534.php DELETED
@@ -1,107 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 1.2.5
17
- *
18
- */
19
-
20
- /**
21
- * TYPE65534 - Private space
22
- *
23
- * Since Bind 9.8 beta, it use a private recode as documented
24
- * in the Bind ARM, chapter 4, "Private-type records.
25
- * Basically they store signing process state.
26
- *
27
- */
28
- class Net_DNS2_RR_TYPE65534 extends Net_DNS2_RR
29
- {
30
- /*
31
- * The Private data field
32
- */
33
- public $private_data;
34
-
35
- /**
36
- * method to return the rdata portion of the packet as a string
37
- *
38
- * @return string
39
- * @access protected
40
- *
41
- */
42
- protected function rrToString()
43
- {
44
- return base64_encode($this->private_data);
45
- }
46
-
47
- /**
48
- * parses the rdata portion from a standard DNS config line
49
- *
50
- * @param array $rdata a string split line of values for the rdata
51
- *
52
- * @return boolean
53
- * @access protected
54
- *
55
- */
56
- protected function rrFromString(array $rdata)
57
- {
58
- $this->private_data = base64_decode(implode('', $rdata));
59
-
60
- return true;
61
- }
62
-
63
- /**
64
- * parses the rdata of the Net_DNS2_Packet object
65
- *
66
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
67
- *
68
- * @return boolean
69
- * @access protected
70
- *
71
- */
72
- protected function rrSet(Net_DNS2_Packet &$packet)
73
- {
74
- if ($this->rdlength > 0) {
75
- $this->private_data = $this->rdata;
76
-
77
- return true;
78
- }
79
-
80
- return false;
81
- }
82
-
83
- /**
84
- * returns the rdata portion of the DNS packet
85
- *
86
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
87
- * compressed names
88
- *
89
- * @return mixed either returns a binary packed
90
- * string or null on failure
91
- * @access protected
92
- *
93
- */
94
- protected function rrGet(Net_DNS2_Packet &$packet)
95
- {
96
- if (strlen($this->private_data) > 0) {
97
-
98
- $data = $this->private_data;
99
-
100
- $packet->offset += strlen($data);
101
-
102
- return $data;
103
- }
104
-
105
- return null;
106
- }
107
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/URI.php DELETED
@@ -1,135 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 1.2.0
17
- *
18
- */
19
-
20
- /**
21
- * URI Resource Record - http://tools.ietf.org/html/draft-faltstrom-uri-06
22
- *
23
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
24
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
25
- * | Priority | Weight |
26
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
27
- * / /
28
- * / Target /
29
- * / /
30
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
31
- *
32
- */
33
- class Net_DNS2_RR_URI extends Net_DNS2_RR
34
- {
35
- /*
36
- * The priority of this target host.
37
- */
38
- public $priority;
39
-
40
- /*
41
- * a relative weight for entries with the same priority
42
- */
43
- public $weight;
44
-
45
- /*
46
- * The domain name of the target host
47
- */
48
- public $target;
49
-
50
- /**
51
- * method to return the rdata portion of the packet as a string
52
- *
53
- * @return string
54
- * @access protected
55
- *
56
- */
57
- protected function rrToString()
58
- {
59
- //
60
- // presentation format has double quotes (") around the target.
61
- //
62
- return $this->priority . ' ' . $this->weight . ' "' . $this->target . '"';
63
- }
64
-
65
- /**
66
- * parses the rdata portion from a standard DNS config line
67
- *
68
- * @param array $rdata a string split line of values for the rdata
69
- *
70
- * @return boolean
71
- * @access protected
72
- *
73
- */
74
- protected function rrFromString(array $rdata)
75
- {
76
- $this->priority = $rdata[0];
77
- $this->weight = $rdata[1];
78
- $this->target = trim(strtolower(trim($rdata[2])), '"');
79
-
80
- return true;
81
- }
82
-
83
- /**
84
- * parses the rdata of the Net_DNS2_Packet object
85
- *
86
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
87
- *
88
- * @return boolean
89
- * @access protected
90
- *
91
- */
92
- protected function rrSet(Net_DNS2_Packet &$packet)
93
- {
94
- if ($this->rdlength > 0) {
95
-
96
- //
97
- // unpack the priority and weight
98
- //
99
- $x = unpack('npriority/nweight/a*target', $this->rdata);
100
-
101
- $this->priority = $x['priority'];
102
- $this->weight = $x['weight'];
103
- $this->target = $x['target'];
104
-
105
- return true;
106
- }
107
-
108
- return false;
109
- }
110
-
111
- /**
112
- * returns the rdata portion of the DNS packet
113
- *
114
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
115
- * compressed names
116
- *
117
- * @return mixed either returns a binary packed
118
- * string or null on failure
119
- * @access protected
120
- *
121
- */
122
- protected function rrGet(Net_DNS2_Packet &$packet)
123
- {
124
- if (strlen($this->target) > 0) {
125
-
126
- $data = pack('nna*', $this->priority, $this->weight, $this->target);
127
-
128
- $packet->offset += strlen($data);
129
-
130
- return $data;
131
- }
132
-
133
- return null;
134
- }
135
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/WKS.php DELETED
@@ -1,187 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 1.0.1
17
- *
18
- */
19
-
20
- /**
21
- * WKS Resource Record - RFC1035 section 3.4.2
22
- *
23
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
24
- * | ADDRESS |
25
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
26
- * | PROTOCOL | |
27
- * +--+--+--+--+--+--+--+--+ |
28
- * | |
29
- * / <BIT MAP> /
30
- * / /
31
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
32
- *
33
- */
34
- class Net_DNS2_RR_WKS extends Net_DNS2_RR
35
- {
36
- /*
37
- * The IP address of the service
38
- */
39
- public $address;
40
-
41
- /*
42
- * The protocol of the service
43
- */
44
- public $protocol;
45
-
46
- /*
47
- * bitmap
48
- */
49
- public $bitmap = [];
50
-
51
- /**
52
- * method to return the rdata portion of the packet as a string
53
- *
54
- * @return string
55
- * @access protected
56
- *
57
- */
58
- protected function rrToString()
59
- {
60
- $data = $this->address . ' ' . $this->protocol;
61
-
62
- foreach ($this->bitmap as $port) {
63
- $data .= ' ' . $port;
64
- }
65
-
66
- return $data;
67
- }
68
-
69
- /**
70
- * parses the rdata portion from a standard DNS config line
71
- *
72
- * @param array $rdata a string split line of values for the rdata
73
- *
74
- * @return boolean
75
- * @access protected
76
- *
77
- */
78
- protected function rrFromString(array $rdata)
79
- {
80
- $this->address = strtolower(trim(array_shift($rdata), '.'));
81
- $this->protocol = array_shift($rdata);
82
- $this->bitmap = $rdata;
83
-
84
- return true;
85
- }
86
-
87
- /**
88
- * parses the rdata of the Net_DNS2_Packet object
89
- *
90
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
91
- *
92
- * @return boolean
93
- * @access protected
94
- *
95
- */
96
- protected function rrSet(Net_DNS2_Packet &$packet)
97
- {
98
- if ($this->rdlength > 0) {
99
-
100
- //
101
- // get the address and protocol value
102
- //
103
- $x = unpack('Naddress/Cprotocol', $this->rdata);
104
-
105
- $this->address = long2ip($x['address']);
106
- $this->protocol = $x['protocol'];
107
-
108
- //
109
- // unpack the port list bitmap
110
- //
111
- $port = 0;
112
- foreach (unpack('@5/C*', $this->rdata) as $set) {
113
-
114
- $s = sprintf('%08b', $set);
115
-
116
- for ($i=0; $i<8; $i++, $port++) {
117
- if ($s[$i] == '1') {
118
- $this->bitmap[] = $port;
119
- }
120
- }
121
- }
122
-
123
- return true;
124
- }
125
-
126
- return false;
127
- }
128
-
129
- /**
130
- * returns the rdata portion of the DNS packet
131
- *
132
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
133
- * compressed names
134
- *
135
- * @return mixed either returns a binary packed
136
- * string or null on failure
137
- * @access protected
138
- *
139
- */
140
- protected function rrGet(Net_DNS2_Packet &$packet)
141
- {
142
- if (strlen($this->address) > 0) {
143
-
144
- $data = pack('NC', ip2long($this->address), $this->protocol);
145
-
146
- $ports = [];
147
-
148
- $n = 0;
149
- foreach ($this->bitmap as $port) {
150
- $ports[$port] = 1;
151
-
152
- if ($port > $n) {
153
- $n = $port;
154
- }
155
- }
156
- for ($i=0; $i<ceil($n/8)*8; $i++) {
157
- if (!isset($ports[$i])) {
158
- $ports[$i] = 0;
159
- }
160
- }
161
-
162
- ksort($ports);
163
-
164
- $string = '';
165
- $n = 0;
166
-
167
- foreach ($ports as $s) {
168
-
169
- $string .= $s;
170
- $n++;
171
-
172
- if ($n == 8) {
173
-
174
- $data .= chr(bindec($string));
175
- $string = '';
176
- $n = 0;
177
- }
178
- }
179
-
180
- $packet->offset += strlen($data);
181
-
182
- return $data;
183
- }
184
-
185
- return null;
186
- }
187
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/RR/X25.php DELETED
@@ -1,112 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 0.6.0
17
- *
18
- */
19
-
20
- /**
21
- * X25 Resource Record - RFC1183 section 3.1
22
- *
23
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
24
- * / PSDN-address /
25
- * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
26
- *
27
- */
28
- class Net_DNS2_RR_X25 extends Net_DNS2_RR
29
- {
30
- /*
31
- * The PSDN address
32
- */
33
- public $psdnaddress;
34
-
35
- /**
36
- * method to return the rdata portion of the packet as a string
37
- *
38
- * @return string
39
- * @access protected
40
- *
41
- */
42
- protected function rrToString()
43
- {
44
- return $this->formatString($this->psdnaddress);
45
- }
46
-
47
- /**
48
- * parses the rdata portion from a standard DNS config line
49
- *
50
- * @param array $rdata a string split line of values for the rdata
51
- *
52
- * @return boolean
53
- * @access protected
54
- *
55
- */
56
- protected function rrFromString(array $rdata)
57
- {
58
- $data = $this->buildString($rdata);
59
- if (count($data) == 1) {
60
-
61
- $this->psdnaddress = $data[0];
62
- return true;
63
- }
64
-
65
- return false;
66
- }
67
-
68
- /**
69
- * parses the rdata of the Net_DNS2_Packet object
70
- *
71
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
72
- *
73
- * @return boolean
74
- * @access protected
75
- *
76
- */
77
- protected function rrSet(Net_DNS2_Packet &$packet)
78
- {
79
- if ($this->rdlength > 0) {
80
-
81
- $this->psdnaddress = Net_DNS2_Packet::label($packet, $packet->offset);
82
- return true;
83
- }
84
-
85
- return false;
86
- }
87
-
88
- /**
89
- * returns the rdata portion of the DNS packet
90
- *
91
- * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
92
- * compressed names
93
- *
94
- * @return mixed either returns a binary packed
95
- * string or null on failure
96
- * @access protected
97
- *
98
- */
99
- protected function rrGet(Net_DNS2_Packet &$packet)
100
- {
101
- if (strlen($this->psdnaddress) > 0) {
102
-
103
- $data = chr(strlen($this->psdnaddress)) . $this->psdnaddress;
104
-
105
- $packet->offset += strlen($data);
106
-
107
- return $data;
108
- }
109
-
110
- return null;
111
- }
112
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/Resolver.php DELETED
@@ -1,284 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 0.6.0
17
- *
18
- */
19
-
20
- /**
21
- * This is the main resolver class, providing DNS query functions.
22
- *
23
- */
24
- class Net_DNS2_Resolver extends Net_DNS2
25
- {
26
- /**
27
- * Constructor - creates a new Net_DNS2_Resolver object
28
- *
29
- * @param mixed $options either an array with options or null
30
- *
31
- * @access public
32
- *
33
- */
34
- public function __construct(array $options = null)
35
- {
36
- parent::__construct($options);
37
- }
38
-
39
- /**
40
- * does a basic DNS lookup query
41
- *
42
- * @param string $name the DNS name to loookup
43
- * @param string $type the name of the RR type to lookup
44
- * @param string $class the name of the RR class to lookup
45
- *
46
- * @return Net_DNS2_Packet_Response object
47
- * @throws Net_DNS2_Exception
48
- * @access public
49
- *
50
- */
51
- public function query($name, $type = 'A', $class = 'IN')
52
- {
53
- //
54
- // make sure we have some name servers set
55
- //
56
- $this->checkServers(Net_DNS2::RESOLV_CONF);
57
-
58
- //
59
- // we dont' support incremental zone tranfers; so if it's requested, a full
60
- // zone transfer can be returned
61
- //
62
- if ($type == 'IXFR') {
63
-
64
- $type = 'AXFR';
65
- }
66
-
67
- //
68
- // if the name *looks* too short, then append the domain from the config
69
- //
70
- if ( (strpos($name, '.') === false) && ($type != 'PTR') ) {
71
-
72
- $name .= '.' . strtolower($this->domain);
73
- }
74
-
75
- //
76
- // create a new packet based on the input
77
- //
78
- $packet = new Net_DNS2_Packet_Request($name, $type, $class);
79
-
80
- //
81
- // check for an authentication method; either TSIG or SIG
82
- //
83
- if ( ($this->auth_signature instanceof Net_DNS2_RR_TSIG)
84
- || ($this->auth_signature instanceof Net_DNS2_RR_SIG)
85
- ) {
86
- $packet->additional[] = $this->auth_signature;
87
- $packet->header->arcount = count($packet->additional);
88
- }
89
-
90
- //
91
- // check for the DNSSEC flag, and if it's true, then add an OPT
92
- // RR to the additional section, and set the DO flag to 1.
93
- //
94
- if ($this->dnssec == true) {
95
-
96
- //
97
- // create a new OPT RR
98
- //
99
- $opt = new Net_DNS2_RR_OPT();
100
-
101
- //
102
- // set the DO flag, and the other values
103
- //
104
- $opt->do = 1;
105
- $opt->class = $this->dnssec_payload_size;
106
-
107
- //
108
- // add the RR to the additional section.
109
- //
110
- $packet->additional[] = $opt;
111
- $packet->header->arcount = count($packet->additional);
112
- }
113
-
114
- //
115
- // set the DNSSEC AD or CD bits
116
- //
117
- if ($this->dnssec_ad_flag == true) {
118
-
119
- $packet->header->ad = 1;
120
- }
121
- if ($this->dnssec_cd_flag == true) {
122
-
123
- $packet->header->cd = 1;
124
- }
125
-
126
- //
127
- // if caching is turned on, then check then hash the question, and
128
- // do a cache lookup.
129
- //
130
- // don't use the cache for zone transfers
131
- //
132
- $packet_hash = '';
133
-
134
- if ( ($this->use_cache == true) && ($this->cacheable($type) == true) ) {
135
-
136
- //
137
- // open the cache
138
- //
139
- $this->cache->open(
140
- $this->cache_file, $this->cache_size, $this->cache_serializer
141
- );
142
-
143
- //
144
- // build the key and check for it in the cache.
145
- //
146
- $packet_hash = md5(
147
- $packet->question[0]->qname . '|' . $packet->question[0]->qtype
148
- );
149
-
150
- if ($this->cache->has($packet_hash)) {
151
-
152
- return $this->cache->get($packet_hash);
153
- }
154
- }
155
-
156
- //
157
- // set the RD (recursion desired) bit to 1 / 0 depending on the config
158
- // setting.
159
- //
160
- if ($this->recurse == false) {
161
- $packet->header->rd = 0;
162
- } else {
163
- $packet->header->rd = 1;
164
- }
165
-
166
- //
167
- // send the packet and get back the response
168
- //
169
- // *always* use TCP for zone transfers- does this cause any problems?
170
- //
171
- $response = $this->sendPacket(
172
- $packet, ($type == 'AXFR') ? true : $this->use_tcp
173
- );
174
-
175
- //
176
- // if strict mode is enabled, then make sure that the name that was
177
- // looked up is *actually* in the response object.
178
- //
179
- // only do this is strict_query_mode is turned on, AND we've received
180
- // some answers; no point doing any else if there were no answers.
181
- //
182
- if ( ($this->strict_query_mode == true)
183
- && ($response->header->ancount > 0)
184
- ) {
185
-
186
- $found = false;
187
-
188
- //
189
- // look for the requested name/type/class
190
- //
191
- foreach ($response->answer as $index => $object) {
192
-
193
- if ( (strcasecmp(trim($object->name, '.'), trim($packet->question[0]->qname, '.')) == 0)
194
- && ($object->type == $packet->question[0]->qtype)
195
- && ($object->class == $packet->question[0]->qclass)
196
- ) {
197
- $found = true;
198
- break;
199
- }
200
- }
201
-
202
- //
203
- // if it's not found, then unset the answer section; it's not correct to
204
- // throw an exception here; if the hostname didn't exist, then
205
- // sendPacket() would have already thrown an NXDOMAIN error- so the host
206
- // *exists*, but just not the request type/class.
207
- //
208
- // the correct response in this case, is an empty answer section; the
209
- // authority section may still have usual information, like a SOA record.
210
- //
211
- if ($found == false) {
212
-
213
- $response->answer = [];
214
- $response->header->ancount = 0;
215
- }
216
- }
217
-
218
- //
219
- // cache the response object
220
- //
221
- if ( ($this->use_cache == true) && ($this->cacheable($type) == true) ) {
222
-
223
- $this->cache->put($packet_hash, $response);
224
- }
225
-
226
- return $response;
227
- }
228
-
229
- /**
230
- * does an inverse query for the given RR; most DNS servers do not implement
231
- * inverse queries, but they should be able to return "not implemented"
232
- *
233
- * @param Net_DNS2_RR $rr the RR object to lookup
234
- *
235
- * @return Net_DNS2_RR object
236
- * @throws Net_DNS2_Exception
237
- * @access public
238
- *
239
- */
240
- public function iquery(Net_DNS2_RR $rr)
241
- {
242
- //
243
- // make sure we have some name servers set
244
- //
245
- $this->checkServers(Net_DNS2::RESOLV_CONF);
246
-
247
- //
248
- // create an empty packet
249
- //
250
- $packet = new Net_DNS2_Packet_Request($rr->name, 'A', 'IN');
251
-
252
- //
253
- // unset the question
254
- //
255
- $packet->question = [];
256
- $packet->header->qdcount = 0;
257
-
258
- //
259
- // set the opcode to IQUERY
260
- //
261
- $packet->header->opcode = Net_DNS2_Lookups::OPCODE_IQUERY;
262
-
263
- //
264
- // add the given RR as the answer
265
- //
266
- $packet->answer[] = $rr;
267
- $packet->header->ancount = 1;
268
-
269
- //
270
- // check for an authentication method; either TSIG or SIG
271
- //
272
- if ( ($this->auth_signature instanceof Net_DNS2_RR_TSIG)
273
- || ($this->auth_signature instanceof Net_DNS2_RR_SIG)
274
- ) {
275
- $packet->additional[] = $this->auth_signature;
276
- $packet->header->arcount = count($packet->additional);
277
- }
278
-
279
- //
280
- // send the packet and get back the response
281
- //
282
- return $this->sendPacket($packet, $this->use_tcp);
283
- }
284
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/Socket.php DELETED
@@ -1,440 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 0.6.0
17
- *
18
- */
19
-
20
- /*
21
- * check to see if the socket defines exist; if they don't, then define them
22
- */
23
- if (defined('SOCK_STREAM') == false) {
24
- define('SOCK_STREAM', 1);
25
- }
26
- if (defined('SOCK_DGRAM') == false) {
27
- define('SOCK_DGRAM', 2);
28
- }
29
-
30
- /**
31
- * Socket handling class using the PHP Streams
32
- *
33
- */
34
- class Net_DNS2_Socket
35
- {
36
- private $sock;
37
- private $type;
38
- private $host;
39
- private $port;
40
- private $timeout;
41
- private $context;
42
-
43
- /*
44
- * the local IP and port we'll send the request from
45
- */
46
- private $local_host;
47
- private $local_port;
48
-
49
- /*
50
- * the last error message on the object
51
- */
52
- public $last_error;
53
-
54
- /*
55
- * date the socket connection was created, and the date it was last used
56
- */
57
- public $date_created;
58
- public $date_last_used;
59
-
60
- /*
61
- * type of sockets
62
- */
63
- const SOCK_STREAM = SOCK_STREAM;
64
- const SOCK_DGRAM = SOCK_DGRAM;
65
-
66
- /**
67
- * constructor - set the port details
68
- *
69
- * @param integer $type the socket type
70
- * @param string $host the IP address of the DNS server to connect to
71
- * @param integer $port the port of the DNS server to connect to
72
- * @param integer $timeout the timeout value to use for socket functions
73
- *
74
- * @access public
75
- *
76
- */
77
- public function __construct($type, $host, $port, $timeout)
78
- {
79
- $this->type = $type;
80
- $this->host = $host;
81
- $this->port = $port;
82
- $this->timeout = $timeout;
83
- $this->date_created = microtime(true);
84
- }
85
-
86
- /**
87
- * destructor
88
- *
89
- * @access public
90
- */
91
- public function __destruct()
92
- {
93
- $this->close();
94
- }
95
-
96
- /**
97
- * sets the local address/port for the socket to bind to
98
- *
99
- * @param string $address the local IP address to bind to
100
- * @param mixed $port the local port to bind to, or 0 to let the socket
101
- * function select a port
102
- *
103
- * @return boolean
104
- * @access public
105
- *
106
- */
107
- public function bindAddress($address, $port = 0)
108
- {
109
- $this->local_host = $address;
110
- $this->local_port = $port;
111
-
112
- return true;
113
- }
114
-
115
- /**
116
- * opens a socket connection to the DNS server
117
- *
118
- * @return boolean
119
- * @access public
120
- *
121
- */
122
- public function open()
123
- {
124
- //
125
- // create a list of options for the context
126
- //
127
- $opts = [ 'socket' => [] ];
128
-
129
- //
130
- // bind to a local IP/port if it's set
131
- //
132
- if (strlen($this->local_host) > 0) {
133
-
134
- $opts['socket']['bindto'] = $this->local_host;
135
- if ($this->local_port > 0) {
136
-
137
- $opts['socket']['bindto'] .= ':' . $this->local_port;
138
- }
139
- }
140
-
141
- //
142
- // create the context
143
- //
144
- $this->context = @stream_context_create($opts);
145
-
146
- //
147
- // create socket
148
- //
149
- $errno;
150
- $errstr;
151
-
152
- switch($this->type) {
153
- case Net_DNS2_Socket::SOCK_STREAM:
154
-
155
- if (Net_DNS2::isIPv4($this->host) == true) {
156
-
157
- $this->sock = @stream_socket_client(
158
- 'tcp://' . $this->host . ':' . $this->port,
159
- $errno, $errstr, $this->timeout,
160
- STREAM_CLIENT_CONNECT, $this->context
161
- );
162
- } else if (Net_DNS2::isIPv6($this->host) == true) {
163
-
164
- $this->sock = @stream_socket_client(
165
- 'tcp://[' . $this->host . ']:' . $this->port,
166
- $errno, $errstr, $this->timeout,
167
- STREAM_CLIENT_CONNECT, $this->context
168
- );
169
- } else {
170
-
171
- $this->last_error = 'invalid address type: ' . $this->host;
172
- return false;
173
- }
174
-
175
- break;
176
-
177
- case Net_DNS2_Socket::SOCK_DGRAM:
178
-
179
- if (Net_DNS2::isIPv4($this->host) == true) {
180
-
181
- $this->sock = @stream_socket_client(
182
- 'udp://' . $this->host . ':' . $this->port,
183
- $errno, $errstr, $this->timeout,
184
- STREAM_CLIENT_CONNECT, $this->context
185
- );
186
- } else if (Net_DNS2::isIPv6($this->host) == true) {
187
-
188
- $this->sock = @stream_socket_client(
189
- 'udp://[' . $this->host . ']:' . $this->port,
190
- $errno, $errstr, $this->timeout,
191
- STREAM_CLIENT_CONNECT, $this->context
192
- );
193
- } else {
194
-
195
- $this->last_error = 'invalid address type: ' . $this->host;
196
- return false;
197
- }
198
-
199
- break;
200
-
201
- default:
202
- $this->last_error = 'Invalid socket type: ' . $this->type;
203
- return false;
204
- }
205
-
206
- if ($this->sock === false) {
207
-
208
- $this->last_error = $errstr;
209
- return false;
210
- }
211
-
212
- //
213
- // set it to non-blocking and set the timeout
214
- //
215
- @stream_set_blocking($this->sock, 0);
216
- @stream_set_timeout($this->sock, $this->timeout);
217
-
218
- return true;
219
- }
220
-
221
- /**
222
- * closes a socket connection to the DNS server
223
- *
224
- * @return boolean
225
- * @access public
226
- *
227
- */
228
- public function close()
229
- {
230
- if (is_resource($this->sock) === true) {
231
-
232
- @fclose($this->sock);
233
- }
234
- return true;
235
- }
236
-
237
- /**
238
- * writes the given string to the DNS server socket
239
- *
240
- * @param string $data a binary packed DNS packet
241
- *
242
- * @return boolean
243
- * @access public
244
- *
245
- */
246
- public function write($data)
247
- {
248
- $length = strlen($data);
249
- if ($length == 0) {
250
-
251
- $this->last_error = 'empty data on write()';
252
- return false;
253
- }
254
-
255
- $read = null;
256
- $write = [ $this->sock ];
257
- $except = null;
258
-
259
- //
260
- // increment the date last used timestamp
261
- //
262
- $this->date_last_used = microtime(true);
263
-
264
- //
265
- // select on write
266
- //
267
- $result = stream_select($read, $write, $except, $this->timeout);
268
- if ($result === false) {
269
-
270
- $this->last_error = 'failed on write select()';
271
- return false;
272
-
273
- } else if ($result == 0) {
274
-
275
- $this->last_error = 'timeout on write select()';
276
- return false;
277
- }
278
-
279
- //
280
- // if it's a TCP socket, then we need to packet and send the length of the
281
- // data as the first 16bit of data.
282
- //
283
- if ($this->type == Net_DNS2_Socket::SOCK_STREAM) {
284
-
285
- $s = chr($length >> 8) . chr($length);
286
-
287
- if (@fwrite($this->sock, $s) === false) {
288
-
289
- $this->last_error = 'failed to fwrite() 16bit length';
290
- return false;
291
- }
292
- }
293
-
294
- //
295
- // write the data to the socket
296
- //
297
- $size = @fwrite($this->sock, $data);
298
- if ( ($size === false) || ($size != $length) ) {
299
-
300
- $this->last_error = 'failed to fwrite() packet';
301
- return false;
302
- }
303
-
304
- return true;
305
- }
306
-
307
- /**
308
- * reads a response from a DNS server
309
- *
310
- * @param integer &$size the size of the DNS packet read is passed back
311
- * @param integer $max_size the max data size returned.
312
- *
313
- * @return mixed returns the data on success and false on error
314
- * @access public
315
- *
316
- */
317
- public function read(&$size, $max_size)
318
- {
319
- $read = [ $this->sock ];
320
- $write = null;
321
- $except = null;
322
-
323
- //
324
- // increment the date last used timestamp
325
- //
326
- $this->date_last_used = microtime(true);
327
-
328
- //
329
- // make sure our socket is non-blocking
330
- //
331
- @stream_set_blocking($this->sock, 0);
332
-
333
- //
334
- // select on read
335
- //
336
- $result = stream_select($read, $write, $except, $this->timeout);
337
- if ($result === false) {
338
-
339
- $this->last_error = 'error on read select()';
340
- return false;
341
-
342
- } else if ($result == 0) {
343
-
344
- $this->last_error = 'timeout on read select()';
345
- return false;
346
- }
347
-
348
- $data = '';
349
- $length = $max_size;
350
-
351
- //
352
- // if it's a TCP socket, then the first two bytes is the length of the DNS
353
- // packet- we need to read that off first, then use that value for the
354
- // packet read.
355
- //
356
- if ($this->type == Net_DNS2_Socket::SOCK_STREAM) {
357
-
358
- if (($data = fread($this->sock, 2)) === false) {
359
-
360
- $this->last_error = 'failed on fread() for data length';
361
- return false;
362
- }
363
- if (strlen($data) == 0)
364
- {
365
- $this->last_error = 'failed on fread() for data length';
366
- return false;
367
- }
368
-
369
- $length = ord($data[0]) << 8 | ord($data[1]);
370
- if ($length < Net_DNS2_Lookups::DNS_HEADER_SIZE) {
371
-
372
- return false;
373
- }
374
- }
375
-
376
- //
377
- // at this point, we know that there is data on the socket to be read,
378
- // because we've already extracted the length from the first two bytes.
379
- //
380
- // so the easiest thing to do, is just turn off socket blocking, and
381
- // wait for the data.
382
- //
383
- @stream_set_blocking($this->sock, 1);
384
-
385
- //
386
- // read the data from the socket
387
- //
388
- $data = '';
389
-
390
- //
391
- // the streams socket is weird for TCP sockets; it doesn't seem to always
392
- // return all the data properly; but the looping code I added broke UDP
393
- // packets- my fault-
394
- //
395
- // the sockets library works much better.
396
- //
397
- if ($this->type == Net_DNS2_Socket::SOCK_STREAM) {
398
-
399
- $chunk = '';
400
- $chunk_size = $length;
401
-
402
- //
403
- // loop so we make sure we read all the data
404
- //
405
- while (1) {
406
-
407
- $chunk = fread($this->sock, $chunk_size);
408
- if ($chunk === false) {
409
-
410
- $this->last_error = 'failed on fread() for data';
411
- return false;
412
- }
413
-
414
- $data .= $chunk;
415
- $chunk_size -= strlen($chunk);
416
-
417
- if (strlen($data) >= $length) {
418
- break;
419
- }
420
- }
421
-
422
- } else {
423
-
424
- //
425
- // if it's UDP, it's a single fixed-size frame, and the streams library
426
- // doesn't seem to have a problem reading it.
427
- //
428
- $data = fread($this->sock, $length);
429
- if ($length === false) {
430
-
431
- $this->last_error = 'failed on fread() for data';
432
- return false;
433
- }
434
- }
435
-
436
- $size = strlen($data);
437
-
438
- return $data;
439
- }
440
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/Net/DNS2/Updater.php DELETED
@@ -1,606 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 0.6.0
17
- *
18
- */
19
-
20
- /**
21
- * The main dynamic DNS updater class.
22
- *
23
- * This class provices functions to handle all defined dynamic DNS update
24
- * requests as defined by RFC 2136.
25
- *
26
- * This is separate from the Net_DNS2_Resolver class, as while the underlying
27
- * protocol is the same, the functionality is completely different.
28
- *
29
- * Generally, query (recursive) lookups are done against caching server, while
30
- * update requests are done against authoratative servers.
31
- *
32
- */
33
- class Net_DNS2_Updater extends Net_DNS2
34
- {
35
- /*
36
- * a Net_DNS2_Packet_Request object used for the update request
37
- */
38
- private $_packet;
39
-
40
- /**
41
- * Constructor - builds a new Net_DNS2_Updater objected used for doing
42
- * dynamic DNS updates
43
- *
44
- * @param string $zone the domain name to use for DNS updates
45
- * @param mixed $options an array of config options or null
46
- *
47
- * @throws Net_DNS2_Exception
48
- * @access public
49
- *
50
- */
51
- public function __construct($zone, array $options = null)
52
- {
53
- parent::__construct($options);
54
-
55
- //
56
- // create the packet
57
- //
58
- $this->_packet = new Net_DNS2_Packet_Request(
59
- strtolower(trim($zone, " \n\r\t.")), 'SOA', 'IN'
60
- );
61
-
62
- //
63
- // make sure the opcode on the packet is set to UPDATE
64
- //
65
- $this->_packet->header->opcode = Net_DNS2_Lookups::OPCODE_UPDATE;
66
- }
67
-
68
- /**
69
- * checks that the given name matches the name for the zone we're updating
70
- *
71
- * @param string $name The name to be checked.
72
- *
73
- * @return boolean
74
- * @throws Net_DNS2_Exception
75
- * @access private
76
- *
77
- */
78
- private function _checkName($name)
79
- {
80
- if (!preg_match('/' . $this->_packet->question[0]->qname . '$/', $name)) {
81
-
82
- throw new Net_DNS2_Exception(
83
- 'name provided (' . $name . ') does not match zone name (' .
84
- $this->_packet->question[0]->qname . ')',
85
- Net_DNS2_Lookups::E_PACKET_INVALID
86
- );
87
- }
88
-
89
- return true;
90
- }
91
-
92
- /**
93
- * add a signature to the request for authentication
94
- *
95
- * @param string $keyname the key name to use for the TSIG RR
96
- * @param string $signature the key to sign the request.
97
- *
98
- * @return boolean
99
- * @access public
100
- * @see Net_DNS2::signTSIG()
101
- * @deprecated function deprecated in 1.1.0
102
- *
103
- */
104
- public function signature($keyname, $signature)
105
- {
106
- return $this->signTSIG($keyname, $signature);
107
- }
108
-
109
- /**
110
- * 2.5.1 - Add To An RRset
111
- *
112
- * RRs are added to the Update Section whose NAME, TYPE, TTL, RDLENGTH
113
- * and RDATA are those being added, and CLASS is the same as the zone
114
- * class. Any duplicate RRs will be silently ignored by the primary
115
- * master.
116
- *
117
- * @param Net_DNS2_RR $rr the Net_DNS2_RR object to be added to the zone
118
- *
119
- * @return boolean
120
- * @throws Net_DNS2_Exception
121
- * @access public
122
- *
123
- */
124
- public function add(Net_DNS2_RR $rr)
125
- {
126
- $this->_checkName($rr->name);
127
-
128
- //
129
- // add the RR to the "update" section
130
- //
131
- if (!in_array($rr, $this->_packet->authority)) {
132
- $this->_packet->authority[] = $rr;
133
- }
134
-
135
- return true;
136
- }
137
-
138
- /**
139
- * 2.5.4 - Delete An RR From An RRset
140
- *
141
- * RRs to be deleted are added to the Update Section. The NAME, TYPE,
142
- * RDLENGTH and RDATA must match the RR being deleted. TTL must be
143
- * specified as zero (0) and will otherwise be ignored by the primary
144
- * master. CLASS must be specified as NONE to distinguish this from an
145
- * RR addition. If no such RRs exist, then this Update RR will be
146
- * silently ignored by the primary master.
147
- *
148
- * @param Net_DNS2_RR $rr the Net_DNS2_RR object to be deleted from the zone
149
- *
150
- * @return boolean
151
- * @throws Net_DNS2_Exception
152
- * @access public
153
- *
154
- */
155
- public function delete(Net_DNS2_RR $rr)
156
- {
157
- $this->_checkName($rr->name);
158
-
159
- $rr->ttl = 0;
160
- $rr->class = 'NONE';
161
-
162
- //
163
- // add the RR to the "update" section
164
- //
165
- if (!in_array($rr, $this->_packet->authority)) {
166
- $this->_packet->authority[] = $rr;
167
- }
168
-
169
- return true;
170
- }
171
-
172
- /**
173
- * 2.5.2 - Delete An RRset
174
- *
175
- * One RR is added to the Update Section whose NAME and TYPE are those
176
- * of the RRset to be deleted. TTL must be specified as zero (0) and is
177
- * otherwise not used by the primary master. CLASS must be specified as
178
- * ANY. RDLENGTH must be zero (0) and RDATA must therefore be empty.
179
- * If no such RRset exists, then this Update RR will be silently ignored
180
- * by the primary master
181
- *
182
- * @param string $name the RR name to be removed from the zone
183
- * @param string $type the RR type to be removed from the zone
184
- *
185
- * @return boolean
186
- * @throws Net_DNS2_Exception
187
- * @access public
188
- *
189
- */
190
- public function deleteAny($name, $type)
191
- {
192
- $this->_checkName($name);
193
-
194
- $class = Net_DNS2_Lookups::$rr_types_id_to_class[
195
- Net_DNS2_Lookups::$rr_types_by_name[$type]
196
- ];
197
- if (!isset($class)) {
198
-
199
- throw new Net_DNS2_Exception(
200
- 'unknown or un-supported resource record type: ' . $type,
201
- Net_DNS2_Lookups::E_RR_INVALID
202
- );
203
- }
204
-
205
- $rr = new $class;
206
-
207
- $rr->name = $name;
208
- $rr->ttl = 0;
209
- $rr->class = 'ANY';
210
- $rr->rdlength = -1;
211
- $rr->rdata = '';
212
-
213
- //
214
- // add the RR to the "update" section
215
- //
216
- if (!in_array($rr, $this->_packet->authority)) {
217
- $this->_packet->authority[] = $rr;
218
- }
219
-
220
- return true;
221
- }
222
-
223
- /**
224
- * 2.5.3 - Delete All RRsets From A Name
225
- *
226
- * One RR is added to the Update Section whose NAME is that of the name
227
- * to be cleansed of RRsets. TYPE must be specified as ANY. TTL must
228
- * be specified as zero (0) and is otherwise not used by the primary
229
- * master. CLASS must be specified as ANY. RDLENGTH must be zero (0)
230
- * and RDATA must therefore be empty. If no such RRsets exist, then
231
- * this Update RR will be silently ignored by the primary master.
232
- *
233
- * @param string $name the RR name to be removed from the zone
234
- *
235
- * @return boolean
236
- * @throws Net_DNS2_Exception
237
- * @access public
238
- *
239
- */
240
- public function deleteAll($name)
241
- {
242
- $this->_checkName($name);
243
-
244
- //
245
- // the Net_DNS2_RR_ANY class is just an empty stub class used for these
246
- // cases only
247
- //
248
- $rr = new Net_DNS2_RR_ANY;
249
-
250
- $rr->name = $name;
251
- $rr->ttl = 0;
252
- $rr->type = 'ANY';
253
- $rr->class = 'ANY';
254
- $rr->rdlength = -1;
255
- $rr->rdata = '';
256
-
257
- //
258
- // add the RR to the "update" section
259
- //
260
- if (!in_array($rr, $this->_packet->authority)) {
261
- $this->_packet->authority[] = $rr;
262
- }
263
-
264
- return true;
265
- }
266
-
267
- /**
268
- * 2.4.1 - RRset Exists (Value Independent)
269
- *
270
- * At least one RR with a specified NAME and TYPE (in the zone and class
271
- * specified in the Zone Section) must exist.
272
- *
273
- * For this prerequisite, a requestor adds to the section a single RR
274
- * whose NAME and TYPE are equal to that of the zone RRset whose
275
- * existence is required. RDLENGTH is zero and RDATA is therefore
276
- * empty. CLASS must be specified as ANY to differentiate this
277
- * condition from that of an actual RR whose RDLENGTH is naturally zero
278
- * (0) (e.g., NULL). TTL is specified as zero (0).
279
- *
280
- * @param string $name the RR name for the prerequisite
281
- * @param string $type the RR type for the prerequisite
282
- *
283
- * @return boolean
284
- * @throws Net_DNS2_Exception
285
- * @access public
286
- *
287
- */
288
- public function checkExists($name, $type)
289
- {
290
- $this->_checkName($name);
291
-
292
- $class = Net_DNS2_Lookups::$rr_types_id_to_class[
293
- Net_DNS2_Lookups::$rr_types_by_name[$type]
294
- ];
295
- if (!isset($class)) {
296
-
297
- throw new Net_DNS2_Exception(
298
- 'unknown or un-supported resource record type: ' . $type,
299
- Net_DNS2_Lookups::E_RR_INVALID
300
- );
301
- }
302
-
303
- $rr = new $class;
304
-
305
- $rr->name = $name;
306
- $rr->ttl = 0;
307
- $rr->class = 'ANY';
308
- $rr->rdlength = -1;
309
- $rr->rdata = '';
310
-
311
- //
312
- // add the RR to the "prerequisite" section
313
- //
314
- if (!in_array($rr, $this->_packet->answer)) {
315
- $this->_packet->answer[] = $rr;
316
- }
317
-
318
- return true;
319
- }
320
-
321
- /**
322
- * 2.4.2 - RRset Exists (Value Dependent)
323
- *
324
- * A set of RRs with a specified NAME and TYPE exists and has the same
325
- * members with the same RDATAs as the RRset specified here in this
326
- * section. While RRset ordering is undefined and therefore not
327
- * significant to this comparison, the sets be identical in their
328
- * extent.
329
- *
330
- * For this prerequisite, a requestor adds to the section an entire
331
- * RRset whose preexistence is required. NAME and TYPE are that of the
332
- * RRset being denoted. CLASS is that of the zone. TTL must be
333
- * specified as zero (0) and is ignored when comparing RRsets for
334
- * identity.
335
- *
336
- * @param Net_DNS2_RR $rr the RR object to be used as a prerequisite
337
- *
338
- * @return boolean
339
- * @throws Net_DNS2_Exception
340
- * @access public
341
- *
342
- */
343
- public function checkValueExists(Net_DNS2_RR $rr)
344
- {
345
- $this->_checkName($rr->name);
346
-
347
- $rr->ttl = 0;
348
-
349
- //
350
- // add the RR to the "prerequisite" section
351
- //
352
- if (!in_array($rr, $this->_packet->answer)) {
353
- $this->_packet->answer[] = $rr;
354
- }
355
-
356
- return true;
357
- }
358
-
359
- /**
360
- * 2.4.3 - RRset Does Not Exist
361
- *
362
- * No RRs with a specified NAME and TYPE (in the zone and class denoted
363
- * by the Zone Section) can exist.
364
- *
365
- * For this prerequisite, a requestor adds to the section a single RR
366
- * whose NAME and TYPE are equal to that of the RRset whose nonexistence
367
- * is required. The RDLENGTH of this record is zero (0), and RDATA
368
- * field is therefore empty. CLASS must be specified as NONE in order
369
- * to distinguish this condition from a valid RR whose RDLENGTH is
370
- * naturally zero (0) (for example, the NULL RR). TTL must be specified
371
- * as zero (0).
372
- *
373
- * @param string $name the RR name for the prerequisite
374
- * @param string $type the RR type for the prerequisite
375
- *
376
- * @return boolean
377
- * @throws Net_DNS2_Exception
378
- * @access public
379
- *
380
- */
381
- public function checkNotExists($name, $type)
382
- {
383
- $this->_checkName($name);
384
-
385
- $class = Net_DNS2_Lookups::$rr_types_id_to_class[
386
- Net_DNS2_Lookups::$rr_types_by_name[$type]
387
- ];
388
- if (!isset($class)) {
389
-
390
- throw new Net_DNS2_Exception(
391
- 'unknown or un-supported resource record type: ' . $type,
392
- Net_DNS2_Lookups::E_RR_INVALID
393
- );
394
- }
395
-
396
- $rr = new $class;
397
-
398
- $rr->name = $name;
399
- $rr->ttl = 0;
400
- $rr->class = 'NONE';
401
- $rr->rdlength = -1;
402
- $rr->rdata = '';
403
-
404
- //
405
- // add the RR to the "prerequisite" section
406
- //
407
- if (!in_array($rr, $this->_packet->answer)) {
408
- $this->_packet->answer[] = $rr;
409
- }
410
-
411
- return true;
412
- }
413
-
414
- /**
415
- * 2.4.4 - Name Is In Use
416
- *
417
- * Name is in use. At least one RR with a specified NAME (in the zone
418
- * and class specified by the Zone Section) must exist. Note that this
419
- * prerequisite is NOT satisfied by empty nonterminals.
420
- *
421
- * For this prerequisite, a requestor adds to the section a single RR
422
- * whose NAME is equal to that of the name whose ownership of an RR is
423
- * required. RDLENGTH is zero and RDATA is therefore empty. CLASS must
424
- * be specified as ANY to differentiate this condition from that of an
425
- * actual RR whose RDLENGTH is naturally zero (0) (e.g., NULL). TYPE
426
- * must be specified as ANY to differentiate this case from that of an
427
- * RRset existence test. TTL is specified as zero (0).
428
- *
429
- * @param string $name the RR name for the prerequisite
430
- *
431
- * @return boolean
432
- * @throws Net_DNS2_Exception
433
- * @access public
434
- *
435
- */
436
- public function checkNameInUse($name)
437
- {
438
- $this->_checkName($name);
439
-
440
- //
441
- // the Net_DNS2_RR_ANY class is just an empty stub class used for these
442
- // cases only
443
- //
444
- $rr = new Net_DNS2_RR_ANY;
445
-
446
- $rr->name = $name;
447
- $rr->ttl = 0;
448
- $rr->type = 'ANY';
449
- $rr->class = 'ANY';
450
- $rr->rdlength = -1;
451
- $rr->rdata = '';
452
-
453
- //
454
- // add the RR to the "prerequisite" section
455
- //
456
- if (!in_array($rr, $this->_packet->answer)) {
457
- $this->_packet->answer[] = $rr;
458
- }
459
-
460
- return true;
461
- }
462
-
463
- /**
464
- * 2.4.5 - Name Is Not In Use
465
- *
466
- * Name is not in use. No RR of any type is owned by a specified NAME.
467
- * Note that this prerequisite IS satisfied by empty nonterminals.
468
- *
469
- * For this prerequisite, a requestor adds to the section a single RR
470
- * whose NAME is equal to that of the name whose nonownership of any RRs
471
- * is required. RDLENGTH is zero and RDATA is therefore empty. CLASS
472
- * must be specified as NONE. TYPE must be specified as ANY. TTL must
473
- * be specified as zero (0).
474
- *
475
- * @param string $name the RR name for the prerequisite
476
- *
477
- * @return boolean
478
- * @throws Net_DNS2_Exception
479
- * @access public
480
- *
481
- */
482
- public function checkNameNotInUse($name)
483
- {
484
- $this->_checkName($name);
485
-
486
- //
487
- // the Net_DNS2_RR_ANY class is just an empty stub class used for these
488
- // cases only
489
- //
490
- $rr = new Net_DNS2_RR_ANY;
491
-
492
- $rr->name = $name;
493
- $rr->ttl = 0;
494
- $rr->type = 'ANY';
495
- $rr->class = 'NONE';
496
- $rr->rdlength = -1;
497
- $rr->rdata = '';
498
-
499
- //
500
- // add the RR to the "prerequisite" section
501
- //
502
- if (!in_array($rr, $this->_packet->answer)) {
503
- $this->_packet->answer[] = $rr;
504
- }
505
-
506
- return true;
507
- }
508
-
509
- /**
510
- * returns the current internal packet object.
511
- *
512
- * @return Net_DNS2_Packet_Request
513
- * @access public
514
- #
515
- */
516
- public function packet()
517
- {
518
- //
519
- // take a copy
520
- //
521
- $p = $this->_packet;
522
-
523
- //
524
- // check for an authentication method; either TSIG or SIG
525
- //
526
- if ( ($this->auth_signature instanceof Net_DNS2_RR_TSIG)
527
- || ($this->auth_signature instanceof Net_DNS2_RR_SIG)
528
- ) {
529
- $p->additional[] = $this->auth_signature;
530
- }
531
-
532
- //
533
- // update the counts
534
- //
535
- $p->header->qdcount = count($p->question);
536
- $p->header->ancount = count($p->answer);
537
- $p->header->nscount = count($p->authority);
538
- $p->header->arcount = count($p->additional);
539
-
540
- return $p;
541
- }
542
-
543
- /**
544
- * executes the update request with the object informaton
545
- *
546
- * @param Net_DNS2_Packet_Response &$response ref to the response object
547
- *
548
- * @return boolean
549
- * @throws Net_DNS2_Exception
550
- * @access public
551
- *
552
- */
553
- public function update(&$response = null)
554
- {
555
- //
556
- // make sure we have some name servers set
557
- //
558
- $this->checkServers(Net_DNS2::RESOLV_CONF);
559
-
560
- //
561
- // check for an authentication method; either TSIG or SIG
562
- //
563
- if ( ($this->auth_signature instanceof Net_DNS2_RR_TSIG)
564
- || ($this->auth_signature instanceof Net_DNS2_RR_SIG)
565
- ) {
566
- $this->_packet->additional[] = $this->auth_signature;
567
- }
568
-
569
- //
570
- // update the counts
571
- //
572
- $this->_packet->header->qdcount = count($this->_packet->question);
573
- $this->_packet->header->ancount = count($this->_packet->answer);
574
- $this->_packet->header->nscount = count($this->_packet->authority);
575
- $this->_packet->header->arcount = count($this->_packet->additional);
576
-
577
- //
578
- // make sure we have some data to send
579
- //
580
- if ( ($this->_packet->header->qdcount == 0)
581
- || ($this->_packet->header->nscount == 0)
582
- ) {
583
- throw new Net_DNS2_Exception(
584
- 'empty headers- nothing to send!',
585
- Net_DNS2_Lookups::E_PACKET_INVALID
586
- );
587
- }
588
-
589
- //
590
- // send the packet and get back the response
591
- //
592
- $response = $this->sendPacket($this->_packet, $this->use_tcp);
593
-
594
- //
595
- // clear the internal packet so if we make another request, we don't have
596
- // old data being sent.
597
- //
598
- $this->_packet->reset();
599
-
600
- //
601
- // for updates, we just need to know it worked- we don't actualy need to
602
- // return the response object
603
- //
604
- return true;
605
- }
606
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/README.md DELETED
@@ -1,40 +0,0 @@
1
- # Net\_DNS2 - Native PHP DNS Resolver and Updater #
2
-
3
- ### The main features for this package include: ###
4
-
5
- * Increased performance; most requests are 2-10x faster than Net\_DNS
6
- * Near drop-in replacement for Net\_DNS
7
- * Uses modern PHP classes and exceptions
8
- * Support for IPv4 and IPv6, TCP and UDP sockets.
9
- * Includes a separate, more intuitive "Updater" class for handling dynamic update
10
- * Support zone signing using TSIG and SIG(0) for updates and zone transfers
11
- * Includes a local cache using shared memory or flat file to improve performance
12
- * includes many more RR's, including DNSSEC RR's.
13
-
14
-
15
- ## Installing Net\_DNS2 ##
16
-
17
- You can download it directly from PEAR: http://pear.php.net/package/Net_DNS2
18
-
19
- ```
20
- pear install Net_DNS2
21
- ```
22
-
23
- Or you can require it directly via Composer: https://packagist.org/packages/pear/net_dns2
24
-
25
- ```
26
- composer require pear/net_dns2
27
- ```
28
-
29
- Or download the source above.
30
-
31
- ## Requirements ##
32
-
33
- * PHP 5.4+
34
- * The PHP INI setting `mbstring.func_overload` equals 0, 1, 4, or 5.
35
-
36
-
37
- ## Using Net\_DNS2 ##
38
-
39
- See the Net\_DNS2 Website for more details - https://netdns2.com/
40
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/composer.json DELETED
@@ -1,40 +0,0 @@
1
- {
2
- "name": "pear/net_dns2",
3
- "type": "library",
4
- "description": "Native PHP DNS Resolver and Updater Library",
5
- "keywords": [
6
- "dns",
7
- "network",
8
- "pear"
9
- ],
10
- "homepage": "https://netdns2.com/",
11
- "license": "BSD-2-Clause",
12
- "support": {
13
- "issues": "https://github.com/mikepultz/netdns2/issues",
14
- "source": "https://github.com/mikepultz/netdns2"
15
- },
16
- "authors": [
17
- {
18
- "name": "Mike Pultz",
19
- "email": "mike@mikepultz.com",
20
- "homepage": "https://mikepultz.com/",
21
- "role": "lead"
22
- }
23
- ],
24
- "require": {
25
- "php": ">=5.4"
26
- },
27
- "require-dev": {
28
- "phpunit/phpunit": "^9"
29
- },
30
- "autoload": {
31
- "psr-0": {
32
- "Net_DNS2": ""
33
- }
34
- },
35
- "autoload-dev": {
36
- "psr-0": {
37
- "Tests_Net_DNS2": "tests/"
38
- }
39
- }
40
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/package.php DELETED
@@ -1,50 +0,0 @@
1
- <?php
2
-
3
- date_default_timezone_set('America/Toronto');
4
-
5
- ini_set("include_path", ".:/usr/local/php/lib/php/:/usr/share/pear/");
6
- require_once 'PEAR/PackageFileManager/File.php';
7
- require_once 'PEAR/PackageFileManager2.php';
8
-
9
- $pkg = new PEAR_PackageFileManager2;
10
-
11
- $e = $pkg->setOptions([
12
-
13
- 'baseinstalldir' => '/',
14
- 'packagedirectory' => '/u/devel/net_dns/Net_DNS2/',
15
- 'ignore' => [
16
- 'package.php',
17
- 'package.xml',
18
- 'TODO',
19
- 'composer.json'
20
- ],
21
- 'installexceptions' => [ 'phpdoc' => '/*' ],
22
- 'dir_roles' => [
23
- 'tests' => 'test'
24
- ],
25
- 'exceptions' => [
26
- 'LICENSE' => 'doc',
27
- 'README.md' => 'doc'
28
- ]
29
- ]);
30
-
31
- $pkg->setPackage('Net_DNS2');
32
- $pkg->setSummary('PHP Resolver library used to communicate with a DNS server.');
33
- $pkg->setDescription("Provides (roughly) the same functionality as Net_DNS, but using modern PHP objects, exceptions for error handling, better sockets support.\n\nThis release is (in most cases) 2x - 10x faster than Net_DNS, as well as includes more RR's (including DNSSEC RR's), and improved sockets and streams support.");
34
- $pkg->setChannel('pear.php.net');
35
- $pkg->setAPIVersion('1.5.2');
36
- $pkg->setReleaseVersion('1.5.2');
37
- $pkg->setReleaseStability('stable');
38
- $pkg->setAPIStability('stable');
39
- $pkg->setNotes(
40
- "- fixed a mistake in the autoload section of the composer.json file.\n"
41
- );
42
- $pkg->setPackageType('php');
43
- $pkg->addRelease();
44
- $pkg->setPhpDep('5.4');
45
- $pkg->setPearinstallerDep('1.4.0a12');
46
- $pkg->addMaintainer('lead', 'mikepultz', 'Mike Pultz', 'mike@mikepultz.com');
47
- $pkg->setLicense('BSD License', 'http://www.opensource.org/licenses/bsd-license.php');
48
- $pkg->generateContents();
49
-
50
- $pkg->writePackageFile();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/package.xml DELETED
@@ -1,592 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <package packagerversion="1.10.7" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0
3
- http://pear.php.net/dtd/tasks-1.0.xsd
4
- http://pear.php.net/dtd/package-2.0
5
- http://pear.php.net/dtd/package-2.0.xsd">
6
- <name>Net_DNS2</name>
7
- <channel>pear.php.net</channel>
8
- <summary>PHP Resolver library used to communicate with a DNS server.</summary>
9
- <description>Provides (roughly) the same functionality as Net_DNS, but using modern PHP objects, exceptions for error handling, better sockets support.
10
-
11
- This release is (in most cases) 2x - 10x faster than Net_DNS, as well as includes more RR&apos;s (including DNSSEC RR&apos;s), and improved sockets and streams support.</description>
12
- <lead>
13
- <name>Mike Pultz</name>
14
- <user>mikepultz</user>
15
- <email>mike@mikepultz.com</email>
16
- <active>yes</active>
17
- </lead>
18
- <date>2020-10-11</date>
19
- <time>13:33:23</time>
20
- <version>
21
- <release>1.5.2</release>
22
- <api>1.5.2</api>
23
- </version>
24
- <stability>
25
- <release>stable</release>
26
- <api>stable</api>
27
- </stability>
28
- <license uri="http://www.opensource.org/licenses/bsd-license.php">BSD License</license>
29
- <notes>
30
- - fixed a mistake in the autoload section of the composer.json file.
31
- </notes>
32
- <contents>
33
- <dir baseinstalldir="/" name="/">
34
- <file baseinstalldir="/" md5sum="60e78d78de1f7a6b60f349170ccca46d" name="Net/DNS2.php" role="php" />
35
- <file baseinstalldir="/" md5sum="a05ee07e0b50d137c4a5486872911093" name="Net/DNS2/BitMap.php" role="php" />
36
- <file baseinstalldir="/" md5sum="65fabaf95bc04552b66b22c0441bab73" name="Net/DNS2/Cache.php" role="php" />
37
- <file baseinstalldir="/" md5sum="1a0842fb4f719125ef964c270611964e" name="Net/DNS2/Exception.php" role="php" />
38
- <file baseinstalldir="/" md5sum="1f6ebf8bca03bde07bad274ffb771d7a" name="Net/DNS2/Header.php" role="php" />
39
- <file baseinstalldir="/" md5sum="55b62c9d65c69253ea9b87a12ea9401a" name="Net/DNS2/Lookups.php" role="php" />
40
- <file baseinstalldir="/" md5sum="296147746ecf5a19d2092d02bf9fcc0b" name="Net/DNS2/Notifier.php" role="php" />
41
- <file baseinstalldir="/" md5sum="9d25d44b6b0290d4f14b4b0825428d29" name="Net/DNS2/Packet.php" role="php" />
42
- <file baseinstalldir="/" md5sum="dee35a349bb4108722df87ca09af1442" name="Net/DNS2/PrivateKey.php" role="php" />
43
- <file baseinstalldir="/" md5sum="ef491e78b77bb42eb292c291b45290b0" name="Net/DNS2/Question.php" role="php" />
44
- <file baseinstalldir="/" md5sum="7e7b32bfefd33cc42d0ec4300679a47d" name="Net/DNS2/Resolver.php" role="php" />
45
- <file baseinstalldir="/" md5sum="ea79782942dbc27bebb659112de12f14" name="Net/DNS2/RR.php" role="php" />
46
- <file baseinstalldir="/" md5sum="5c409764944ce8b37eaa267100fe9789" name="Net/DNS2/Socket.php" role="php" />
47
- <file baseinstalldir="/" md5sum="229cacd971d704721be0c8b48b087d84" name="Net/DNS2/Updater.php" role="php" />
48
- <file baseinstalldir="/" md5sum="192a4460393942fdbe945af73f4b54a7" name="Net/DNS2/Cache/File.php" role="php" />
49
- <file baseinstalldir="/" md5sum="7bfd53087dc791ba3b3b4f9a60b5bbb4" name="Net/DNS2/Cache/Shm.php" role="php" />
50
- <file baseinstalldir="/" md5sum="65d8427f0db5c87c6e4bb4cd8e556f3e" name="Net/DNS2/Packet/Request.php" role="php" />
51
- <file baseinstalldir="/" md5sum="5681148554ab5174940fef48d15414bf" name="Net/DNS2/Packet/Response.php" role="php" />
52
- <file baseinstalldir="/" md5sum="49269e3bac6ee18abc3b512120a26540" name="Net/DNS2/RR/A.php" role="php" />
53
- <file baseinstalldir="/" md5sum="c57bbe951f550bfb0630e589a84a246a" name="Net/DNS2/RR/AAAA.php" role="php" />
54
- <file baseinstalldir="/" md5sum="3d999b64ba97395990f3b6c2874ef620" name="Net/DNS2/RR/AFSDB.php" role="php" />
55
- <file baseinstalldir="/" md5sum="1a8fcfd73b8b6afc13402a78aa7625cc" name="Net/DNS2/RR/AMTRELAY.php" role="php" />
56
- <file baseinstalldir="/" md5sum="4eaf33515b4303276d467bca4e24f89c" name="Net/DNS2/RR/ANY.php" role="php" />
57
- <file baseinstalldir="/" md5sum="53634f62f21f5b944422d1a735d8f8fb" name="Net/DNS2/RR/APL.php" role="php" />
58
- <file baseinstalldir="/" md5sum="3f4d4bfdfbce921546e35cc2ace0c0ac" name="Net/DNS2/RR/ATMA.php" role="php" />
59
- <file baseinstalldir="/" md5sum="b16d7fe6a80eac184b329f5a0cdc4713" name="Net/DNS2/RR/AVC.php" role="php" />
60
- <file baseinstalldir="/" md5sum="22c1e7d8ff6f08e3d94d4515aae52888" name="Net/DNS2/RR/CAA.php" role="php" />
61
- <file baseinstalldir="/" md5sum="a7c1566d3b6f3ee640bde61ea6a3e150" name="Net/DNS2/RR/CDNSKEY.php" role="php" />
62
- <file baseinstalldir="/" md5sum="3ef118f6dbe1ddd0f71cf2c9fb456da9" name="Net/DNS2/RR/CDS.php" role="php" />
63
- <file baseinstalldir="/" md5sum="550be6c3a34c881b7c72c44f231f1ab7" name="Net/DNS2/RR/CERT.php" role="php" />
64
- <file baseinstalldir="/" md5sum="1f4e875f71f1fc32cfdbd79209f356f4" name="Net/DNS2/RR/CNAME.php" role="php" />
65
- <file baseinstalldir="/" md5sum="97b49c0131fc18d9bf8207054758ac76" name="Net/DNS2/RR/CSYNC.php" role="php" />
66
- <file baseinstalldir="/" md5sum="fee5353026cf0af55b51b009d76d5e67" name="Net/DNS2/RR/DHCID.php" role="php" />
67
- <file baseinstalldir="/" md5sum="ec74257bac87820aa77d6e7f27a1cec2" name="Net/DNS2/RR/DLV.php" role="php" />
68
- <file baseinstalldir="/" md5sum="936e95ec37a9a775ea0692641e5ddc90" name="Net/DNS2/RR/DNAME.php" role="php" />
69
- <file baseinstalldir="/" md5sum="d2e17925888cc69d8787134130ed8053" name="Net/DNS2/RR/DNSKEY.php" role="php" />
70
- <file baseinstalldir="/" md5sum="b144653c65cfe1463a7b88a2423a050e" name="Net/DNS2/RR/DS.php" role="php" />
71
- <file baseinstalldir="/" md5sum="778ef8ef8e57bebe6eaaaa7ace381f33" name="Net/DNS2/RR/EID.php" role="php" />
72
- <file baseinstalldir="/" md5sum="959142f481c541ee5aaccd46cfdcc9ae" name="Net/DNS2/RR/EUI48.php" role="php" />
73
- <file baseinstalldir="/" md5sum="015e75928a6385ae9d6ca0574c4d2b1e" name="Net/DNS2/RR/EUI64.php" role="php" />
74
- <file baseinstalldir="/" md5sum="c6374c8fb7c3c3e332f88ad718eef5cd" name="Net/DNS2/RR/HINFO.php" role="php" />
75
- <file baseinstalldir="/" md5sum="eef4a0f3642706288c74c12bf2198bdf" name="Net/DNS2/RR/HIP.php" role="php" />
76
- <file baseinstalldir="/" md5sum="578957ee06a2d9d8218cb3072239b922" name="Net/DNS2/RR/IPSECKEY.php" role="php" />
77
- <file baseinstalldir="/" md5sum="f8ee26d8ec2cb614b3fbe13c56313eb5" name="Net/DNS2/RR/ISDN.php" role="php" />
78
- <file baseinstalldir="/" md5sum="2b6ed2ff0fde52cdc88a431bec58104d" name="Net/DNS2/RR/KEY.php" role="php" />
79
- <file baseinstalldir="/" md5sum="f4e96df16e036f6c2cf9a3406cd04de8" name="Net/DNS2/RR/KX.php" role="php" />
80
- <file baseinstalldir="/" md5sum="da45fda79826d4175a0f2b02c7bb40bc" name="Net/DNS2/RR/L32.php" role="php" />
81
- <file baseinstalldir="/" md5sum="3611fac651fc4bc52c951c9f61ac8c3a" name="Net/DNS2/RR/L64.php" role="php" />
82
- <file baseinstalldir="/" md5sum="738dd9a1f3ee0bb4036c703badaea0a0" name="Net/DNS2/RR/LOC.php" role="php" />
83
- <file baseinstalldir="/" md5sum="c32281671d6fa2d956bfa4f1cf05ebf8" name="Net/DNS2/RR/LP.php" role="php" />
84
- <file baseinstalldir="/" md5sum="b5f0bacafa02befec4f7189389dff918" name="Net/DNS2/RR/MX.php" role="php" />
85
- <file baseinstalldir="/" md5sum="78be48bd0cfde365342aa6a2916a6522" name="Net/DNS2/RR/NAPTR.php" role="php" />
86
- <file baseinstalldir="/" md5sum="4c28c455b84147db6f1a46de78841429" name="Net/DNS2/RR/NID.php" role="php" />
87
- <file baseinstalldir="/" md5sum="27a6cb081d0d3e6016411653904dd260" name="Net/DNS2/RR/NIMLOC.php" role="php" />
88
- <file baseinstalldir="/" md5sum="d76c5df21dcb81b9109f2c4a7b200ff9" name="Net/DNS2/RR/NS.php" role="php" />
89
- <file baseinstalldir="/" md5sum="3cf2ce4f193515eb03ece1b8f3884feb" name="Net/DNS2/RR/NSAP.php" role="php" />
90
- <file baseinstalldir="/" md5sum="cecb91d02db19a875e7684cbff4acf87" name="Net/DNS2/RR/NSEC.php" role="php" />
91
- <file baseinstalldir="/" md5sum="81e177672209c308430e48a45ba6eb73" name="Net/DNS2/RR/NSEC3.php" role="php" />
92
- <file baseinstalldir="/" md5sum="985388bb4428be846ebf9e886fb5a3d1" name="Net/DNS2/RR/NSEC3PARAM.php" role="php" />
93
- <file baseinstalldir="/" md5sum="ab0bd2b517a2a1e595623f68d25970aa" name="Net/DNS2/RR/OPENPGPKEY.php" role="php" />
94
- <file baseinstalldir="/" md5sum="d7d11e5b9b943086291ced0b59d90801" name="Net/DNS2/RR/OPT.php" role="php" />
95
- <file baseinstalldir="/" md5sum="ab49dbd9c41c7df30dddfc93cb130973" name="Net/DNS2/RR/PTR.php" role="php" />
96
- <file baseinstalldir="/" md5sum="b3f187ca793b2da25f895bdf2dab90ef" name="Net/DNS2/RR/PX.php" role="php" />
97
- <file baseinstalldir="/" md5sum="22fc47471cb8de0b4a412f3014aeeb40" name="Net/DNS2/RR/RP.php" role="php" />
98
- <file baseinstalldir="/" md5sum="a91497c89dec29eaf6f992480c0673e1" name="Net/DNS2/RR/RRSIG.php" role="php" />
99
- <file baseinstalldir="/" md5sum="315dbea20fb2a78b9bb3c8cf03b582ef" name="Net/DNS2/RR/RT.php" role="php" />
100
- <file baseinstalldir="/" md5sum="ce0bc0b8b3f780863daee53895b2ddff" name="Net/DNS2/RR/SIG.php" role="php" />
101
- <file baseinstalldir="/" md5sum="a8efd38d743fecbfbb4eee3021f5391d" name="Net/DNS2/RR/SMIMEA.php" role="php" />
102
- <file baseinstalldir="/" md5sum="c35ff748bc1e3db49202fac271169f59" name="Net/DNS2/RR/SOA.php" role="php" />
103
- <file baseinstalldir="/" md5sum="0af8927cfd8cffc1ab2154b91b37359a" name="Net/DNS2/RR/SPF.php" role="php" />
104
- <file baseinstalldir="/" md5sum="2746407a7d6d18572c1f6042af401697" name="Net/DNS2/RR/SRV.php" role="php" />
105
- <file baseinstalldir="/" md5sum="2904fa31c4bbb0cd41ccd7aa439f5dee" name="Net/DNS2/RR/SSHFP.php" role="php" />
106
- <file baseinstalldir="/" md5sum="b3c2fd46e6492e2dd4953ce8f29bff41" name="Net/DNS2/RR/TA.php" role="php" />
107
- <file baseinstalldir="/" md5sum="6f7a7ba44dfa738b79460eb69943eb2c" name="Net/DNS2/RR/TALINK.php" role="php" />
108
- <file baseinstalldir="/" md5sum="5de67db84edc0a9edbcbd51ffe38e2b4" name="Net/DNS2/RR/TKEY.php" role="php" />
109
- <file baseinstalldir="/" md5sum="31388482a1b79cfa133a0be89f6b30cd" name="Net/DNS2/RR/TLSA.php" role="php" />
110
- <file baseinstalldir="/" md5sum="d82e2c80f75792a889b822160f653901" name="Net/DNS2/RR/TSIG.php" role="php" />
111
- <file baseinstalldir="/" md5sum="3b5e380325028df22f75ce27468240ae" name="Net/DNS2/RR/TXT.php" role="php" />
112
- <file baseinstalldir="/" md5sum="2e8a982ec1aa5b6ee2ec9d490b120e35" name="Net/DNS2/RR/TYPE65534.php" role="php" />
113
- <file baseinstalldir="/" md5sum="1aa1500cda6504917dd54f3557150e73" name="Net/DNS2/RR/URI.php" role="php" />
114
- <file baseinstalldir="/" md5sum="6526a0f47cc7dd0822779e1cf49cc007" name="Net/DNS2/RR/WKS.php" role="php" />
115
- <file baseinstalldir="/" md5sum="828f7072c6a19f9b6392d6f02a61d062" name="Net/DNS2/RR/X25.php" role="php" />
116
- <file baseinstalldir="/" md5sum="57c06ed7d6032aff2f1715b10cc649f6" name="tests/Tests_Net_DNS2_AllTests.php" role="test" />
117
- <file baseinstalldir="/" md5sum="149ac6f774c77c487ca1ad97b3af0260" name="tests/Tests_Net_DNS2_DNSSECTest.php" role="test" />
118
- <file baseinstalldir="/" md5sum="5745a475e93e23bf543a1359c2fe0372" name="tests/Tests_Net_DNS2_ParserTest.php" role="test" />
119
- <file baseinstalldir="/" md5sum="5efb0d1ca908d87c315c70630e556c20" name="tests/Tests_Net_DNS2_ResolverTest.php" role="test" />
120
- <file baseinstalldir="/" md5sum="2755e1326b816c8e8634ad96aa891085" name="LICENSE" role="doc" />
121
- <file baseinstalldir="/" md5sum="67647d87e3a3803d137a1120c43c3cb8" name="README.md" role="doc" />
122
- </dir>
123
- </contents>
124
- <dependencies>
125
- <required>
126
- <php>
127
- <min>5.4</min>
128
- </php>
129
- <pearinstaller>
130
- <min>1.4.0a12</min>
131
- </pearinstaller>
132
- </required>
133
- </dependencies>
134
- <phprelease />
135
- <changelog>
136
- <release>
137
- <version>
138
- <release>0.6.0</release>
139
- <api>0.6.0</api>
140
- </version>
141
- <stability>
142
- <release>beta</release>
143
- <api>beta</api>
144
- </stability>
145
- <date>2010-09-26</date>
146
- <license uri="http://www.opensource.org/licenses/bsd-license.php">BSD License</license>
147
- <notes>
148
- Initial Beta release of Net_DNS2
149
- </notes>
150
- </release>
151
- <release>
152
- <version>
153
- <release>1.0.0</release>
154
- <api>1.0.0</api>
155
- </version>
156
- <stability>
157
- <release>stable</release>
158
- <api>beta</api>
159
- </stability>
160
- <date>2010-10-25</date>
161
- <license uri="http://www.opensource.org/licenses/bsd-license.php">BSD License</license>
162
- <notes>
163
- - finished support for the OPT, APL, and the HIP RR
164
- - fixed a small bug in the Net_DNS2_RR::fromString method when parsing strings. apparently PHP doesn&apos;t think that 0 is numeric sometimes
165
- - updated the @since value for all the files; it was set with the incorrect version.
166
- </notes>
167
- </release>
168
- <release>
169
- <version>
170
- <release>1.0.1</release>
171
- <api>1.0.1</api>
172
- </version>
173
- <stability>
174
- <release>stable</release>
175
- <api>stable</api>
176
- </stability>
177
- <date>2010-12-02</date>
178
- <license uri="http://www.opensource.org/licenses/bsd-license.php">BSD License</license>
179
- <notes>
180
- - fixed a problem Sockets and Streams class; was using the wrong shift operators when calculating the size
181
- - added support for the WKS RR
182
- - fixed some phpcs issues
183
- </notes>
184
- </release>
185
- <release>
186
- <version>
187
- <release>1.1.0</release>
188
- <api>1.1.0</api>
189
- </version>
190
- <stability>
191
- <release>stable</release>
192
- <api>stable</api>
193
- </stability>
194
- <date>2011-04-24</date>
195
- <license uri="http://www.opensource.org/licenses/bsd-license.php">BSD License</license>
196
- <notes>
197
- - added support for signing requests using SIG(0); uses the PHP openssl extension, and only currently supports RSA- DSA support in PHP is limited.
198
- - moved the signing code for SIG(0) and TSIG to the base class so it can be used for both updates and queries (for AXFR)
199
- - added a simple local cache feature using shared memory (shmop extension) or using a flat fille. This feature is disabled by default.
200
- - added support for the ATMA resource record (supported in Windows)
201
- </notes>
202
- </release>
203
- <release>
204
- <version>
205
- <release>1.1.1</release>
206
- <api>1.1.1</api>
207
- </version>
208
- <stability>
209
- <release>stable</release>
210
- <api>stable</api>
211
- </stability>
212
- <date>2011-05-07</date>
213
- <license uri="http://www.opensource.org/licenses/bsd-license.php">BSD License</license>
214
- <notes>
215
- - fixed a bug in the autoload function; if you had another autoload function defined, and tried to load a class with an _ in the name, it would fail.
216
- </notes>
217
- </release>
218
- <release>
219
- <version>
220
- <release>1.1.2</release>
221
- <api>1.1.2</api>
222
- </version>
223
- <stability>
224
- <release>stable</release>
225
- <api>stable</api>
226
- </stability>
227
- <date>2011-06-01</date>
228
- <license uri="http://www.opensource.org/licenses/bsd-license.php">BSD License</license>
229
- <notes>
230
- - fixed a bug in the Net_DNS2_Updater class; I wasn&apos;t resetting the internal packet request values, so in some cases making more than one request on the same instance would fail.
231
- - Fixed a bug in Net_DNS2; I wasn&apos;t handling comments properly when parsing the resolv.conf file.
232
- - check for duplicate entries when adding/deleting entries in the Updater() class; BIND will throw and error if you try to delete the same RR twice in the same request, not sure if this is expected behaviour
233
- - modified several RR&apos;s to clean up the trailing period when it&apos;s displayed on hosts.
234
- </notes>
235
- </release>
236
- <release>
237
- <version>
238
- <release>1.1.3</release>
239
- <api>1.1.3</api>
240
- </version>
241
- <stability>
242
- <release>stable</release>
243
- <api>stable</api>
244
- </stability>
245
- <date>2011-07-01</date>
246
- <license uri="http://www.opensource.org/licenses/bsd-license.php">BSD License</license>
247
- <notes>
248
- - added support for IPv6 DNS servers; from resolv.conf files, and from name server arrays
249
- - added new IPv4 and IPv6 validation functions, and a IPv6 expand function
250
- - changed the A, AAAA and IPSECKEY RR&apos;s to use the new validation methods
251
- - added support for IPv6 PTR records
252
- - dropped the old IPv4 regex from the lookups class
253
- </notes>
254
- </release>
255
- <release>
256
- <version>
257
- <release>1.1.4</release>
258
- <api>1.1.4</api>
259
- </version>
260
- <stability>
261
- <release>stable</release>
262
- <api>stable</api>
263
- </stability>
264
- <date>2011-07-25</date>
265
- <license uri="http://www.opensource.org/licenses/bsd-license.php">BSD License</license>
266
- <notes>
267
- - fixed a math issue with the name compress logic; this would somtimes screw up Updates with multiple RR&apos;s
268
- - added a new test in the test suite, that validates that the domain name compression and expansion works properly
269
- </notes>
270
- </release>
271
- <release>
272
- <version>
273
- <release>1.2.0</release>
274
- <api>1.2.0</api>
275
- </version>
276
- <stability>
277
- <release>stable</release>
278
- <api>stable</api>
279
- </stability>
280
- <date>2011-12-04</date>
281
- <license uri="http://www.opensource.org/licenses/bsd-license.php">BSD License</license>
282
- <notes>
283
- - added numeric error codes to the Lookups class, and had each method that throws an exception throw a numeric error code along with the message.
284
- - dropped all references to InvalidArgumentException; we only use the Net_DNS2_Exception from now on.
285
- - added the CAA, URI, TALINK, CDS and TA resource records. Some of these are experimental, but are pretty straight forward.
286
- - fixed a bug in formatString(); my version was only putting double quotes around strings that have spaces, but apparently ALL strings should have double quotes around them. This is how BIND does it.
287
- - re-organized the Net_DNS2_Lookups initialization code; it no longer creates a global object of itself.
288
- - fixed a bug in the caching code; in some cases it wouldn&apos;t cache the same content more than once.
289
- - added an option to use JSON to serialize the cache data rather than using the PHP serialize function. JSON is much faster, but loses the class definition, and becomes a stdClass object.
290
- - fixed a handful of cases where I was using double quotes where a single quote would be fine.
291
- </notes>
292
- </release>
293
- <release>
294
- <version>
295
- <release>1.2.1</release>
296
- <api>1.2.1</api>
297
- </version>
298
- <stability>
299
- <release>stable</release>
300
- <api>stable</api>
301
- </stability>
302
- <date>2012-03-24</date>
303
- <license uri="http://www.opensource.org/licenses/bsd-license.php">BSD License</license>
304
- <notes>
305
- - changed the Net_DNS2_Sockets::_sock property from private to protected; this was causing some problems when the request was failing.
306
- - PHP doesn&apos;t support unsigned integers, but many of the RR&apos;s return unsigned values (like SOA), so there is the possibility that the value will overrun on 32bit systems, and you&apos;ll end up with a negative value. So a new function was added to convert the negative value, to a string with the correct unsigned value.
307
- </notes>
308
- </release>
309
- <release>
310
- <version>
311
- <release>1.2.2</release>
312
- <api>1.2.2</api>
313
- </version>
314
- <stability>
315
- <release>stable</release>
316
- <api>stable</api>
317
- </stability>
318
- <date>2012-08-13</date>
319
- <license uri="http://www.opensource.org/licenses/bsd-license.php">BSD License</license>
320
- <notes>
321
- - added some trimming of whitespace to Net_DNS2_RR::buildString(); we&apos;d get some Uninitialized string offset errors if there was some blank space at the end.
322
- - fixed a few cases where Net_DNS2_Lookup where it should Net_DNS2_Lookups
323
- - added support for a strict query mode, that lets you handle the weird way DNS handles failed lookups + CNAME recors; see RFC 1034 section 3.6.2 for more information.
324
- - fixed some warning messages that were coming from the cache classes when a json_decode() would fail.
325
- - fixed a bug in Net_DNS2_Cache_File and Net_DNS2_Cache_Shm; it would try to write the file even if caching was turned off
326
- - made sure we don&apos;t cache records when we do a zone transfer
327
- - added some blocking in both the Sockets.php and Streams.php file around the read function
328
- - I wasn&apos;t handling multi-message zone transfers properly; now we loop through and read all the messages and pack them together as one big result
329
- </notes>
330
- </release>
331
- <release>
332
- <version>
333
- <release>1.2.3</release>
334
- <api>1.2.3</api>
335
- </version>
336
- <stability>
337
- <release>stable</release>
338
- <api>stable</api>
339
- </stability>
340
- <date>2012-08-17</date>
341
- <license uri="http://www.opensource.org/licenses/bsd-license.php">BSD License</license>
342
- <notes>
343
- - added a LICENSE file to satisfy fedora packaging guidelines
344
- - included the tests folder in the PEAR package
345
- - updated the tests to not include a specific include_path, and to use the Google public DNS servers for the resolution tests, rather than the /etc/resolv.conf file (which won&apos;t exist on a Windows system)
346
- - fixed a endless loop bug in the Streams.php file; this was related to the code changes I made + UDP packets
347
- </notes>
348
- </release>
349
- <release>
350
- <version>
351
- <release>1.2.4</release>
352
- <api>1.2.4</api>
353
- </version>
354
- <stability>
355
- <release>stable</release>
356
- <api>stable</api>
357
- </stability>
358
- <date>2012-09-19</date>
359
- <license uri="http://www.opensource.org/licenses/bsd-license.php">BSD License</license>
360
- <notes>
361
- - added the name server that the response came from to the Net_DNS2_Packet_Response object
362
- - added the socket type (TCP or UDP) that was used for the request.
363
- - changed the internal socket logic to use a local define for SOCK_STREAM and SOCK_DGRAM rather than the one provied with the sockets library; this isn&apos;t available if you&apos;re not using the library.
364
- - fixed a bug when an AXFR fails; rather than returning right away, it was waiting until there was a timeout condition. Now it returns right away on failure.
365
- </notes>
366
- </release>
367
- <release>
368
- <version>
369
- <release>1.2.5</release>
370
- <api>1.2.5</api>
371
- </version>
372
- <stability>
373
- <release>stable</release>
374
- <api>stable</api>
375
- </stability>
376
- <date>2012-12-30</date>
377
- <license uri="http://www.opensource.org/licenses/bsd-license.php">BSD License</license>
378
- <notes>
379
- - changed the socket_connect() code to start off non-blocking, and call select() after connect() so a timeout on a invalid server works properly
380
- - added the new TLSA RR - RFC 6698
381
- - fixed the socket defines again; apparently the values of the SOCK_* are different under solaris
382
- - changed the Net_DNS2_Updater::update() so you can pass a reference to a variable that will be populated with the response object
383
- - moved the lines that add the response server/type to after the is_null() check- it should have been there to begin with.
384
- - fixed a whole bunch of cases where I wasn&apos;t incrementing the offset values properly
385
- - added support to set the RD (recursion desired) bit when making a request
386
- </notes>
387
- </release>
388
- <release>
389
- <version>
390
- <release>1.3.0</release>
391
- <api>1.3.0</api>
392
- </version>
393
- <stability>
394
- <release>stable</release>
395
- <api>stable</api>
396
- </stability>
397
- <date>2013-04-07</date>
398
- <license uri="http://www.opensource.org/licenses/bsd-license.php">BSD License</license>
399
- <notes>
400
- - re-worked a lot of the code around OPT RR&apos;s, including adding support for the DO flag
401
- - added the AD and CD flags to the Net_DNS2_Header class for DNSSEC
402
- - added a new function to keep track of RR&apos;s that should NOT be cached.
403
- - added a new flag (dnssec) to request DNSSEC lookups; this adds an OPT RR to the additional section
404
- - added a new flag (dnssec_payload_size) to adjust the EDNS(0) UDP payload size.
405
- - added a new flag (dnssec_cd_flag) to set the DNSSEC CD bit to disable signature validation.
406
- - added a new flag (dnssec_ad_flag) to set the DNSSEC AD bit to request authentic data without needing to set the DO flag.
407
- - fixed an issue in Net_DNS2_Socket_Sockets; Windows (specifically &lt; 2003) has problems with MSG_WAITALL
408
- - added a DNSSEC test to the testing suite.
409
- </notes>
410
- </release>
411
- <release>
412
- <version>
413
- <release>1.3.1</release>
414
- <api>1.3.1</api>
415
- </version>
416
- <stability>
417
- <release>stable</release>
418
- <api>stable</api>
419
- </stability>
420
- <date>2013-06-12</date>
421
- <license uri="http://www.opensource.org/licenses/bsd-license.php">BSD License</license>
422
- <notes>
423
- - added the Net_DNS2_Packet_Request and Net_DNS2_Packet_Response objects to the Net_DNS2_Exception object
424
- - added support in the TSIG class for SHA algorithms (requires the hash extension, which is included in PHP &gt;= 5.1.2), patch provided by Manuel Mausz
425
- - added support for the NID, L32, L64, and LP DNS RR&apos;s (RFC6742)
426
- - lots of phpcs cleanup
427
- </notes>
428
- </release>
429
- <release>
430
- <version>
431
- <release>1.3.2</release>
432
- <api>1.3.2</api>
433
- </version>
434
- <stability>
435
- <release>stable</release>
436
- <api>stable</api>
437
- </stability>
438
- <date>2013-11-30</date>
439
- <license uri="http://www.opensource.org/licenses/bsd-license.php">BSD License</license>
440
- <notes>
441
- - added support for the EUI48 and EUI64 resource records (RFC7043)
442
- - fixed how we handle the return values from socket select() statements; this wasn&apos;t causing a problem, but it wasn&apos;t quite right
443
- - added some error messaging when the socket times out
444
- - before we cache the data, unset the rdata value; this was causing some JSON errors to be generated, and we don&apos;t need the data anyway.
445
- </notes>
446
- </release>
447
- <release>
448
- <version>
449
- <release>1.4.1</release>
450
- <api>1.4.1</api>
451
- </version>
452
- <stability>
453
- <release>stable</release>
454
- <api>stable</api>
455
- </stability>
456
- <date>2015-04-13</date>
457
- <license uri="http://www.opensource.org/licenses/bsd-license.php">BSD License</license>
458
- <notes>
459
- - increased the default DNSSEC payload size value to 4000 bytes per RFC 4035 section 4.1; this is still configurable.
460
- - fixed a bug where I was still using the DNS_MAX_UDP_SIZE default (512 bytes) for all requests, event DNSSEC, where I should have been using the dnssec_payload_size config value.
461
- - removed the limitation that PTR records had to look like IP addresses; you can add other things to PTR records, like service discovery objects- RFC 6763.
462
- - dropped support for using the Sockets library on Windows. There have been too many inconsistencies between versions of Windows; we&apos;ll just default to use the Streams library.
463
- - fixed the Net_DNS2_RR_PTR class so we can pass ptrdname&apos;s with spaces in them so that we can support DNS-Based Service Discovery (RFC 6763).
464
- - added support for the CSYNC resource record - see RFC 7477.
465
- </notes>
466
- </release>
467
- <release>
468
- <version>
469
- <release>1.4.2</release>
470
- <api>1.4.2</api>
471
- </version>
472
- <stability>
473
- <release>stable</release>
474
- <api>stable</api>
475
- </stability>
476
- <date>2016-08-22</date>
477
- <license uri="http://www.opensource.org/licenses/bsd-license.php">BSD License</license>
478
- <notes>
479
- - changed the role for the README.md file to doc
480
- - parse the resolv.conf options line; right now I just support the timeout and rotate options.
481
- - the options values only work if you set the new option use_resolv_options to true; this is to keep backwards compatibility.
482
- - added support for RFC 6594; support for SHA-256 and ECDSA in the SSHFP resource record.
483
- - added the SMIMEA resource record; this just extends the TLSA record.
484
- - added the AVC resource records; this just extends the TXT record.
485
- - added error and EDNS0 defines for DNS Cookies (RFC7873)
486
- - added EDNS0 defines to the lookup class
487
- - dropped the Net_DNS2_Packet::formatIPv6() function; this was deprecated in v1.1.3
488
- - re-wrote the Net_DNS2::expandIPv6() function. Based on testing, the new version is about twice as fast.
489
- </notes>
490
- </release>
491
- <release>
492
- <version>
493
- <release>1.4.3</release>
494
- <api>1.4.3</api>
495
- </version>
496
- <stability>
497
- <release>stable</release>
498
- <api>stable</api>
499
- </stability>
500
- <date>2017-03-06</date>
501
- <license uri="http://www.opensource.org/licenses/bsd-license.php">BSD License</license>
502
- <notes>
503
- - fixed an issue when looking up . or com., when using the strict_query_mode flag.
504
- - fixed a bug in the caching logic where I was loading the content more than once per instance, when really I only need to do it once.
505
- - changed the Net_DNS2::sock array to use the SOCK_DGRAM and SOCK_STREAM defines, rather than the strings &apos;tcp&apos; or &apos;udp&apos;.
506
- - fixed a bug in the Net_DNS2_Header and Net_DNS2_Question classes, where I was using the wrong bit-shift operators when parsing some of the values. This only became apparent when somebody was trying to use the CAA class (id 257); it was causing this to roll over to the next 8 bit value, and returning 1 (RR A) instead of the CAA class.
507
- - fixed a bug that occurs when a DNS lookup request times out, and then the same class is reused for a subsequent request. Because I&apos;m caching the sockets, the timed out data could eventually come in, and end up being seen as the result for a subsequent lookup.
508
- - fixed a couple cases in NSAP.php where I was comparing a string to to an integer.
509
- </notes>
510
- </release>
511
- <release>
512
- <version>
513
- <release>1.4.4</release>
514
- <api>1.4.4</api>
515
- </version>
516
- <stability>
517
- <release>stable</release>
518
- <api>stable</api>
519
- </stability>
520
- <date>2018-02-12</date>
521
- <license uri="http://www.opensource.org/licenses/bsd-license.php">BSD License</license>
522
- <notes>
523
- - bugfix when returning an empty bitmap-type in BitMap.php - patch from BugMaster510945.
524
- - added the BIND 9 private record RR (TYPE65534) - patch from BugMaster510945.
525
- - added DNSSEC algorithms 13-16 (ECDSAP256SHA256, ECDSAP384SHA384, ED25519, and ED448).
526
- - added SSHFP algoritm ED25519.
527
- - modified Net_DNS2::sendPacket() to use current()/next() rather than the deprecated each() (deprecated in 7.2).
528
- </notes>
529
- </release>
530
- <release>
531
- <version>
532
- <release>1.5.0</release>
533
- <api>1.5.0</api>
534
- </version>
535
- <stability>
536
- <release>stable</release>
537
- <api>stable</api>
538
- </stability>
539
- <date>2020-10-08</date>
540
- <license uri="http://www.opensource.org/licenses/bsd-license.php">BSD License</license>
541
- <notes>
542
- - added the AMTRELAY resource record type (RFC 8777).
543
- - added Net_DNS2_RR::asArray(), which returns the same values as __toString(), but as an array for easier access.
544
- - added Net_DNS2::closeSockets(), which lets you close all cached network sockets in the resolver object.
545
- - added Net_DNS2::getSockets(), which returns the local sockets cache array.
546
- - added date_created and date_last_used to the Net_DNS2_Socket object, to track usage stats on each socket object.
547
- - added the SHA256, SHA384, and GOST digest defines to Lookups.php.
548
- - dropped the Net_DNS2_Socket_Sockets, and switch to just using the streams code. There&apos;s no speed difference anymore.
549
- - fixed a bug in Net_DNS2_Packet::compress() and Net_DNS2_Packet::expand() related to dot literals in compressed names.
550
- - fixed a display issue in the IPSECKEY RR when displaying hostname / domain names in the gateway field.
551
- - fixed a couple inconsistencies in the docs.
552
- - fixed a PHP 7.4 bug in Sockets.php; accessing a null value as an array throws an exception now.
553
- - fixed Net_DNS2_RR_DS so it will be able to support other digest definitions without any other changes.
554
- - the Net_DNS2_RR_NIMLOC class was incorrectly named Net_DNS2_RR_NIMLOCK.
555
- - Net_DNS2_PrivateKey was using the wrong member variable name for the key_format value.
556
- - changed all references to array() to [].
557
- - removed all sorts of license noise from the files.
558
- - updated the test cases to use PHPUnit v9+.
559
- </notes>
560
- </release>
561
- <release>
562
- <version>
563
- <release>1.5.1</release>
564
- <api>1.5.1</api>
565
- </version>
566
- <stability>
567
- <release>stable</release>
568
- <api>stable</api>
569
- </stability>
570
- <date>2020-10-11</date>
571
- <license uri="http://www.opensource.org/licenses/bsd-license.php">BSD License</license>
572
- <notes>
573
- - fixed a mistake in the autoload section of the composer.json file.
574
- </notes>
575
- </release>
576
- <release>
577
- <version>
578
- <release>1.5.2</release>
579
- <api>1.5.2</api>
580
- </version>
581
- <stability>
582
- <release>stable</release>
583
- <api>stable</api>
584
- </stability>
585
- <date>2020-10-11</date>
586
- <license uri="http://www.opensource.org/licenses/bsd-license.php">BSD License</license>
587
- <notes>
588
- - fixed a mistake in the autoload section of the composer.json file.
589
- </notes>
590
- </release>
591
- </changelog>
592
- </package>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/tests/Tests_Net_DNS2_AllTests.php DELETED
@@ -1,73 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 1.0.0
17
- *
18
- */
19
-
20
- error_reporting(E_ALL | E_STRICT);
21
-
22
- if (!defined('PHPUNIT_MAIN_METHOD')) {
23
- define('PHPUNIT_MAIN_METHOD', 'Tests_Net_DNS2_AllTests::main');
24
- }
25
-
26
- require_once 'Tests_Net_DNS2_ParserTest.php';
27
- require_once 'Tests_Net_DNS2_ResolverTest.php';
28
- require_once 'Tests_Net_DNS2_DNSSECTest.php';
29
-
30
- set_include_path('..:.');
31
-
32
- /**
33
- * This test suite assumes that Net_DNS2 will be in the include path, otherwise it
34
- * will fail. There's no other way to hardcode a include_path in here that would
35
- * make it work everywhere.
36
- *
37
- */
38
- class Tests_Net_DNS2_AllTests
39
- {
40
- /**
41
- * the main runner
42
- *
43
- * @return void
44
- * @access public
45
- *
46
- */
47
- public static function main()
48
- {
49
- PHPUnit_TextUI_TestRunner::run(self::suite());
50
- }
51
-
52
- /**
53
- * test suite
54
- *
55
- * @return void
56
- * @access public
57
- *
58
- */
59
- public static function suite()
60
- {
61
- $suite = new PHPUnit_Framework_TestSuite('PEAR - Net_DNS2');
62
-
63
- $suite->addTestSuite('Tests_Net_DNS2_ParserTest');
64
- $suite->addTestSuite('Tests_Net_DNS2_ResolverTest');
65
- $suite->addTestSuite('Tests_Net_DNS2_DNSSECTest');
66
-
67
- return $suite;
68
- }
69
- }
70
-
71
- if (PHPUNIT_MAIN_METHOD == 'Tests_Net_DNS2_AllTests::main') {
72
- Tests_Net_DNS2_AllTests::main();
73
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/tests/Tests_Net_DNS2_DNSSECTest.php DELETED
@@ -1,49 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 1.0.0
17
- *
18
- */
19
-
20
- require_once 'Net/DNS2.php';
21
-
22
- /**
23
- * Test class to test the DNSSEC logic
24
- *
25
- */
26
- class Tests_Net_DNS2_DNSSECTest extends PHPUnit\Framework\TestCase
27
- {
28
- /**
29
- * function to test the TSIG logic
30
- *
31
- * @return void
32
- * @access public
33
- *
34
- */
35
- public function testDNSSEC()
36
- {
37
- $ns = [ '8.8.8.8', '8.8.4.4' ];
38
-
39
- $r = new Net_DNS2_Resolver([ 'nameservers' => $ns ]);
40
-
41
- $r->dnssec = true;
42
-
43
- $result = $r->query('org', 'SOA', 'IN');
44
-
45
- $this->assertTrue(($result->header->ad == 1));
46
- $this->assertTrue(($result->additional[0] instanceof Net_DNS2_RR_OPT));
47
- $this->assertTrue(($result->additional[0]->do == 1));
48
- }
49
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/tests/Tests_Net_DNS2_ParserTest.php DELETED
@@ -1,292 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 1.0.0
17
- *
18
- */
19
-
20
- require_once 'Net/DNS2.php';
21
-
22
- /**
23
- * Test class to test the parsing code
24
- *
25
- */
26
- class Tests_Net_DNS2_ParserTest extends PHPUnit\Framework\TestCase
27
- {
28
- /**
29
- * function to test the TSIG logic
30
- *
31
- * @return void
32
- * @access public
33
- *
34
- */
35
- public function testTSIG()
36
- {
37
- //
38
- // create a new packet
39
- //
40
- $request = new Net_DNS2_Packet_Request('example.com', 'SOA', 'IN');
41
-
42
- //
43
- // add a A record to the authority section, like an update request
44
- //
45
- $request->authority[] = Net_DNS2_RR::fromString('test.example.com A 10.10.10.10');
46
- $request->header->nscount = 1;
47
-
48
- //
49
- // add the TSIG as additional
50
- //
51
- $request->additional[] = Net_DNS2_RR::fromString('mykey TSIG Zm9vYmFy');
52
- $request->header->arcount = 1;
53
-
54
- $line = $request->additional[0]->name . '. ' . $request->additional[0]->ttl . ' ' .
55
- $request->additional[0]->class . ' ' . $request->additional[0]->type . ' ' .
56
- $request->additional[0]->algorithm . '. ' . $request->additional[0]->time_signed . ' '.
57
- $request->additional[0]->fudge;
58
-
59
- //
60
- // get the binary packet data
61
- //
62
- $data = $request->get();
63
-
64
- //
65
- // parse the binary
66
- //
67
- $response = new Net_DNS2_Packet_Response($data, strlen($data));
68
-
69
- //
70
- // the answer data in the response, should match our initial line exactly
71
- //
72
- $this->assertSame($line, substr($response->additional[0]->__toString(), 0, 58));
73
- }
74
-
75
- /**
76
- * function to test parsing the individual RR's
77
- *
78
- * @return void
79
- * @access public
80
- *
81
- */
82
- public function testParser()
83
- {
84
- $rrs = [
85
-
86
- 'A' => 'example.com. 300 IN A 172.168.0.50',
87
- 'NS' => 'example.com. 300 IN NS ns1.mrdns.com.',
88
- 'CNAME' => 'example.com. 300 IN CNAME www.example.com.',
89
- 'SOA' => 'example.com. 300 IN SOA ns1.mrdns.com. help\.team.mrhost.ca. 1278700841 900 1800 86400 21400',
90
- 'WKS' => 'example.com. 300 IN WKS 128.8.1.14 6 21 25',
91
- 'PTR' => '1.0.0.127.in-addr.arpa. 300 IN PTR localhost.',
92
- 'HINFO' => 'example.com. 300 IN HINFO "PC-Intel-700mhz" "Redhat \"Linux\" 7.1"',
93
- 'MX' => 'example.com. 300 IN MX 10 mx1.mrhost.ca.',
94
- 'TXT' => 'example.com. 300 IN TXT "first record" "another records" "a third"',
95
- 'RP' => 'example.com. 300 IN RP louie\.trantor.umd.edu. lam1.people.test.com.',
96
- 'AFSDB' => 'example.com. 300 IN AFSDB 3 afsdb.example.com.',
97
- 'X25' => 'example.com. 300 IN X25 "311 06 17 0 09 56"',
98
- 'ISDN' => 'example.com. 300 IN ISDN "150 862 028 003 217" "42"',
99
- 'RT' => 'example.com. 300 IN RT 2 relay.prime.com.',
100
- 'NSAP' => 'example.com. 300 IN NSAP 0x47.0005.80.005a00.0000.0001.e133.aaaaaa000151.00',
101
- 'SIG' => 'example.com. 300 IN SIG DNSKEY 7 1 86400 20100827211706 20100822211706 57970 gov. KoWPhMtLHp8sWYZSgsMiYJKB9P71CQmh9CnxJCs5GutKfo7Jpw+nNnDLiNnsd6U1JSkf99rYRWCyOTAPC47xkHr+2Uh7n6HDJznfdCzRa/v9uwEcbXIxCZ7KfzNJewW3EvYAxDIrW6sY/4MAsjS5XM/O9LaWzw6pf7TX5obBbLI+zRECbPNTdY+RF6Fl9K0GVaEZJNYi2PRXnATwvwca2CNRWxeMT/dF5STUram3cWjH0Pkm19Gc1jbdzlZVDbUudDauWoHcc0mfH7PV1sMpe80NqK7yQ24AzAkXSiknO13itHsCe4LECUu0/OtnhHg2swwXaVTf5hqHYpzi3bQenw==',
102
- 'KEY' => 'example.com. 300 IN KEY 256 3 7 AwEAAYCXh/ZABi8kiJIDXYmyUlHzC0CHeBzqcpyZAIjC7dK1wkRYVcUvIlpTOpnOVVfcC3Py9Ui/x45qKb0LytvK7WYAe3WyOOwk5klwIqRC/0p4luafbd2yhRMF7quOBVqYrLoHwv8i9LrV+r8dhB7rXv/lkTSI6mEZsg5rDfee8Yy1',
103
- 'PX' => 'example.com. 300 IN PX 10 ab.net2.it. o-ab.prmd-net2.admdb.c-it.',
104
- 'AAAA' => 'example.com. 300 IN AAAA 1080:0:0:0:8:800:200c:417a',
105
- 'LOC' => 'example.com. 300 IN LOC 42 21 54.675 N 71 06 18.343 W 24.12m 30.00m 40.00m 5.00m',
106
- 'SRV' => 'example.com. 300 IN SRV 20 0 5269 xmpp-server2.l.google.com.',
107
- 'ATMA' => 'example.com. 300 IN ATMA 39246f00e7c9c0312000100100001234567800',
108
- 'NAPTR' => 'example.com. 300 IN NAPTR 100 10 "S" "SIP+D2U" "!^.*$!sip:customer-service@example.com!" _sip._udp.example.com.',
109
- 'KX' => 'example.com. 300 IN KX 10 mx1.mrhost.ca.',
110
- 'CERT' => 'example.com. 300 IN CERT 3 0 0 TUlJQ1hnSUJBQUtCZ1FDcXlqbzNFMTU0dFU1Um43ajlKTFZsOGIwcUlCSVpGWENFelZvanVJT1BsMTM0by9zcHkxSE1hQytiUGh3Wk1UYVd4QlJpZHBFbUprNlEwNFJNTXdqdkFyLzFKWjhnWThtTzdCdTh1RUROVkNWeG5rQkUzMHhDSjhHRTNzL3EyN2VWSXBCUGFtU1lkNDVKZjNIeVBRRE4yaU45RjVHdGlIa2E2OXNhcmtKUnJ3SURBUUFCQW9HQkFJaUtDQ1NEM2FFUEFjQUx1MjdWN0JmR1BYN3lDTVg0OSsyVDVwNXNJdkduQjcrQ0NZZ09QaVQybmlpMGJPNVBBOTlnZnhPQXl1WCs5Z3llclVQbUFSc1ViUzcvUndkNGorRUlOVW1DanJSK2R6dGVXT0syeGxHamFOdGNPZU5jMkVtelQyMFRsekxVeUxTWGpzMzVlU2NQK0loeVptM2xJd21vbWtNb2d1QkFrRUE0a1FsOVBxaTJ2MVBDeGJCelU4Nnphblo2b0hsV0IzMUh4MllCNmFLYXhjNkVOZHhVejFzNjU2VncrRDhSVGpoSllyeDdMVkxzZDBRaVZJM0liSjVvUUpCQU1FN3k0aHg0SCtnQU40MEdrYjNjTFZGNHNpSEZrNnA2QVZRdlpzREwvVnh3bVlOdE4rM0txT3NVcG11WXZ3a3h0ajhIQnZtckxUYStXb3NmRDQwS1U4Q1FRQ1dvNmhob1R3cmI5bmdHQmFQQ2VDc2JCaVkrRUlvbUVsSm5mcEpuYWNxQlJ5emVid0pIeXdVOGsvalNUYXJIMk5HQzJ0bG5JMzRyS1VGeDZiTTJIWUJBa0VBbXBYSWZPNkZKL1NMM1RlWGNnQ1A5U1RraVlHd2NkdnhGeGVCcDlvRDZ2cElCN2FkWlgrMko5dzY5R0VUSlI0U3loSGVOdC95ZUhqWm9YdlhKVGc3ZHdKQVpEamxwL25wNEFZV3JYaGFrMVAvNGZlaDVNSU5WVHNXQkhTNlRZNW0xRmZMUEpybklHNW1FSHNidWkvdnhuQ1JmRUR4ZlU1V1E0cS9HUkZuaVl3SHB3PT0=',
111
- 'DNAME' => 'example.com. 300 IN DNAME frobozz-division.acme.example.',
112
- 'APL' => 'example.com. 300 IN APL 1:224.0.0.0/4 2:a0:0:0:0:0:0:0:0/8 !1:192.168.38.0/28',
113
- 'DS' => 'example.com. 300 IN DS 21366 7 2 96eeb2ffd9b00cd4694e78278b5efdab0a80446567b69f634da078f0d90f01ba',
114
- 'SSHFP' => 'example.com. 300 IN SSHFP 2 1 123456789abcdef67890123456789abcdef67890',
115
- 'IPSECKEY' => 'example.com. 300 IN IPSECKEY 10 2 2 2001:db8:0:8002:0:0:2000:1 AQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ==',
116
- 'RRSIG' => 'example.com. 300 IN RRSIG DNSKEY 7 1 86400 20100827211706 20100822211706 57970 gov. KoWPhMtLHp8sWYZSgsMiYJKB9P71CQmh9CnxJCs5GutKfo7Jpw+nNnDLiNnsd6U1JSkf99rYRWCyOTAPC47xkHr+2Uh7n6HDJznfdCzRa/v9uwEcbXIxCZ7KfzNJewW3EvYAxDIrW6sY/4MAsjS5XM/O9LaWzw6pf7TX5obBbLI+zRECbPNTdY+RF6Fl9K0GVaEZJNYi2PRXnATwvwca2CNRWxeMT/dF5STUram3cWjH0Pkm19Gc1jbdzlZVDbUudDauWoHcc0mfH7PV1sMpe80NqK7yQ24AzAkXSiknO13itHsCe4LECUu0/OtnhHg2swwXaVTf5hqHYpzi3bQenw==',
117
- 'NSEC' => 'example.com. 300 IN NSEC dog.poo.com. A MX RRSIG NSEC TYPE1234',
118
- 'DNSKEY' => 'example.com. 300 IN DNSKEY 256 3 7 AwEAAYCXh/ZABi8kiJIDXYmyUlHzC0CHeBzqcpyZAIjC7dK1wkRYVcUvIlpTOpnOVVfcC3Py9Ui/x45qKb0LytvK7WYAe3WyOOwk5klwIqRC/0p4luafbd2yhRMF7quOBVqYrLoHwv8i9LrV+r8dhB7rXv/lkTSI6mEZsg5rDfee8Yy1',
119
- 'DHCID' => 'example.com. 300 IN DHCID AAIBY2/AuCccgoJbsaxcQc9TUapptP69lOjxfNuVAA2kjEA=',
120
- 'NSEC3' => 'example.com. 300 IN NSEC3 1 1 12 AABBCCDD b4um86eghhds6nea196smvmlo4ors995 NS DS RRSIG',
121
- 'NSEC3PARAM' => 'example.com. 300 IN NSEC3PARAM 1 0 1 D399EAAB',
122
- 'TLSA' => '_443._tcp.www.example.com. 300 IN TLSA 1 1 2 92003ba34942dc74152e2f2c408d29eca5a520e7f2e06bb944f4dca346baf63c1b177615d466f6c4b71c216a50292bd58c9ebdd2f74e38fe51ffd48c43326cbc',
123
- 'SMIMEA' => 'c93f1e400f26708f98cb19d936620da35eec8f72e57f9eec01c1afd6._smimecert.example.com. 300 IN SMIMEA 1 1 2 92003ba34942dc74152e2f2c408d29eca5a520e7f2e06bb944f4dca346baf63c1b177615d466f6c4b71c216a50292bd58c9ebdd2f74e38fe51ffd48c43326cbc',
124
- 'HIP' => 'example.com. 300 IN HIP 2 200100107B1A74DF365639CC39F1D578 AwEAAbdxyhNuSutc5EMzxTs9LBPCIkOFH8cIvM4p9+LrV4e19WzK00+CI6zBCQTdtWsuxKbWIy87UOoJTwkUs7lBu+Upr1gsNrut79ryra+bSRGQb1slImA8YVJyuIDsj7kwzG7jnERNqnWxZ48AWkskmdHaVDP4BcelrTI3rMXdXF5D rvs.example.com. another.example.com. test.domain.org.',
125
- 'TALINK' => 'example.com. 300 IN TALINK c1.example.com. c3.example.com.',
126
- 'CDS' => 'example.com. 300 IN CDS 21366 7 2 96eeb2ffd9b00cd4694e78278b5efdab0a80446567b69f634da078f0d90f01ba',
127
- 'OPENPGPKEY' => '8d5730bd8d76d417bf974c03f59eedb7af98cb5c3dc73ea8ebbd54b7._openpgpkey.example.com. 300 IN OPENPGPKEY AwEAAYCXh/ZABi8kiJIDXYmyUlHzC0CHeBzqcpyZAIjC7dK1wkRYVcUvIlpTOpnOVVfcC3Py9Ui/x45qKb0LytvK7WYAe3WyOOwk5klwIqRC/0p4luafbd2yhRMF7quOBVqYrLoHwv8i9LrV+r8dhB7rXv/lkTSI6mEZsg5rDfee8Yy1',
128
- 'CSYNC' => 'example.com. 300 IN CSYNC 1278700841 3 A NS AAAA',
129
- 'SPF' => 'example.com. 300 IN SPF "v=spf1 ip4:192.168.0.1/24 mx ?all"',
130
- 'NID' => 'example.com. 300 IN NID 10 14:4fff:ff20:ee64',
131
- 'L32' => 'example.com. 300 IN L32 10 10.1.2.0',
132
- 'L64' => 'example.com. 300 IN L64 10 2001:db8:1140:1000',
133
- 'LP' => 'example.com. 300 IN LP 10 l64-subnet1.example.com.',
134
- 'EUI48' => 'example.com. 300 IN EUI48 00-00-5e-00-53-2a',
135
- 'EUI64' => 'example.com. 300 IN EUI64 00-00-5e-ef-10-00-00-2a',
136
- 'TKEY' => 'example.com. 300 IN TKEY gss.microsoft.com. 3 123456.',
137
- 'URI' => 'example.com. 300 IN URI 10 1 "http://mrdns.com/contact.html"',
138
- 'CAA' => 'example.com. 300 IN CAA 0 issue "ca.example.net; policy=ev"',
139
- 'AVC' => 'example.com. 300 IN AVC "first record" "another records" "a third"',
140
- 'AMTRELAY' => 'example.com. 300 IN AMTRELAY 10 0 0 .',
141
- 'AMTRELAY' => 'example.com. 300 IN AMTRELAY 10 0 1 203.0.113.15',
142
- 'AMTRELAY' => 'example.com. 300 IN AMTRELAY 10 0 2 2600:1f16:17c:3950:47ac:cb79:62ba:702e',
143
- 'AMTRELAY' => 'example.com. 300 IN AMTRELAY 10 0 3 test.google.com.',
144
- 'TA' => 'example.com. 300 IN TA 21366 7 2 96eeb2ffd9b00cd4694e78278b5efdab0a80446567b69f634da078f0d90f01ba',
145
- 'DLV' => 'example.com. 300 IN DLV 21366 7 2 96eeb2ffd9b00cd4694e78278b5efdab0a80446567b69f634da078f0d90f01ba',
146
- ];
147
-
148
- foreach ($rrs as $rr => $line) {
149
-
150
- $class_name = 'Net_DNS2_RR_' . $rr;
151
-
152
- //
153
- // create a new packet
154
- //
155
- if ($rr == 'PTR') {
156
- $request = new Net_DNS2_Packet_Request('1.0.0.127.in-addr.arpa', $rr, 'IN');
157
- } else {
158
- $request = new Net_DNS2_Packet_Request('example.com', $rr, 'IN');
159
- }
160
-
161
- //
162
- // parse the line
163
- //
164
- $a = Net_DNS2_RR::fromString($line);
165
-
166
- //
167
- // check that the object is right
168
- //
169
- $this->assertTrue($a instanceof $class_name);
170
-
171
- //
172
- // set it on the packet
173
- //
174
- $request->answer[] = $a;
175
- $request->header->ancount = 1;
176
-
177
- //
178
- // get the binary packet data
179
- //
180
- $data = $request->get();
181
-
182
- //
183
- // parse the binary
184
- //
185
- $response = new Net_DNS2_Packet_Response($data, strlen($data));
186
-
187
- //
188
- // the answer data in the response, should match our initial line exactly
189
- //
190
- $this->assertSame($line, $response->answer[0]->__toString());
191
- }
192
- }
193
-
194
- /**
195
- * function to test the compression logic
196
- *
197
- * @return void
198
- * @access public
199
- *
200
- */
201
- public function testCompression()
202
- {
203
- //
204
- // this list of RR's uses name compression
205
- //
206
- $rrs = [
207
-
208
- 'NS' => 'example.com. 300 IN NS ns1.mrdns.com.',
209
- 'CNAME' => 'example.com. 300 IN CNAME www.example.com.',
210
- 'SOA' => 'example.com. 300 IN SOA ns1.mrdns.com. help\.desk.mrhost.ca. 1278700841 900 1800 86400 21400',
211
- 'MX' => 'example.com. 300 IN MX 10 mx1.mrhost.ca.',
212
- 'RP' => 'example.com. 300 IN RP louie\.trantor.umd.edu. lam1.people.test.com.',
213
- 'AFSDB' => 'example.com. 300 IN AFSDB 3 afsdb.example.com.',
214
- 'RT' => 'example.com. 300 IN RT 2 relay.prime.com.',
215
- 'PX' => 'example.com. 300 IN PX 10 ab.net2.it. o-ab.prmd-net2.admdb.c-it.',
216
- 'SRV' => 'example.com. 300 IN SRV 20 0 5269 xmpp-server2.l.google.com.',
217
- 'NAPTR' => 'example.com. 300 IN NAPTR 100 10 S SIP+D2U !^.*$!sip:customer-service@example.com! _sip._udp.example.com.',
218
- 'DNAME' => 'example.com. 300 IN DNAME frobozz-division.acme.example.',
219
- 'HIP' => 'example.com. 300 IN HIP 2 200100107B1A74DF365639CC39F1D578 AwEAAbdxyhNuSutc5EMzxTs9LBPCIkOFH8cIvM4p9+LrV4e19WzK00+CI6zBCQTdtWsuxKbWIy87UOoJTwkUs7lBu+Upr1gsNrut79ryra+bSRGQb1slImA8YVJyuIDsj7kwzG7jnERNqnWxZ48AWkskmdHaVDP4BcelrTI3rMXdXF5D rvs.example.com. another.example.com. test.domain.org.'
220
- ];
221
-
222
- //
223
- // create a new updater object
224
- //
225
- $u = new Net_DNS2_Updater("example.com", [ 'nameservers' => [ '10.10.0.1' ] ]);
226
-
227
- //
228
- // add each RR to the same object, so we can build a build compressed name list
229
- //
230
- foreach ($rrs as $rr => $line) {
231
-
232
- $class_name = 'Net_DNS2_RR_' . $rr;
233
-
234
- //
235
- // parse the line
236
- //
237
- $a = Net_DNS2_RR::fromString($line);
238
-
239
- //
240
- // check that the object is right
241
- //
242
- $this->assertTrue($a instanceof $class_name);
243
-
244
- //
245
- // set it on the packet
246
- //
247
- $u->add($a);
248
- }
249
-
250
- //
251
- // get the request packet
252
- //
253
- $request = $u->packet();
254
-
255
- //
256
- // get the authority section of the request
257
- //
258
- $request_authority = $request->authority;
259
-
260
- //
261
- // parse the binary
262
- //
263
- $data = $request->get();
264
- $response = new Net_DNS2_Packet_Response($data, strlen($data));
265
-
266
- //
267
- // get the authority section of the response, and clean up the
268
- // rdata so everything will match.
269
- //
270
- // the request packet doesn't have the rdlength and rdata fields
271
- // built yet, so it will throw off the hash
272
- //
273
- $response_authority = $response->authority;
274
-
275
- foreach ($response_authority as $id => $object) {
276
-
277
- $response_authority[$id]->rdlength = '';
278
- $response_authority[$id]->rdata = '';
279
- }
280
-
281
- //
282
- // build the hashes
283
- //
284
- $a = md5(print_r($request_authority, 1));
285
- $b = md5(print_r($response_authority, 1));
286
-
287
- //
288
- // the new hashes should match.
289
- //
290
- $this->assertSame($a, $b);
291
- }
292
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/pear/net_dns2/tests/Tests_Net_DNS2_ResolverTest.php DELETED
@@ -1,49 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * DNS Library for handling lookups and updates.
5
- *
6
- * Copyright (c) 2020, Mike Pultz <mike@mikepultz.com>. All rights reserved.
7
- *
8
- * See LICENSE for more details.
9
- *
10
- * @category Networking
11
- * @package Net_DNS2
12
- * @author Mike Pultz <mike@mikepultz.com>
13
- * @copyright 2020 Mike Pultz <mike@mikepultz.com>
14
- * @license http://www.opensource.org/licenses/bsd-license.php BSD License
15
- * @link https://netdns2.com/
16
- * @since File available since Release 1.0.0
17
- *
18
- */
19
-
20
- require_once 'Net/DNS2.php';
21
-
22
- /**
23
- * This test uses the Google public DNS servers to perform a resolution test;
24
- * this should work on *nix and Windows, but will require an internet connection.
25
- *
26
- */
27
- class Tests_Net_DNS2_ResolverTest extends PHPUnit\Framework\TestCase
28
- {
29
- /**
30
- * function to test the resolver
31
- *
32
- * @return void
33
- * @access public
34
- *
35
- */
36
- public function testResolver()
37
- {
38
- $ns = [ '8.8.8.8', '8.8.4.4' ];
39
-
40
- $r = new Net_DNS2_Resolver([ 'nameservers' => $ns ]);
41
-
42
- $result = $r->query('google.com', 'MX');
43
-
44
- $this->assertSame($result->header->qr, Net_DNS2_Lookups::QR_RESPONSE);
45
- $this->assertSame(count($result->question), 1);
46
- $this->assertTrue(count($result->answer) > 0);
47
- $this->assertTrue($result->answer[0] instanceof Net_DNS2_RR_MX);
48
- }
49
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/siteground/siteground-i18n/src/i18n_Service.php CHANGED
@@ -20,15 +20,24 @@ class i18n_Service {
20
  */
21
  public $sg_textdomain;
22
 
 
 
 
 
 
 
 
23
  /**
24
  * Class construct.
25
  *
26
  * @since 1.0.0
27
  *
28
  * @param string $textdomain The text domain that will be used for the instance.
 
29
  */
30
- public function __construct( $textdomain ) {
31
  $this->sg_textdomain = $textdomain;
 
32
  }
33
 
34
  /**
@@ -40,7 +49,7 @@ class i18n_Service {
40
  load_plugin_textdomain(
41
  $this->sg_textdomain,
42
  false,
43
- $this->sg_textdomain . '/languages'
44
  );
45
  }
46
 
@@ -83,14 +92,14 @@ class i18n_Service {
83
  foreach ( $keys as $key ) {
84
  // Convert a PO file to Jed-compatible JSON.
85
  $json = $po_to_json
86
- ->withPoFile( WP_CONTENT_DIR . '/languages/plugins/' . $this->sg_textdomain . '-' . $extra['translations'][ $key ]['language'] . '.po' )
87
  ->toJedJson( false, $this->sg_textdomain );
88
 
89
  // Convert and get the json content.
90
  $content = json_decode( $json, true );
91
 
92
  // Build the json filepath.
93
- $json_filepath = WP_CONTENT_DIR . '/languages/plugins/' . $this->sg_textdomain . '-' . $extra['translations'][ $key ]['language'] . '.json';
94
 
95
  // Create the file if donesn't exists.
96
  if ( ! is_file( $json_filepath ) ) {
@@ -120,7 +129,7 @@ class i18n_Service {
120
  // Possible langugaes paths.
121
  $dirs = array(
122
  'wp-content/languages/plugins/',
123
- 'wp-content/plugins/' . $this->sg_textdomain . '/languages/json/',
124
  );
125
 
126
  foreach ( $dirs as $dir ) {
20
  */
21
  public $sg_textdomain;
22
 
23
+ /**
24
+ * Variable holding the plugin folder.
25
+ *
26
+ * @var string
27
+ */
28
+ public $folder;
29
+
30
  /**
31
  * Class construct.
32
  *
33
  * @since 1.0.0
34
  *
35
  * @param string $textdomain The text domain that will be used for the instance.
36
+ * @param string $folder The folder that will be used for the instance.
37
  */
38
+ public function __construct( $textdomain, $folder = '' ) {
39
  $this->sg_textdomain = $textdomain;
40
+ $this->folder = empty( $folder ) ? $textdomain : $folder;
41
  }
42
 
43
  /**
49
  load_plugin_textdomain(
50
  $this->sg_textdomain,
51
  false,
52
+ $this->folder . '/languages'
53
  );
54
  }
55
 
92
  foreach ( $keys as $key ) {
93
  // Convert a PO file to Jed-compatible JSON.
94
  $json = $po_to_json
95
+ ->withPoFile( WP_CONTENT_DIR . '/languages/plugins/' . $this->folder . '-' . $extra['translations'][ $key ]['language'] . '.po' )
96
  ->toJedJson( false, $this->sg_textdomain );
97
 
98
  // Convert and get the json content.
99
  $content = json_decode( $json, true );
100
 
101
  // Build the json filepath.
102
+ $json_filepath = WP_CONTENT_DIR . '/languages/plugins/' . $this->folder . '-' . $extra['translations'][ $key ]['language'] . '.json';
103
 
104
  // Create the file if donesn't exists.
105
  if ( ! is_file( $json_filepath ) ) {
129
  // Possible langugaes paths.
130
  $dirs = array(
131
  'wp-content/languages/plugins/',
132
+ 'wp-content/plugins/' . $this->folder . '/languages/json/',
133
  );
134
 
135
  foreach ( $dirs as $dir ) {