Commit a72bec2e authored by Elena's avatar Elena 🤷‍♀️ Committed by Pier Angelo Vendrame
Browse files

TB 44806: Implement the tor integration in Rust.

parent 842b1c12
Loading
Loading
Loading
Loading
+28 −0
Changes for Cargo.lock: 28 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -2990,6 +2990,8 @@ dependencies = [
 "ssl_tokens_cache",
 "static_prefs",
 "storage",
 "tor_provider",
 "tor_service",
 "trust-anchors",
 "unic-langid",
 "unic-langid-ffi",
@@ -8167,6 +8169,32 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa7c7f42dea4b1b99439786f5633aeb9c14c1b53f75e282803c2ec2ad545873c"

[[package]]
name = "tor_provider"
version = "0.1.0"
dependencies = [
 "bytes",
 "hex",
 "log",
 "memchr",
 "thiserror 2.0.12",
]

[[package]]
name = "tor_service"
version = "0.1.0"
dependencies = [
 "bytes",
 "cstr",
 "log",
 "moz_task",
 "nserror",
 "nsstring",
 "thin-vec",
 "tor_provider",
 "xpcom",
]

[[package]]
name = "tower-service"
version = "0.3.2"
+3 −0
Changes for toolkit/components/moz.build: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -159,6 +159,9 @@ if CONFIG["MOZ_UNIFFI_FIXTURES"]:

# Exclude aboutinference (about:inference). tor-browser#44045.

if CONFIG["TOR_RUST_INTEGRATION"]:
    DIRS += ["tor-integration"]

UNIFIED_SOURCES += [
    "/toolkit/components/antitracking/ContentBlockingAllowList.cpp",
]
+29 −0
Changes for toolkit/components/tor-integration/TorService.h: 29 added lines, 0 removed lines.
Original line number Diff line number Diff line
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef TOOLKIT_COMPONENTS_TOR_INTEGRATION_TORSERVICE_H_
#define TOOLKIT_COMPONENTS_TOR_INTEGRATION_TORSERVICE_H_

#include "nsCOMPtr.h"

#include "torITorService.h"

// Inspired by
// toolkit/components/extensions/storage/ExtensionStorageComponents.h.

// Implemented in Rust
extern "C" nsresult NewTorServiceImpl(torITorService** aResult);

namespace torproject {
already_AddRefed<torITorService> NewTorService() {
  nsCOMPtr<torITorService> service;
  nsresult rv = NewTorServiceImpl(getter_AddRefs(service));
  if (NS_WARN_IF(NS_FAILED(rv))) {
    return nullptr;
  }
  return service.forget();
}
}  // namespace torproject

#endif  // TOOLKIT_COMPONENTS_TOR_INTEGRATION_TORSERVICE_H_
+14 −0
Changes for toolkit/components/tor-integration/components.conf: 14 added lines, 0 removed lines.
Original line number Diff line number Diff line
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

Classes = [
    {
        'cid': '{2537313c-e120-408c-a2f6-86e6e1bdf899}',
        'contract_ids': ['@torproject.org/tor-service;1'],
        'interfaces': ['torITorService'],
        'constructor': 'torproject::NewTorService',
        'headers': ['torproject/TorService.h'],
        'js_name': 'tor',
    },
]
+13 −0
Changes for toolkit/components/tor-integration/moz.build: 13 added lines, 0 removed lines.
Original line number Diff line number Diff line
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

XPIDL_MODULE = "tor"
XPIDL_SOURCES += ["torITorService.idl"]
XPCOM_MANIFESTS += [
    "components.conf",
]

EXPORTS.torproject += ["TorService.h"]

XPCSHELL_TESTS_MANIFESTS += ["test/xpcshell/xpcshell.toml"]
Loading