Skip to content

Sync with Foundation-Devices/tor: Change package name and author #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 48 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
a4ebc6d
Merge pull request #10 from cypherstack/main
icota Sep 7, 2023
2644b34
Merge pull request #11 from cypherstack/staging
icota Sep 13, 2023
7c3d1c4
Change plugin name and author
icota Sep 14, 2023
c3382ff
Merge pull request #12 from Foundation-Devices/change-name
icota Sep 15, 2023
01ce694
Allow .onion addresses
icota Sep 20, 2023
6594a55
Merge pull request #16 from Foundation-Devices/onion-addresses
icota Sep 21, 2023
948e577
Fix macOS build
icota Sep 22, 2023
80e8429
Fix iOS and macOS build
icota Sep 22, 2023
e262903
Merge pull request #18 from Foundation-Devices/fix-macos-build
icota Sep 22, 2023
45928a0
Move socks_socket.dart to main lib directory
icota Sep 22, 2023
90837e0
Merge pull request #19 from Foundation-Devices/socks-socket
icota Sep 22, 2023
16d9adf
Squashed 'cargokit/' changes from 62bb5c9..7a5bba8
icota Sep 24, 2023
f77ec51
Merge commit '16d9adfff55baccbfa3f8e0a5c8542c62611420c'
icota Sep 24, 2023
a833bec
Merge pull request #20 from Foundation-Devices/update-cargokit
icota Sep 24, 2023
df5e231
Don't set enabled to true once bootstrapped and clarify in comments
icota Oct 5, 2023
5403e5c
Merge pull request #21 from Foundation-Devices/dont-enable
icota Oct 5, 2023
1d35204
Fix example app (missing tor.init)
icota Oct 6, 2023
cf109c6
Merge pull request #22 from Foundation-Devices/fix-example
icota Oct 6, 2023
09ba92c
Bump arti to 1.1.9
icota Oct 17, 2023
3f7317f
Add licence
icota Nov 21, 2023
d699f14
Merge pull request #24 from Foundation-Devices/add-reuse-licence
icota Nov 21, 2023
6a338f6
Initial GH Actions yaml
icota Nov 21, 2023
f15f2a3
Bump iOS target to 12
icota Dec 12, 2023
70ee863
Bump arti to 1.1.11
icota Dec 12, 2023
c63b3c6
Merge pull request #25 from Foundation-Devices/bump-arti
icota Dec 12, 2023
87067b6
Limit the number of open files for the process
icota Jan 9, 2024
7964878
Increase nofile_limit to 16384
icota Jan 9, 2024
2dbeef1
Return err if unable to increase_nofile_limit
icota Jan 9, 2024
143bab2
Refactor
icota Jan 10, 2024
11a8f4f
Fix binding generation
icota Jan 11, 2024
c953192
Use void pointers on the FFI boundary
icota Jan 11, 2024
cb6b718
ffigen: generate less bindings
icota Jan 11, 2024
366e894
util: add getter/setter for process nofile_limit
icota Jan 12, 2024
80f902a
Add more CI checks
icota Jan 16, 2024
9c74126
Disable Dart tests (for now)
icota Jan 16, 2024
9b312cf
Merge pull request #27 from Foundation-Devices/happy-new-year
icota Jan 16, 2024
e35c982
Update README.md
icota Jan 16, 2024
b30ba87
Prepare package for pub.deb release
icota Jan 19, 2024
f72491f
Merge pull request #28 from Foundation-Devices/pub-dev
icota Jan 19, 2024
6bf5786
pubspec: add supported platforms
icota Jan 19, 2024
bc18df4
Do not compile nofile_limit util functions on Windows
icota Jan 22, 2024
b8dcfef
lib.rs: do not import nofile_limit util functions on Windows
icota Jan 22, 2024
7c17b05
Bump to 0.0.2
icota Jan 22, 2024
b31e4db
Merge pull request #30 from Foundation-Devices/fix-windows-build
icota Jan 22, 2024
4d70dab
Add restart function
icota Jan 29, 2024
2c8fe55
(re)start: add example
icota Feb 4, 2024
e5c8b3f
Add setClientDormant function
icota Feb 4, 2024
78ad843
Merge pull request #32 from Foundation-Devices/stop
icota Feb 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# SPDX-FileCopyrightText: 2022 Foundation Devices Inc.
#
# SPDX-License-Identifier: GPL-3.0-or-later

name: Check

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: REUSE Compliance Check
uses: fsfe/reuse-action@v1

- uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: rustfmt, clippy

- uses: subosito/flutter-action@v2
with:
channel: 'stable'
flutter-version: '3.16.3'

- name: Install dependencies
run: flutter pub get

- name: Verify Dart formatting
run: dart format --output=none --set-exit-if-changed .

- name: Verify Rust formatting
run: cargo fmt --manifest-path rust/Cargo.toml --all -- --check

- name: Run Rust tests
run: cargo test --manifest-path rust/Cargo.toml

- name: Analyze Dart project source
run: flutter analyze

# - name: Run Dart tests
# run: flutter test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ migrate_working_dir/
build/

rust/target/.rustc_info.json
rust/target/debug
3 changes: 3 additions & 0 deletions .gitignore.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2023 Foundation Devices Inc.

SPDX-License-Identifier: GPL-3.0-or-later
20 changes: 20 additions & 0 deletions .reuse/dep5
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: tor
Upstream-Contact: Igor Cota <[email protected]>
Source: https://github.com/Foundation-Devices/tor

Files: cargokit/*
Copyright: 2022 Matej Knopp
License: MIT

Files: lib/generated*
Copyright: 2024 Foundation Devices Inc.
License: GPL-3.0-or-later

Files: rust/target/*
Copyright: 2024 Foundation Devices Inc.
License: GPL-3.0-or-later

Files: CHANGELOG.md
Copyright: 2024 Foundation Devices Inc.
License: GPL-3.0-or-later
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 0.0.3

* Added functions to stop and restart the proxy.

## 0.0.2

* Fixed the Windows build.

## 0.0.1

* TODO: Describe initial release.
* Initial release.
233 changes: 232 additions & 1 deletion LICENSE

Large diffs are not rendered by default.

232 changes: 232 additions & 0 deletions LICENSES/GPL-3.0-or-later.txt

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions LICENSES/MIT.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
MIT License

Copyright (c) <year> <copyright holders>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,10 @@ git subtree pull --prefix cargokit https://github.com/irondash/cargokit.git main

## Development

To generate `tor-ffi.h` C bindings for Rust, `cbindgen --config cbindgen.toml --crate tor-ffi --output target/tor-ffi.h` or `cargo build` in `native/tor-ffi` to produce headers according to `build.rs`
To generate `tor_bindings_generated.dart` Dart bindings for C, `flutter pub run ffigen --config ffigen.yaml`
To (re)generate Dart bindings run `just generate`

## Example app

`flutter run` in `example` to run the example app

See `example/lib/main.dart` for usage. Must run the build script for your platform first.
See `example/lib/main.dart` for usage.
3 changes: 3 additions & 0 deletions README.md.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2023 Foundation Devices Inc.

SPDX-License-Identifier: GPL-3.0-or-later
9 changes: 7 additions & 2 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# SPDX-FileCopyrightText: 2022 Foundation Devices Inc.
#
# SPDX-License-Identifier: GPL-3.0-or-later
include: package:flutter_lints/flutter.yaml

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
analyzer:
exclude:
- 'lib/generated*'
- 'cargokit'
3 changes: 3 additions & 0 deletions android/.gitignore.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2023 Foundation Devices Inc.

SPDX-License-Identifier: GPL-3.0-or-later
6 changes: 3 additions & 3 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// The Android Gradle Plugin builds the native code with the Android NDK.

group 'com.cypherstack.tor_ffi_plugin'
group 'com.foundationdevices.tor'
version '1.0'

buildscript {
Expand All @@ -26,7 +26,7 @@ apply plugin: 'com.android.library'

android {
if (project.android.hasProperty("namespace")) {
namespace 'com.cypherstack.tor_ffi_plugin'
namespace 'com.foundationdevices.tor'
}
// Bumping the plugin compileSdkVersion requires all clients of this plugin
// to bump the version in their app.
Expand All @@ -46,5 +46,5 @@ apply from: "../cargokit/gradle/plugin.gradle"

cargokit {
manifestDir = "../rust"
libname = "tor_ffi_plugin"
libname = "tor"
}
3 changes: 3 additions & 0 deletions android/build.gradle.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2023 Foundation Devices Inc.

SPDX-License-Identifier: GPL-3.0-or-later
2 changes: 1 addition & 1 deletion android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1 @@
rootProject.name = 'tor_ffi_plugin'
rootProject.name = 'tor'
3 changes: 3 additions & 0 deletions android/settings.gradle.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2023 Foundation Devices Inc.

SPDX-License-Identifier: GPL-3.0-or-later
2 changes: 1 addition & 1 deletion android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.cypherstack.tor_ffi_plugin">
package="com.foundationdevices.tor">
</manifest>
3 changes: 3 additions & 0 deletions android/src/main/AndroidManifest.xml.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2023 Foundation Devices Inc.

SPDX-License-Identifier: GPL-3.0-or-later
14 changes: 13 additions & 1 deletion cargokit/build_pod.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,22 @@ export CARGOKIT_TOOL_TEMP_DIR=$TARGET_TEMP_DIR/build_tool
# Directory inside root project. Not necessarily the top level directory of root project.
export CARGOKIT_ROOT_PROJECT_DIR=$SRCROOT

FLUTTER_EXPORT_BUILD_ENVIRONMENT=(
"$PODS_ROOT/../Flutter/ephemeral/flutter_export_environment.sh" # macOS
"$PODS_ROOT/../Flutter/flutter_export_environment.sh" # iOS
)

for path in "${FLUTTER_EXPORT_BUILD_ENVIRONMENT[@]}"
do
if [[ -f "$path" ]]; then
source "$path"
fi
done

"$BASEDIR/run_build_tool.sh" build-pod "$@"

# Make a symlink from built framework to phony file, which will be used as input to
# build script. This should force rebuild (podspec currently doesn't support alwaysOutOfDate
# attribute on custom build phase)
ln -Fs "${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}" "${BUILT_PRODUCTS_DIR}/cargokit_phony"
ln -Fs "$OBJROOT/XCBuildData/build.db" "${BUILT_PRODUCTS_DIR}/cargokit_phony"
ln -Fs "${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}" "${BUILT_PRODUCTS_DIR}/cargokit_phony_out"
6 changes: 3 additions & 3 deletions cargokit/build_tool/lib/src/builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,14 @@ class RustBuilder {
Rustup rustup,
) {
final toolchain = _toolchain;
if (!rustup.installedToolchains.any((i) => i.startsWith('$toolchain-'))) {
if (rustup.installedTargets(toolchain) == null) {
rustup.installToolchain(toolchain);
}
if (toolchain == 'nightly') {
rustup.installRustSrcForNightly();
}
if (!rustup.installedTargets.contains(target.rust)) {
rustup.installTarget(target.rust);
if (!rustup.installedTargets(toolchain)!.contains(target.rust)) {
rustup.installTarget(target.rust, toolchain: toolchain);
}
}

Expand Down
79 changes: 64 additions & 15 deletions cargokit/build_tool/lib/src/rustup.dart
Original file line number Diff line number Diff line change
@@ -1,41 +1,90 @@
import 'dart:io';

import 'package:collection/collection.dart';
import 'package:path/path.dart' as path;

import 'util.dart';

class Rustup {
final List<String> installedTargets;
final List<String> installedToolchains;
class _Toolchain {
_Toolchain(
this.name,
this.targets,
);

Rustup()
: installedTargets = _getInstalledTargets(),
installedToolchains = _getInstalledToolchains();
final String name;
final List<String> targets;
}

void installTarget(String target) {
log.info("Installing Rust target: $target");
runCommand("rustup", ['target', 'add', target]);
installedTargets.add(target);
class Rustup {
List<String>? installedTargets(String toolchain) {
final targets = _installedTargets(toolchain);
return targets != null ? List.unmodifiable(targets) : null;
}

void installToolchain(String toolchain) {
log.info("Installing Rust toolchain: $toolchain");
runCommand("rustup", ['toolchain', 'install', toolchain]);
installedToolchains.add(toolchain);
_installedToolchains
.add(_Toolchain(toolchain, _getInstalledTargets(toolchain)));
}

static List<String> _getInstalledToolchains() {
void installTarget(
String target, {
required String toolchain,
}) {
log.info("Installing Rust target: $target");
runCommand("rustup", [
'target',
'add',
'--toolchain',
toolchain,
target,
]);
_installedTargets(toolchain)?.add(target);
}

final List<_Toolchain> _installedToolchains;

Rustup() : _installedToolchains = _getInstalledToolchains();

List<String>? _installedTargets(String toolchain) => _installedToolchains
.firstWhereOrNull(
(e) => e.name == toolchain || e.name.startsWith('$toolchain-'))
?.targets;

static List<_Toolchain> _getInstalledToolchains() {
String extractToolchainName(String line) {
// ignore (default) after toolchain name
final parts = line.split(' ');
return parts[0];
}

final res = runCommand("rustup", ['toolchain', 'list']);
final lines = res.stdout
.toString()
.split('\n')
.where((e) => e.isNotEmpty)
.map(extractToolchainName)
.toList(growable: true);

return lines
.map(
(name) => _Toolchain(
name,
_getInstalledTargets(name),
),
)
.toList(growable: true);
return lines;
}

static List<String> _getInstalledTargets() {
final res = runCommand("rustup", ['target', 'list', '--installed']);
static List<String> _getInstalledTargets(String toolchain) {
final res = runCommand("rustup", [
'target',
'list',
'--toolchain',
toolchain,
'--installed',
]);
final lines = res.stdout
.toString()
.split('\n')
Expand Down
3 changes: 3 additions & 0 deletions example/.gitignore.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2023 Foundation Devices Inc.

SPDX-License-Identifier: GPL-3.0-or-later
3 changes: 3 additions & 0 deletions example/README.md.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2023 Foundation Devices Inc.

SPDX-License-Identifier: GPL-3.0-or-later
26 changes: 1 addition & 25 deletions example/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,29 +1,5 @@
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.

# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml

linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at
# https://dart-lang.github.io/linter/lints/index.html.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
avoid_print: false
3 changes: 3 additions & 0 deletions example/analysis_options.yaml.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2023 Foundation Devices Inc.

SPDX-License-Identifier: GPL-3.0-or-later
3 changes: 3 additions & 0 deletions example/android/.gitignore.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2023 Foundation Devices Inc.

SPDX-License-Identifier: GPL-3.0-or-later
4 changes: 2 additions & 2 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
namespace "com.cypherstack.tor_ffi_plugin_example"
namespace "com.foundationdevices.tor_example"
compileSdkVersion flutter.compileSdkVersion
ndkVersion flutter.ndkVersion

Expand All @@ -45,7 +45,7 @@ android {

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.cypherstack.tor_ffi_plugin_example"
applicationId "com.foundationdevices.tor_example"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion flutter.minSdkVersion
Expand Down
Loading