Skip to content

Add async tun/tap device abstractions, use them in onion-tunnel

eta requested to merge eta/onionmasq:async-device into main

This adds https://gitlab.torproject.org/eta/onionmasq-device-testing to the repo via git subtree import, and uses it in onion-tunnel. See the commit messages for more information:

    Add 'crates/onionmasq-device-testing/' from commit '8b01a295e7822763b681841b5d6edef1dcf8d5f7'
    
    This new crate provides a smoltcp Device abstraction that lets you use
    smoltcp with something that implements `AsyncRead` and `AsyncWrite`.
    To use, create a new `AsyncDevice` and poll the returned
    `PollableAsyncDevice` as described in the documentation.
    
    This does a git subtree import of
    https://gitlab.torproject.org/eta/onionmasq-device-testing, together
    with fixing up some small things (like making it part of the workspace,
    and adding an ignore file).
    onion-tunnel: add async tun/tap interface type
    
    This is basically a wrapper around a file descriptor that calls
    libc::read()/::write() accordingly, and has some utility functions to
    create one using the smoltcp crate.
    
    Since it also provides a method to make a new interface without
    modifying the fd in any way (e.g. calling `ioctl`), we should be able to
    use that for Android.
    onion-tunnel: use new AsyncDevice abstraction
    
    The old not-really-async code in `OnionTunnel` is now replaced with code
    using the new `AsyncDevice` and `AsyncTunTapInterface` types, making it
    20% less hacky. This should also enable android to actually work, but I
    haven't tested that yet. (It does seem to work on Linux though.)

fixes #13 (closed), #12 (closed)

Things to fix before merging

  • the default log level is seemingly TRACE and that's way too much spew
  • the MTU is currently hardcoded to 1500; we'll want the jni layer to specify that or something
  • some of the code is a bit ugly
  • arguably we don't need dgoulet's fork of smoltcp any more
  • the warn! spew about the poll guard actually fires
Edited by Alexander Hansen Færøy

Merge request reports

Loading