Skip to content

Tokio v1 #14

New issue

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

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

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Tokio v1 #14

wants to merge 6 commits into from

Conversation

mrdxxm
Copy link

@mrdxxm mrdxxm commented Nov 12, 2023

Issue #13

This is pretty big changes to async part of API and I'm noob in tokio infrastructure, so it's definitely needs a picky review and further testing.

I tested it only in devcontainer on aarch64 so long.

VPN example turned out to be tricky to adapt, so I'll do it later.

MSRV changed to 1.60 because of 'version-sink' crate.

TODO:

  • update vpn example
  • improve docs
  • async integration tests
  • more examples

@mrdxxm mrdxxm mentioned this pull request Nov 12, 2023
Copy link
Owner

@vorner vorner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at it, I believe the AsyncRead/AsyncWrite traits are the wrong kind of abstraction for this thing…

libc = { version = "~0.2", optional = true }
mio = { version = "~0.6", optional = true }
tokio-core = { version = "~0.1", optional = true }
tokio = {version = "~1.29", features = ["io-util", "net"], optional = true }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that 1.29 minimal version needed? What's the feature that is not in the lower ones?

@@ -0,0 +1,33 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I like this thing in here… this seems to be one of the things that every developer likes to have different.

@@ -37,6 +37,9 @@ sh tests/clean.sh

Sudo permission is required.

## MSRV
The current MSRV(minimum supported rust version) is 1.60.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think a 0.1 crate needs to specify/hold itself to some specific MSRV or even specify it 😇. Specifically, I'm not sure if anyone in future changes will take the care to update it.


use futures::{Future, Stream};
use tokio_core::reactor::{Core, Interval};
use tun_tap::r#async::Async;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style nitpick. It looks a bit strange to intermix blocks of "std" imports with blocks of "foreign". My own personal preference is to have 3 blocks (std, foreign, internal), but I'm flexible in the order of these… and I try to keep each separate block sorted.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, as async is now a keyword, and you seem to have modified the API anyway, it would be a good time to think of a better name.

},
Err(ref e) if e.kind() == ErrorKind::WouldBlock => Ok(FAsync::NotReady),
Err(e) => Err(e),
impl AsyncRead for Async {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid implementing AsyncRead/AsyncWrite for a pcap interface is conceptually wrong. These trains are for things that streams of bytes without being split into messages.

The pcap interface is more message oriented ‒ more like a UdpSocket, where message boundaries have a meaning. Exposing interface like this could lead to weird hard to reproduce bugs where sometimes some kind of buffer is accidentally split into two messages or two messages joined into one buffer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants