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