blob: d0410ac984933c5ca68f69e0b887a2b81d8cf5c8 [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
5import("//testing/libfuzzer/fuzzer_test.gni")
6import("//net/features.gni")
7
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.
12 visibility = [ "//net" ]
13
14 # Internals only intended for use inside network stack (and tests).
15 friend = [
16 "//chrome/browser:test_support",
17 "//chrome/test/*",
18 "//components/certificate_transparency:unit_tests",
19 "//components/cronet/*",
20 "//net/*",
21 "//services/network/*",
22 ]
23
24 public = []
25 sources = [
26 "dns_util.cc",
27 "dns_util.h",
28 ]
29
30 if (!is_nacl) {
31 sources += [
32 "address_sorter.h",
33 "address_sorter_win.cc",
34 "dns_config_service.cc",
35 "dns_config_service_win.cc",
36 "dns_config_service_win.h",
37 "dns_config_watcher_mac.cc",
38 "dns_config_watcher_mac.h",
39 "dns_hosts.cc",
40 "dns_hosts.h",
41 "dns_query.cc",
42 "dns_query.h",
43 "dns_reloader.cc",
44 "dns_reloader.h",
45 "dns_response.cc",
46 "dns_session.cc",
47 "dns_session.h",
48 "dns_socket_pool.cc",
49 "dns_socket_pool.h",
50 "dns_transaction.cc",
51 "host_cache.cc",
52 "host_resolver.cc",
53 "host_resolver_impl.cc",
54 "host_resolver_proc.cc",
55 "host_resolver_proc.h",
Eric Orthdc35748e2018-08-23 22:41:4856 "host_resolver_source.h",
Eric Orth24feb5b2018-05-25 19:42:4657 "mapped_host_resolver.cc",
58 "notify_watcher_mac.cc",
59 "notify_watcher_mac.h",
60 "record_parsed.cc",
61 "record_rdata.cc",
62 "serial_worker.cc",
63 "serial_worker.h",
64 ]
65
66 if (is_posix || is_fuchsia) {
67 sources += [ "dns_config_service_posix.cc" ]
68
69 if (enable_built_in_dns) {
70 sources += [
71 "address_sorter_posix.cc",
72 "address_sorter_posix.h",
73 ]
74 }
75 }
76
77 if (enable_built_in_dns) {
78 sources += [ "dns_client.cc" ]
79 }
80
81 if (enable_mdns) {
82 sources += [
83 "mdns_cache.cc",
84 "mdns_cache.h",
85 "mdns_client.cc",
86 "mdns_client_impl.cc",
87 "mdns_client_impl.h",
88 ]
89 }
90 }
91
92 deps = [
93 "//net:net_deps",
94 ]
95
96 public_deps = [
97 ":dns_client",
Eric Orth168a7e52018-08-27 19:11:3298 ":host_resolver",
Eric Orth24feb5b2018-05-25 19:42:4699 ":host_resolver_impl",
100 ":mdns_client",
Eric Orth24feb5b2018-05-25 19:42:46101 "//net:net_public_deps",
102 ]
103
104 allow_circular_includes_from = [
105 ":dns_client",
Eric Orth168a7e52018-08-27 19:11:32106 ":host_resolver",
Eric Orth24feb5b2018-05-25 19:42:46107 ":host_resolver_impl",
108 ":mdns_client",
Eric Orth24feb5b2018-05-25 19:42:46109 ]
110}
111
Eric Orth168a7e52018-08-27 19:11:32112# The standard API of net/dns.
113#
114# Should typically only be used within the network service. Usage external to
115# the network service should instead use network service Mojo IPCs for host
116# resolution. See ResolveHost() in
117# /services/network/public/mojom/network_context.mojom and
118# /services/network/public/mojom/host_resolver.mojom.
119source_set("host_resolver") {
Eric Orth24feb5b2018-05-25 19:42:46120 # Due to circular dependencies, should only be depended on through //net.
121 # Limit visibility to //net and other source_sets with the same access
122 # restriction.
123 visibility = [
124 ":dns",
Eric Orth24feb5b2018-05-25 19:42:46125 ":host_resolver_impl",
126 ":mdns_client",
127 "//net",
128 ]
129
Eric Orth168a7e52018-08-27 19:11:32130 # Whitelist-only access so we can keep track of all usage external to the
131 # network stack and network service.
132 friend = [
133 # chrome/browser/devtools/device/tcp_device_provider.cc
134 # TODO(crbug.com/874653): Remove once migrated to network service IPC.
135 #
136 # chrome/browser/devtools/device/port_forwarding_controller.cc
137 # TODO(crbug.com/874651): Remove once migrated to network service IPC.
138 "//chrome/browser/devtools",
139
140 # chrome/browser/io_thread.cc
141 # Used to build in-process HostResolver when network service disabled.
142 #
143 # chrome/browser/net/dns_probe_service.cc
144 # TODO(crbug.com/874660): Remove once migrated to network service IPC.
145 #
146 # chrome/browser/net/url_info.h
147 # chrome/browser/net_benchmarking.cc
148 # HostResolver only used for deprecated net::Predictor.
149 # TODO(crbug.com/875238): Remove once deprecated code is removed.
150 "//chrome/browser",
151
152 # chrome/browser/ui/webui/net_internals/net_internals_ui.cc
153 # TODO(crbug.com/876110): Remove once migrated to network service IPC.
154 "//chrome/browser/ui",
155
156 # chromecast/browser/url_request_context_factory.cc
157 # URLRequestContext creation for chromecast.
158 "//chromecast/browser",
159
160 # components/network_hints/browser/network_hints_message_filter.cc
161 # TODO(crbug.com/874654): Remove once migrated to network service IPC.
162 "//components/network_hints/browser",
163
164 # content/public/browser/resource_hints.h
165 # Deprecated and soon to be removed.
166 # TODO(crbug.com/875238): Remove once code is removed.
167 "//content/public/browser:browser_sources",
168
169 # headless/lib/browser/headless_url_request_context_getter.cc
170 # URLRequestContext creation for headless.
171 "//headless",
172
173 # URLRequestContext and HttpNetworkSession::Context creation for iOS.
174 "//ios/components/io_thread",
175 "//ios/web/shell",
176 "//ios/web_view:*",
177
178 # Tests and test support.
179 "//chrome/browser:test_support",
180 "//chrome/test:browser_tests",
181 "//components/grpc_support/test:unit_tests",
182 "//content/shell:content_shell_lib",
183
184 # Stand-alone tools.
185 "//components/sync/tools:*",
186 "//google_apis/gcm:mcs_probe",
187
188 # Network stack/service.
189 "//components/certificate_transparency/*",
190 "//components/cronet/*",
191 "//net/*",
192 "//services/network/*",
193 ]
194
Eric Orth24feb5b2018-05-25 19:42:46195 sources = []
196 public = []
197
198 if (!is_nacl) {
Eric Orth168a7e52018-08-27 19:11:32199 sources += [
Eric Orth24feb5b2018-05-25 19:42:46200 "dns_config_service.h",
Eric Orth24feb5b2018-05-25 19:42:46201 "host_cache.h",
202 "host_resolver.h",
203 "mapped_host_resolver.h",
204 ]
205 }
206
207 deps = [
208 "//net:net_deps",
209 ]
210 public_deps = [
211 "//net:net_public_deps",
212 ]
213}
214
215# Overridable implementation details of HostResolver.
216# TODO(crbug.com/846423): Servicify or remove external usage.
217source_set("host_resolver_impl") {
218 # Due to circular dependencies, should only be depended on through //net.
219 # Limit visibility to //net and other source_sets with the same access
220 # restriction.
221 visibility = [
222 ":dns",
Eric Orth24feb5b2018-05-25 19:42:46223 "//net",
224 ]
225
226 # Whitelist-only access so we can keep track of all usage external to the
227 # network stack.
228 friend = [
229 "//chromeos",
230 "//components/cronet/*",
231 "//net/*",
232 ]
233
234 sources = []
235 public = []
236
237 if (!is_nacl) {
238 sources += [ "host_resolver_impl.h" ]
239
240 if (is_posix || is_fuchsia) {
241 sources += [ "dns_config_service_posix.h" ]
242 }
243 }
244
245 deps = [
Eric Orth168a7e52018-08-27 19:11:32246 ":host_resolver",
Eric Orth24feb5b2018-05-25 19:42:46247 "//net:net_deps",
248 ]
249 public_deps = [
250 "//net:net_public_deps",
251 ]
252}
253
254# DnsClient interfaces. Primarily intended as part of the impelementation of the
255# standard HostResolver interface, but can be used as an alternative external
256# interface for advanced usage.
257# TODO(crbug.com/846423): Figure out what we want to do with these for
258# servicification.
259source_set("dns_client") {
260 # Due to circular dependencies, should only be depended on through //net.
261 # Limit visibility to //net and other source_sets with the same access
262 # restriction.
263 visibility = [
264 ":dns",
265 ":mdns_client",
266 "//net",
267 ]
268
269 # Whitelist-only access so we can keep track of all usage external to the
270 # network stack.
271 friend = [
272 "//chrome/browser",
273 "//chrome/browser:test_support",
274 "//chrome/browser/chromeos",
275 "//chrome/test/*",
276 "//components/certificate_transparency/*",
277 "//net/*",
Eric Orth168a7e52018-08-27 19:11:32278 "//services/network/*",
Eric Orth24feb5b2018-05-25 19:42:46279 ]
280
281 sources = []
282 public = []
283
284 if (!is_nacl) {
285 sources += [
286 "dns_client.h",
Eric Orth168a7e52018-08-27 19:11:32287 "dns_protocol.h",
Eric Orth24feb5b2018-05-25 19:42:46288 "dns_response.h",
289 "dns_transaction.h",
290 "record_parsed.h",
291 "record_rdata.h",
292 ]
293 }
294
295 deps = [
Eric Orth24feb5b2018-05-25 19:42:46296 "//net:net_deps",
297 ]
298 public_deps = [
299 "//net:net_public_deps",
300 ]
301}
302
303# MdnsClient interfaces.
304# TODO(crbug.com/846423): Figure out what we want to do with these for
305# servicification.
306source_set("mdns_client") {
307 # Due to circular dependencies, should only be depended on through //net.
308 # Limit visibility to //net and other source_sets with the same access
309 # restriction.
310 visibility = [
311 ":dns",
312 "//net",
313 ]
314
315 # Whitelist-only access so we can keep track of all usage external to the
316 # network stack.
317 friend = [
318 "//chrome/browser",
319 "//chrome/browser:test_support",
320 "//chrome/browser/chromeos",
321 "//chrome/tools/service_discovery_sniffer",
322 "//net/*",
323 ]
324
325 public = []
326 sources = []
327
328 if (!is_nacl && enable_mdns) {
329 sources += [ "mdns_client.h" ]
330 }
331
332 deps = [
333 ":dns_client",
Eric Orth168a7e52018-08-27 19:11:32334 ":host_resolver",
Eric Orth24feb5b2018-05-25 19:42:46335 "//net:net_deps",
336 ]
337 public_deps = [
338 "//net:net_public_deps",
339 ]
340}
341
342if (enable_net_mojo) {
343 # A host resolver implementation that forwards resolve requests to a mojo
344 # service, thus acting as a client library to a servicified host resolver.
345 # TODO(crbug.com/821021): Decide if this has any place in the generalized
346 # host resolver servicification.
347 source_set("mojo_client") {
348 sources = [
349 "host_resolver_mojo.cc",
350 "host_resolver_mojo.h",
351 ]
352
353 deps = [
354 "//base",
355 "//net",
356 "//net:net_with_v8",
357 ]
358
359 public_deps = [
360 "//mojo/public/cpp/bindings",
361 "//net/interfaces",
362 ]
363 }
364
365 # A utility to handle host resolver requests coming into the network service
366 # via mojo and pass the requests on to the actual host resolver. This utility
367 # therefore acts as the service side of mojo interactions for host resolver.
368 # TODO(crbug.com/821021): Decide if this has any place in the generalized
369 # host resolver servicification.
370 source_set("mojo_service") {
371 sources = [
372 "mojo_host_resolver_impl.cc",
373 "mojo_host_resolver_impl.h",
374 ]
375
376 deps = [
377 "//base",
378 "//net",
379 ]
380
381 public_deps = [
382 "//mojo/public/cpp/bindings",
383 "//net/interfaces",
384 ]
385 }
386}
387
388source_set("tests") {
389 testonly = true
390 sources = [
391 "dns_config_service_unittest.cc",
392 "dns_config_service_win_unittest.cc",
393 "dns_hosts_unittest.cc",
394 "dns_query_unittest.cc",
395 "dns_response_unittest.cc",
396 "dns_session_unittest.cc",
397 "dns_socket_pool_unittest.cc",
398 "dns_transaction_unittest.cc",
399 "dns_util_unittest.cc",
400 "host_cache_unittest.cc",
401 "host_resolver_impl_unittest.cc",
402 "mapped_host_resolver_unittest.cc",
403 "record_parsed_unittest.cc",
404 "record_rdata_unittest.cc",
405 "serial_worker_unittest.cc",
406 ]
407
408 if (is_posix || is_fuchsia) {
409 sources += [ "dns_config_service_posix_unittest.cc" ]
410 }
411
412 if (enable_built_in_dns) {
413 sources += [ "address_sorter_unittest.cc" ]
414 if (is_posix || is_fuchsia) {
415 sources += [ "address_sorter_posix_unittest.cc" ]
416 }
417 }
418
419 if (enable_net_mojo) {
420 sources += [
421 "host_resolver_mojo_unittest.cc",
422 "mojo_host_resolver_impl_unittest.cc",
423 ]
424 }
425
426 if (enable_mdns) {
427 sources += [
428 "mdns_cache_unittest.cc",
429 "mdns_client_unittest.cc",
430 ]
431 }
432
433 deps = [
434 "//base",
435 "//net",
436 "//net:test_support",
437 "//testing/gmock",
438 "//testing/gtest",
439 ]
440
441 if (enable_net_mojo) {
442 deps += [
443 "//net/dns:mojo_client",
444 "//net/dns:mojo_service",
445 ]
446 }
447}
448
449source_set("test_support") {
450 testonly = true
451 sources = [
452 "dns_test_util.cc",
453 "mock_host_resolver.cc",
454 ]
455 public = [
456 "dns_test_util.h",
457 "mock_host_resolver.h",
458 ]
459
460 if (enable_mdns) {
461 sources += [ "mock_mdns_socket_factory.cc" ]
462 public += [ "mock_mdns_socket_factory.h" ]
463 }
464
465 deps = [
466 "//base",
467 "//net",
468 "//testing/gmock",
469 "//testing/gtest",
470 ]
471}
472
473source_set("fuzzer_test_support") {
474 testonly = true
475 sources = [
476 "fuzzed_host_resolver.cc",
477 "fuzzed_host_resolver.h",
478 ]
479 deps = [
480 "//base",
481 "//base/test:test_support",
482 "//net",
483 ]
484}
485
486fuzzer_test("net_dns_hosts_parse_fuzzer") {
487 sources = [
488 "dns_hosts_parse_fuzzer.cc",
489 ]
490 deps = [
491 "//base",
492 "//net",
493 "//net:net_fuzzer_test_support",
494 ]
495 dict = "//net/data/fuzzer_dictionaries/net_dns_hosts_parse_fuzzer.dict"
496}
497
498fuzzer_test("net_dns_record_fuzzer") {
499 sources = [
500 "dns_record_fuzzer.cc",
501 ]
502 deps = [
503 "//base",
504 "//net",
505 "//net:net_fuzzer_test_support",
506 ]
507 dict = "//net/data/fuzzer_dictionaries/net_dns_record_fuzzer.dict"
508}
509
510fuzzer_test("net_host_resolver_impl_fuzzer") {
511 sources = [
512 "host_resolver_impl_fuzzer.cc",
513 ]
514 deps = [
515 "//base",
516 "//net",
517 "//net:net_fuzzer_test_support",
518 "//net:test_support",
519 ]
520 dict = "//net/data/fuzzer_dictionaries/net_host_resolver_impl_fuzzer.dict"
521}