blob: 71764bc4bf22391a11c188f0c49204609a9c0c8a [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",
76 ]
77
Sergey Ulanov4593ec92019-04-09 02:06:4478 if (is_fuchsia) {
79 sources += [
80 "dns_config_service_fuchsia.cc",
81 "dns_config_service_fuchsia.h",
82 ]
83 }
Eric Orth24feb5b2018-05-25 19:42:4684
Sergey Ulanov4593ec92019-04-09 02:06:4485 if (is_posix) {
86 sources += [
87 "dns_config_service_posix.cc",
88 "dns_config_service_posix.h",
89 ]
90 }
91
92 if (enable_built_in_dns) {
93 sources += [ "dns_client.cc" ]
94
95 if (is_posix || is_fuchsia) {
Eric Orth24feb5b2018-05-25 19:42:4696 sources += [
97 "address_sorter_posix.cc",
98 "address_sorter_posix.h",
99 ]
100 }
101 }
102
Eric Orth24feb5b2018-05-25 19:42:46103 if (enable_mdns) {
104 sources += [
105 "mdns_cache.cc",
106 "mdns_cache.h",
107 "mdns_client.cc",
108 "mdns_client_impl.cc",
109 "mdns_client_impl.h",
110 ]
111 }
112 }
113
114 deps = [
115 "//net:net_deps",
116 ]
117
118 public_deps = [
119 ":dns_client",
Eric Orth168a7e52018-08-27 19:11:32120 ":host_resolver",
Eric Orth0bea1662019-03-20 19:11:22121 ":host_resolver_manager",
Eric Orth24feb5b2018-05-25 19:42:46122 ":mdns_client",
Eric Orth24feb5b2018-05-25 19:42:46123 "//net:net_public_deps",
124 ]
125
126 allow_circular_includes_from = [
127 ":dns_client",
Eric Orth168a7e52018-08-27 19:11:32128 ":host_resolver",
Eric Orth0bea1662019-03-20 19:11:22129 ":host_resolver_manager",
Eric Orth24feb5b2018-05-25 19:42:46130 ":mdns_client",
Eric Orth24feb5b2018-05-25 19:42:46131 ]
132}
133
Eric Orth168a7e52018-08-27 19:11:32134# The standard API of net/dns.
135#
136# Should typically only be used within the network service. Usage external to
137# the network service should instead use network service Mojo IPCs for host
138# resolution. See ResolveHost() in
139# /services/network/public/mojom/network_context.mojom and
140# /services/network/public/mojom/host_resolver.mojom.
141source_set("host_resolver") {
Eric Orth24feb5b2018-05-25 19:42:46142 # Due to circular dependencies, should only be depended on through //net.
143 # Limit visibility to //net and other source_sets with the same access
144 # restriction.
145 visibility = [
146 ":dns",
Eric Orth0bea1662019-03-20 19:11:22147 ":host_resolver_manager",
Eric Orth24feb5b2018-05-25 19:42:46148 ":mdns_client",
149 "//net",
150 ]
151
Eric Orth168a7e52018-08-27 19:11:32152 # Whitelist-only access so we can keep track of all usage external to the
153 # network stack and network service.
154 friend = [
Eric Orth168a7e52018-08-27 19:11:32155 # chromecast/browser/url_request_context_factory.cc
156 # URLRequestContext creation for chromecast.
157 "//chromecast/browser",
158
Eric Orth168a7e52018-08-27 19:11:32159 # URLRequestContext and HttpNetworkSession::Context creation for iOS.
160 "//ios/components/io_thread",
161 "//ios/web/shell",
162 "//ios/web_view:*",
163
164 # Tests and test support.
165 "//chrome/browser:test_support",
166 "//chrome/test:browser_tests",
Eric Orth1556c382018-11-08 06:05:02167 "//chrome/test:unit_tests",
Eric Orth168a7e52018-08-27 19:11:32168 "//components/grpc_support/test:unit_tests",
169 "//content/shell:content_shell_lib",
170
171 # Stand-alone tools.
Eric Orth168a7e52018-08-27 19:11:32172 "//google_apis/gcm:mcs_probe",
173
174 # Network stack/service.
175 "//components/certificate_transparency/*",
176 "//components/cronet/*",
177 "//net/*",
178 "//services/network/*",
Matt Menked60f16ec2018-11-07 20:18:26179
180 # The proxy resolution service uses its own host cache and HostResolver Mojo
181 # wrapper.
182 "//services/proxy_resolver/*",
Eric Orth168a7e52018-08-27 19:11:32183 ]
184
Eric Orth24feb5b2018-05-25 19:42:46185 sources = []
186 public = []
187
188 if (!is_nacl) {
Eric Orth168a7e52018-08-27 19:11:32189 sources += [
Eric Orth6432c1a82018-10-02 15:10:25190 "dns_config.h",
Eric Orthc1eb1292018-10-09 22:07:07191 "dns_config_overrides.h",
Eric Orth24feb5b2018-05-25 19:42:46192 "host_cache.h",
193 "host_resolver.h",
194 "mapped_host_resolver.h",
195 ]
196 }
197
198 deps = [
199 "//net:net_deps",
Eric Orth192e3bb2018-11-14 19:30:32200 "//net/dns/public",
Eric Orth24feb5b2018-05-25 19:42:46201 ]
202 public_deps = [
203 "//net:net_public_deps",
204 ]
205}
206
Eric Orth0bea1662019-03-20 19:11:22207# Shared mostly-global handler of HostResolver requests.
208#
209# Typically should only be directly interacted with by NetworkService (or other
210# mostly-global creators of request contexts), standalone tools, and tests. Host
211# resolution should generally instead go through HostResolvers received from
212# URLRequestContext or network service Mojo IPCs.
213source_set("host_resolver_manager") {
214 # Due to circular dependencies, should only be depended on through //net.
215 # Limit visibility to //net and other source_sets with the same access
216 # restriction.
217 visibility = [
218 ":dns",
219 ":host_resolver",
220 "//net",
221 ]
222
223 # Whitelist-only access so we can keep track of all usage external to the
224 # network stack and network service.
225 friend = [
Eric Orth89f8c0d2019-04-08 16:42:45226 # chromecast/browser/url_request_context_factory.cc
227 # URLRequestContext creation for chromecast.
228 "//chromecast/browser",
229
Eric Orth4e55b362019-05-07 22:00:03230 # Tests and test support.
231 "//components/cronet:cronet_common_unittests",
232
Eric Orth0bea1662019-03-20 19:11:22233 # Network stack/service.
234 "//net/*",
235 "//services/network/*",
236 ]
237
238 sources = []
239 public = []
240
241 if (!is_nacl) {
242 sources += [ "host_resolver_manager.h" ]
243 }
244
245 deps = [
246 ":host_resolver",
247 "//net:net_deps",
248 "//net/dns/public",
249 ]
250 public_deps = [
251 "//net:net_public_deps",
252 ]
253}
254
Eric Orth1556c382018-11-08 06:05:02255# DnsClient interfaces. Primarily intended as part of the implementation of the
Eric Orth24feb5b2018-05-25 19:42:46256# standard HostResolver interface, but can be used as an alternative external
257# interface for advanced usage.
Eric Orth24feb5b2018-05-25 19:42:46258source_set("dns_client") {
259 # Due to circular dependencies, should only be depended on through //net.
260 # Limit visibility to //net and other source_sets with the same access
261 # restriction.
262 visibility = [
263 ":dns",
264 ":mdns_client",
265 "//net",
266 ]
267
268 # Whitelist-only access so we can keep track of all usage external to the
269 # network stack.
270 friend = [
Eric Orth1556c382018-11-08 06:05:02271 # chrome/browser/local_discovery/service_discovery_client_impl.cc
272 # Result parsing utilities for parsing results read through MdnsClient.
273 # TODO(crbug.com/874662): Remove once migrated to network service.
Eric Orth24feb5b2018-05-25 19:42:46274 "//chrome/browser",
Eric Orth1556c382018-11-08 06:05:02275
276 # chrome/browser/chromeos/smb_client/discovery/mdns_host_locator.cc
277 # Result parsing for results read through MdnsClient.
278 # TODO(crbug.com/902531): Remove once migrated to network service.
Eric Orth24feb5b2018-05-25 19:42:46279 "//chrome/browser/chromeos",
Eric Orth1556c382018-11-08 06:05:02280
281 # Tests and test support
282 "//chrome/browser:test_support",
Eric Orth24feb5b2018-05-25 19:42:46283 "//chrome/test/*",
Eric Orth1556c382018-11-08 06:05:02284
285 # Network stack/service
Eric Orth24feb5b2018-05-25 19:42:46286 "//components/certificate_transparency/*",
287 "//net/*",
Eric Orth168a7e52018-08-27 19:11:32288 "//services/network/*",
Eric Orth24feb5b2018-05-25 19:42:46289 ]
290
291 sources = []
292 public = []
293
294 if (!is_nacl) {
295 sources += [
296 "dns_client.h",
297 "dns_response.h",
298 "dns_transaction.h",
dalykc7bed522019-02-13 17:50:04299 "dns_util.h",
Eric Orth24feb5b2018-05-25 19:42:46300 "record_parsed.h",
301 "record_rdata.h",
302 ]
303 }
304
305 deps = [
Eric Orth24feb5b2018-05-25 19:42:46306 "//net:net_deps",
307 ]
308 public_deps = [
309 "//net:net_public_deps",
Eric Orth8afaf152018-11-07 21:01:26310 "//net/dns/public",
Eric Orth24feb5b2018-05-25 19:42:46311 ]
312}
313
314# MdnsClient interfaces.
Eric Orth24feb5b2018-05-25 19:42:46315source_set("mdns_client") {
316 # Due to circular dependencies, should only be depended on through //net.
317 # Limit visibility to //net and other source_sets with the same access
318 # restriction.
319 visibility = [
320 ":dns",
321 "//net",
322 ]
323
324 # Whitelist-only access so we can keep track of all usage external to the
325 # network stack.
326 friend = [
Eric Orth1556c382018-11-08 06:05:02327 # chrome/browser/local_discovery/service_discovery_client_mdns.h
328 # chrome/browser/local_discovery/service_discovery_client_impl.h
329 # Makes MDNS queries using MDnsClient.
330 # TODO(crbug.com/874662): Remove once migrated to network service.
Eric Orth24feb5b2018-05-25 19:42:46331 "//chrome/browser",
Eric Orth1556c382018-11-08 06:05:02332
333 # chrome/tools/service_discovery_sniffer/service_discovery_sniffer.cc
334 # Creates MDnsClient instance and passes to ServiceDiscoveryClientImpl.
335 # TODO(crbug.com/874662): Remove once discovery client migrated.
Eric Orth24feb5b2018-05-25 19:42:46336 "//chrome/tools/service_discovery_sniffer",
Eric Orth1556c382018-11-08 06:05:02337
338 # chrome/browser/chromeos/smb_client/discovery/mdns_host_locator.h
339 # chrome/browser/chromeos/smb_client/discovery/mdns_host_locator.cc
340 # Makes MDNS queries using MDnsClient.
341 # TODO(crbug.com/902531): Remove once migrated to network service.
342 "//chrome/browser/chromeos",
343
344 # Tests and test support
345 "//chrome/browser:test_support",
346
347 # Network stack/service
Eric Orth24feb5b2018-05-25 19:42:46348 "//net/*",
Qingsi Wangc2213d5d2018-11-02 01:28:12349 "//services/network/*",
Eric Orth24feb5b2018-05-25 19:42:46350 ]
351
352 public = []
353 sources = []
354
355 if (!is_nacl && enable_mdns) {
356 sources += [ "mdns_client.h" ]
357 }
358
359 deps = [
360 ":dns_client",
Eric Orth168a7e52018-08-27 19:11:32361 ":host_resolver",
Eric Orth24feb5b2018-05-25 19:42:46362 "//net:net_deps",
363 ]
364 public_deps = [
365 "//net:net_public_deps",
366 ]
367}
368
Eric Orth24feb5b2018-05-25 19:42:46369source_set("tests") {
370 testonly = true
371 sources = [
Eric Orth5233c3a2019-04-08 17:01:14372 "context_host_resolver_unittest.cc",
Eric Orth24feb5b2018-05-25 19:42:46373 "dns_config_service_unittest.cc",
374 "dns_config_service_win_unittest.cc",
375 "dns_hosts_unittest.cc",
376 "dns_query_unittest.cc",
377 "dns_response_unittest.cc",
378 "dns_session_unittest.cc",
379 "dns_socket_pool_unittest.cc",
380 "dns_transaction_unittest.cc",
381 "dns_util_unittest.cc",
382 "host_cache_unittest.cc",
Eric Orth960e7062019-03-08 18:43:54383 "host_resolver_manager_unittest.cc",
Eric Orth24feb5b2018-05-25 19:42:46384 "mapped_host_resolver_unittest.cc",
385 "record_parsed_unittest.cc",
386 "record_rdata_unittest.cc",
387 "serial_worker_unittest.cc",
388 ]
389
Sergey Ulanov4593ec92019-04-09 02:06:44390 if (is_posix) {
Eric Orth24feb5b2018-05-25 19:42:46391 sources += [ "dns_config_service_posix_unittest.cc" ]
392 }
393
394 if (enable_built_in_dns) {
395 sources += [ "address_sorter_unittest.cc" ]
396 if (is_posix || is_fuchsia) {
397 sources += [ "address_sorter_posix_unittest.cc" ]
398 }
399 }
400
Eric Orth24feb5b2018-05-25 19:42:46401 if (enable_mdns) {
402 sources += [
403 "mdns_cache_unittest.cc",
404 "mdns_client_unittest.cc",
405 ]
406 }
407
408 deps = [
409 "//base",
410 "//net",
411 "//net:test_support",
412 "//testing/gmock",
413 "//testing/gtest",
414 ]
Eric Orth24feb5b2018-05-25 19:42:46415}
416
417source_set("test_support") {
418 testonly = true
419 sources = [
420 "dns_test_util.cc",
421 "mock_host_resolver.cc",
422 ]
423 public = [
424 "dns_test_util.h",
425 "mock_host_resolver.h",
426 ]
427
428 if (enable_mdns) {
Eric Orth9871aafa2018-10-02 19:59:18429 sources += [
430 "mock_mdns_client.cc",
431 "mock_mdns_socket_factory.cc",
432 ]
433 public += [
434 "mock_mdns_client.h",
435 "mock_mdns_socket_factory.h",
436 ]
Eric Orth24feb5b2018-05-25 19:42:46437 }
438
439 deps = [
440 "//base",
441 "//net",
442 "//testing/gmock",
443 "//testing/gtest",
444 ]
445}
446
447source_set("fuzzer_test_support") {
448 testonly = true
449 sources = [
Eric Orth4e55b362019-05-07 22:00:03450 "fuzzed_host_resolver_util.cc",
451 "fuzzed_host_resolver_util.h",
Eric Orth24feb5b2018-05-25 19:42:46452 ]
453 deps = [
454 "//base",
455 "//base/test:test_support",
456 "//net",
457 ]
458}
459
460fuzzer_test("net_dns_hosts_parse_fuzzer") {
461 sources = [
462 "dns_hosts_parse_fuzzer.cc",
463 ]
464 deps = [
465 "//base",
466 "//net",
467 "//net:net_fuzzer_test_support",
468 ]
469 dict = "//net/data/fuzzer_dictionaries/net_dns_hosts_parse_fuzzer.dict"
470}
471
472fuzzer_test("net_dns_record_fuzzer") {
473 sources = [
474 "dns_record_fuzzer.cc",
475 ]
476 deps = [
477 "//base",
478 "//net",
479 "//net:net_fuzzer_test_support",
480 ]
481 dict = "//net/data/fuzzer_dictionaries/net_dns_record_fuzzer.dict"
482}
483
Qingsi Wangecd69252018-09-27 21:35:55484fuzzer_test("net_dns_query_parse_fuzzer") {
485 sources = [
486 "dns_query_parse_fuzzer.cc",
487 ]
488 deps = [
489 "//base",
490 "//net",
491 "//net:net_fuzzer_test_support",
492 ]
493 dict = "//net/data/fuzzer_dictionaries/net_dns_record_fuzzer.dict"
494}
495
Qingsi Wang65841072018-10-09 01:14:45496fuzzer_test("net_dns_response_fuzzer") {
497 sources = [
498 "dns_response_fuzzer.cc",
499 ]
500 deps = [
501 "//base",
502 "//net",
503 "//net:net_fuzzer_test_support",
504 ]
505 dict = "//net/data/fuzzer_dictionaries/net_dns_record_fuzzer.dict"
506}
507
Eric Orth960e7062019-03-08 18:43:54508fuzzer_test("net_host_resolver_manager_fuzzer") {
Eric Orth24feb5b2018-05-25 19:42:46509 sources = [
Eric Orth960e7062019-03-08 18:43:54510 "host_resolver_manager_fuzzer.cc",
Eric Orth24feb5b2018-05-25 19:42:46511 ]
512 deps = [
513 "//base",
514 "//net",
515 "//net:net_fuzzer_test_support",
516 "//net:test_support",
517 ]
Eric Orth960e7062019-03-08 18:43:54518 dict = "//net/data/fuzzer_dictionaries/net_host_resolver_manager_fuzzer.dict"
Eric Orth24feb5b2018-05-25 19:42:46519}
Max Morozf5eeca02018-12-01 18:43:30520
521if (is_win) {
522 fuzzer_test("net_dns_parse_domain_ascii_win_fuzzer") {
523 sources = [
524 "dns_parse_domain_ascii_win_fuzzer.cc",
525 ]
526 deps = [
527 "//base",
528 "//net",
529 "//net:net_fuzzer_test_support",
530 ]
531 }
532}