1# 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("//net/features.gni") 6import("//testing/libfuzzer/fuzzer_test.gni") 7 8enable_built_in_dns = !is_ios 9 10source_set("dns") { 11 # Due to circular dependencies, should only be depended on through //net. 12 visibility = [ 13 "//net", 14 "//net/http:transport_security_state_generated_files", 15 ] 16 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_info.cc", 36 "address_info.h", 37 "address_sorter.h", 38 "address_sorter_win.cc", 39 "context_host_resolver.cc", 40 "context_host_resolver.h", 41 "dns_config.cc", 42 "dns_config_overrides.cc", 43 "dns_config_service.cc", 44 "dns_config_service.h", 45 "dns_config_service_win.cc", 46 "dns_config_service_win.h", 47 "dns_config_watcher_mac.cc", 48 "dns_config_watcher_mac.h", 49 "dns_hosts.cc", 50 "dns_hosts.h", 51 "dns_query.cc", 52 "dns_query.h", 53 "dns_reloader.cc", 54 "dns_reloader.h", 55 "dns_response.cc", 56 "dns_server_iterator.cc", 57 "dns_server_iterator.h", 58 "dns_session.cc", 59 "dns_session.h", 60 "dns_socket_pool.cc", 61 "dns_socket_pool.h", 62 "dns_transaction.cc", 63 "esni_content.cc", 64 "host_cache.cc", 65 "host_resolver.cc", 66 "host_resolver_manager.cc", 67 "host_resolver_mdns_listener_impl.cc", 68 "host_resolver_mdns_listener_impl.h", 69 "host_resolver_mdns_task.cc", 70 "host_resolver_mdns_task.h", 71 "host_resolver_proc.cc", 72 "host_resolver_proc.h", 73 "mapped_host_resolver.cc", 74 "notify_watcher_mac.cc", 75 "notify_watcher_mac.h", 76 "record_parsed.cc", 77 "record_rdata.cc", 78 "resolve_context.cc", 79 "resolve_context.h", 80 "serial_worker.cc", 81 "serial_worker.h", 82 "system_dns_config_change_notifier.cc", 83 "system_dns_config_change_notifier.h", 84 ] 85 86 if (is_fuchsia) { 87 sources += [ 88 "dns_config_service_fuchsia.cc", 89 "dns_config_service_fuchsia.h", 90 ] 91 } 92 93 if (is_posix) { 94 sources += [ 95 "dns_config_service_posix.cc", 96 "dns_config_service_posix.h", 97 ] 98 } 99 100 if (enable_built_in_dns) { 101 sources += [ "dns_client.cc" ] 102 103 if (is_posix || is_fuchsia) { 104 sources += [ 105 "address_sorter_posix.cc", 106 "address_sorter_posix.h", 107 ] 108 } 109 } 110 111 if (enable_mdns) { 112 sources += [ 113 "mdns_cache.cc", 114 "mdns_cache.h", 115 "mdns_client.cc", 116 "mdns_client_impl.cc", 117 "mdns_client_impl.h", 118 ] 119 } 120 } 121 122 deps = [ "//net:net_deps" ] 123 124 public_deps = [ 125 ":dns_client", 126 ":host_resolver", 127 ":host_resolver_manager", 128 ":mdns_client", 129 "//net:net_public_deps", 130 ] 131 132 allow_circular_includes_from = [ 133 ":dns_client", 134 ":host_resolver", 135 ":host_resolver_manager", 136 ":mdns_client", 137 ] 138} 139 140# The standard API of net/dns. 141# 142# Should typically only be used within the network service. Usage external to 143# the network service should instead use network service Mojo IPCs for host 144# resolution. See ResolveHost() in 145# /services/network/public/mojom/network_context.mojom and 146# /services/network/public/mojom/host_resolver.mojom. 147source_set("host_resolver") { 148 # Due to circular dependencies, should only be depended on through //net. 149 # Limit visibility to //net and other source_sets with the same access 150 # restriction. 151 visibility = [ 152 ":dns", 153 ":dns_client", 154 ":host_resolver_manager", 155 ":mdns_client", 156 "//net", 157 ] 158 159 # Restricted access so we can keep track of all usage external to the 160 # network stack and network service. 161 friend = [ 162 # chromecast/browser/url_request_context_factory.cc 163 # URLRequestContext creation for chromecast. 164 "//chromecast/browser", 165 166 # URLRequestContext and HttpNetworkSession::Context creation for iOS. 167 "//ios/components/io_thread", 168 "//ios/web/shell", 169 "//ios/web_view:*", 170 171 # Tests and test support. 172 "//chrome/browser:test_support", 173 "//chrome/test:browser_tests", 174 "//chrome/test:unit_tests", 175 "//components/grpc_support/test:unit_tests", 176 "//content/shell:content_shell_lib", 177 178 # Stand-alone tools. 179 "//google_apis/gcm:mcs_probe", 180 181 # Network stack/service. 182 "//components/certificate_transparency/*", 183 "//components/cronet/*", 184 "//net/*", 185 "//services/network/*", 186 187 # The proxy resolution service uses its own host cache and HostResolver Mojo 188 # wrapper. 189 "//services/proxy_resolver/*", 190 ] 191 192 sources = [] 193 public = [] 194 195 if (!is_nacl) { 196 sources += [ 197 "dns_config.h", 198 "dns_config_overrides.h", 199 "esni_content.h", 200 "host_cache.h", 201 "host_resolver.h", 202 "host_resolver_source.h", 203 "mapped_host_resolver.h", 204 ] 205 } 206 207 deps = [ 208 "//net:net_deps", 209 "//net/dns/public", 210 ] 211 public_deps = [ "//net:net_public_deps" ] 212} 213 214# Shared mostly-global handler of HostResolver requests. 215# 216# Typically should only be directly interacted with by NetworkService (or other 217# mostly-global creators of request contexts), standalone tools, and tests. Host 218# resolution should generally instead go through HostResolvers received from 219# URLRequestContext or network service Mojo IPCs. 220source_set("host_resolver_manager") { 221 # Due to circular dependencies, should only be depended on through //net. 222 # Limit visibility to //net and other source_sets with the same access 223 # restriction. 224 visibility = [ 225 ":dns", 226 ":host_resolver", 227 "//net", 228 ] 229 230 # Restricted access so we can keep track of all usage external to the 231 # network stack and network service. 232 friend = [ 233 # chromecast/browser/url_request_context_factory.cc 234 # URLRequestContext creation for chromecast. 235 "//chromecast/browser", 236 237 # Tests and test support. 238 "//components/cronet:cronet_common_unittests", 239 240 # Network stack/service. 241 "//net/*", 242 "//services/network/*", 243 ] 244 245 sources = [] 246 public = [] 247 248 if (!is_nacl) { 249 sources += [ "host_resolver_manager.h" ] 250 } 251 252 deps = [ 253 ":host_resolver", 254 "//net:net_deps", 255 "//net/dns/public", 256 ] 257 public_deps = [ "//net:net_public_deps" ] 258} 259 260# DnsClient interfaces. Primarily intended as part of the implementation of the 261# standard HostResolver interface, but can be used as an alternative external 262# interface for advanced usage. 263source_set("dns_client") { 264 # Due to circular dependencies, should only be depended on through //net. 265 # Limit visibility to //net and other source_sets with the same access 266 # restriction. 267 visibility = [ 268 ":dns", 269 ":mdns_client", 270 "//net", 271 ] 272 273 # Restricted access so we can keep track of all usage external to the 274 # network stack. 275 friend = [ 276 # chrome/browser/local_discovery/service_discovery_client_impl.cc 277 # Result parsing utilities for parsing results read through MdnsClient. 278 # TODO(crbug.com/874662): Remove once migrated to network service. 279 "//chrome/browser", 280 281 # chrome/browser/chromeos/smb_client/discovery/mdns_host_locator.cc 282 # Result parsing for results read through MdnsClient. 283 # TODO(crbug.com/902531): Remove once migrated to network service. 284 "//chrome/browser/chromeos", 285 286 # Tests and test support 287 "//chrome/browser:test_support", 288 "//chrome/test/*", 289 290 # Network stack/service 291 "//components/certificate_transparency/*", 292 "//net/*", 293 "//services/network/*", 294 ] 295 296 sources = [] 297 public = [] 298 299 if (!is_nacl) { 300 sources += [ 301 "dns_client.h", 302 "dns_response.h", 303 "dns_transaction.h", 304 "record_parsed.h", 305 "record_rdata.h", 306 ] 307 } 308 309 deps = [ 310 ":host_resolver", 311 "//net:net_deps", 312 ] 313 public_deps = [ 314 "//net:net_public_deps", 315 "//net/dns/public", 316 ] 317} 318 319# MdnsClient interfaces. 320source_set("mdns_client") { 321 # Due to circular dependencies, should only be depended on through //net. 322 # Limit visibility to //net and other source_sets with the same access 323 # restriction. 324 visibility = [ 325 ":dns", 326 "//net", 327 ] 328 329 # Restricted access so we can keep track of all usage external to the 330 # network stack. 331 friend = [ 332 # chrome/browser/local_discovery/service_discovery_client_mdns.h 333 # chrome/browser/local_discovery/service_discovery_client_impl.h 334 # Makes MDNS queries using MDnsClient. 335 # TODO(crbug.com/874662): Remove once migrated to network service. 336 "//chrome/browser", 337 338 # chrome/tools/service_discovery_sniffer/service_discovery_sniffer.cc 339 # Creates MDnsClient instance and passes to ServiceDiscoveryClientImpl. 340 # TODO(crbug.com/874662): Remove once discovery client migrated. 341 "//chrome/tools/service_discovery_sniffer", 342 343 # chrome/browser/chromeos/smb_client/discovery/mdns_host_locator.h 344 # chrome/browser/chromeos/smb_client/discovery/mdns_host_locator.cc 345 # Makes MDNS queries using MDnsClient. 346 # TODO(crbug.com/902531): Remove once migrated to network service. 347 "//chrome/browser/chromeos", 348 349 # Tests and test support 350 "//chrome/browser:test_support", 351 352 # Network stack/service 353 "//net/*", 354 "//services/network/*", 355 ] 356 357 public = [] 358 sources = [] 359 360 if (!is_nacl && enable_mdns) { 361 sources += [ "mdns_client.h" ] 362 } 363 364 deps = [ 365 ":dns_client", 366 ":host_resolver", 367 "//net:net_deps", 368 ] 369 public_deps = [ "//net:net_public_deps" ] 370} 371 372source_set("tests") { 373 testonly = true 374 sources = [ 375 "address_info_unittest.cc", 376 "context_host_resolver_unittest.cc", 377 "dns_config_service_unittest.cc", 378 "dns_config_service_win_unittest.cc", 379 "dns_hosts_unittest.cc", 380 "dns_query_unittest.cc", 381 "dns_response_unittest.cc", 382 "dns_session_unittest.cc", 383 "dns_socket_pool_unittest.cc", 384 "dns_transaction_unittest.cc", 385 "dns_util_unittest.cc", 386 "esni_content_unittest.cc", 387 "host_cache_unittest.cc", 388 "host_resolver_manager_unittest.cc", 389 "mapped_host_resolver_unittest.cc", 390 "record_parsed_unittest.cc", 391 "record_rdata_unittest.cc", 392 "resolve_context_unittest.cc", 393 "serial_worker_unittest.cc", 394 "system_dns_config_change_notifier_unittest.cc", 395 ] 396 397 if (is_posix) { 398 sources += [ "dns_config_service_posix_unittest.cc" ] 399 } 400 401 if (enable_built_in_dns) { 402 sources += [ 403 "address_sorter_unittest.cc", 404 "dns_client_unittest.cc", 405 ] 406 if (is_posix || is_fuchsia) { 407 sources += [ "address_sorter_posix_unittest.cc" ] 408 } 409 } 410 411 if (enable_mdns) { 412 sources += [ 413 "mdns_cache_unittest.cc", 414 "mdns_client_unittest.cc", 415 ] 416 } 417 418 deps = [ 419 "//base", 420 "//net", 421 "//net:test_support", 422 "//testing/gmock", 423 "//testing/gtest", 424 ] 425} 426 427source_set("test_support") { 428 visibility = [ "//net:test_support" ] 429 testonly = true 430 sources = [ 431 "address_info_test_util.cc", 432 "dns_test_util.cc", 433 "mock_host_resolver.cc", 434 "test_dns_config_service.cc", 435 ] 436 public = [ 437 "address_info_test_util.h", 438 "dns_test_util.h", 439 "mock_host_resolver.h", 440 "test_dns_config_service.h", 441 ] 442 443 if (enable_mdns) { 444 sources += [ 445 "mock_mdns_client.cc", 446 "mock_mdns_socket_factory.cc", 447 ] 448 public += [ 449 "mock_mdns_client.h", 450 "mock_mdns_socket_factory.h", 451 ] 452 } 453 454 deps = [ 455 "//base", 456 "//net", 457 "//testing/gmock", 458 "//testing/gtest", 459 ] 460} 461 462if (use_fuzzing_engine) { 463 # fuzzer_test targets are no-op when |use_fuzzing_engine| is false. Fuzzer 464 # support targets should be disabled too. 465 source_set("fuzzer_test_support") { 466 testonly = true 467 sources = [ 468 "fuzzed_host_resolver_util.cc", 469 "fuzzed_host_resolver_util.h", 470 ] 471 deps = [ 472 "//base", 473 "//base/test:test_support", 474 "//net", 475 ] 476 } 477} 478 479fuzzer_test("net_dns_hosts_parse_fuzzer") { 480 sources = [ "dns_hosts_parse_fuzzer.cc" ] 481 deps = [ 482 "//base", 483 "//net", 484 "//net:net_fuzzer_test_support", 485 ] 486 dict = "//net/data/fuzzer_dictionaries/net_dns_hosts_parse_fuzzer.dict" 487} 488 489fuzzer_test("net_dns_record_fuzzer") { 490 sources = [ "dns_record_fuzzer.cc" ] 491 deps = [ 492 "//base", 493 "//net", 494 "//net:net_fuzzer_test_support", 495 ] 496 dict = "//net/data/fuzzer_dictionaries/net_dns_record_fuzzer.dict" 497} 498 499fuzzer_test("net_dns_query_parse_fuzzer") { 500 sources = [ "dns_query_parse_fuzzer.cc" ] 501 deps = [ 502 "//base", 503 "//net", 504 "//net:net_fuzzer_test_support", 505 ] 506 dict = "//net/data/fuzzer_dictionaries/net_dns_record_fuzzer.dict" 507} 508 509fuzzer_test("net_dns_response_fuzzer") { 510 sources = [ "dns_response_fuzzer.cc" ] 511 deps = [ 512 "//base", 513 "//net", 514 "//net:net_fuzzer_test_support", 515 ] 516 dict = "//net/data/fuzzer_dictionaries/net_dns_record_fuzzer.dict" 517} 518 519fuzzer_test("net_host_resolver_manager_fuzzer") { 520 sources = [ "host_resolver_manager_fuzzer.cc" ] 521 deps = [ 522 "//base", 523 "//net", 524 "//net:net_fuzzer_test_support", 525 "//net:test_support", 526 ] 527 dict = "//net/data/fuzzer_dictionaries/net_host_resolver_manager_fuzzer.dict" 528} 529 530if (is_win) { 531 fuzzer_test("net_dns_parse_domain_ascii_win_fuzzer") { 532 sources = [ "dns_parse_domain_ascii_win_fuzzer.cc" ] 533 deps = [ 534 "//base", 535 "//net", 536 "//net:net_fuzzer_test_support", 537 ] 538 dict = "//net/data/fuzzer_dictionaries/net_dns_hosts_parse_fuzzer.dict" 539 seed_corpus = "//net/data/fuzzer_data/dns_parse_domain_ascii_win_fuzzer" 540 } 541} 542