blob: ca54108824eac285d0e0a2a8df067f462c0d80cc [file] [log] [blame]
Eric Orth24feb5b2018-05-25 19:42:461# Copyright 2018 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
Yngve N. Pettersend5a75172018-07-09 06:36:563# found in the LICENSE file.
Eric Orth24feb5b2018-05-25 19:42:464
Eric Orth24feb5b2018-05-25 19:42:465import("//net/features.gni")
Max Morozf5eeca02018-12-01 18:43:306import("//testing/libfuzzer/fuzzer_test.gni")
Eric Orth24feb5b2018-05-25 19:42:467
Victor Vasilievc0110d72019-07-21 19:29:468enable_built_in_dns = !is_ios
Eric Orth24feb5b2018-05-25 19:42:469
10source_set("dns") {
11 # Due to circular dependencies, should only be depended on through //net.
Takuto Ikuta94330d9b2019-03-09 11:03:1412 visibility = [
13 "//net",
14 "//net/http:transport_security_state_generated_files",
15 ]
Eric Orth24feb5b2018-05-25 19:42:4616
17 # Internals only intended for use inside network stack (and tests).
18 friend = [
19 "//chrome/browser:test_support",
20 "//chrome/test/*",
21 "//components/certificate_transparency:unit_tests",
22 "//components/cronet/*",
23 "//net/*",
24 "//services/network/*",
25 ]
26
27 public = []
28 sources = [
29 "dns_util.cc",
30 "dns_util.h",
31 ]
32
33 if (!is_nacl) {
34 sources += [
Scott Sheehan135dadb2019-10-30 17:50:4735 "address_info.cc",
36 "address_info.h",
Eric Orth24feb5b2018-05-25 19:42:4637 "address_sorter.h",
38 "address_sorter_win.cc",
Eric Orth59066222019-03-07 23:52:2739 "context_host_resolver.cc",
40 "context_host_resolver.h",
Eric Orth6432c1a82018-10-02 15:10:2541 "dns_config.cc",
Eric Orthc1eb1292018-10-09 22:07:0742 "dns_config_overrides.cc",
Eric Orth24feb5b2018-05-25 19:42:4643 "dns_config_service.cc",
Eric Orth6432c1a82018-10-02 15:10:2544 "dns_config_service.h",
Eric Orth24feb5b2018-05-25 19:42:4645 "dns_config_service_win.cc",
46 "dns_config_service_win.h",
47 "dns_config_watcher_mac.cc",
48 "dns_config_watcher_mac.h",
49 "dns_hosts.cc",
50 "dns_hosts.h",
51 "dns_query.cc",
52 "dns_query.h",
53 "dns_reloader.cc",
54 "dns_reloader.h",
55 "dns_response.cc",
56 "dns_session.cc",
57 "dns_session.h",
58 "dns_socket_pool.cc",
59 "dns_socket_pool.h",
60 "dns_transaction.cc",
David Van Cleve6c3f6bb2019-10-17 21:06:5761 "esni_content.cc",
Eric Orth24feb5b2018-05-25 19:42:4662 "host_cache.cc",
63 "host_resolver.cc",
David Van Cleveb1f45bd2019-11-14 07:36:4964 "host_resolver_histograms.cc",
65 "host_resolver_histograms.h",
Eric Orth960e7062019-03-08 18:43:5466 "host_resolver_manager.cc",
Eric Orth026776a2019-01-18 00:13:2867 "host_resolver_mdns_listener_impl.cc",
68 "host_resolver_mdns_listener_impl.h",
Eric Orth9871aafa2018-10-02 19:59:1869 "host_resolver_mdns_task.cc",
70 "host_resolver_mdns_task.h",
Eric Orth24feb5b2018-05-25 19:42:4671 "host_resolver_proc.cc",
72 "host_resolver_proc.h",
Eric Orth24feb5b2018-05-25 19:42:4673 "mapped_host_resolver.cc",
74 "notify_watcher_mac.cc",
75 "notify_watcher_mac.h",
76 "record_parsed.cc",
77 "record_rdata.cc",
78 "serial_worker.cc",
79 "serial_worker.h",
Eric Orthde0c5662019-06-25 15:36:0280 "system_dns_config_change_notifier.cc",
81 "system_dns_config_change_notifier.h",
Eric Orth24feb5b2018-05-25 19:42:4682 ]
83
Sergey Ulanov4593ec92019-04-09 02:06:4484 if (is_fuchsia) {
85 sources += [
86 "dns_config_service_fuchsia.cc",
87 "dns_config_service_fuchsia.h",
88 ]
89 }
Eric Orth24feb5b2018-05-25 19:42:4690
Sergey Ulanov4593ec92019-04-09 02:06:4491 if (is_posix) {
92 sources += [
93 "dns_config_service_posix.cc",
94 "dns_config_service_posix.h",
95 ]
96 }
97
98 if (enable_built_in_dns) {
99 sources += [ "dns_client.cc" ]
100
101 if (is_posix || is_fuchsia) {
Eric Orth24feb5b2018-05-25 19:42:46102 sources += [
103 "address_sorter_posix.cc",
104 "address_sorter_posix.h",
105 ]
106 }
107 }
108
Eric Orth24feb5b2018-05-25 19:42:46109 if (enable_mdns) {
110 sources += [
111 "mdns_cache.cc",
112 "mdns_cache.h",
113 "mdns_client.cc",
114 "mdns_client_impl.cc",
115 "mdns_client_impl.h",
116 ]
117 }
118 }
119
120 deps = [
121 "//net:net_deps",
122 ]
123
124 public_deps = [
125 ":dns_client",
Eric Orth168a7e52018-08-27 19:11:32126 ":host_resolver",
Eric Orth0bea1662019-03-20 19:11:22127 ":host_resolver_manager",
Eric Orth24feb5b2018-05-25 19:42:46128 ":mdns_client",
Eric Orth24feb5b2018-05-25 19:42:46129 "//net:net_public_deps",
130 ]
131
132 allow_circular_includes_from = [
133 ":dns_client",
Eric Orth168a7e52018-08-27 19:11:32134 ":host_resolver",
Eric Orth0bea1662019-03-20 19:11:22135 ":host_resolver_manager",
Eric Orth24feb5b2018-05-25 19:42:46136 ":mdns_client",
Eric Orth24feb5b2018-05-25 19:42:46137 ]
138}
139
Eric Orth168a7e52018-08-27 19:11:32140# The standard API of net/dns.
141#
142# Should typically only be used within the network service. Usage external to
143# the network service should instead use network service Mojo IPCs for host
144# resolution. See ResolveHost() in
145# /services/network/public/mojom/network_context.mojom and
146# /services/network/public/mojom/host_resolver.mojom.
147source_set("host_resolver") {
Eric Orth24feb5b2018-05-25 19:42:46148 # Due to circular dependencies, should only be depended on through //net.
149 # Limit visibility to //net and other source_sets with the same access
150 # restriction.
151 visibility = [
152 ":dns",
dalykbd726ee2019-05-30 01:44:06153 ":dns_client",
Eric Orth0bea1662019-03-20 19:11:22154 ":host_resolver_manager",
Eric Orth24feb5b2018-05-25 19:42:46155 ":mdns_client",
156 "//net",
157 ]
158
Ryan Sleevia9d6aa62019-07-26 13:32:18159 # Restricted access so we can keep track of all usage external to the
Eric Orth168a7e52018-08-27 19:11:32160 # network stack and network service.
161 friend = [
Eric Orth168a7e52018-08-27 19:11:32162 # chromecast/browser/url_request_context_factory.cc
163 # URLRequestContext creation for chromecast.
164 "//chromecast/browser",
165
Eric Orth168a7e52018-08-27 19:11:32166 # URLRequestContext and HttpNetworkSession::Context creation for iOS.
167 "//ios/components/io_thread",
168 "//ios/web/shell",
169 "//ios/web_view:*",
170
171 # Tests and test support.
172 "//chrome/browser:test_support",
173 "//chrome/test:browser_tests",
Eric Orth1556c382018-11-08 06:05:02174 "//chrome/test:unit_tests",
Eric Orth168a7e52018-08-27 19:11:32175 "//components/grpc_support/test:unit_tests",
176 "//content/shell:content_shell_lib",
177
178 # Stand-alone tools.
Eric Orth168a7e52018-08-27 19:11:32179 "//google_apis/gcm:mcs_probe",
180
181 # Network stack/service.
182 "//components/certificate_transparency/*",
183 "//components/cronet/*",
184 "//net/*",
185 "//services/network/*",
Matt Menked60f16ec2018-11-07 20:18:26186
187 # The proxy resolution service uses its own host cache and HostResolver Mojo
188 # wrapper.
189 "//services/proxy_resolver/*",
Eric Orth168a7e52018-08-27 19:11:32190 ]
191
Eric Orth24feb5b2018-05-25 19:42:46192 sources = []
193 public = []
194
195 if (!is_nacl) {
Eric Orth168a7e52018-08-27 19:11:32196 sources += [
Eric Orth6432c1a82018-10-02 15:10:25197 "dns_config.h",
Eric Orthc1eb1292018-10-09 22:07:07198 "dns_config_overrides.h",
David Van Cleve6c3f6bb2019-10-17 21:06:57199 "esni_content.h",
Eric Orth24feb5b2018-05-25 19:42:46200 "host_cache.h",
201 "host_resolver.h",
Matt Menke92cc72f12019-10-25 01:11:11202 "host_resolver_source.h",
Eric Orth24feb5b2018-05-25 19:42:46203 "mapped_host_resolver.h",
204 ]
205 }
206
207 deps = [
208 "//net:net_deps",
Eric Orth192e3bb2018-11-14 19:30:32209 "//net/dns/public",
Eric Orth24feb5b2018-05-25 19:42:46210 ]
211 public_deps = [
212 "//net:net_public_deps",
213 ]
214}
215
Eric Orth0bea1662019-03-20 19:11:22216# Shared mostly-global handler of HostResolver requests.
217#
218# Typically should only be directly interacted with by NetworkService (or other
219# mostly-global creators of request contexts), standalone tools, and tests. Host
220# resolution should generally instead go through HostResolvers received from
221# URLRequestContext or network service Mojo IPCs.
222source_set("host_resolver_manager") {
223 # Due to circular dependencies, should only be depended on through //net.
224 # Limit visibility to //net and other source_sets with the same access
225 # restriction.
226 visibility = [
227 ":dns",
228 ":host_resolver",
229 "//net",
230 ]
231
Ryan Sleevia9d6aa62019-07-26 13:32:18232 # Restricted access so we can keep track of all usage external to the
Eric Orth0bea1662019-03-20 19:11:22233 # network stack and network service.
234 friend = [
Eric Orth89f8c0d2019-04-08 16:42:45235 # chromecast/browser/url_request_context_factory.cc
236 # URLRequestContext creation for chromecast.
237 "//chromecast/browser",
238
Eric Orth4e55b362019-05-07 22:00:03239 # Tests and test support.
240 "//components/cronet:cronet_common_unittests",
241
Eric Orth0bea1662019-03-20 19:11:22242 # Network stack/service.
243 "//net/*",
244 "//services/network/*",
245 ]
246
247 sources = []
248 public = []
249
250 if (!is_nacl) {
251 sources += [ "host_resolver_manager.h" ]
252 }
253
254 deps = [
255 ":host_resolver",
256 "//net:net_deps",
257 "//net/dns/public",
258 ]
259 public_deps = [
260 "//net:net_public_deps",
261 ]
262}
263
Eric Orth1556c382018-11-08 06:05:02264# DnsClient interfaces. Primarily intended as part of the implementation of the
Eric Orth24feb5b2018-05-25 19:42:46265# standard HostResolver interface, but can be used as an alternative external
266# interface for advanced usage.
Eric Orth24feb5b2018-05-25 19:42:46267source_set("dns_client") {
268 # Due to circular dependencies, should only be depended on through //net.
269 # Limit visibility to //net and other source_sets with the same access
270 # restriction.
271 visibility = [
272 ":dns",
273 ":mdns_client",
274 "//net",
275 ]
276
Ryan Sleevia9d6aa62019-07-26 13:32:18277 # Restricted access so we can keep track of all usage external to the
Eric Orth24feb5b2018-05-25 19:42:46278 # network stack.
279 friend = [
Eric Orth1556c382018-11-08 06:05:02280 # chrome/browser/local_discovery/service_discovery_client_impl.cc
281 # Result parsing utilities for parsing results read through MdnsClient.
282 # TODO(crbug.com/874662): Remove once migrated to network service.
Eric Orth24feb5b2018-05-25 19:42:46283 "//chrome/browser",
Eric Orth1556c382018-11-08 06:05:02284
285 # chrome/browser/chromeos/smb_client/discovery/mdns_host_locator.cc
286 # Result parsing for results read through MdnsClient.
287 # TODO(crbug.com/902531): Remove once migrated to network service.
Eric Orth24feb5b2018-05-25 19:42:46288 "//chrome/browser/chromeos",
Eric Orth1556c382018-11-08 06:05:02289
290 # Tests and test support
291 "//chrome/browser:test_support",
Eric Orth24feb5b2018-05-25 19:42:46292 "//chrome/test/*",
Eric Orth1556c382018-11-08 06:05:02293
294 # Network stack/service
Eric Orth24feb5b2018-05-25 19:42:46295 "//components/certificate_transparency/*",
296 "//net/*",
Eric Orth168a7e52018-08-27 19:11:32297 "//services/network/*",
Eric Orth24feb5b2018-05-25 19:42:46298 ]
299
300 sources = []
301 public = []
302
303 if (!is_nacl) {
304 sources += [
305 "dns_client.h",
306 "dns_response.h",
307 "dns_transaction.h",
308 "record_parsed.h",
309 "record_rdata.h",
310 ]
311 }
312
313 deps = [
dalykbd726ee2019-05-30 01:44:06314 ":host_resolver",
Eric Orth24feb5b2018-05-25 19:42:46315 "//net:net_deps",
316 ]
317 public_deps = [
318 "//net:net_public_deps",
Eric Orth8afaf152018-11-07 21:01:26319 "//net/dns/public",
Eric Orth24feb5b2018-05-25 19:42:46320 ]
321}
322
323# MdnsClient interfaces.
Eric Orth24feb5b2018-05-25 19:42:46324source_set("mdns_client") {
325 # Due to circular dependencies, should only be depended on through //net.
326 # Limit visibility to //net and other source_sets with the same access
327 # restriction.
328 visibility = [
329 ":dns",
330 "//net",
331 ]
332
Ryan Sleevia9d6aa62019-07-26 13:32:18333 # Restricted access so we can keep track of all usage external to the
Eric Orth24feb5b2018-05-25 19:42:46334 # network stack.
335 friend = [
Eric Orth1556c382018-11-08 06:05:02336 # chrome/browser/local_discovery/service_discovery_client_mdns.h
337 # chrome/browser/local_discovery/service_discovery_client_impl.h
338 # Makes MDNS queries using MDnsClient.
339 # TODO(crbug.com/874662): Remove once migrated to network service.
Eric Orth24feb5b2018-05-25 19:42:46340 "//chrome/browser",
Eric Orth1556c382018-11-08 06:05:02341
342 # chrome/tools/service_discovery_sniffer/service_discovery_sniffer.cc
343 # Creates MDnsClient instance and passes to ServiceDiscoveryClientImpl.
344 # TODO(crbug.com/874662): Remove once discovery client migrated.
Eric Orth24feb5b2018-05-25 19:42:46345 "//chrome/tools/service_discovery_sniffer",
Eric Orth1556c382018-11-08 06:05:02346
347 # chrome/browser/chromeos/smb_client/discovery/mdns_host_locator.h
348 # chrome/browser/chromeos/smb_client/discovery/mdns_host_locator.cc
349 # Makes MDNS queries using MDnsClient.
350 # TODO(crbug.com/902531): Remove once migrated to network service.
351 "//chrome/browser/chromeos",
352
353 # Tests and test support
354 "//chrome/browser:test_support",
355
356 # Network stack/service
Eric Orth24feb5b2018-05-25 19:42:46357 "//net/*",
Qingsi Wangc2213d5d2018-11-02 01:28:12358 "//services/network/*",
Eric Orth24feb5b2018-05-25 19:42:46359 ]
360
361 public = []
362 sources = []
363
364 if (!is_nacl && enable_mdns) {
365 sources += [ "mdns_client.h" ]
366 }
367
368 deps = [
369 ":dns_client",
Eric Orth168a7e52018-08-27 19:11:32370 ":host_resolver",
Eric Orth24feb5b2018-05-25 19:42:46371 "//net:net_deps",
372 ]
373 public_deps = [
374 "//net:net_public_deps",
375 ]
376}
377
Eric Orth24feb5b2018-05-25 19:42:46378source_set("tests") {
379 testonly = true
380 sources = [
Scott Sheehan135dadb2019-10-30 17:50:47381 "address_info_unittest.cc",
Eric Orth5233c3a2019-04-08 17:01:14382 "context_host_resolver_unittest.cc",
Eric Orth24feb5b2018-05-25 19:42:46383 "dns_config_service_unittest.cc",
384 "dns_config_service_win_unittest.cc",
385 "dns_hosts_unittest.cc",
386 "dns_query_unittest.cc",
387 "dns_response_unittest.cc",
388 "dns_session_unittest.cc",
389 "dns_socket_pool_unittest.cc",
390 "dns_transaction_unittest.cc",
391 "dns_util_unittest.cc",
David Van Cleve6c3f6bb2019-10-17 21:06:57392 "esni_content_unittest.cc",
Eric Orth24feb5b2018-05-25 19:42:46393 "host_cache_unittest.cc",
Eric Orth960e7062019-03-08 18:43:54394 "host_resolver_manager_unittest.cc",
Eric Orth24feb5b2018-05-25 19:42:46395 "mapped_host_resolver_unittest.cc",
396 "record_parsed_unittest.cc",
397 "record_rdata_unittest.cc",
398 "serial_worker_unittest.cc",
Eric Orthde0c5662019-06-25 15:36:02399 "system_dns_config_change_notifier_unittest.cc",
Eric Orth24feb5b2018-05-25 19:42:46400 ]
401
Sergey Ulanov4593ec92019-04-09 02:06:44402 if (is_posix) {
Eric Orth24feb5b2018-05-25 19:42:46403 sources += [ "dns_config_service_posix_unittest.cc" ]
404 }
405
406 if (enable_built_in_dns) {
Eric Orth394db1732019-08-27 20:09:39407 sources += [
408 "address_sorter_unittest.cc",
409 "dns_client_unittest.cc",
410 ]
Eric Orth24feb5b2018-05-25 19:42:46411 if (is_posix || is_fuchsia) {
412 sources += [ "address_sorter_posix_unittest.cc" ]
413 }
414 }
415
Eric Orth24feb5b2018-05-25 19:42:46416 if (enable_mdns) {
417 sources += [
418 "mdns_cache_unittest.cc",
419 "mdns_client_unittest.cc",
420 ]
421 }
422
423 deps = [
424 "//base",
425 "//net",
426 "//net:test_support",
427 "//testing/gmock",
428 "//testing/gtest",
429 ]
Eric Orth24feb5b2018-05-25 19:42:46430}
431
432source_set("test_support") {
433 testonly = true
434 sources = [
Scott Sheehan135dadb2019-10-30 17:50:47435 "address_info_test_util.cc",
Eric Orth24feb5b2018-05-25 19:42:46436 "dns_test_util.cc",
437 "mock_host_resolver.cc",
Eric Orthde0c5662019-06-25 15:36:02438 "test_dns_config_service.cc",
Eric Orth24feb5b2018-05-25 19:42:46439 ]
440 public = [
Scott Sheehan135dadb2019-10-30 17:50:47441 "address_info_test_util.h",
Eric Orth24feb5b2018-05-25 19:42:46442 "dns_test_util.h",
443 "mock_host_resolver.h",
Eric Orthde0c5662019-06-25 15:36:02444 "test_dns_config_service.h",
Eric Orth24feb5b2018-05-25 19:42:46445 ]
446
447 if (enable_mdns) {
Eric Orth9871aafa2018-10-02 19:59:18448 sources += [
449 "mock_mdns_client.cc",
450 "mock_mdns_socket_factory.cc",
451 ]
452 public += [
453 "mock_mdns_client.h",
454 "mock_mdns_socket_factory.h",
455 ]
Eric Orth24feb5b2018-05-25 19:42:46456 }
457
458 deps = [
459 "//base",
460 "//net",
461 "//testing/gmock",
462 "//testing/gtest",
463 ]
464}
465
Max Morozc3dc6fc2019-08-29 20:04:28466if (use_fuzzing_engine) {
467 # fuzzer_test targets are no-op when |use_fuzzing_engine| is false. Fuzzer
468 # support targets should be disabled too.
469 source_set("fuzzer_test_support") {
470 testonly = true
471 sources = [
472 "fuzzed_host_resolver_util.cc",
473 "fuzzed_host_resolver_util.h",
474 ]
475 deps = [
476 "//base",
477 "//base/test:test_support",
478 "//net",
479 ]
480 }
Eric Orth24feb5b2018-05-25 19:42:46481}
482
483fuzzer_test("net_dns_hosts_parse_fuzzer") {
484 sources = [
485 "dns_hosts_parse_fuzzer.cc",
486 ]
487 deps = [
488 "//base",
489 "//net",
490 "//net:net_fuzzer_test_support",
491 ]
492 dict = "//net/data/fuzzer_dictionaries/net_dns_hosts_parse_fuzzer.dict"
493}
494
495fuzzer_test("net_dns_record_fuzzer") {
496 sources = [
497 "dns_record_fuzzer.cc",
498 ]
499 deps = [
500 "//base",
501 "//net",
502 "//net:net_fuzzer_test_support",
503 ]
504 dict = "//net/data/fuzzer_dictionaries/net_dns_record_fuzzer.dict"
505}
506
Qingsi Wangecd69252018-09-27 21:35:55507fuzzer_test("net_dns_query_parse_fuzzer") {
508 sources = [
509 "dns_query_parse_fuzzer.cc",
510 ]
511 deps = [
512 "//base",
513 "//net",
514 "//net:net_fuzzer_test_support",
515 ]
516 dict = "//net/data/fuzzer_dictionaries/net_dns_record_fuzzer.dict"
517}
518
Qingsi Wang65841072018-10-09 01:14:45519fuzzer_test("net_dns_response_fuzzer") {
520 sources = [
521 "dns_response_fuzzer.cc",
522 ]
523 deps = [
524 "//base",
525 "//net",
526 "//net:net_fuzzer_test_support",
527 ]
528 dict = "//net/data/fuzzer_dictionaries/net_dns_record_fuzzer.dict"
529}
530
Eric Orth960e7062019-03-08 18:43:54531fuzzer_test("net_host_resolver_manager_fuzzer") {
Eric Orth24feb5b2018-05-25 19:42:46532 sources = [
Eric Orth960e7062019-03-08 18:43:54533 "host_resolver_manager_fuzzer.cc",
Eric Orth24feb5b2018-05-25 19:42:46534 ]
535 deps = [
536 "//base",
537 "//net",
538 "//net:net_fuzzer_test_support",
539 "//net:test_support",
540 ]
Eric Orth960e7062019-03-08 18:43:54541 dict = "//net/data/fuzzer_dictionaries/net_host_resolver_manager_fuzzer.dict"
Eric Orth24feb5b2018-05-25 19:42:46542}
Max Morozf5eeca02018-12-01 18:43:30543
544if (is_win) {
545 fuzzer_test("net_dns_parse_domain_ascii_win_fuzzer") {
546 sources = [
547 "dns_parse_domain_ascii_win_fuzzer.cc",
548 ]
549 deps = [
550 "//base",
551 "//net",
552 "//net:net_fuzzer_test_support",
553 ]
Max Morozcd52e3f2019-10-10 20:04:47554 dict = "//net/data/fuzzer_dictionaries/net_dns_hosts_parse_fuzzer.dict"
555 seed_corpus = "//net/data/fuzzer_data/dns_parse_domain_ascii_win_fuzzer"
Max Morozf5eeca02018-12-01 18:43:30556 }
557}