BUILD.gn 15 KB

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