Skip to content

在android下运行tun遇到的问题 #856

Closed
@dev4u

Description

@dev4u

本来想试试能不能用tun来替换ss android下的tun2socks,但是没办法编译通过。

cargo {
    module = "src/main/rust/shadowsocks-rust"
    libname = "sslocal"
    targets = listOf("arm64")
    profile = findProperty("CARGO_PROFILE")?.toString() ?: currentFlavor
    extraCargoBuildArguments = listOf("--bin", libname!!)
    featureSpec.noDefaultBut(arrayOf(
        "stream-cipher",
        "aead-cipher-extra",
        "logging",
        "local-flow-stat",
        "local-dns",
        "local-tun",
        "armv8",
        "neon",
        "aead-cipher-2022",
    ))
    exec = { spec, toolchain ->
        spec.environment("RUST_ANDROID_GRADLE_PYTHON_COMMAND", "python3")
        spec.environment("RUST_ANDROID_GRADLE_LINKER_WRAPPER_PY", "$projectDir/$module/../linker-wrapper.py")
        spec.environment("RUST_ANDROID_GRADLE_TARGET", "target/${toolchain.target}/$profile/lib$libname.so")
    }
}
   Compiling tun v0.5.3
error[E0433]: failed to resolve: use of undeclared crate or module `tokio`
  --> /Users/.cargo/registry/src/github.com-1ecc6299db9ec823/tun-0.5.3/src/async/device.rs:21:5
   |
21 | use tokio::io::unix::AsyncFd;
   |     ^^^^^ use of undeclared crate or module `tokio`

error[E0433]: failed to resolve: use of undeclared crate or module `tokio`
  --> /Users/.cargo/registry/src/github.com-1ecc6299db9ec823/tun-0.5.3/src/async/device.rs:22:5
   |
22 | use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
   |     ^^^^^ use of undeclared crate or module `tokio`

error[E0433]: failed to resolve: use of undeclared crate or module `tokio_util`
  --> /Users/.cargo/registry/src/github.com-1ecc6299db9ec823/tun-0.5.3/src/async/device.rs:23:5
   |
23 | use tokio_util::codec::Framed;
   |     ^^^^^^^^^^ use of undeclared crate or module `tokio_util`

error[E0432]: unresolved import `futures_core`
  --> /Users/.cargo/registry/src/github.com-1ecc6299db9ec823/tun-0.5.3/src/async/device.rs:20:5
   |
20 | use futures_core::ready;
   |     ^^^^^^^^^^^^ use of undeclared crate or module `futures_core`

error[E0432]: unresolved import `byteorder`
  --> /Users/.cargo/registry/src/github.com-1ecc6299db9ec823/tun-0.5.3/src/async/codec.rs:17:5
   |
17 | use byteorder::{NativeEndian, NetworkEndian, WriteBytesExt};
   |     ^^^^^^^^^ use of undeclared crate or module `byteorder`

error[E0433]: failed to resolve: use of undeclared crate or module `tokio_util`
  --> /Users/.cargo/registry/src/github.com-1ecc6299db9ec823/tun-0.5.3/src/async/codec.rs:19:5
   |
19 | use tokio_util::codec::{Decoder, Encoder};
   |     ^^^^^^^^^^ use of undeclared crate or module `tokio_util`

error[E0432]: unresolved import `bytes`
  --> /Users/.cargo/registry/src/github.com-1ecc6299db9ec823/tun-0.5.3/src/async/codec.rs:18:5
   |
18 | use bytes::{BufMut, Bytes, BytesMut};
   |     ^^^^^ use of undeclared crate or module `bytes`

error: cannot determine resolution for the macro `ready`
  --> /Users/.cargo/registry/src/github.com-1ecc6299db9ec823/tun-0.5.3/src/async/device.rs:67:29
   |
cannot determine resolution for the macro `ready`

67 |             let mut guard = ready!(self.inner.poll_read_ready_mut(cx))?;
   |                             ^^^^^
   |
   = note: import resolution is stuck, try simplifying macro imports

error: cannot determine resolution for the macro `ready`
  --> /Users/.cargo/registry/src/github.com-1ecc6299db9ec823/tun-0.5.3/src/async/device.rs:84:29
   |
84 |             let mut guard = ready!(self.inner.poll_write_ready_mut(cx))?;
   |                             ^^^^^
   |
   = note: import resolution is stuck, try simplifying macro imports

error: cannot determine resolution for the macro `ready`
  --> /Users/.cargo/registry/src/github.com-1ecc6299db9ec823/tun-0.5.3/src/async/device.rs:94:29
   |
94 |             let mut guard = ready!(self.inner.poll_write_ready_mut(cx))?;
   |                             ^^^^^
   |
   = note: import resolution is stuck, try simplifying macro imports

error: cannot determine resolution for the macro `ready`
   --> /Users/.cargo/registry/src/github.com-1ecc6299db9ec823/tun-0.5.3/src/async/device.rs:112:29
    |
112 |             let mut guard = ready!(self.inner.poll_write_ready_mut(cx))?;
    |                             ^^^^^
    |
    = note: import resolution is stuck, try simplifying macro imports

error: cannot determine resolution for the macro `ready`
   --> /Users/.cargo/registry/src/github.com-1ecc6299db9ec823/tun-0.5.3/src/async/device.rs:163:29
    |
163 |             let mut guard = ready!(self.inner.poll_read_ready_mut(cx))?;
    |                             ^^^^^
    |
    = note: import resolution is stuck, try simplifying macro imports

error: cannot determine resolution for the macro `ready`
   --> /Users/.cargo/registry/src/github.com-1ecc6299db9ec823/tun-0.5.3/src/async/device.rs:180:29
    |
180 |             let mut guard = ready!(self.inner.poll_write_ready_mut(cx))?;
    |                             ^^^^^
    |
    = note: import resolution is stuck, try simplifying macro imports

error: cannot determine resolution for the macro `ready`
   --> /Users/.cargo/registry/src/github.com-1ecc6299db9ec823/tun-0.5.3/src/async/device.rs:190:29
    |
190 |             let mut guard = ready!(self.inner.poll_write_ready_mut(cx))?;
    |                             ^^^^^
    |
    = note: import resolution is stuck, try simplifying macro imports

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions