From c1e741587196a8c6fada48721d4db33ef1d5da0e Mon Sep 17 00:00:00 2001 From: Conrad Kramer Date: Mon, 10 Apr 2023 16:49:23 -0400 Subject: [PATCH] Initial commit --- .devcontainer.json | 8 + .github/CODEOWNERS | 1 + .github/actions/archive/action.yml | 43 + .github/actions/build-for-testing/action.yml | 37 + .github/actions/export/action.yml | 47 + .github/actions/import-cert/action.yml | 26 + .../actions/test-without-building/action.yml | 37 + .github/workflows/build-apple.yml | 70 + .github/workflows/build-rust.yml | 55 + .github/workflows/lint-git.yml | 20 + .github/workflows/lint-swift.yml | 21 + .github/workflows/release-apple.yml | 65 + .gitignore | 5 + .gitlint | 19 + .swiftlint.yml | 99 ++ .vscode/extensions.json | 5 + .vscode/settings.json | 16 + .vscode/tasks.json | 17 + Apple/App/App-iOS.entitlements | 10 + Apple/App/App-macOS.entitlements | 10 + .../AccentColor.colorset/Contents.json | 11 + .../AppIcon.appiconset/Contents.json | 63 + Apple/App/Assets.xcassets/Contents.json | 6 + Apple/App/Burrow.xcconfig | 17 + Apple/App/BurrowApp.swift | 10 + Apple/App/ContentView.swift | 19 + Apple/Burrow.xcodeproj/project.pbxproj | 334 ++++ .../contents.xcworkspacedata | 7 + .../xcshareddata/IDEWorkspaceChecks.plist | 8 + Apple/Configuration/App.xcconfig | 10 + Apple/Configuration/Compiler.xcconfig | 61 + Apple/Configuration/Extension.xcconfig | 2 + Apple/Configuration/Identity.xcconfig | 2 + Apple/Configuration/Info.plist | 8 + Apple/NetworkExtension/Info.plist | 13 + .../NetworkExtension-iOS.entitlements | 10 + .../NetworkExtension-macOS.entitlements | 10 + .../NetworkExtension.xcconfig | 8 + .../PacketTunnelProvider.swift | 29 + Cargo.lock | 1523 +++++++++++++++++ Cargo.toml | 6 + burrow/Cargo.toml | 10 + burrow/src/main.rs | 14 + tun-async/Cargo.toml | 9 + tun-async/src/lib.rs | 14 + tun/Cargo.toml | 24 + tun/build.rs | 79 + tun/src/apple/kern_control.rs | 53 + tun/src/apple/mod.rs | 90 + tun/src/apple/queue.rs | 17 + tun/src/lib.rs | 16 + tun/src/linux.rs | 56 + tun/src/queue.rs | 1 + tun/src/unix.rs | 11 + tun/src/windows/mod.rs | 44 + tun/src/windows/queue.rs | 19 + 56 files changed, 3225 insertions(+) create mode 100644 .devcontainer.json create mode 100644 .github/CODEOWNERS create mode 100644 .github/actions/archive/action.yml create mode 100644 .github/actions/build-for-testing/action.yml create mode 100644 .github/actions/export/action.yml create mode 100644 .github/actions/import-cert/action.yml create mode 100644 .github/actions/test-without-building/action.yml create mode 100644 .github/workflows/build-apple.yml create mode 100644 .github/workflows/build-rust.yml create mode 100644 .github/workflows/lint-git.yml create mode 100644 .github/workflows/lint-swift.yml create mode 100644 .github/workflows/release-apple.yml create mode 100644 .gitignore create mode 100644 .gitlint create mode 100644 .swiftlint.yml create mode 100644 .vscode/extensions.json create mode 100644 .vscode/settings.json create mode 100644 .vscode/tasks.json create mode 100644 Apple/App/App-iOS.entitlements create mode 100644 Apple/App/App-macOS.entitlements create mode 100644 Apple/App/Assets.xcassets/AccentColor.colorset/Contents.json create mode 100644 Apple/App/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 Apple/App/Assets.xcassets/Contents.json create mode 100644 Apple/App/Burrow.xcconfig create mode 100644 Apple/App/BurrowApp.swift create mode 100644 Apple/App/ContentView.swift create mode 100644 Apple/Burrow.xcodeproj/project.pbxproj create mode 100644 Apple/Burrow.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 Apple/Burrow.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 Apple/Configuration/App.xcconfig create mode 100644 Apple/Configuration/Compiler.xcconfig create mode 100644 Apple/Configuration/Extension.xcconfig create mode 100644 Apple/Configuration/Identity.xcconfig create mode 100644 Apple/Configuration/Info.plist create mode 100644 Apple/NetworkExtension/Info.plist create mode 100644 Apple/NetworkExtension/NetworkExtension-iOS.entitlements create mode 100644 Apple/NetworkExtension/NetworkExtension-macOS.entitlements create mode 100644 Apple/NetworkExtension/NetworkExtension.xcconfig create mode 100644 Apple/NetworkExtension/PacketTunnelProvider.swift create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 burrow/Cargo.toml create mode 100644 burrow/src/main.rs create mode 100644 tun-async/Cargo.toml create mode 100644 tun-async/src/lib.rs create mode 100644 tun/Cargo.toml create mode 100644 tun/build.rs create mode 100644 tun/src/apple/kern_control.rs create mode 100644 tun/src/apple/mod.rs create mode 100644 tun/src/apple/queue.rs create mode 100644 tun/src/lib.rs create mode 100644 tun/src/linux.rs create mode 100644 tun/src/queue.rs create mode 100644 tun/src/unix.rs create mode 100644 tun/src/windows/mod.rs create mode 100644 tun/src/windows/queue.rs diff --git a/.devcontainer.json b/.devcontainer.json new file mode 100644 index 0000000..8b90a41 --- /dev/null +++ b/.devcontainer.json @@ -0,0 +1,8 @@ +{ + "image": "mcr.microsoft.com/devcontainers/rust", + "customizations": { + "vscode": { + "extensions": ["rust-lang.rust-analyzer"] + } + } +} diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..20c920e --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @conradev diff --git a/.github/actions/archive/action.yml b/.github/actions/archive/action.yml new file mode 100644 index 0000000..c34bd3c --- /dev/null +++ b/.github/actions/archive/action.yml @@ -0,0 +1,43 @@ +name: Archive +inputs: + scheme: + description: Scheme + required: true + destination: + description: Destination + required: true + app-store-key: + description: App Store key in PEM PKCS#8 format + required: true + app-store-key-id: + description: App Store key ID + required: true + app-store-key-issuer-id: + description: App Store key issuer ID + required: true + archive-path: + description: Xcode archive path + required: true +runs: + using: composite + steps: + - shell: bash + working-directory: Apple + run: | + echo "${{ inputs.app-store-key }}" > AuthKey_${{ inputs.app-store-key-id }}.p8 + + xcodebuild archive \ + -allowProvisioningUpdates \ + -allowProvisioningDeviceRegistration \ + -authenticationKeyID ${{ inputs.app-store-key-id }} \ + -authenticationKeyIssuerID ${{ inputs.app-store-key-issuer-id }} \ + -authenticationKeyPath "${PWD}/AuthKey_${{ inputs.app-store-key-id }}.p8" \ + -onlyUsePackageVersionsFromResolvedFile \ + -scheme '${{ inputs.scheme }}' \ + -destination '${{ inputs.destination }}' \ + -archivePath '${{ inputs.archive-path }}' \ + -resultBundlePath BuildResults.xcresult + + ./Tools/xcresulttool-github BuildResults.xcresult + + rm -rf AuthKey_${{ inputs.app-store-key-id }}.p8 diff --git a/.github/actions/build-for-testing/action.yml b/.github/actions/build-for-testing/action.yml new file mode 100644 index 0000000..9691122 --- /dev/null +++ b/.github/actions/build-for-testing/action.yml @@ -0,0 +1,37 @@ +name: Build For Testing +inputs: + scheme: + description: Scheme + required: true + destination: + description: Destination + required: true + app-store-key: + description: App Store key in PEM PKCS#8 format + required: true + app-store-key-id: + description: App Store key ID + required: true + app-store-key-issuer-id: + description: App Store key issuer ID + required: true +runs: + using: composite + steps: + - shell: bash + working-directory: Apple + run: | + echo "${{ inputs.app-store-key }}" > AuthKey_${{ inputs.app-store-key-id }}.p8 + + xcodebuild clean build-for-testing \ + -allowProvisioningUpdates \ + -allowProvisioningDeviceRegistration \ + -authenticationKeyID ${{ inputs.app-store-key-id }} \ + -authenticationKeyIssuerID ${{ inputs.app-store-key-issuer-id }} \ + -authenticationKeyPath "${PWD}/AuthKey_${{ inputs.app-store-key-id }}.p8" \ + -onlyUsePackageVersionsFromResolvedFile \ + -scheme '${{ inputs.scheme }}' \ + -destination '${{ inputs.destination }}' \ + -resultBundlePath BuildResults.xcresult + + rm -rf AuthKey_${{ inputs.app-store-key-id }}.p8 diff --git a/.github/actions/export/action.yml b/.github/actions/export/action.yml new file mode 100644 index 0000000..bf007a7 --- /dev/null +++ b/.github/actions/export/action.yml @@ -0,0 +1,47 @@ +name: Notarize +inputs: + app-store-key: + description: App Store key in PEM PKCS#8 format + required: true + app-store-key-id: + description: App Store key ID + required: true + app-store-key-issuer-id: + description: App Store key issuer ID + required: true + archive-path: + description: Xcode archive path + required: true + destination: + description: The Xcode export destination. This can either be "export" or "upload" + required: true + method: + description: The Xcode export method. This can be one of app-store, validation, ad-hoc, package, enterprise, development, developer-id, or mac-application. + required: true + export-path: + description: The path to export the archive to + required: true +runs: + using: composite + steps: + - id: notarize + shell: bash + working-directory: Apple + run: | + echo "${{ inputs.app-store-key }}" > AuthKey_${{ inputs.app-store-key-id }}.p8 + + echo '{"destination":"${{ inputs.destination }}","method":"${{ inputs.method }}"}' \ + | plutil -convert xml1 -o ExportOptions.plist - + + xcodebuild \ + -exportArchive \ + -allowProvisioningUpdates \ + -allowProvisioningDeviceRegistration \ + -authenticationKeyID ${{ inputs.app-store-key-id }} \ + -authenticationKeyIssuerID ${{ inputs.app-store-key-issuer-id }} \ + -authenticationKeyPath "${PWD}/AuthKey_${{ inputs.app-store-key-id }}.p8" \ + -archivePath '${{ inputs.archive-path }}' \ + -exportPath '${{ inputs.export-path }}' \ + -exportOptionsPlist ExportOptions.plist + + rm -rf AuthKey_${{ inputs.app-store-key-id }}.p8 ExportOptions.plist diff --git a/.github/actions/import-cert/action.yml b/.github/actions/import-cert/action.yml new file mode 100644 index 0000000..759418e --- /dev/null +++ b/.github/actions/import-cert/action.yml @@ -0,0 +1,26 @@ +name: Import Certificate +inputs: + certificate: + description: 'The certificate in p12 format, encoded as base64' + required: true + password: + description: 'The certificate password' + required: true +runs: + using: composite + steps: + - shell: bash + run: | + echo -n "${{ inputs.certificate }}" | base64 -d > Developer.p12 + security create-keychain -p password Developer.keychain + security set-keychain-settings -lut 21600 Developer.keychain + security unlock-keychain -p password Developer.keychain + security import Developer.p12 \ + -k Developer.keychain \ + -f pkcs12 \ + -A \ + -T /usr/bin/codesign \ + -T /usr/bin/security \ + -P ${{ inputs.password }} + security set-key-partition-list -S apple-tool:,apple: -k password Developer.keychain + security list-keychains -d user -s login.keychain Developer.keychain diff --git a/.github/actions/test-without-building/action.yml b/.github/actions/test-without-building/action.yml new file mode 100644 index 0000000..5903d07 --- /dev/null +++ b/.github/actions/test-without-building/action.yml @@ -0,0 +1,37 @@ +name: Test Without Building +inputs: + scheme: + description: Scheme + required: true + destination: + description: Destination + required: true + test-plan: + description: Test Plan + required: false + artifact-prefix: + description: The prefix for the filename of the uploaded xcresults file + required: true + check-name: + description: The check name + required: true +runs: + using: composite + steps: + - shell: bash + id: vars + run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + - shell: bash + working-directory: Apple + run: | + xcodebuild test-without-building \ + -scheme '${{ inputs.scheme }}' \ + -destination '${{ inputs.destination }}' \ + ${{ inputs.test-plan && '-testPlan ' }}${{ inputs.test-plan }} \ + -resultBundlePath "${{ inputs.artifact-prefix }}-${{ steps.vars.outputs.sha_short }}.xcresult" + - uses: kishikawakatsumi/xcresulttool@v1 + if: always() + with: + path: Apple/${{ inputs.artifact-prefix }}-${{ steps.vars.outputs.sha_short }}.xcresult + title: ${{ inputs.check-name }} + show-passed-tests: false diff --git a/.github/workflows/build-apple.yml b/.github/workflows/build-apple.yml new file mode 100644 index 0000000..b7383b0 --- /dev/null +++ b/.github/workflows/build-apple.yml @@ -0,0 +1,70 @@ +name: Apple Build +on: + push: + branches: + - main + pull_request: + branches: + - "*" +jobs: + build: + name: Build App (${{ matrix.platform }}) + runs-on: macos-12 + strategy: + fail-fast: false + matrix: + include: + - scheme: App (iOS) + destination: generic/platform=iOS + platform: iOS + sdk-name: iphoneos + - scheme: App (iOS) + destination: platform=iOS Simulator,OS=16.2,name=iPhone 14 Pro + platform: iOS Simulator + sdk-name: iphonesimulator + - scheme: App (macOS) + destination: platform=macOS + platform: macOS + sdk-name: macos + env: + DEVELOPER_DIR: /Applications/Xcode_14.2.app/Contents/Developer + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + ssh-key: ${{ secrets.DEPLOY_KEY }} + submodules: recursive + - name: Import Certificate + uses: ./.github/actions/import-cert + with: + certificate: ${{ secrets.DEVELOPER_CERT }} + password: ${{ secrets.DEVELOPER_CERT_PASSWORD }} + - name: Build + id: build + uses: ./.github/actions/build-for-testing + with: + scheme: ${{ matrix.scheme }} + destination: ${{ matrix.destination }} + app-store-key: ${{ secrets.APPSTORE_KEY }} + app-store-key-id: ${{ secrets.APPSTORE_KEY_ID }} + app-store-key-issuer-id: ${{ secrets.APPSTORE_KEY_ISSUER_ID }} + - name: Xcode Unit Test + if: ${{ matrix.xcode-unit-test != '' }} + continue-on-error: true + uses: ./.github/actions/test-without-building + with: + scheme: ${{ matrix.scheme }} + destination: ${{ matrix.destination }} + test-plan: ${{ matrix.xcode-unit-test }} + artifact-prefix: unit-tests-${{ matrix.sdk-name }} + check-name: Xcode Unit Tests (${{ matrix.platform }}) + - name: Xcode UI Test + if: ${{ matrix.xcode-ui-test != '' }} + continue-on-error: true + uses: ./.github/actions/test-without-building + with: + scheme: ${{ matrix.scheme }} + destination: ${{ matrix.destination }} + test-plan: ${{ matrix.xcode-ui-test }} + artifact-prefix: ui-tests-${{ matrix.sdk-name }} + check-name: Xcode UI Tests (${{ matrix.platform }}) diff --git a/.github/workflows/build-rust.yml b/.github/workflows/build-rust.yml new file mode 100644 index 0000000..641b6b6 --- /dev/null +++ b/.github/workflows/build-rust.yml @@ -0,0 +1,55 @@ +name: Rust Build +on: + push: + branches: + - main + pull_request: + branches: + - "*" +jobs: + build: + name: Build Crate (${{ matrix.platform }}) + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-latest + platform: Linux + targets: + - x86_64-unknown-linux-gnu + - aarch64-unknown-linux-gnu + - os: macos-12 + platform: macOS + targets: + - x86_64-apple-darwin + - aarch64-apple-darwin + - aarch64-apple-ios + - aarch64-apple-ios-sim + - x86_64-apple-ios + - os: windows-2022 + platform: Windows + targets: + - x86_64-pc-windows-msvc + - aarch64-pc-windows-msvc + runs-on: ${{ matrix.os }} + env: + DEVELOPER_DIR: /Applications/Xcode_14.2.app/Contents/Developer + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + ssh-key: ${{ secrets.DEPLOY_KEY }} + submodules: recursive + - name: Install Rust + uses: dtolnay/rust-toolchain@master + with: + toolchain: stable + components: rustfmt + targets: ${{ join(matrix.targets, ', ') }} + - name: Build + shell: bash + run: cargo build --verbose --workspace --all-features + - uses: actions-rs/cargo@v1 + with: + command: build + args: --workspace --all-features --target ${{ join(matrix.targets, ' --target ') }} diff --git a/.github/workflows/lint-git.yml b/.github/workflows/lint-git.yml new file mode 100644 index 0000000..aefe199 --- /dev/null +++ b/.github/workflows/lint-git.yml @@ -0,0 +1,20 @@ +name: Git Lint +on: + pull_request: + branches: + - "*" +jobs: + lint: + name: Git Lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.sha }} + fetch-depth: 0 + - name: Install Gitlint + shell: bash + run: python -m pip install gitlint + - name: Run Gitlint + shell: bash + run: gitlint --commits "${{ github.event.pull_request.base.sha }}..HEAD" diff --git a/.github/workflows/lint-swift.yml b/.github/workflows/lint-swift.yml new file mode 100644 index 0000000..7e62afd --- /dev/null +++ b/.github/workflows/lint-swift.yml @@ -0,0 +1,21 @@ +name: Swift Lint +on: + push: + branches: + - main + pull_request: + branches: + - "*" +jobs: + lint: + name: Swift Lint + runs-on: ubuntu-latest + container: + image: ghcr.io/realm/swiftlint:latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + ssh-key: ${{ secrets.DEPLOY_KEY }} + - name: Lint + run: swiftlint lint --reporter github-actions-logging diff --git a/.github/workflows/release-apple.yml b/.github/workflows/release-apple.yml new file mode 100644 index 0000000..8b8a76c --- /dev/null +++ b/.github/workflows/release-apple.yml @@ -0,0 +1,65 @@ +name: Build Apple Release +on: + release: + types: + - created +jobs: + build: + name: Build ${{ matrix.configuration['platform'] }} Release + runs-on: macos-12 + strategy: + fail-fast: false + matrix: + configuration: + - scheme: App (iOS) + destination: generic/platform=iOS + platform: iOS + method: ad-hoc + artifact-file: Apple/Release/Burrow.ipa + - scheme: App (macOS) + destination: generic/platform=macOS + platform: macOS + method: mac-application + artifact-file: Burrow.app.txz + env: + DEVELOPER_DIR: /Applications/Xcode_14.2.app/Contents/Developer + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + ssh-key: ${{ secrets.DEPLOY_KEY }} + submodules: recursive + - name: Import Certificate + uses: ./.github/actions/import-cert + with: + certificate: ${{ secrets.DEVELOPER_CERT }} + password: ${{ secrets.DEVELOPER_CERT_PASSWORD }} + - name: Archive + uses: ./.github/actions/archive + with: + scheme: ${{ matrix.configuration['scheme'] }} + destination: ${{ matrix.configuration['destination'] }} + app-store-key: ${{ secrets.APPSTORE_KEY }} + app-store-key-id: ${{ secrets.APPSTORE_KEY_ID }} + app-store-key-issuer-id: ${{ secrets.APPSTORE_KEY_ISSUER_ID }} + archive-path: Burrow.xcarchive + - name: Export Locally + uses: ./.github/actions/export + with: + method: ${{ matrix.configuration['method'] }} + destination: export + app-store-key: ${{ secrets.APPSTORE_KEY }} + app-store-key-id: ${{ secrets.APPSTORE_KEY_ID }} + app-store-key-issuer-id: ${{ secrets.APPSTORE_KEY_ISSUER_ID }} + archive-path: Burrow.xcarchive + export-path: Release + - name: Compress + if: ${{ matrix.configuration['platform'] == 'macOS' }} + shell: bash + run: tar --options xz:compression-level=9 -C Apple/Release -cJf Burrow.app.txz ./ + - name: Attach Artifact + uses: SierraSoftworks/gh-releases@v1.0.6 + with: + token: ${{ secrets.GITHUB_TOKEN }} + overwrite: 'false' + files: ${{ matrix.configuration['artifact-file'] }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..102ee0d --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +# Xcode +xcuserdata + +# Rust +target/ diff --git a/.gitlint b/.gitlint new file mode 100644 index 0000000..b185b1c --- /dev/null +++ b/.gitlint @@ -0,0 +1,19 @@ +[general] +ignore=body-changed-file-mention +ignore-merge-commits=false +ignore-fixup-commits=false +ignore-squash-commits=false +ignore-stdin=true +fail-without-commits=true + +[title-max-length] +line-length=50 + +[body-max-line-length] +line-length=72 + +[title-match-regex] +regex=^(?!.*(#\d+)) + +[body-match-regex] +regex=^(?!.*(#\d+)) diff --git a/.swiftlint.yml b/.swiftlint.yml new file mode 100644 index 0000000..d609718 --- /dev/null +++ b/.swiftlint.yml @@ -0,0 +1,99 @@ +opt_in_rules: +- anonymous_argument_in_multiline_closure +- array_init +- attributes +- closure_end_indentation +- closure_spacing +- collection_alignment +- contains_over_filter_count +- contains_over_filter_is_empty +- contains_over_first_not_nil +- contains_over_range_nil_comparison +- convenience_type +- discarded_notification_center_observer +- discouraged_assert +- discouraged_none_name +- discouraged_object_literal +- empty_collection_literal +- empty_count +- empty_string +- empty_xctest_method +- enum_case_associated_values_count +- expiring_todo +- explicit_init +- fallthrough +- fatal_error_message +- file_header +- file_name_no_space +- first_where +- flatmap_over_map_reduce +- function_default_parameter_at_end +- ibinspectable_in_extension +- identical_operands +- implicitly_unwrapped_optional +- indentation_width +- joined_default_parameter +- last_where +- legacy_multiple +- legacy_random +- literal_expression_end_indentation +- lower_acl_than_parent +- modifier_order +- multiline_arguments +- multiline_arguments_brackets +- multiline_function_chains +- multiline_literal_brackets +- multiline_parameters +- multiline_parameters_brackets +- no_extension_access_modifier +- no_grouping_extension +- nslocalizedstring_key +- nslocalizedstring_require_bundle +- number_separator +- object_literal +- operator_usage_whitespace +- optional_enum_case_matching +- overridden_super_call +- override_in_extension +- pattern_matching_keywords +- prefer_self_in_static_references +- prefer_self_type_over_type_of_self +- prefer_zero_over_explicit_init +- private_action +- private_outlet +- private_subject +- prohibited_interface_builder +- prohibited_super_call +- quick_discouraged_call +- quick_discouraged_focused_test +- quick_discouraged_pending_test +- raw_value_for_camel_cased_codable_enum +- reduce_into +- redundant_nil_coalescing +- redundant_type_annotation +- required_enum_case +- single_test_class +- sorted_first_last +- sorted_imports +- static_operator +- strict_fileprivate +- strong_iboutlet +- switch_case_on_newline +- test_case_accessibility +- toggle_bool +- trailing_closure +- type_contents_order +- unavailable_function +- unneeded_parentheses_in_closure_argument +- unowned_variable_capture +- untyped_error_in_catch +- vertical_parameter_alignment_on_call +- vertical_whitespace_closing_braces +- vertical_whitespace_opening_braces +- weak_delegate +- xct_specific_matcher +- yoda_condition +disabled_rules: +- force_try +- nesting +- todo diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..c5c0dd4 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,5 @@ +{ + "recommendations": [ + "rust-lang.rust-analyzer", + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..287ffdd --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,16 @@ +{ + "files.autoSave": "onFocusChange", + "files.defaultLanguage": "rust", + "explorer.excludeGitIgnore": true, + "editor.formatOnPaste": true, + "editor.formatOnSave": true, + "files.trimTrailingWhitespace": true, + "editor.suggest.preview": true, + "editor.acceptSuggestionOnEnter": "on", + "rust-analyzer.checkOnSave.command": "clippy", + "rust-analyzer.restartServerOnConfigChange": true, + "rust-analyzer.cargo.features": "all", + "[rust]": { + "editor.defaultFormatter": "rust-lang.rust-analyzer", + }, +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..5008897 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,17 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "type": "cargo", + "command": "check", + "problemMatcher": [ + "$rustc" + ], + "group": { + "kind": "build", + "isDefault": true + }, + "label": "Check" + } + ] +} diff --git a/Apple/App/App-iOS.entitlements b/Apple/App/App-iOS.entitlements new file mode 100644 index 0000000..d9849a8 --- /dev/null +++ b/Apple/App/App-iOS.entitlements @@ -0,0 +1,10 @@ + + + + + com.apple.security.application-groups + + $(APP_GROUP_IDENTIFIER) + + + diff --git a/Apple/App/App-macOS.entitlements b/Apple/App/App-macOS.entitlements new file mode 100644 index 0000000..d9849a8 --- /dev/null +++ b/Apple/App/App-macOS.entitlements @@ -0,0 +1,10 @@ + + + + + com.apple.security.application-groups + + $(APP_GROUP_IDENTIFIER) + + + diff --git a/Apple/App/Assets.xcassets/AccentColor.colorset/Contents.json b/Apple/App/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 0000000..eb87897 --- /dev/null +++ b/Apple/App/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Apple/App/Assets.xcassets/AppIcon.appiconset/Contents.json b/Apple/App/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..532cd72 --- /dev/null +++ b/Apple/App/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,63 @@ +{ + "images" : [ + { + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "16x16" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "16x16" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "32x32" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "32x32" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "128x128" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "128x128" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "256x256" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "256x256" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "512x512" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "512x512" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Apple/App/Assets.xcassets/Contents.json b/Apple/App/Assets.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/Apple/App/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Apple/App/Burrow.xcconfig b/Apple/App/Burrow.xcconfig new file mode 100644 index 0000000..a4922de --- /dev/null +++ b/Apple/App/Burrow.xcconfig @@ -0,0 +1,17 @@ +#include "../Configuration/App.xcconfig" + +PRODUCT_NAME = Burrow +PRODUCT_BUNDLE_IDENTIFIER = $(APP_BUNDLE_IDENTIFIER) + +INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphone*] = YES +INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents[sdk=iphone*] = YES +INFOPLIST_KEY_UILaunchScreen_Generation[sdk=iphone*] = YES +INFOPLIST_KEY_UIStatusBarStyle[sdk=iphone*] = UIStatusBarStyleDefault +INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad[sdk=iphone*] = UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight +INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone[sdk=iphone*] = UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight +TARGETED_DEVICE_FAMILY[sdk=iphone*] = 1,2 + +INFOPLIST_KEY_LSApplicationCategoryType[sdk=macos*] = public.app-category.utilities + +CODE_SIGN_ENTITLEMENTS = App/App-iOS.entitlements +CODE_SIGN_ENTITLEMENTS[sdk=macos*] = App/App-macOS.entitlements diff --git a/Apple/App/BurrowApp.swift b/Apple/App/BurrowApp.swift new file mode 100644 index 0000000..b145dea --- /dev/null +++ b/Apple/App/BurrowApp.swift @@ -0,0 +1,10 @@ +import SwiftUI + +@main +struct BurrowApp: App { + var body: some Scene { + WindowGroup { + ContentView() + } + } +} diff --git a/Apple/App/ContentView.swift b/Apple/App/ContentView.swift new file mode 100644 index 0000000..f54deab --- /dev/null +++ b/Apple/App/ContentView.swift @@ -0,0 +1,19 @@ +import SwiftUI + +struct ContentView: View { + var body: some View { + VStack { + Image(systemName: "globe") + .imageScale(.large) + .foregroundColor(.accentColor) + Text("Hello, world!") + } + .padding() + } +} + +struct ContentView_Previews: PreviewProvider { + static var previews: some View { + ContentView() + } +} diff --git a/Apple/Burrow.xcodeproj/project.pbxproj b/Apple/Burrow.xcodeproj/project.pbxproj new file mode 100644 index 0000000..fa4009a --- /dev/null +++ b/Apple/Burrow.xcodeproj/project.pbxproj @@ -0,0 +1,334 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 56; + objects = { + +/* Begin PBXBuildFile section */ + D020F65829E4A697002790F6 /* PacketTunnelProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = D020F65729E4A697002790F6 /* PacketTunnelProvider.swift */; }; + D020F65D29E4A697002790F6 /* BurrowNetworkExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = D020F65329E4A697002790F6 /* BurrowNetworkExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; + D05B9F7629E39EEC008CB1F9 /* BurrowApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = D05B9F7529E39EEC008CB1F9 /* BurrowApp.swift */; }; + D05B9F7829E39EEC008CB1F9 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D05B9F7729E39EEC008CB1F9 /* ContentView.swift */; }; + D05B9F7A29E39EED008CB1F9 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D05B9F7929E39EED008CB1F9 /* Assets.xcassets */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + D020F65B29E4A697002790F6 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = D05B9F6A29E39EEC008CB1F9 /* Project object */; + proxyType = 1; + remoteGlobalIDString = D020F65229E4A697002790F6; + remoteInfo = BurrowNetworkExtension; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + D020F66129E4A697002790F6 /* Embed Foundation Extensions */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 13; + files = ( + D020F65D29E4A697002790F6 /* BurrowNetworkExtension.appex in Embed Foundation Extensions */, + ); + name = "Embed Foundation Extensions"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + D020F63D29E4A1FF002790F6 /* Identity.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Identity.xcconfig; sourceTree = ""; }; + D020F64029E4A1FF002790F6 /* Compiler.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Compiler.xcconfig; sourceTree = ""; }; + D020F64229E4A1FF002790F6 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + D020F64929E4A34B002790F6 /* Burrow.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Burrow.xcconfig; sourceTree = ""; }; + D020F64A29E4A452002790F6 /* App.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = App.xcconfig; sourceTree = ""; }; + D020F65329E4A697002790F6 /* BurrowNetworkExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = BurrowNetworkExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; }; + D020F65729E4A697002790F6 /* PacketTunnelProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PacketTunnelProvider.swift; sourceTree = ""; }; + D020F65929E4A697002790F6 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + D020F66229E4A6E5002790F6 /* NetworkExtension.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = NetworkExtension.xcconfig; sourceTree = ""; }; + D020F66329E4A703002790F6 /* Extension.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Extension.xcconfig; sourceTree = ""; }; + D020F66629E4A95D002790F6 /* NetworkExtension-macOS.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "NetworkExtension-macOS.entitlements"; sourceTree = ""; }; + D020F66729E4A95D002790F6 /* NetworkExtension-iOS.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "NetworkExtension-iOS.entitlements"; sourceTree = ""; }; + D020F66829E4AA74002790F6 /* App-iOS.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "App-iOS.entitlements"; sourceTree = ""; }; + D020F66929E4AA74002790F6 /* App-macOS.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "App-macOS.entitlements"; sourceTree = ""; }; + D05B9F7229E39EEC008CB1F9 /* Burrow.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Burrow.app; sourceTree = BUILT_PRODUCTS_DIR; }; + D05B9F7529E39EEC008CB1F9 /* BurrowApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BurrowApp.swift; sourceTree = ""; }; + D05B9F7729E39EEC008CB1F9 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; + D05B9F7929E39EED008CB1F9 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + D020F65029E4A697002790F6 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + D05B9F6F29E39EEC008CB1F9 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + D020F63C29E4A1FF002790F6 /* Configuration */ = { + isa = PBXGroup; + children = ( + D020F63D29E4A1FF002790F6 /* Identity.xcconfig */, + D020F64A29E4A452002790F6 /* App.xcconfig */, + D020F66329E4A703002790F6 /* Extension.xcconfig */, + D020F64029E4A1FF002790F6 /* Compiler.xcconfig */, + D020F64229E4A1FF002790F6 /* Info.plist */, + ); + path = Configuration; + sourceTree = ""; + }; + D020F65629E4A697002790F6 /* NetworkExtension */ = { + isa = PBXGroup; + children = ( + D020F65729E4A697002790F6 /* PacketTunnelProvider.swift */, + D020F65929E4A697002790F6 /* Info.plist */, + D020F66729E4A95D002790F6 /* NetworkExtension-iOS.entitlements */, + D020F66629E4A95D002790F6 /* NetworkExtension-macOS.entitlements */, + D020F66229E4A6E5002790F6 /* NetworkExtension.xcconfig */, + ); + path = NetworkExtension; + sourceTree = ""; + }; + D05B9F6929E39EEC008CB1F9 = { + isa = PBXGroup; + children = ( + D05B9F7429E39EEC008CB1F9 /* App */, + D020F65629E4A697002790F6 /* NetworkExtension */, + D020F63C29E4A1FF002790F6 /* Configuration */, + D05B9F7329E39EEC008CB1F9 /* Products */, + ); + sourceTree = ""; + }; + D05B9F7329E39EEC008CB1F9 /* Products */ = { + isa = PBXGroup; + children = ( + D05B9F7229E39EEC008CB1F9 /* Burrow.app */, + D020F65329E4A697002790F6 /* BurrowNetworkExtension.appex */, + ); + name = Products; + sourceTree = ""; + }; + D05B9F7429E39EEC008CB1F9 /* App */ = { + isa = PBXGroup; + children = ( + D05B9F7529E39EEC008CB1F9 /* BurrowApp.swift */, + D05B9F7729E39EEC008CB1F9 /* ContentView.swift */, + D05B9F7929E39EED008CB1F9 /* Assets.xcassets */, + D020F66829E4AA74002790F6 /* App-iOS.entitlements */, + D020F66929E4AA74002790F6 /* App-macOS.entitlements */, + D020F64929E4A34B002790F6 /* Burrow.xcconfig */, + ); + path = App; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + D020F65229E4A697002790F6 /* NetworkExtension */ = { + isa = PBXNativeTarget; + buildConfigurationList = D020F65E29E4A697002790F6 /* Build configuration list for PBXNativeTarget "NetworkExtension" */; + buildPhases = ( + D020F64F29E4A697002790F6 /* Sources */, + D020F65029E4A697002790F6 /* Frameworks */, + D020F65129E4A697002790F6 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = NetworkExtension; + productName = BurrowNetworkExtension; + productReference = D020F65329E4A697002790F6 /* BurrowNetworkExtension.appex */; + productType = "com.apple.product-type.app-extension"; + }; + D05B9F7129E39EEC008CB1F9 /* Burrow */ = { + isa = PBXNativeTarget; + buildConfigurationList = D05B9F8129E39EED008CB1F9 /* Build configuration list for PBXNativeTarget "Burrow" */; + buildPhases = ( + D05B9F6E29E39EEC008CB1F9 /* Sources */, + D05B9F6F29E39EEC008CB1F9 /* Frameworks */, + D05B9F7029E39EEC008CB1F9 /* Resources */, + D020F66129E4A697002790F6 /* Embed Foundation Extensions */, + ); + buildRules = ( + ); + dependencies = ( + D020F65C29E4A697002790F6 /* PBXTargetDependency */, + ); + name = Burrow; + productName = Burrow; + productReference = D05B9F7229E39EEC008CB1F9 /* Burrow.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + D05B9F6A29E39EEC008CB1F9 /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastSwiftUpdateCheck = 1430; + LastUpgradeCheck = 1430; + TargetAttributes = { + D020F65229E4A697002790F6 = { + CreatedOnToolsVersion = 14.3; + }; + D05B9F7129E39EEC008CB1F9 = { + CreatedOnToolsVersion = 14.3; + }; + }; + }; + buildConfigurationList = D05B9F6D29E39EEC008CB1F9 /* Build configuration list for PBXProject "Burrow" */; + compatibilityVersion = "Xcode 14.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = D05B9F6929E39EEC008CB1F9; + productRefGroup = D05B9F7329E39EEC008CB1F9 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + D05B9F7129E39EEC008CB1F9 /* Burrow */, + D020F65229E4A697002790F6 /* NetworkExtension */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + D020F65129E4A697002790F6 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + D05B9F7029E39EEC008CB1F9 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + D05B9F7A29E39EED008CB1F9 /* Assets.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + D020F64F29E4A697002790F6 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + D020F65829E4A697002790F6 /* PacketTunnelProvider.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + D05B9F6E29E39EEC008CB1F9 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + D05B9F7829E39EEC008CB1F9 /* ContentView.swift in Sources */, + D05B9F7629E39EEC008CB1F9 /* BurrowApp.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + D020F65C29E4A697002790F6 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = D020F65229E4A697002790F6 /* NetworkExtension */; + targetProxy = D020F65B29E4A697002790F6 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin XCBuildConfiguration section */ + D020F65F29E4A697002790F6 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = D020F66229E4A6E5002790F6 /* NetworkExtension.xcconfig */; + buildSettings = { + }; + name = Debug; + }; + D020F66029E4A697002790F6 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = D020F66229E4A6E5002790F6 /* NetworkExtension.xcconfig */; + buildSettings = { + }; + name = Release; + }; + D05B9F7F29E39EED008CB1F9 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = D020F64029E4A1FF002790F6 /* Compiler.xcconfig */; + buildSettings = { + }; + name = Debug; + }; + D05B9F8029E39EED008CB1F9 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = D020F64029E4A1FF002790F6 /* Compiler.xcconfig */; + buildSettings = { + }; + name = Release; + }; + D05B9F8229E39EED008CB1F9 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = D020F64929E4A34B002790F6 /* Burrow.xcconfig */; + buildSettings = { + }; + name = Debug; + }; + D05B9F8329E39EED008CB1F9 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = D020F64929E4A34B002790F6 /* Burrow.xcconfig */; + buildSettings = { + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + D020F65E29E4A697002790F6 /* Build configuration list for PBXNativeTarget "NetworkExtension" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + D020F65F29E4A697002790F6 /* Debug */, + D020F66029E4A697002790F6 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + D05B9F6D29E39EEC008CB1F9 /* Build configuration list for PBXProject "Burrow" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + D05B9F7F29E39EED008CB1F9 /* Debug */, + D05B9F8029E39EED008CB1F9 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + D05B9F8129E39EED008CB1F9 /* Build configuration list for PBXNativeTarget "Burrow" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + D05B9F8229E39EED008CB1F9 /* Debug */, + D05B9F8329E39EED008CB1F9 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = D05B9F6A29E39EEC008CB1F9 /* Project object */; +} diff --git a/Apple/Burrow.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Apple/Burrow.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/Apple/Burrow.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Apple/Burrow.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Apple/Burrow.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/Apple/Burrow.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Apple/Configuration/App.xcconfig b/Apple/Configuration/App.xcconfig new file mode 100644 index 0000000..f536e9d --- /dev/null +++ b/Apple/Configuration/App.xcconfig @@ -0,0 +1,10 @@ + +SKIP_INSTALL = NO + +LD_RUNPATH_SEARCH_PATHS[sdk=iphone*] = $(inherited) @executable_path/Frameworks +LD_RUNPATH_SEARCH_PATHS[sdk=macosx*] = $(inherited) @executable_path/../Frameworks + +ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon +ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor + +ENABLE_PREVIEWS = YES diff --git a/Apple/Configuration/Compiler.xcconfig b/Apple/Configuration/Compiler.xcconfig new file mode 100644 index 0000000..ebf6136 --- /dev/null +++ b/Apple/Configuration/Compiler.xcconfig @@ -0,0 +1,61 @@ +#include "Identity.xcconfig" + +SDKROOT = auto +ALLOW_TARGET_PLATFORM_SPECIALIZATION = YES + +SUPPORTED_PLATFORMS = iphoneos iphonesimulator macosx +IPHONEOS_DEPLOYMENT_TARGET = 15.0 +MACOSX_DEPLOYMENT_TARGET = 12.0 +SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO +SUPPORTS_MACCATALYST = NO + +ALWAYS_SEARCH_USER_PATHS = NO +PRODUCT_NAME = $(TARGET_NAME:c99extidentifier) +PRODUCT_BUNDLE_IDENTIFIER = $(APP_BUNDLE_IDENTIFIER).$(PRODUCT_NAME) +CURRENT_PROJECT_VERSION = 1 +MARKETING_VERSION = 0.1 + +SKIP_INSTALL = YES + +CODE_SIGN_IDENTITY = Apple Development + +INFOPLIST_FILE = Configuration/Info.plist +GENERATE_INFOPLIST_FILE = YES +INFOPLIST_KEY_NSHumanReadableCopyright = Copyright © 2023 Hack Club +INFOPLIST_KEY_CFBundleDisplayName = Burrow + +ENABLE_BITCODE = NO + +ENABLE_APP_SANDBOX[sdk=macosx*] = YES +ENABLE_HARDENED_RUNTIME[sdk=macosx*] = YES +COMBINE_HIDPI_IMAGES = YES +COPY_PHASE_STRIP = NO + +FUSE_BUILD_SCRIPT_PHASES = YES + +APP_GROUP_IDENTIFIER = group.$(APP_BUNDLE_IDENTIFIER) +APP_GROUP_IDENTIFIER[sdk=macosx*] = $(DEVELOPMENT_TEAM).$(APP_BUNDLE_IDENTIFIER) + +// Swift +SWIFT_VERSION = 5.0 +SWIFT_EMIT_LOC_STRINGS = YES + +// Release +DEBUG_INFORMATION_FORMAT = dwarf-with-dsym +SWIFT_REFLECTION_METADATA_LEVEL = none +SWIFT_COMPILATION_MODE = wholemodule +SWIFT_OPTIMIZATION_LEVEL = -Osize +LLVM_LTO = YES +DEAD_CODE_STRIPPING = YES +VALIDATE_PRODUCT = YES + +// Debug +ONLY_ACTIVE_ARCH[config=Debug] = YES +DEBUG_INFORMATION_FORMAT[config=Debug] = dwarf +ENABLE_TESTABILITY[config=Debug] = YES +SWIFT_OPTIMIZATION_LEVEL[config=Debug] = -Onone +SWIFT_ACTIVE_COMPILATION_CONDITIONS[config=Debug] = DEBUG +SWIFT_COMPILATION_MODE[config=Debug] = singlefile +LLVM_LTO[config=Debug] = NO +DEAD_CODE_STRIPPING[config=Debug] = NO +VALIDATE_PRODUCT[config=Debug] = NO diff --git a/Apple/Configuration/Extension.xcconfig b/Apple/Configuration/Extension.xcconfig new file mode 100644 index 0000000..dfe9f5c --- /dev/null +++ b/Apple/Configuration/Extension.xcconfig @@ -0,0 +1,2 @@ +LD_RUNPATH_SEARCH_PATHS = $(inherited) @executable_path/Frameworks @executable_path/../../Frameworks +LD_RUNPATH_SEARCH_PATHS[sdk=macos*] = $(inherited) @executable_path/../Frameworks @executable_path/../../../../Frameworks diff --git a/Apple/Configuration/Identity.xcconfig b/Apple/Configuration/Identity.xcconfig new file mode 100644 index 0000000..e4ef90e --- /dev/null +++ b/Apple/Configuration/Identity.xcconfig @@ -0,0 +1,2 @@ +DEVELOPMENT_TEAM = 87PW93R2ZR +APP_BUNDLE_IDENTIFIER = com.hackclub.burrow diff --git a/Apple/Configuration/Info.plist b/Apple/Configuration/Info.plist new file mode 100644 index 0000000..7632dad --- /dev/null +++ b/Apple/Configuration/Info.plist @@ -0,0 +1,8 @@ + + + + + CFBundleName + $(INFOPLIST_KEY_CFBundleDisplayName) + + diff --git a/Apple/NetworkExtension/Info.plist b/Apple/NetworkExtension/Info.plist new file mode 100644 index 0000000..3059459 --- /dev/null +++ b/Apple/NetworkExtension/Info.plist @@ -0,0 +1,13 @@ + + + + + NSExtension + + NSExtensionPointIdentifier + com.apple.networkextension.packet-tunnel + NSExtensionPrincipalClass + $(PRODUCT_MODULE_NAME).PacketTunnelProvider + + + diff --git a/Apple/NetworkExtension/NetworkExtension-iOS.entitlements b/Apple/NetworkExtension/NetworkExtension-iOS.entitlements new file mode 100644 index 0000000..d9849a8 --- /dev/null +++ b/Apple/NetworkExtension/NetworkExtension-iOS.entitlements @@ -0,0 +1,10 @@ + + + + + com.apple.security.application-groups + + $(APP_GROUP_IDENTIFIER) + + + diff --git a/Apple/NetworkExtension/NetworkExtension-macOS.entitlements b/Apple/NetworkExtension/NetworkExtension-macOS.entitlements new file mode 100644 index 0000000..d9849a8 --- /dev/null +++ b/Apple/NetworkExtension/NetworkExtension-macOS.entitlements @@ -0,0 +1,10 @@ + + + + + com.apple.security.application-groups + + $(APP_GROUP_IDENTIFIER) + + + diff --git a/Apple/NetworkExtension/NetworkExtension.xcconfig b/Apple/NetworkExtension/NetworkExtension.xcconfig new file mode 100644 index 0000000..f606079 --- /dev/null +++ b/Apple/NetworkExtension/NetworkExtension.xcconfig @@ -0,0 +1,8 @@ +#include "../Configuration/Extension.xcconfig" + +PRODUCT_NAME = BurrowNetworkExtension +PRODUCT_BUNDLE_IDENTIFIER = $(APP_BUNDLE_IDENTIFIER).network +INFOPLIST_FILE = NetworkExtension/Info.plist + +CODE_SIGN_ENTITLEMENTS = NetworkExtension/NetworkExtension-iOS.entitlements +CODE_SIGN_ENTITLEMENTS[sdk=macos*] = NetworkExtension/NetworkExtension-macOS.entitlements diff --git a/Apple/NetworkExtension/PacketTunnelProvider.swift b/Apple/NetworkExtension/PacketTunnelProvider.swift new file mode 100644 index 0000000..c8a87cf --- /dev/null +++ b/Apple/NetworkExtension/PacketTunnelProvider.swift @@ -0,0 +1,29 @@ +import NetworkExtension + +class PacketTunnelProvider: NEPacketTunnelProvider { + + override func startTunnel(options: [String : NSObject]?, completionHandler: @escaping (Error?) -> Void) { + // Add code here to start the process of connecting the tunnel. + } + + override func stopTunnel(with reason: NEProviderStopReason, completionHandler: @escaping () -> Void) { + // Add code here to start the process of stopping the tunnel. + completionHandler() + } + + override func handleAppMessage(_ messageData: Data, completionHandler: ((Data?) -> Void)?) { + // Add code here to handle the message. + if let handler = completionHandler { + handler(messageData) + } + } + + override func sleep(completionHandler: @escaping () -> Void) { + // Add code here to get ready to sleep. + completionHandler() + } + + override func wake() { + // Add code here to wake up. + } +} diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..7fa5b6c --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,1523 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "aes" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8" +dependencies = [ + "cfg-if", + "cipher", + "cpufeatures", + "opaque-debug", +] + +[[package]] +name = "anyhow" +version = "1.0.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "216261ddc8289130e551ddcd5ce8a064710c0d064a4d2895c67151c92b5443f6" + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + +[[package]] +name = "base64ct" +version = "1.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b645a089122eccb6111b4f81cbc1a49f5900ac4666bb93ac027feaecf15607bf" + +[[package]] +name = "bindgen" +version = "0.61.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a022e58a142a46fea340d68012b9201c094e93ec3d033a944a24f8fd4a4f09a" +dependencies = [ + "bitflags", + "cexpr", + "clang-sys", + "lazy_static", + "lazycell", + "log", + "peeking_take_while", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", + "syn", + "which", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "block-buffer" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" +dependencies = [ + "generic-array", +] + +[[package]] +name = "bumpalo" +version = "3.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba" + +[[package]] +name = "burrow" +version = "0.1.0" +dependencies = [ + "tokio", + "tun", +] + +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + +[[package]] +name = "bytes" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec8a7b6a70fde80372154c65702f00a0f56f3e1c36abbc6c440484be248856db" + +[[package]] +name = "bzip2" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6afcd980b5f3a45017c57e57a2fcccbb351cc43a356ce117ef760ef8052b89b0" +dependencies = [ + "bzip2-sys", + "libc", +] + +[[package]] +name = "bzip2-sys" +version = "0.1.11+1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "736a955f3fa7875102d57c82b8cac37ec45224a07fd32d58f9f7a186b6cd4cdc" +dependencies = [ + "cc", + "libc", + "pkg-config", +] + +[[package]] +name = "cc" +version = "1.0.74" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "581f5dba903aac52ea3feb5ec4810848460ee833876f1f9b0fdeab1f19091574" +dependencies = [ + "jobserver", +] + +[[package]] +name = "cexpr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "cipher" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7" +dependencies = [ + "generic-array", +] + +[[package]] +name = "clang-sys" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa2e27ae6ab525c3d369ded447057bca5438d86dc3a68f6faafb8269ba82ebf3" +dependencies = [ + "glob", + "libc", + "libloading", +] + +[[package]] +name = "constant_time_eq" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" + +[[package]] +name = "core-foundation" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" + +[[package]] +name = "cpufeatures" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" +dependencies = [ + "libc", +] + +[[package]] +name = "crc32fast" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edbafec5fa1f196ca66527c1b12c2ec4745ca14b50f1ad8f9f6f720b55d11fac" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "digest" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adfbc57365a37acbd2ebf2b64d7e69bb766e2fea813521ed536f5d0520dcf86c" +dependencies = [ + "block-buffer", + "crypto-common", + "subtle", +] + +[[package]] +name = "either" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" + +[[package]] +name = "encoding_rs" +version = "0.8.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9852635589dc9f9ea1b6fe9f05b50ef208c85c834a562f0c6abb1c475736ec2b" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "fastrand" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" +dependencies = [ + "instant", +] + +[[package]] +name = "flate2" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f82b0f4c27ad9f8bfd1f3208d882da2b09c301bc1c828fd3a00d0216d2fbbff6" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "form_urlencoded" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures-channel" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52ba265a92256105f45b719605a571ffe2d1f0fea3807304b522c1d778f79eed" +dependencies = [ + "futures-core", +] + +[[package]] +name = "futures-core" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04909a7a7e4633ae6c4a9ab280aeb86da1236243a77b694a49eacd659a4bd3ac" + +[[package]] +name = "futures-sink" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39c15cf1a4aa79df40f1bb462fb39676d0ad9e366c2a33b590d7c66f4f81fcf9" + +[[package]] +name = "futures-task" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ffb393ac5d9a6eaa9d3fdf37ae2776656b706e200c8e16b1bdb227f5198e6ea" + +[[package]] +name = "futures-util" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "197676987abd2f9cadff84926f410af1c183608d36641465df73ae8211dc65d6" +dependencies = [ + "futures-core", + "futures-task", + "pin-project-lite", + "pin-utils", +] + +[[package]] +name = "generic-array" +version = "0.14.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "glob" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" + +[[package]] +name = "h2" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f9f29bc9dda355256b2916cf526ab02ce0aeaaaf2bad60d65ef3f12f11dd0f4" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "hex-literal" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest", +] + +[[package]] +name = "http" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" +dependencies = [ + "bytes", + "http", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" + +[[package]] +name = "httpdate" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" + +[[package]] +name = "hyper" +version = "0.14.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abfba89e19b959ca163c7752ba59d737c1ceea53a5d31a149c805446fc958064" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "hyper-tls" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +dependencies = [ + "bytes", + "hyper", + "native-tls", + "tokio", + "tokio-native-tls", +] + +[[package]] +name = "idna" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "indexmap" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" +dependencies = [ + "autocfg", + "hashbrown", +] + +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "ipnet" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "879d54834c8c76457ef4293a689b2a8c59b076067ad77b15efafbb05f92a592b" + +[[package]] +name = "itoa" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc" + +[[package]] +name = "jobserver" +version = "0.1.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "068b1ee6743e4d11fb9c6a1e6064b3693a1b600e7f5f5988047d98b3dc9fb90b" +dependencies = [ + "libc", +] + +[[package]] +name = "js-sys" +version = "0.3.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + +[[package]] +name = "libc" +version = "0.2.137" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89" + +[[package]] +name = "libloading" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "efbc0f03f9a775e9f6aed295c6a1ba2253c5757a9e03d55c6caa46a681abcddd" +dependencies = [ + "cfg-if", + "winapi", +] + +[[package]] +name = "log" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "memoffset" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +dependencies = [ + "autocfg", +] + +[[package]] +name = "mime" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "miniz_oxide" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96590ba8f175222643a85693f33d26e9c8a015f599c216509b1a6894af675d34" +dependencies = [ + "adler", +] + +[[package]] +name = "mio" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5d732bc30207a6423068df043e3d02e0735b155ad7ce1a6f76fe2baa5b158de" +dependencies = [ + "libc", + "log", + "wasi", + "windows-sys 0.42.0", +] + +[[package]] +name = "native-tls" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd7e2f3618557f980e0b17e8856252eee3c97fa12c54dff0ca290fb6266ca4a9" +dependencies = [ + "lazy_static", + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + +[[package]] +name = "nix" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e322c04a9e3440c327fca7b6c8a63e6890a32fa2ad689db972425f07e0d22abb" +dependencies = [ + "autocfg", + "bitflags", + "cfg-if", + "libc", + "memoffset", + "pin-utils", +] + +[[package]] +name = "nom" +version = "7.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8903e5a29a317527874d0402f867152a3d21c908bb0b933e416c65e301d4c36" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "num_threads" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2819ce041d2ee131036f4fc9d6ae7ae125a3a40e97ba64d04fe799ad9dabbb44" +dependencies = [ + "libc", +] + +[[package]] +name = "once_cell" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" + +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + +[[package]] +name = "openssl" +version = "0.10.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12fc0523e3bd51a692c8850d075d74dc062ccf251c0110668cbd921917118a13" +dependencies = [ + "bitflags", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "openssl-sys" +version = "0.9.77" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b03b84c3b2d099b81f0953422b4d4ad58761589d0229b5506356afca05a3670a" +dependencies = [ + "autocfg", + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "password-hash" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7676374caaee8a325c9e7a2ae557f216c5563a171d6997b0ef8a65af35147700" +dependencies = [ + "base64ct", + "rand_core", + "subtle", +] + +[[package]] +name = "pbkdf2" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" +dependencies = [ + "digest", + "hmac", + "password-hash", + "sha2", +] + +[[package]] +name = "peeking_take_while" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" + +[[package]] +name = "percent-encoding" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" + +[[package]] +name = "pin-project-lite" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkg-config" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" + +[[package]] +name = "platforms" +version = "3.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8ec293fd25f7fcfeb7c70129241419a62c6200a26a725f680aff07c91d0ed05" + +[[package]] +name = "proc-macro2" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" + +[[package]] +name = "redox_syscall" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags", +] + +[[package]] +name = "regex" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b" +dependencies = [ + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" + +[[package]] +name = "remove_dir_all" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" +dependencies = [ + "winapi", +] + +[[package]] +name = "reqwest" +version = "0.11.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "431949c384f4e2ae07605ccaa56d1d9d2ecdb5cadd4f9577ccfab29f2e5149fc" +dependencies = [ + "base64", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "hyper", + "hyper-tls", + "ipnet", + "js-sys", + "log", + "mime", + "native-tls", + "once_cell", + "percent-encoding", + "pin-project-lite", + "serde", + "serde_json", + "serde_urlencoded", + "tokio", + "tokio-native-tls", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "winreg", +] + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "ryu" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" + +[[package]] +name = "schannel" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88d6731146462ea25d9244b2ed5fd1d716d25c52e4d54aa4fb0f3c4e9854dbe2" +dependencies = [ + "lazy_static", + "windows-sys 0.36.1", +] + +[[package]] +name = "security-framework" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bc1bb97804af6631813c55739f771071e0f2ed33ee20b68c86ec505d906356c" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0160a13a177a45bfb43ce71c01580998474f556ad854dcbca936dd2841a5c556" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "serde" +version = "1.0.147" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d193d69bae983fc11a79df82342761dfbf28a99fc8d203dca4c3c1b590948965" + +[[package]] +name = "serde_json" +version = "1.0.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce777b7b150d76b9cf60d28b55f5847135a003f7d7350c6be7a773508ce7d45" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha1" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "sha2" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "shlex" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3" + +[[package]] +name = "slab" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" +dependencies = [ + "autocfg", +] + +[[package]] +name = "socket2" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "subtle" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" + +[[package]] +name = "syn" +version = "1.0.103" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a864042229133ada95abf3b54fdc62ef5ccabe9515b64717bcb9a1919e59445d" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "tempfile" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" +dependencies = [ + "cfg-if", + "fastrand", + "libc", + "redox_syscall", + "remove_dir_all", + "winapi", +] + +[[package]] +name = "time" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fab5c8b9980850e06d92ddbe3ab839c062c801f3927c0fb8abd6fc8e918fbca" +dependencies = [ + "itoa", + "libc", + "num_threads", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" + +[[package]] +name = "time-macros" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65bb801831d812c562ae7d2bfb531f26e66e4e1f6b17307ba4149c5064710e5b" +dependencies = [ + "time-core", +] + +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" + +[[package]] +name = "tokio" +version = "1.21.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9e03c497dc955702ba729190dc4aac6f2a0ce97f913e5b1b5912fc5039d9099" +dependencies = [ + "autocfg", + "bytes", + "libc", + "memchr", + "mio", + "pin-project-lite", + "socket2", + "tokio-macros", + "winapi", +] + +[[package]] +name = "tokio-macros" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9724f9a975fb987ef7a3cd9be0350edcbe130698af5b8f7a631e23d42d052484" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tokio-native-tls" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7d995660bd2b7f8c1568414c1126076c13fbb725c40112dc0120b78eb9b717b" +dependencies = [ + "native-tls", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bb2e075f03b3d66d8d8785356224ba688d2906a371015e225beeb65ca92c740" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", + "tracing", +] + +[[package]] +name = "tower-service" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" + +[[package]] +name = "tracing" +version = "0.1.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +dependencies = [ + "cfg-if", + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" +dependencies = [ + "once_cell", +] + +[[package]] +name = "try-lock" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" + +[[package]] +name = "tun" +version = "0.1.0" +dependencies = [ + "anyhow", + "bindgen", + "hex-literal", + "libc", + "libloading", + "nix", + "platforms", + "reqwest", + "sha2", + "socket2", + "tokio", + "widestring", + "zip", +] + +[[package]] +name = "tun-async" +version = "0.1.0" +dependencies = [ + "tun", +] + +[[package]] +name = "typenum" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" + +[[package]] +name = "unicode-bidi" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" + +[[package]] +name = "unicode-ident" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" + +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "url" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "want" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" +dependencies = [ + "log", + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-bindgen" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23639446165ca5a5de86ae1d8896b737ae80319560fbaa4c2887b7da6e7ebd7d" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" + +[[package]] +name = "web-sys" +version = "0.3.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcda906d8be16e728fd5adc5b729afad4e444e106ab28cd1c7256e54fa61510f" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "which" +version = "4.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c831fbbee9e129a8cf93e7747a82da9d95ba8e16621cae60ec2cdc849bacb7b" +dependencies = [ + "either", + "libc", + "once_cell", +] + +[[package]] +name = "widestring" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "653f141f39ec16bba3c5abe400a0c60da7468261cc2cbf36805022876bc721a8" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" +dependencies = [ + "windows_aarch64_msvc 0.36.1", + "windows_i686_gnu 0.36.1", + "windows_i686_msvc 0.36.1", + "windows_x86_64_gnu 0.36.1", + "windows_x86_64_msvc 0.36.1", +] + +[[package]] +name = "windows-sys" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc 0.42.0", + "windows_i686_gnu 0.42.0", + "windows_i686_msvc 0.42.0", + "windows_x86_64_gnu 0.42.0", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc 0.42.0", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4" + +[[package]] +name = "windows_i686_gnu" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7" + +[[package]] +name = "windows_i686_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5" + +[[package]] +name = "winreg" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" +dependencies = [ + "winapi", +] + +[[package]] +name = "zip" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "537ce7411d25e54e8ae21a7ce0b15840e7bfcff15b51d697ec3266cc76bdf080" +dependencies = [ + "aes", + "byteorder", + "bzip2", + "constant_time_eq", + "crc32fast", + "crossbeam-utils", + "flate2", + "hmac", + "pbkdf2", + "sha1", + "time", + "zstd", +] + +[[package]] +name = "zstd" +version = "0.11.2+zstd.1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4" +dependencies = [ + "zstd-safe", +] + +[[package]] +name = "zstd-safe" +version = "5.0.2+zstd.1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d2a5585e04f9eea4b2a3d1eca508c4dee9592a89ef6f450c11719da0726f4db" +dependencies = [ + "libc", + "zstd-sys", +] + +[[package]] +name = "zstd-sys" +version = "2.0.1+zstd.1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fd07cbbc53846d9145dbffdf6dd09a7a0aa52be46741825f5c97bdd4f73f12b" +dependencies = [ + "cc", + "libc", +] diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..8afa305 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,6 @@ +[workspace] +members = [ + "burrow", + "tun-async", + "tun" +] diff --git a/burrow/Cargo.toml b/burrow/Cargo.toml new file mode 100644 index 0000000..ec16981 --- /dev/null +++ b/burrow/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "burrow" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +tokio = { version = "1.21", features = ["rt", "macros"] } +tun = { version = "0.1", path = "../tun" } diff --git a/burrow/src/main.rs b/burrow/src/main.rs new file mode 100644 index 0000000..3d59fd3 --- /dev/null +++ b/burrow/src/main.rs @@ -0,0 +1,14 @@ +use tokio::io::Result; +use tun::TunInterface; + +async fn lol() -> Result<()> { + let iface = TunInterface::new()?; + println!("{:?}", iface.name()); + + Ok(()) +} + +#[tokio::main(flavor = "current_thread")] +async fn main() { + lol().await.unwrap(); +} diff --git a/tun-async/Cargo.toml b/tun-async/Cargo.toml new file mode 100644 index 0000000..e011ca4 --- /dev/null +++ b/tun-async/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "tun-async" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +tun = { version = "0.1", path = "../tun" } diff --git a/tun-async/src/lib.rs b/tun-async/src/lib.rs new file mode 100644 index 0000000..7d12d9a --- /dev/null +++ b/tun-async/src/lib.rs @@ -0,0 +1,14 @@ +pub fn add(left: usize, right: usize) -> usize { + left + right +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn it_works() { + let result = add(2, 2); + assert_eq!(result, 4); + } +} diff --git a/tun/Cargo.toml b/tun/Cargo.toml new file mode 100644 index 0000000..9a6f8fd --- /dev/null +++ b/tun/Cargo.toml @@ -0,0 +1,24 @@ +[package] +name = "tun" +version = "0.1.0" +edition = "2021" + +[dependencies] +libc = "0.2" +nix = { version = "0.25", features = ["ioctl"] } +socket2 = "0.4" +tokio = { version = "1.21", features = [] } + +[target.'cfg(windows)'.dependencies] +libloading = "0.7" +widestring = "1.0" + +[target.'cfg(windows)'.build-dependencies] +anyhow = "1.0" +bindgen = "0.61" +hex-literal = "0.3" +platforms = "3.0" +reqwest = { version = "0.11", features = ["native-tls"] } +sha2 = "0.10" +tokio = { version = "1.21", features = ["rt"] } +zip = { version = "0.6", features = ["deflate"] } diff --git a/tun/build.rs b/tun/build.rs new file mode 100644 index 0000000..47ea9fd --- /dev/null +++ b/tun/build.rs @@ -0,0 +1,79 @@ +#[cfg(windows)] +#[tokio::main(flavor = "current_thread")] +async fn main() -> anyhow::Result<()> { + use std::io::{Cursor, Read}; + + let buf = reqwest::get("https://www.wintun.net/builds/wintun-0.14.1.zip") + .await? + .bytes() + .await?; + assert_content_hash( + &buf, + hex_literal::hex!("07c256185d6ee3652e09fa55c0b673e2624b565e02c4b9091c79ca7d2f24ef51"), + ); + let mut archive = zip::ZipArchive::new(Cursor::new(buf))?; + + let out_dir = std::path::PathBuf::from(std::env::var("OUT_DIR")?); + + let mut header = String::new(); + archive + .by_name("wintun/include/wintun.h")? + .read_to_string(&mut header)?; + header.push_str( + "WINTUN_CLOSE_ADAPTER_FUNC WintunCloseAdapter; + WINTUN_OPEN_ADAPTER_FUNC WintunOpenAdapter; + WINTUN_GET_ADAPTER_LUID_FUNC WintunGetAdapterLUID; + WINTUN_GET_RUNNING_DRIVER_VERSION_FUNC WintunGetRunningDriverVersion; + WINTUN_DELETE_DRIVER_FUNC WintunDeleteDriver; + WINTUN_SET_LOGGER_FUNC WintunSetLogger; + WINTUN_START_SESSION_FUNC WintunStartSession; + WINTUN_END_SESSION_FUNC WintunEndSession; + WINTUN_CREATE_ADAPTER_FUNC WintunCreateAdapter; + WINTUN_GET_READ_WAIT_EVENT_FUNC WintunGetReadWaitEvent; + WINTUN_RECEIVE_PACKET_FUNC WintunReceivePacket; + WINTUN_RELEASE_RECEIVE_PACKET_FUNC WintunReleaseReceivePacket; + WINTUN_ALLOCATE_SEND_PACKET_FUNC WintunAllocateSendPacket; + WINTUN_SEND_PACKET_FUNC WintunSendPacket;", + ); + let bindings = bindgen::Builder::default() + .header_contents("wintun.h", &header) + .allowlist_function("Wintun.*") + .allowlist_type("WINTUN_.*") + .dynamic_library_name("wintun") + .dynamic_link_require_all(true) + .generate() + .unwrap(); + bindings.write_to_file(out_dir.join("wintun.rs"))?; + + let mut library = Vec::new(); + let platform = platforms::Platform::find(&env::var("TARGET")?).unwrap(); + let arch = match platform.target_arch { + platforms::target::Arch::Arm => "arm", + platforms::Arch::AArch64 => "arm64", + platforms::Arch::X86 => "x86", + platforms::Arch::X86_64 => "amd64", + arch => panic!("{} is not a supported architecture", arch), + }; + archive + .by_name(&format!("wintun/bin/{}/wintun.dll", arch))? + .read_to_end(&mut library)?; + std::fs::write(out_dir.join("wintun.dll"), library)?; + + println!("cargo:rerun-if-changed=build.rs"); + + Ok(()) +} + +#[cfg(not(windows))] +fn main() { + println!("cargo:rerun-if-changed=build.rs"); +} + +#[cfg(windows)] +fn assert_content_hash(content: &[u8], hash: [u8; 32]) { + use sha2::digest::Update; + use sha2::Digest; + + let computed = sha2::Sha256::new().chain(content).finalize(); + assert_eq!(computed.as_slice(), &hash[..]); +} diff --git a/tun/src/apple/kern_control.rs b/tun/src/apple/kern_control.rs new file mode 100644 index 0000000..f913fb6 --- /dev/null +++ b/tun/src/apple/kern_control.rs @@ -0,0 +1,53 @@ +use libc::{sockaddr_ctl, AF_SYSTEM, AF_SYS_CONTROL}; +use std::io::Result; +use std::mem::size_of; +use std::os::unix::io::AsRawFd; + +/// Trait to connect to kernel extensions on Apple platforms +/// +/// Pulled from XNU source: https://github.com/apple/darwin-xnu/blob/main/bsd/sys/kern_control.h +pub trait SysControlSocket { + fn resolve(&self, name: &str, index: u32) -> Result; +} + +impl SysControlSocket for socket2::Socket { + fn resolve(&self, name: &str, index: u32) -> Result { + let mut info = sys::ctl_info { + ctl_id: 0, + ctl_name: [0; 96], + }; + info.ctl_name[..name.len()].copy_from_slice(name.as_bytes()); + + unsafe { sys::resolve_ctl_info(self.as_raw_fd(), &mut info as *mut sys::ctl_info)? }; + + let (_, addr) = unsafe { + socket2::SockAddr::init(|addr_storage, len| { + *len = size_of::() as u32; + + let mut addr: &mut sockaddr_ctl = &mut *addr_storage.cast(); + addr.sc_len = *len as u8; + addr.sc_family = AF_SYSTEM as u8; + addr.ss_sysaddr = AF_SYS_CONTROL as u16; + addr.sc_id = info.ctl_id; + addr.sc_unit = index; + Ok(()) + }) + }?; + + Ok(addr) + } +} + +mod sys { + use nix::ioctl_readwrite; + + const MAX_KCTL_NAME: usize = 96; + + #[repr(C)] + pub struct ctl_info { + pub ctl_id: u32, + pub ctl_name: [u8; MAX_KCTL_NAME], + } + + ioctl_readwrite!(resolve_ctl_info, b'N', 3, ctl_info); +} diff --git a/tun/src/apple/mod.rs b/tun/src/apple/mod.rs new file mode 100644 index 0000000..ff78a49 --- /dev/null +++ b/tun/src/apple/mod.rs @@ -0,0 +1,90 @@ +use socket2::SockAddr; +use std::io::Result; +use std::os::unix::io::{AsRawFd, IntoRawFd, RawFd}; + +mod kern_control; +mod queue; + +pub use queue::TunQueue; + +use crate::syscall; +use crate::unix::copy_if_name; +use kern_control::SysControlSocket; + +pub struct TunInterface { + socket: socket2::Socket, +} + +impl TunInterface { + pub fn new() -> Result { + TunInterface::connect(None) + } + + fn connect(addr: Option) -> Result { + use socket2::{Domain, Protocol, Socket, Type}; + + let socket = Socket::new( + Domain::from(libc::AF_SYSTEM), + Type::DGRAM, + Some(Protocol::from(libc::SYSPROTO_CONTROL)), + )?; + let addr = match addr { + Some(addr) => addr, + None => socket.resolve(sys::UTUN_CONTROL_NAME, 0)?, + }; + socket.connect(&addr)?; + + Ok(TunInterface { socket }) + } + + pub fn name(&self) -> Result { + let mut buf = [0u8; libc::IFNAMSIZ]; + let mut len = buf.len() as libc::socklen_t; + syscall!(getsockopt( + self.as_raw_fd(), + libc::SYSPROTO_CONTROL, + sys::UTUN_OPT_IFNAME, + buf.as_mut_ptr() as *mut libc::c_void, + &mut len, + ))?; + let name = copy_if_name(buf); + Ok(name) + } + + pub fn queue(&self) -> Result { + todo!() + } +} + +impl AsRawFd for TunInterface { + fn as_raw_fd(&self) -> RawFd { + self.socket.as_raw_fd() + } +} + +impl IntoRawFd for TunInterface { + fn into_raw_fd(self) -> RawFd { + self.socket.into_raw_fd() + } +} + +mod sys { + pub const UTUN_CONTROL_NAME: &str = "com.apple.net.utun_control"; + + pub const UTUN_OPT_IFNAME: libc::c_int = 2; + + /// Copied from https://github.com/rust-lang/socket2/blob/61314a231f73964b3db969ef72c0e9479df320f3/src/sys/unix.rs#L168-L178 + /// getsockopt is not exposed by socket2 + #[macro_export] + macro_rules! syscall { + ($fn: ident ( $($arg: expr),* $(,)* ) ) => {{ + #[allow(unused_unsafe)] + let res = unsafe { libc::$fn($($arg, )*) }; + if res == -1 { + Err(std::io::Error::last_os_error()) + } else { + Ok(res) + } + }}; + } +} diff --git a/tun/src/apple/queue.rs b/tun/src/apple/queue.rs new file mode 100644 index 0000000..fdc23b6 --- /dev/null +++ b/tun/src/apple/queue.rs @@ -0,0 +1,17 @@ +use std::os::unix::io::{AsRawFd, IntoRawFd, RawFd}; + +pub struct TunQueue { + socket: socket2::Socket, +} + +impl AsRawFd for TunQueue { + fn as_raw_fd(&self) -> RawFd { + self.socket.as_raw_fd() + } +} + +impl IntoRawFd for TunQueue { + fn into_raw_fd(self) -> RawFd { + self.socket.into_raw_fd() + } +} diff --git a/tun/src/lib.rs b/tun/src/lib.rs new file mode 100644 index 0000000..7082e2d --- /dev/null +++ b/tun/src/lib.rs @@ -0,0 +1,16 @@ +#[cfg(target_vendor = "apple")] +#[path = "apple/mod.rs"] +mod imp; + +#[cfg(target_os = "linux")] +#[path = "linux.rs"] +mod imp; + +#[cfg(target_os = "windows")] +#[path = "windows/mod.rs"] +mod imp; + +#[cfg(any(target_os = "linux", target_vendor = "apple"))] +pub(crate) mod unix; + +pub use imp::{TunInterface, TunQueue}; diff --git a/tun/src/linux.rs b/tun/src/linux.rs new file mode 100644 index 0000000..93a341e --- /dev/null +++ b/tun/src/linux.rs @@ -0,0 +1,56 @@ +use std::fs::OpenOptions; +use std::io::Result; +use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd}; + +use crate::unix::copy_if_name; + +pub struct TunInterface { + inner: socket2::Socket, +} + +impl TunInterface { + pub fn new() -> Result { + let file = OpenOptions::new() + .read(true) + .write(true) + .open("/dev/net/tun")?; + + let mut iff = libc::ifreq { + ifr_name: [0; libc::IFNAMSIZ], + ifr_ifru: libc::__c_anonymous_ifr_ifru { + ifru_flags: (libc::IFF_TUN | libc::IFF_TUN_EXCL | libc::IFF_NO_PI) as i16, + }, + }; + unsafe { sys::tun_set_iff(file.as_raw_fd(), &mut iff)? }; + + let inner = unsafe { socket2::Socket::from_raw_fd(file.into_raw_fd()) }; + Ok(TunInterface { inner }) + } + + pub fn name(&self) -> Result { + let mut iff = libc::ifreq { + ifr_name: [0; libc::IFNAMSIZ], + ifr_ifru: libc::__c_anonymous_ifr_ifru { ifru_flags: 0 }, + }; + unsafe { sys::tun_get_iff(self.inner.as_raw_fd(), &mut iff)? }; + + let name = copy_if_name(iff.ifr_name); + Ok(name) + } +} + +mod sys { + use nix::{ioctl_read_bad, ioctl_write_ptr_bad, request_code_read, request_code_write}; + use std::mem::size_of; + + ioctl_write_ptr_bad!( + tun_set_iff, + request_code_write!(b'T', 202, size_of::()), + libc::ifreq + ); + ioctl_read_bad!( + tun_get_iff, + request_code_read!(b'T', 210, size_of::()), + libc::ifreq + ); +} diff --git a/tun/src/queue.rs b/tun/src/queue.rs new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tun/src/queue.rs @@ -0,0 +1 @@ + diff --git a/tun/src/unix.rs b/tun/src/unix.rs new file mode 100644 index 0000000..b598c62 --- /dev/null +++ b/tun/src/unix.rs @@ -0,0 +1,11 @@ +use std::ffi::CStr; + +pub fn copy_if_name(buf: [u8; libc::IFNAMSIZ]) -> String { + // TODO: Switch to `CStr::from_bytes_until_nul` when stabilized + unsafe { + CStr::from_ptr(buf.as_ptr() as *const _) + .to_str() + .unwrap() + .to_string() + } +} diff --git a/tun/src/windows/mod.rs b/tun/src/windows/mod.rs new file mode 100644 index 0000000..2d01db3 --- /dev/null +++ b/tun/src/windows/mod.rs @@ -0,0 +1,44 @@ +use std::io::Result; +use std::ptr; +use widestring::{u16cstr, U16CString}; + +pub struct TunInterface { + wintun: sys::wintun, + handle: sys::WINTUN_ADAPTER_HANDLE, + name: String, +} + +impl TunInterface { + pub fn new() -> Result { + let name = U16CString::from(u16cstr!("ConradNet")); + let wintun = sys::wintun::default(); + let handle = + unsafe { wintun.WintunCreateAdapter(name.as_ptr(), name.as_ptr(), ptr::null()) }; + Ok(TunInterface { + wintun, + handle, + name: String::from("ConradNet"), + }) + } + + pub fn name(&self) -> String { + self.name.clone() + } +} + +impl Drop for TunInterface { + fn drop(&mut self) { + unsafe { self.wintun.WintunCloseAdapter(self.handle) } + } +} + +pub(crate) mod sys { + #![allow(dead_code, non_camel_case_types, non_snake_case)] + include!(concat!(env!("OUT_DIR"), "/wintun.rs")); + + impl Default for wintun { + fn default() -> Self { + unsafe { wintun::new(format!("{}/wintun.dll", env!("OUT_DIR"))).unwrap() } + } + } +} diff --git a/tun/src/windows/queue.rs b/tun/src/windows/queue.rs new file mode 100644 index 0000000..7eccd50 --- /dev/null +++ b/tun/src/windows/queue.rs @@ -0,0 +1,19 @@ +use crate::TunInterface; +use std::os::unix::io::{AsRawFd, IntoRawFd, RawFd}; + +pub struct TunQueue { + inner: crate::windows::sys:: + inner: socket2::Socket, +} + +impl AsRawFd for TunQueue { + fn as_raw_fd(&self) -> RawFd { + self.socket.as_raw_fd() + } +} + +impl IntoRawFd for TunQueue { + fn into_raw_fd(self) -> RawFd { + self.socket.into_raw_fd() + } +}