summaryrefslogtreecommitdiff
path: root/chromium/net/dns/BUILD.gn
blob: 3b87b89a687e089751e864836a2abcb155362126 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
# Copyright 2018 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//net/features.gni")
import("//testing/libfuzzer/fuzzer_test.gni")

enable_built_in_dns = !is_ios && !is_proto_quic

source_set("dns") {
  # Due to circular dependencies, should only be depended on through //net.
  visibility = [ "//net" ]

  # Internals only intended for use inside network stack (and tests).
  friend = [
    "//chrome/browser:test_support",
    "//chrome/test/*",
    "//components/certificate_transparency:unit_tests",
    "//components/cronet/*",
    "//net/*",
    "//services/network/*",
  ]

  public = []
  sources = [
    "dns_util.cc",
    "dns_util.h",
  ]

  if (!is_nacl) {
    sources += [
      "address_sorter.h",
      "address_sorter_win.cc",
      "dns_config.cc",
      "dns_config_overrides.cc",
      "dns_config_service.cc",
      "dns_config_service.h",
      "dns_config_service_win.cc",
      "dns_config_service_win.h",
      "dns_config_watcher_mac.cc",
      "dns_config_watcher_mac.h",
      "dns_hosts.cc",
      "dns_hosts.h",
      "dns_query.cc",
      "dns_query.h",
      "dns_reloader.cc",
      "dns_reloader.h",
      "dns_response.cc",
      "dns_session.cc",
      "dns_session.h",
      "dns_socket_pool.cc",
      "dns_socket_pool.h",
      "dns_transaction.cc",
      "host_cache.cc",
      "host_resolver.cc",
      "host_resolver_impl.cc",
      "host_resolver_mdns_listener_impl.cc",
      "host_resolver_mdns_listener_impl.h",
      "host_resolver_mdns_task.cc",
      "host_resolver_mdns_task.h",
      "host_resolver_proc.cc",
      "host_resolver_proc.h",
      "host_resolver_source.h",
      "mapped_host_resolver.cc",
      "notify_watcher_mac.cc",
      "notify_watcher_mac.h",
      "record_parsed.cc",
      "record_rdata.cc",
      "serial_worker.cc",
      "serial_worker.h",
    ]

    if (is_posix || is_fuchsia) {
      sources += [ "dns_config_service_posix.cc" ]

      if (enable_built_in_dns) {
        sources += [
          "address_sorter_posix.cc",
          "address_sorter_posix.h",
        ]
      }
    }

    if (enable_built_in_dns) {
      sources += [ "dns_client.cc" ]
    }

    if (enable_mdns) {
      sources += [
        "mdns_cache.cc",
        "mdns_cache.h",
        "mdns_client.cc",
        "mdns_client_impl.cc",
        "mdns_client_impl.h",
      ]
    }
  }

  deps = [
    "//net:net_deps",
  ]

  public_deps = [
    ":dns_client",
    ":host_resolver",
    ":host_resolver_impl",
    ":mdns_client",
    "//net:net_public_deps",
  ]

  allow_circular_includes_from = [
    ":dns_client",
    ":host_resolver",
    ":host_resolver_impl",
    ":mdns_client",
  ]
}

# The standard API of net/dns.
#
# Should typically only be used within the network service. Usage external to
# the network service should instead use network service Mojo IPCs for host
# resolution. See ResolveHost() in
# /services/network/public/mojom/network_context.mojom and
# /services/network/public/mojom/host_resolver.mojom.
source_set("host_resolver") {
  # Due to circular dependencies, should only be depended on through //net.
  # Limit visibility to //net and other source_sets with the same access
  # restriction.
  visibility = [
    ":dns",
    ":host_resolver_impl",
    ":mdns_client",
    "//net",
  ]

  # Whitelist-only access so we can keep track of all usage external to the
  # network stack and network service.
  friend = [
    # chrome/browser/io_thread.cc
    # Used to build in-process HostResolver when network service disabled.
    #
    # chrome/browser/net/dns_probe_service.cc
    # TODO(crbug.com/874660): Remove once migrated to network service IPC.
    "//chrome/browser",

    # chromecast/browser/url_request_context_factory.cc
    # URLRequestContext creation for chromecast.
    "//chromecast/browser",

    # URLRequestContext and HttpNetworkSession::Context creation for iOS.
    "//ios/components/io_thread",
    "//ios/web/shell",
    "//ios/web_view:*",

    # Tests and test support.
    "//chrome/browser:test_support",
    "//chrome/test:browser_tests",
    "//chrome/test:unit_tests",
    "//components/grpc_support/test:unit_tests",
    "//content/shell:content_shell_lib",

    # Stand-alone tools.
    "//components/sync/tools:*",
    "//google_apis/gcm:mcs_probe",

    # Network stack/service.
    "//components/certificate_transparency/*",
    "//components/cronet/*",
    "//net/*",
    "//services/network/*",

    # The proxy resolution service uses its own host cache and HostResolver Mojo
    # wrapper.
    "//services/proxy_resolver/*",
  ]

  sources = []
  public = []

  if (!is_nacl) {
    sources += [
      "dns_config.h",
      "dns_config_overrides.h",
      "host_cache.h",
      "host_resolver.h",
      "mapped_host_resolver.h",
    ]
  }

  deps = [
    "//net:net_deps",
    "//net/dns/public",
  ]
  public_deps = [
    "//net:net_public_deps",
  ]
}

# Overridable implementation details of HostResolver.
source_set("host_resolver_impl") {
  # Due to circular dependencies, should only be depended on through //net.
  # Limit visibility to //net and other source_sets with the same access
  # restriction.
  visibility = [
    ":dns",
    "//net",
  ]

  # Whitelist-only access so we can keep track of all usage external to the
  # network stack.
  friend = [
    # chromeos/network/network_change_notifier_posix.cc
    # ChromeOS-specific change notifier with some overrides for DnsConfigService
    # TODO(crbug.com/882610): Remove/cleanup once we figure out servicification.
    "//chromeos/network",

    # Network stack/service
    "//components/cronet/*",
    "//net/*",
    "//services/network:tests",
  ]

  sources = []
  public = []

  if (!is_nacl) {
    sources += [ "host_resolver_impl.h" ]

    if (is_posix || is_fuchsia) {
      sources += [ "dns_config_service_posix.h" ]
    }
  }

  deps = [
    ":host_resolver",
    "//net:net_deps",
    "//net/dns/public",
  ]
  public_deps = [
    "//net:net_public_deps",
  ]
}

# DnsClient interfaces. Primarily intended as part of the implementation of the
# standard HostResolver interface, but can be used as an alternative external
# interface for advanced usage.
source_set("dns_client") {
  # Due to circular dependencies, should only be depended on through //net.
  # Limit visibility to //net and other source_sets with the same access
  # restriction.
  visibility = [
    ":dns",
    ":mdns_client",
    "//net",
  ]

  # Whitelist-only access so we can keep track of all usage external to the
  # network stack.
  friend = [
    # chrome/browser/local_discovery/service_discovery_client_impl.cc
    # Result parsing utilities for parsing results read through MdnsClient.
    # TODO(crbug.com/874662): Remove once migrated to network service.
    #
    # chrome/browser/net/dns_probe_runner.cc
    # chrome/browser/net/dns_probe_service.cc
    # DNS lookups using DnsClient.
    # TODO(crbug.com/874660): Remove once migrated to network service.
    "//chrome/browser",

    # chrome/browser/chromeos/smb_client/discovery/mdns_host_locator.cc
    # Result parsing for results read through MdnsClient.
    # TODO(crbug.com/902531): Remove once migrated to network service.
    "//chrome/browser/chromeos",

    # Tests and test support
    "//chrome/browser:test_support",
    "//chrome/test/*",

    # Network stack/service
    "//components/certificate_transparency/*",
    "//net/*",
    "//services/network/*",
  ]

  sources = []
  public = []

  if (!is_nacl) {
    sources += [
      "dns_client.h",
      "dns_response.h",
      "dns_transaction.h",
      "record_parsed.h",
      "record_rdata.h",
    ]
  }

  deps = [
    "//net:net_deps",
  ]
  public_deps = [
    "//net:net_public_deps",
    "//net/dns/public",
  ]
}

# MdnsClient interfaces.
source_set("mdns_client") {
  # Due to circular dependencies, should only be depended on through //net.
  # Limit visibility to //net and other source_sets with the same access
  # restriction.
  visibility = [
    ":dns",
    "//net",
  ]

  # Whitelist-only access so we can keep track of all usage external to the
  # network stack.
  friend = [
    # chrome/browser/local_discovery/service_discovery_client_mdns.h
    # chrome/browser/local_discovery/service_discovery_client_impl.h
    # Makes MDNS queries using MDnsClient.
    # TODO(crbug.com/874662): Remove once migrated to network service.
    "//chrome/browser",

    # chrome/tools/service_discovery_sniffer/service_discovery_sniffer.cc
    # Creates MDnsClient instance and passes to ServiceDiscoveryClientImpl.
    # TODO(crbug.com/874662): Remove once discovery client migrated.
    "//chrome/tools/service_discovery_sniffer",

    # chrome/browser/chromeos/smb_client/discovery/mdns_host_locator.h
    # chrome/browser/chromeos/smb_client/discovery/mdns_host_locator.cc
    # Makes MDNS queries using MDnsClient.
    # TODO(crbug.com/902531): Remove once migrated to network service.
    "//chrome/browser/chromeos",

    # Tests and test support
    "//chrome/browser:test_support",

    # Network stack/service
    "//net/*",
    "//services/network/*",
  ]

  public = []
  sources = []

  if (!is_nacl && enable_mdns) {
    sources += [ "mdns_client.h" ]
  }

  deps = [
    ":dns_client",
    ":host_resolver",
    "//net:net_deps",
  ]
  public_deps = [
    "//net:net_public_deps",
  ]
}

source_set("tests") {
  testonly = true
  sources = [
    "dns_config_service_unittest.cc",
    "dns_config_service_win_unittest.cc",
    "dns_hosts_unittest.cc",
    "dns_query_unittest.cc",
    "dns_response_unittest.cc",
    "dns_session_unittest.cc",
    "dns_socket_pool_unittest.cc",
    "dns_transaction_unittest.cc",
    "dns_util_unittest.cc",
    "host_cache_unittest.cc",
    "host_resolver_impl_unittest.cc",
    "mapped_host_resolver_unittest.cc",
    "record_parsed_unittest.cc",
    "record_rdata_unittest.cc",
    "serial_worker_unittest.cc",
  ]

  if (is_posix || is_fuchsia) {
    sources += [ "dns_config_service_posix_unittest.cc" ]
  }

  if (enable_built_in_dns) {
    sources += [ "address_sorter_unittest.cc" ]
    if (is_posix || is_fuchsia) {
      sources += [ "address_sorter_posix_unittest.cc" ]
    }
  }

  if (enable_mdns) {
    sources += [
      "mdns_cache_unittest.cc",
      "mdns_client_unittest.cc",
    ]
  }

  deps = [
    "//base",
    "//net",
    "//net:test_support",
    "//testing/gmock",
    "//testing/gtest",
  ]
}

source_set("test_support") {
  testonly = true
  sources = [
    "dns_test_util.cc",
    "mock_host_resolver.cc",
  ]
  public = [
    "dns_test_util.h",
    "mock_host_resolver.h",
  ]

  if (enable_mdns) {
    sources += [
      "mock_mdns_client.cc",
      "mock_mdns_socket_factory.cc",
    ]
    public += [
      "mock_mdns_client.h",
      "mock_mdns_socket_factory.h",
    ]
  }

  deps = [
    "//base",
    "//net",
    "//testing/gmock",
    "//testing/gtest",
  ]
}

source_set("fuzzer_test_support") {
  testonly = true
  sources = [
    "fuzzed_host_resolver.cc",
    "fuzzed_host_resolver.h",
  ]
  deps = [
    "//base",
    "//base/test:test_support",
    "//net",
  ]
}

fuzzer_test("net_dns_hosts_parse_fuzzer") {
  sources = [
    "dns_hosts_parse_fuzzer.cc",
  ]
  deps = [
    "//base",
    "//net",
    "//net:net_fuzzer_test_support",
  ]
  dict = "//net/data/fuzzer_dictionaries/net_dns_hosts_parse_fuzzer.dict"
}

fuzzer_test("net_dns_record_fuzzer") {
  sources = [
    "dns_record_fuzzer.cc",
  ]
  deps = [
    "//base",
    "//net",
    "//net:net_fuzzer_test_support",
  ]
  dict = "//net/data/fuzzer_dictionaries/net_dns_record_fuzzer.dict"
}

fuzzer_test("net_dns_query_parse_fuzzer") {
  sources = [
    "dns_query_parse_fuzzer.cc",
  ]
  deps = [
    "//base",
    "//net",
    "//net:net_fuzzer_test_support",
  ]
  dict = "//net/data/fuzzer_dictionaries/net_dns_record_fuzzer.dict"
}

fuzzer_test("net_dns_response_fuzzer") {
  sources = [
    "dns_response_fuzzer.cc",
  ]
  deps = [
    "//base",
    "//net",
    "//net:net_fuzzer_test_support",
  ]
  dict = "//net/data/fuzzer_dictionaries/net_dns_record_fuzzer.dict"
}

fuzzer_test("net_host_resolver_impl_fuzzer") {
  sources = [
    "host_resolver_impl_fuzzer.cc",
  ]
  deps = [
    "//base",
    "//net",
    "//net:net_fuzzer_test_support",
    "//net:test_support",
  ]
  dict = "//net/data/fuzzer_dictionaries/net_host_resolver_impl_fuzzer.dict"
}

if (is_win) {
  fuzzer_test("net_dns_parse_domain_ascii_win_fuzzer") {
    sources = [
      "dns_parse_domain_ascii_win_fuzzer.cc",
    ]
    deps = [
      "//base",
      "//net",
      "//net:net_fuzzer_test_support",
    ]
  }
}