blob: cbd40daa28d0e53e01e6c14116495a3d96680a4b [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
8enable_built_in_dns = !is_ios && !is_proto_quic
9
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 += [
35 "address_sorter.h",
36 "address_sorter_win.cc",
Eric Orth59066222019-03-07 23:52:2737 "context_host_resolver.cc",
38 "context_host_resolver.h",
Eric Orth6432c1a82018-10-02 15:10:2539 "dns_config.cc",
Eric Orthc1eb1292018-10-09 22:07:0740 "dns_config_overrides.cc",
Eric Orth24feb5b2018-05-25 19:42:4641 "dns_config_service.cc",
Eric Orth6432c1a82018-10-02 15:10:2542 "dns_config_service.h",
Eric Orth24feb5b2018-05-25 19:42:4643 "dns_config_service_win.cc",
44 "dns_config_service_win.h",
45 "dns_config_watcher_mac.cc",
46 "dns_config_watcher_mac.h",
47 "dns_hosts.cc",
48 "dns_hosts.h",
49 "dns_query.cc",
50 "dns_query.h",
51 "dns_reloader.cc",
52 "dns_reloader.h",
53 "dns_response.cc",
54 "dns_session.cc",
55 "dns_session.h",
56 "dns_socket_pool.cc",
57 "dns_socket_pool.h",
58 "dns_transaction.cc",
59 "host_cache.cc",
60 "host_resolver.cc",
Eric Orth960e7062019-03-08 18:43:5461 "host_resolver_manager.cc",
Eric Orth026776a2019-01-18 00:13:2862 "host_resolver_mdns_listener_impl.cc",
63 "host_resolver_mdns_listener_impl.h",
Eric Orth9871aafa2018-10-02 19:59:1864 "host_resolver_mdns_task.cc",
65 "host_resolver_mdns_task.h",
Eric Orth24feb5b2018-05-25 19:42:4666 "host_resolver_proc.cc",
67 "host_resolver_proc.h",
Eric Orthdc35748e2018-08-23 22:41:4868 "host_resolver_source.h",
Eric Orth24feb5b2018-05-25 19:42:4669 "mapped_host_resolver.cc",
70 "notify_watcher_mac.cc",
71 "notify_watcher_mac.h",
72 "record_parsed.cc",
73 "record_rdata.cc",
74 "serial_worker.cc",
75 "serial_worker.h",
Eric Orthde0c5662019-06-25 15:36:0276 "system_dns_config_change_notifier.cc",
77 "system_dns_config_change_notifier.h",
Eric Orth24feb5b2018-05-25 19:42:4678 ]
79
Sergey Ulanov4593ec92019-04-09 02:06:4480 if (is_fuchsia) {
81 sources += [
82 "dns_config_service_fuchsia.cc",
83 "dns_config_service_fuchsia.h",
84 ]
85 }
Eric Orth24feb5b2018-05-25 19:42:4686
Sergey Ulanov4593ec92019-04-09 02:06:4487 if (is_posix) {
88 sources += [
89 "dns_config_service_posix.cc",
90 "dns_config_service_posix.h",
91 ]
92 }
93
94 if (enable_built_in_dns) {
95 sources += [ "dns_client.cc" ]
96
97 if (is_posix || is_fuchsia) {
Eric Orth24feb5b2018-05-25 19:42:4698 sources += [
99 "address_sorter_posix.cc",
100 "address_sorter_posix.h",
101 ]
102 }
103 }
104
Eric Orth24feb5b2018-05-25 19:42:46105 if (enable_mdns) {
106 sources += [
107 "mdns_cache.cc",
108 "mdns_cache.h",
109 "mdns_client.cc",
110 "mdns_client_impl.cc",
111 "mdns_client_impl.h",
112 ]
113 }
114 }
115
116 deps = [
117 "//net:net_deps",
118 ]
119
120 public_deps = [
121 ":dns_client",
Eric Orth168a7e52018-08-27 19:11:32122 ":host_resolver",
Eric Orth0bea1662019-03-20 19:11:22123 ":host_resolver_manager",
Eric Orth24feb5b2018-05-25 19:42:46124 ":mdns_client",
Eric Orth24feb5b2018-05-25 19:42:46125 "//net:net_public_deps",
126 ]
127
128 allow_circular_includes_from = [
129 ":dns_client",
Eric Orth168a7e52018-08-27 19:11:32130 ":host_resolver",
Eric Orth0bea1662019-03-20 19:11:22131 ":host_resolver_manager",
Eric Orth24feb5b2018-05-25 19:42:46132 ":mdns_client",
Eric Orth24feb5b2018-05-25 19:42:46133 ]
134}
135
Eric Orth168a7e52018-08-27 19:11:32136# The standard API of net/dns.
137#
138# Should typically only be used within the network service. Usage external to
139# the network service should instead use network service Mojo IPCs for host
140# resolution. See ResolveHost() in
141# /services/network/public/mojom/network_context.mojom and
142# /services/network/public/mojom/host_resolver.mojom.
143source_set("host_resolver") {
Eric Orth24feb5b2018-05-25 19:42:46144 # Due to circular dependencies, should only be depended on through //net.
145 # Limit visibility to //net and other source_sets with the same access
146 # restriction.
147 visibility = [
148 ":dns",
dalykbd726ee2019-05-30 01:44:06149 ":dns_client",
Eric Orth0bea1662019-03-20 19:11:22150 ":host_resolver_manager",
Eric Orth24feb5b2018-05-25 19:42:46151 ":mdns_client",
152 "//net",
153 ]
154
Eric Orth168a7e52018-08-27 19:11:32155 # Whitelist-only access so we can keep track of all usage external to the
156 # network stack and network service.
157 friend = [
Eric Orth168a7e52018-08-27 19:11:32158 # chromecast/browser/url_request_context_factory.cc
159 # URLRequestContext creation for chromecast.
160 "//chromecast/browser",
161
Eric Orth168a7e52018-08-27 19:11:32162 # URLRequestContext and HttpNetworkSession::Context creation for iOS.
163 "//ios/components/io_thread",
164 "//ios/web/shell",
165 "//ios/web_view:*",
166
167 # Tests and test support.
168 "//chrome/browser:test_support",
169 "//chrome/test:browser_tests",
Eric Orth1556c382018-11-08 06:05:02170 "//chrome/test:unit_tests",
Eric Orth168a7e52018-08-27 19:11:32171 "//components/grpc_support/test:unit_tests",
172 "//content/shell:content_shell_lib",
173
174 # Stand-alone tools.
Eric Orth168a7e52018-08-27 19:11:32175 "//google_apis/gcm:mcs_probe",
176
177 # Network stack/service.
178 "//components/certificate_transparency/*",
179 "//components/cronet/*",
180 "//net/*",
181 "//services/network/*",
Matt Menked60f16ec2018-11-07 20:18:26182
183 # The proxy resolution service uses its own host cache and HostResolver Mojo
184 # wrapper.
185 "//services/proxy_resolver/*",
Eric Orth168a7e52018-08-27 19:11:32186 ]
187
Eric Orth24feb5b2018-05-25 19:42:46188 sources = []
189 public = []
190
191 if (!is_nacl) {
Eric Orth168a7e52018-08-27 19:11:32192 sources += [
Eric Orth6432c1a82018-10-02 15:10:25193 "dns_config.h",
Eric Orthc1eb1292018-10-09 22:07:07194 "dns_config_overrides.h",
Eric Orth24feb5b2018-05-25 19:42:46195 "host_cache.h",
196 "host_resolver.h",
197 "mapped_host_resolver.h",
198 ]
199 }
200
201 deps = [
202 "//net:net_deps",
Eric Orth192e3bb2018-11-14 19:30:32203 "//net/dns/public",
Eric Orth24feb5b2018-05-25 19:42:46204 ]
205 public_deps = [
206 "//net:net_public_deps",
207 ]
208}
209
Eric Orth0bea1662019-03-20 19:11:22210# Shared mostly-global handler of HostResolver requests.
211#
212# Typically should only be directly interacted with by NetworkService (or other
213# mostly-global creators of request contexts), standalone tools, and tests. Host
214# resolution should generally instead go through HostResolvers received from
215# URLRequestContext or network service Mojo IPCs.
216source_set("host_resolver_manager") {
217 # Due to circular dependencies, should only be depended on through //net.
218 # Limit visibility to //net and other source_sets with the same access
219 # restriction.
220 visibility = [
221 ":dns",
222 ":host_resolver",
223 "//net",
224 ]
225
226 # Whitelist-only access so we can keep track of all usage external to the
227 # network stack and network service.
228 friend = [
Eric Orth89f8c0d2019-04-08 16:42:45229 # chromecast/browser/url_request_context_factory.cc
230 # URLRequestContext creation for chromecast.
231 "//chromecast/browser",
232
Eric Orth4e55b362019-05-07 22:00:03233 # Tests and test support.
234 "//components/cronet:cronet_common_unittests",
235
Eric Orth0bea1662019-03-20 19:11:22236 # Network stack/service.
237 "//net/*",
238 "//services/network/*",
239 ]
240
241 sources = []
242 public = []
243
244 if (!is_nacl) {
245 sources += [ "host_resolver_manager.h" ]
246 }
247
248 deps = [
249 ":host_resolver",
250 "//net:net_deps",
251 "//net/dns/public",
252 ]
253 public_deps = [
254 "//net:net_public_deps",
255 ]
256}
257
Eric Orth1556c382018-11-08 06:05:02258# DnsClient interfaces. Primarily intended as part of the implementation of the
Eric Orth24feb5b2018-05-25 19:42:46259# standard HostResolver interface, but can be used as an alternative external
260# interface for advanced usage.
Eric Orth24feb5b2018-05-25 19:42:46261source_set("dns_client") {
262 # Due to circular dependencies, should only be depended on through //net.
263 # Limit visibility to //net and other source_sets with the same access
264 # restriction.
265 visibility = [
266 ":dns",
267 ":mdns_client",
268 "//net",
269 ]
270
271 # Whitelist-only access so we can keep track of all usage external to the
272 # network stack.
273 friend = [
Eric Orth1556c382018-11-08 06:05:02274 # chrome/browser/local_discovery/service_discovery_client_impl.cc
275 # Result parsing utilities for parsing results read through MdnsClient.
276 # TODO(crbug.com/874662): Remove once migrated to network service.
Eric Orth24feb5b2018-05-25 19:42:46277 "//chrome/browser",
Eric Orth1556c382018-11-08 06:05:02278
279 # chrome/browser/chromeos/smb_client/discovery/mdns_host_locator.cc
280 # Result parsing for results read through MdnsClient.
281 # TODO(crbug.com/902531): Remove once migrated to network service.
Eric Orth24feb5b2018-05-25 19:42:46282 "//chrome/browser/chromeos",
Eric Orth1556c382018-11-08 06:05:02283
284 # Tests and test support
285 "//chrome/browser:test_support",
Eric Orth24feb5b2018-05-25 19:42:46286 "//chrome/test/*",
Eric Orth1556c382018-11-08 06:05:02287
288 # Network stack/service
Eric Orth24feb5b2018-05-25 19:42:46289 "//components/certificate_transparency/*",
290 "//net/*",
Eric Orth168a7e52018-08-27 19:11:32291 "//services/network/*",
Eric Orth24feb5b2018-05-25 19:42:46292 ]
293
294 sources = []
295 public = []
296
297 if (!is_nacl) {
298 sources += [
299 "dns_client.h",
300 "dns_response.h",
301 "dns_transaction.h",
302 "record_parsed.h",
303 "record_rdata.h",
304 ]
305 }
306
307 deps = [
dalykbd726ee2019-05-30 01:44:06308 ":host_resolver",
Eric Orth24feb5b2018-05-25 19:42:46309 "//net:net_deps",
310 ]
311 public_deps = [
312 "//net:net_public_deps",
Eric Orth8afaf152018-11-07 21:01:26313 "//net/dns/public",
Eric Orth24feb5b2018-05-25 19:42:46314 ]
315}
316
317# MdnsClient interfaces.
Eric Orth24feb5b2018-05-25 19:42:46318source_set("mdns_client") {
319 # Due to circular dependencies, should only be depended on through //net.
320 # Limit visibility to //net and other source_sets with the same access
321 # restriction.
322 visibility = [
323 ":dns",
324 "//net",
325 ]
326
327 # Whitelist-only access so we can keep track of all usage external to the
328 # network stack.
329 friend = [
Eric Orth1556c382018-11-08 06:05:02330 # chrome/browser/local_discovery/service_discovery_client_mdns.h
331 # chrome/browser/local_discovery/service_discovery_client_impl.h
332 # Makes MDNS queries using MDnsClient.
333 # TODO(crbug.com/874662): Remove once migrated to network service.
Eric Orth24feb5b2018-05-25 19:42:46334 "//chrome/browser",
Eric Orth1556c382018-11-08 06:05:02335
336 # chrome/tools/service_discovery_sniffer/service_discovery_sniffer.cc
337 # Creates MDnsClient instance and passes to ServiceDiscoveryClientImpl.
338 # TODO(crbug.com/874662): Remove once discovery client migrated.
Eric Orth24feb5b2018-05-25 19:42:46339 "//chrome/tools/service_discovery_sniffer",
Eric Orth1556c382018-11-08 06:05:02340
341 # chrome/browser/chromeos/smb_client/discovery/mdns_host_locator.h
342 # chrome/browser/chromeos/smb_client/discovery/mdns_host_locator.cc
343 # Makes MDNS queries using MDnsClient.
344 # TODO(crbug.com/902531): Remove once migrated to network service.
345 "//chrome/browser/chromeos",
346
347 # Tests and test support
348 "//chrome/browser:test_support",
349
350 # Network stack/service
Eric Orth24feb5b2018-05-25 19:42:46351 "//net/*",
Qingsi Wangc2213d5d2018-11-02 01:28:12352 "//services/network/*",
Eric Orth24feb5b2018-05-25 19:42:46353 ]
354
355 public = []
356 sources = []
357
358 if (!is_nacl && enable_mdns) {
359 sources += [ "mdns_client.h" ]
360 }
361
362 deps = [
363 ":dns_client",
Eric Orth168a7e52018-08-27 19:11:32364 ":host_resolver",
Eric Orth24feb5b2018-05-25 19:42:46365 "//net:net_deps",
366 ]
367 public_deps = [
368 "//net:net_public_deps",
369 ]
370}
371
Eric Orth24feb5b2018-05-25 19:42:46372source_set("tests") {
373 testonly = true
374 sources = [
Eric Orth5233c3a2019-04-08 17:01:14375 "context_host_resolver_unittest.cc",
Eric Orth24feb5b2018-05-25 19:42:46376 "dns_config_service_unittest.cc",
377 "dns_config_service_win_unittest.cc",
378 "dns_hosts_unittest.cc",
379 "dns_query_unittest.cc",
380 "dns_response_unittest.cc",
381 "dns_session_unittest.cc",
382 "dns_socket_pool_unittest.cc",
383 "dns_transaction_unittest.cc",
384 "dns_util_unittest.cc",
385 "host_cache_unittest.cc",
Eric Orth960e7062019-03-08 18:43:54386 "host_resolver_manager_unittest.cc",
Eric Orth24feb5b2018-05-25 19:42:46387 "mapped_host_resolver_unittest.cc",
388 "record_parsed_unittest.cc",
389 "record_rdata_unittest.cc",
390 "serial_worker_unittest.cc",
Eric Orthde0c5662019-06-25 15:36:02391 "system_dns_config_change_notifier_unittest.cc",
Eric Orth24feb5b2018-05-25 19:42:46392 ]
393
Sergey Ulanov4593ec92019-04-09 02:06:44394 if (is_posix) {
Eric Orth24feb5b2018-05-25 19:42:46395 sources += [ "dns_config_service_posix_unittest.cc" ]
396 }
397
398 if (enable_built_in_dns) {
399 sources += [ "address_sorter_unittest.cc" ]
400 if (is_posix || is_fuchsia) {
401 sources += [ "address_sorter_posix_unittest.cc" ]
402 }
403 }
404
Eric Orth24feb5b2018-05-25 19:42:46405 if (enable_mdns) {
406 sources += [
407 "mdns_cache_unittest.cc",
408 "mdns_client_unittest.cc",
409 ]
410 }
411
412 deps = [
413 "//base",
414 "//net",
415 "//net:test_support",
416 "//testing/gmock",
417 "//testing/gtest",
418 ]
Eric Orth24feb5b2018-05-25 19:42:46419}
420
421source_set("test_support") {
422 testonly = true
423 sources = [
424 "dns_test_util.cc",
425 "mock_host_resolver.cc",
Eric Orthde0c5662019-06-25 15:36:02426 "test_dns_config_service.cc",
Eric Orth24feb5b2018-05-25 19:42:46427 ]
428 public = [
429 "dns_test_util.h",
430 "mock_host_resolver.h",
Eric Orthde0c5662019-06-25 15:36:02431 "test_dns_config_service.h",
Eric Orth24feb5b2018-05-25 19:42:46432 ]
433
434 if (enable_mdns) {
Eric Orth9871aafa2018-10-02 19:59:18435 sources += [
436 "mock_mdns_client.cc",
437 "mock_mdns_socket_factory.cc",
438 ]
439 public += [
440 "mock_mdns_client.h",
441 "mock_mdns_socket_factory.h",
442 ]
Eric Orth24feb5b2018-05-25 19:42:46443 }
444
445 deps = [
446 "//base",
447 "//net",
448 "//testing/gmock",
449 "//testing/gtest",
450 ]
451}
452
453source_set("fuzzer_test_support") {
454 testonly = true
455 sources = [
Eric Orth4e55b362019-05-07 22:00:03456 "fuzzed_host_resolver_util.cc",
457 "fuzzed_host_resolver_util.h",
Eric Orth24feb5b2018-05-25 19:42:46458 ]
459 deps = [
460 "//base",
461 "//base/test:test_support",
462 "//net",
463 ]
464}
465
466fuzzer_test("net_dns_hosts_parse_fuzzer") {
467 sources = [
468 "dns_hosts_parse_fuzzer.cc",
469 ]
470 deps = [
471 "//base",
472 "//net",
473 "//net:net_fuzzer_test_support",
474 ]
475 dict = "//net/data/fuzzer_dictionaries/net_dns_hosts_parse_fuzzer.dict"
476}
477
478fuzzer_test("net_dns_record_fuzzer") {
479 sources = [
480 "dns_record_fuzzer.cc",
481 ]
482 deps = [
483 "//base",
484 "//net",
485 "//net:net_fuzzer_test_support",
486 ]
487 dict = "//net/data/fuzzer_dictionaries/net_dns_record_fuzzer.dict"
488}
489
Qingsi Wangecd69252018-09-27 21:35:55490fuzzer_test("net_dns_query_parse_fuzzer") {
491 sources = [
492 "dns_query_parse_fuzzer.cc",
493 ]
494 deps = [
495 "//base",
496 "//net",
497 "//net:net_fuzzer_test_support",
498 ]
499 dict = "//net/data/fuzzer_dictionaries/net_dns_record_fuzzer.dict"
500}
501
Qingsi Wang65841072018-10-09 01:14:45502fuzzer_test("net_dns_response_fuzzer") {
503 sources = [
504 "dns_response_fuzzer.cc",
505 ]
506 deps = [
507 "//base",
508 "//net",
509 "//net:net_fuzzer_test_support",
510 ]
511 dict = "//net/data/fuzzer_dictionaries/net_dns_record_fuzzer.dict"
512}
513
Eric Orth960e7062019-03-08 18:43:54514fuzzer_test("net_host_resolver_manager_fuzzer") {
Eric Orth24feb5b2018-05-25 19:42:46515 sources = [
Eric Orth960e7062019-03-08 18:43:54516 "host_resolver_manager_fuzzer.cc",
Eric Orth24feb5b2018-05-25 19:42:46517 ]
518 deps = [
519 "//base",
520 "//net",
521 "//net:net_fuzzer_test_support",
522 "//net:test_support",
523 ]
Eric Orth960e7062019-03-08 18:43:54524 dict = "//net/data/fuzzer_dictionaries/net_host_resolver_manager_fuzzer.dict"
Eric Orth24feb5b2018-05-25 19:42:46525}
Max Morozf5eeca02018-12-01 18:43:30526
527if (is_win) {
528 fuzzer_test("net_dns_parse_domain_ascii_win_fuzzer") {
529 sources = [
530 "dns_parse_domain_ascii_win_fuzzer.cc",
531 ]
532 deps = [
533 "//base",
534 "//net",
535 "//net:net_fuzzer_test_support",
536 ]
537 }
538}