blob: f5c369d0797fb1bfa5b1a932c27260c19d233190 [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",
98 ":host_resolver_impl",
99 ":mdns_client",
100 ":public",
101 "//net:net_public_deps",
102 ]
103
104 allow_circular_includes_from = [
105 ":dns_client",
106 ":host_resolver_impl",
107 ":mdns_client",
108 ":public",
109 ]
110}
111
112# The standard public API of net/dns. Available for use both inside and outside
113# the network stack by any code that needs it.
114# TODO(crbug.com/821021): Servicify and convert all non-constant external usage
115# to IPCs.
116source_set("public") {
117 # Due to circular dependencies, should only be depended on through //net.
118 # Limit visibility to //net and other source_sets with the same access
119 # restriction.
120 visibility = [
121 ":dns",
122 ":dns_client",
123 ":host_resolver_impl",
124 ":mdns_client",
125 "//net",
126 ]
127
128 sources = []
129 public = []
130
131 if (!is_nacl) {
132 public += [
133 "dns_config_service.h",
134 "dns_protocol.h",
135 "host_cache.h",
136 "host_resolver.h",
137 "mapped_host_resolver.h",
138 ]
139 }
140
141 deps = [
142 "//net:net_deps",
143 ]
144 public_deps = [
145 "//net:net_public_deps",
146 ]
147}
148
149# Overridable implementation details of HostResolver.
150# TODO(crbug.com/846423): Servicify or remove external usage.
151source_set("host_resolver_impl") {
152 # Due to circular dependencies, should only be depended on through //net.
153 # Limit visibility to //net and other source_sets with the same access
154 # restriction.
155 visibility = [
156 ":dns",
157 ":public",
158 "//net",
159 ]
160
161 # Whitelist-only access so we can keep track of all usage external to the
162 # network stack.
163 friend = [
164 "//chromeos",
165 "//components/cronet/*",
166 "//net/*",
167 ]
168
169 sources = []
170 public = []
171
172 if (!is_nacl) {
173 sources += [ "host_resolver_impl.h" ]
174
175 if (is_posix || is_fuchsia) {
176 sources += [ "dns_config_service_posix.h" ]
177 }
178 }
179
180 deps = [
181 ":public",
182 "//net:net_deps",
183 ]
184 public_deps = [
185 "//net:net_public_deps",
186 ]
187}
188
189# DnsClient interfaces. Primarily intended as part of the impelementation of the
190# standard HostResolver interface, but can be used as an alternative external
191# interface for advanced usage.
192# TODO(crbug.com/846423): Figure out what we want to do with these for
193# servicification.
194source_set("dns_client") {
195 # Due to circular dependencies, should only be depended on through //net.
196 # Limit visibility to //net and other source_sets with the same access
197 # restriction.
198 visibility = [
199 ":dns",
200 ":mdns_client",
201 "//net",
202 ]
203
204 # Whitelist-only access so we can keep track of all usage external to the
205 # network stack.
206 friend = [
207 "//chrome/browser",
208 "//chrome/browser:test_support",
209 "//chrome/browser/chromeos",
210 "//chrome/test/*",
211 "//components/certificate_transparency/*",
212 "//net/*",
213 ]
214
215 sources = []
216 public = []
217
218 if (!is_nacl) {
219 sources += [
220 "dns_client.h",
221 "dns_response.h",
222 "dns_transaction.h",
223 "record_parsed.h",
224 "record_rdata.h",
225 ]
226 }
227
228 deps = [
229 ":public",
230 "//net:net_deps",
231 ]
232 public_deps = [
233 "//net:net_public_deps",
234 ]
235}
236
237# MdnsClient interfaces.
238# TODO(crbug.com/846423): Figure out what we want to do with these for
239# servicification.
240source_set("mdns_client") {
241 # Due to circular dependencies, should only be depended on through //net.
242 # Limit visibility to //net and other source_sets with the same access
243 # restriction.
244 visibility = [
245 ":dns",
246 "//net",
247 ]
248
249 # Whitelist-only access so we can keep track of all usage external to the
250 # network stack.
251 friend = [
252 "//chrome/browser",
253 "//chrome/browser:test_support",
254 "//chrome/browser/chromeos",
255 "//chrome/tools/service_discovery_sniffer",
256 "//net/*",
257 ]
258
259 public = []
260 sources = []
261
262 if (!is_nacl && enable_mdns) {
263 sources += [ "mdns_client.h" ]
264 }
265
266 deps = [
267 ":dns_client",
268 ":public",
269 "//net:net_deps",
270 ]
271 public_deps = [
272 "//net:net_public_deps",
273 ]
274}
275
276if (enable_net_mojo) {
277 # A host resolver implementation that forwards resolve requests to a mojo
278 # service, thus acting as a client library to a servicified host resolver.
279 # TODO(crbug.com/821021): Decide if this has any place in the generalized
280 # host resolver servicification.
281 source_set("mojo_client") {
282 sources = [
283 "host_resolver_mojo.cc",
284 "host_resolver_mojo.h",
285 ]
286
287 deps = [
288 "//base",
289 "//net",
290 "//net:net_with_v8",
291 ]
292
293 public_deps = [
294 "//mojo/public/cpp/bindings",
295 "//net/interfaces",
296 ]
297 }
298
299 # A utility to handle host resolver requests coming into the network service
300 # via mojo and pass the requests on to the actual host resolver. This utility
301 # therefore acts as the service side of mojo interactions for host resolver.
302 # TODO(crbug.com/821021): Decide if this has any place in the generalized
303 # host resolver servicification.
304 source_set("mojo_service") {
305 sources = [
306 "mojo_host_resolver_impl.cc",
307 "mojo_host_resolver_impl.h",
308 ]
309
310 deps = [
311 "//base",
312 "//net",
313 ]
314
315 public_deps = [
316 "//mojo/public/cpp/bindings",
317 "//net/interfaces",
318 ]
319 }
320}
321
322source_set("tests") {
323 testonly = true
324 sources = [
325 "dns_config_service_unittest.cc",
326 "dns_config_service_win_unittest.cc",
327 "dns_hosts_unittest.cc",
328 "dns_query_unittest.cc",
329 "dns_response_unittest.cc",
330 "dns_session_unittest.cc",
331 "dns_socket_pool_unittest.cc",
332 "dns_transaction_unittest.cc",
333 "dns_util_unittest.cc",
334 "host_cache_unittest.cc",
335 "host_resolver_impl_unittest.cc",
336 "mapped_host_resolver_unittest.cc",
337 "record_parsed_unittest.cc",
338 "record_rdata_unittest.cc",
339 "serial_worker_unittest.cc",
340 ]
341
342 if (is_posix || is_fuchsia) {
343 sources += [ "dns_config_service_posix_unittest.cc" ]
344 }
345
346 if (enable_built_in_dns) {
347 sources += [ "address_sorter_unittest.cc" ]
348 if (is_posix || is_fuchsia) {
349 sources += [ "address_sorter_posix_unittest.cc" ]
350 }
351 }
352
353 if (enable_net_mojo) {
354 sources += [
355 "host_resolver_mojo_unittest.cc",
356 "mojo_host_resolver_impl_unittest.cc",
357 ]
358 }
359
360 if (enable_mdns) {
361 sources += [
362 "mdns_cache_unittest.cc",
363 "mdns_client_unittest.cc",
364 ]
365 }
366
367 deps = [
368 "//base",
369 "//net",
370 "//net:test_support",
371 "//testing/gmock",
372 "//testing/gtest",
373 ]
374
375 if (enable_net_mojo) {
376 deps += [
377 "//net/dns:mojo_client",
378 "//net/dns:mojo_service",
379 ]
380 }
381}
382
383source_set("test_support") {
384 testonly = true
385 sources = [
386 "dns_test_util.cc",
387 "mock_host_resolver.cc",
388 ]
389 public = [
390 "dns_test_util.h",
391 "mock_host_resolver.h",
392 ]
393
394 if (enable_mdns) {
395 sources += [ "mock_mdns_socket_factory.cc" ]
396 public += [ "mock_mdns_socket_factory.h" ]
397 }
398
399 deps = [
400 "//base",
401 "//net",
402 "//testing/gmock",
403 "//testing/gtest",
404 ]
405}
406
407source_set("fuzzer_test_support") {
408 testonly = true
409 sources = [
410 "fuzzed_host_resolver.cc",
411 "fuzzed_host_resolver.h",
412 ]
413 deps = [
414 "//base",
415 "//base/test:test_support",
416 "//net",
417 ]
418}
419
420fuzzer_test("net_dns_hosts_parse_fuzzer") {
421 sources = [
422 "dns_hosts_parse_fuzzer.cc",
423 ]
424 deps = [
425 "//base",
426 "//net",
427 "//net:net_fuzzer_test_support",
428 ]
429 dict = "//net/data/fuzzer_dictionaries/net_dns_hosts_parse_fuzzer.dict"
430}
431
432fuzzer_test("net_dns_record_fuzzer") {
433 sources = [
434 "dns_record_fuzzer.cc",
435 ]
436 deps = [
437 "//base",
438 "//net",
439 "//net:net_fuzzer_test_support",
440 ]
441 dict = "//net/data/fuzzer_dictionaries/net_dns_record_fuzzer.dict"
442}
443
444fuzzer_test("net_host_resolver_impl_fuzzer") {
445 sources = [
446 "host_resolver_impl_fuzzer.cc",
447 ]
448 deps = [
449 "//base",
450 "//net",
451 "//net:net_fuzzer_test_support",
452 "//net:test_support",
453 ]
454 dict = "//net/data/fuzzer_dictionaries/net_host_resolver_impl_fuzzer.dict"
455}