Compare commits

..

27 commits

Author SHA1 Message Date
3ca5ae2181
Merge pull request #85 from aramperes/dependabot/cargo/async-trait-0.1.87
build(deps): bump async-trait from 0.1.83 to 0.1.87
2025-03-10 23:32:19 -04:00
ac83ddbd4d
Merge pull request #86 from aramperes/dependabot/cargo/anyhow-1.0.97
build(deps): bump anyhow from 1.0.94 to 1.0.97
2025-03-10 23:32:12 -04:00
17f424140d
Merge pull request #87 from aramperes/dependabot/cargo/tokio-1.44.0
build(deps): bump tokio from 1.42.0 to 1.44.0
2025-03-10 23:31:55 -04:00
dependabot[bot]
8030ca1a2d
build(deps): bump tokio from 1.42.0 to 1.44.0
Bumps [tokio](https://github.com/tokio-rs/tokio) from 1.42.0 to 1.44.0.
- [Release notes](https://github.com/tokio-rs/tokio/releases)
- [Commits](https://github.com/tokio-rs/tokio/compare/tokio-1.42.0...tokio-1.44.0)

---
updated-dependencies:
- dependency-name: tokio
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-03-10 16:58:22 +00:00
dependabot[bot]
7eddf3f17f
build(deps): bump anyhow from 1.0.94 to 1.0.97
Bumps [anyhow](https://github.com/dtolnay/anyhow) from 1.0.94 to 1.0.97.
- [Release notes](https://github.com/dtolnay/anyhow/releases)
- [Commits](https://github.com/dtolnay/anyhow/compare/1.0.94...1.0.97)

---
updated-dependencies:
- dependency-name: anyhow
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-03-03 16:47:17 +00:00
dependabot[bot]
bcfa43702a
build(deps): bump async-trait from 0.1.83 to 0.1.87
Bumps [async-trait](https://github.com/dtolnay/async-trait) from 0.1.83 to 0.1.87.
- [Release notes](https://github.com/dtolnay/async-trait/releases)
- [Commits](https://github.com/dtolnay/async-trait/compare/0.1.83...0.1.87)

---
updated-dependencies:
- dependency-name: async-trait
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-03-03 16:47:00 +00:00
d0fcab38c3 docs: update README and LICENSE 2025-01-25 21:45:38 -05:00
c83c9ec500
Merge pull request #67 from aramperes/dependabot/cargo/priority-queue-2.1.1 2024-12-11 19:56:22 -05:00
caadd415cd
Merge pull request #68 from aramperes/dependabot/cargo/pretty_env_logger-0.5.0 2024-12-11 19:55:18 -05:00
3a89f2877d
Merge pull request #69 from aramperes/dependabot/cargo/anyhow-1.0.94 2024-12-11 19:54:56 -05:00
341849762c
Merge pull request #70 from aramperes/dependabot/cargo/tokio-1.42.0 2024-12-11 19:54:32 -05:00
dependabot[bot]
57e6ddc74c
Bump tokio from 1.41.1 to 1.42.0
Bumps [tokio](https://github.com/tokio-rs/tokio) from 1.41.1 to 1.42.0.
- [Release notes](https://github.com/tokio-rs/tokio/releases)
- [Commits](https://github.com/tokio-rs/tokio/compare/tokio-1.41.1...tokio-1.42.0)

---
updated-dependencies:
- dependency-name: tokio
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-12-09 17:28:44 +00:00
dependabot[bot]
08d99b9d22
Bump anyhow from 1.0.93 to 1.0.94
Bumps [anyhow](https://github.com/dtolnay/anyhow) from 1.0.93 to 1.0.94.
- [Release notes](https://github.com/dtolnay/anyhow/releases)
- [Commits](https://github.com/dtolnay/anyhow/compare/1.0.93...1.0.94)

---
updated-dependencies:
- dependency-name: anyhow
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-12-09 17:28:37 +00:00
dependabot[bot]
2661a2d29f
Bump pretty_env_logger from 0.4.0 to 0.5.0
Bumps [pretty_env_logger](https://github.com/seanmonstar/pretty-env-logger) from 0.4.0 to 0.5.0.
- [Commits](https://github.com/seanmonstar/pretty-env-logger/compare/v0.4.0...v0.5.0)

---
updated-dependencies:
- dependency-name: pretty_env_logger
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-12-02 03:38:35 +00:00
dependabot[bot]
6722237902
Bump priority-queue from 1.4.0 to 2.1.1
Bumps [priority-queue](https://github.com/garro95/priority-queue) from 1.4.0 to 2.1.1.
- [Release notes](https://github.com/garro95/priority-queue/releases)
- [Commits](https://github.com/garro95/priority-queue/commits/2.1.1)

---
updated-dependencies:
- dependency-name: priority-queue
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-12-02 03:38:32 +00:00
83ef02c695
Create dependabot.yml 2024-12-01 22:37:33 -05:00
89c3b59610 fix: typo 2024-12-01 16:03:32 -05:00
c6544cfe05 fix: assume path is target 2024-12-01 16:01:27 -05:00
f75909fd8f fix: expected output location in release 2024-12-01 15:56:37 -05:00
52d1d589ac use cross to cross-build 2024-12-01 15:45:25 -05:00
eb9c0be437 force cargo build with target 2024-12-01 15:39:16 -05:00
d307a11819 release: v0.3.10 2024-12-01 15:33:13 -05:00
c4c52babae
Merge pull request #65 from aramperes/smoltcp-0.12 2024-12-01 15:31:03 -05:00
6b2f6148c6 chore: add linux-aarch64 build 2024-12-01 15:29:59 -05:00
991eef0311 chore: update MSRV to 1.80.0 2024-12-01 15:27:12 -05:00
0e93a6435a chore: udpate to smoltcp 0.12 2024-12-01 15:22:37 -05:00
ca3590a4c0 chore: bump minor dependencies 2024-12-01 15:13:46 -05:00
11 changed files with 361 additions and 386 deletions

10
.github/dependabot.yml vendored Normal file
View file

@ -0,0 +1,10 @@
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
- package-ecosystem: "cargo"
directory: "/"
schedule:
interval: "weekly"
rebase-strategy: "disabled"

View file

@ -10,7 +10,7 @@ jobs:
matrix: matrix:
rust: rust:
- stable - stable
- 1.78.0 - 1.80.0
steps: steps:
- name: Checkout sources - name: Checkout sources
uses: actions/checkout@v2 uses: actions/checkout@v2
@ -39,7 +39,7 @@ jobs:
matrix: matrix:
rust: rust:
- stable - stable
- 1.78.0 - 1.80.0
steps: steps:
- name: Checkout sources - name: Checkout sources
uses: actions/checkout@v2 uses: actions/checkout@v2

View file

@ -75,20 +75,28 @@ jobs:
RUST_BACKTRACE: 1 RUST_BACKTRACE: 1
strategy: strategy:
matrix: matrix:
build: [ linux-amd64, macos-aarch64, windows ] build: [ linux-amd64, linux-aarch64, macos-aarch64, windows ]
include: include:
- build: linux-amd64 - build: linux-amd64
os: ubuntu-latest os: ubuntu-latest
rust: stable rust: stable
target: x86_64-unknown-linux-musl target: x86_64-unknown-linux-musl
cross: true
- build: linux-aarch64
os: ubuntu-latest
rust: stable
target: aarch64-unknown-linux-musl
cross: true
- build: macos-aarch64 - build: macos-aarch64
os: macos-latest os: macos-latest
rust: stable rust: stable
target: aarch64-apple-darwin target: aarch64-apple-darwin
cross: false
- build: windows - build: windows
os: windows-2019 os: windows-2019
rust: stable rust: stable
target: x86_64-pc-windows-msvc target: x86_64-pc-windows-msvc
cross: false
steps: steps:
- name: Checkout repository - name: Checkout repository
@ -126,17 +134,24 @@ jobs:
echo "release upload url: $release_upload_url" echo "release upload url: $release_upload_url"
- name: Build onetun binary - name: Build onetun binary
run: cargo build --release shell: bash
run: |
if [ "${{ matrix.cross }}" = "true" ]; then
cargo install cross
cross build --release --target ${{ matrix.target }}
else
cargo build --release --target ${{ matrix.target }}
fi
- name: Prepare onetun binary - name: Prepare onetun binary
shell: bash shell: bash
run: | run: |
mkdir -p ci/assets mkdir -p ci/assets
if [ "${{ matrix.build }}" = "windows" ]; then if [ "${{ matrix.build }}" = "windows" ]; then
cp "target/release/onetun.exe" "ci/assets/onetun.exe" cp "target/${{ matrix.target }}/release/onetun.exe" "ci/assets/onetun.exe"
echo "ASSET=onetun.exe" >> $GITHUB_ENV echo "ASSET=onetun.exe" >> $GITHUB_ENV
else else
cp "target/release/onetun" "ci/assets/onetun-${{ matrix.build }}" cp "target/${{ matrix.target }}/release/onetun" "ci/assets/onetun-${{ matrix.build }}"
echo "ASSET=onetun-${{ matrix.build }}" >> $GITHUB_ENV echo "ASSET=onetun-${{ matrix.build }}" >> $GITHUB_ENV
fi fi

674
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
[package] [package]
name = "onetun" name = "onetun"
version = "0.3.9" version = "0.3.10"
edition = "2021" edition = "2021"
license = "MIT" license = "MIT"
description = "A cross-platform, user-space WireGuard port-forwarder that requires no system network configurations." description = "A cross-platform, user-space WireGuard port-forwarder that requires no system network configurations."
@ -19,8 +19,8 @@ futures = "0.3"
rand = "0.8" rand = "0.8"
nom = "7" nom = "7"
async-trait = "0.1" async-trait = "0.1"
priority-queue = "1.3" priority-queue = "2.1"
smoltcp = { version = "0.11", default-features = false, features = [ smoltcp = { version = "0.12", default-features = false, features = [
"std", "std",
"log", "log",
"medium-ip", "medium-ip",
@ -37,7 +37,7 @@ tracing = { version = "0.1", default-features = false, features = ["log"] }
# bin-only dependencies # bin-only dependencies
clap = { version = "4.4.11", default-features = false, features = ["suggestions", "std", "env", "help", "wrap_help"], optional = true } clap = { version = "4.4.11", default-features = false, features = ["suggestions", "std", "env", "help", "wrap_help"], optional = true }
pretty_env_logger = { version = "0.4", optional = true } pretty_env_logger = { version = "0.5", optional = true }
async-recursion = "1.0" async-recursion = "1.0"
[features] [features]

View file

@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2023 Aram Peres Copyright (c) 2025 Aram Peres
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View file

@ -21,13 +21,13 @@ For example,
## Download ## Download
onetun is available to install from [crates.io](https://crates.io/crates/onetun) with Rust ≥1.78.0: onetun is available to install from [crates.io](https://crates.io/crates/onetun) with Rust ≥1.80.0:
```shell ```shell
cargo install onetun cargo install onetun
``` ```
You can also download the binary for Windows, macOS (Intel), and Linux (amd64) from You can also download the binary for Windows, macOS (Apple Silicon), and Linux (amd64, arm64) from
the [Releases](https://github.com/aramperes/onetun/releases) page. the [Releases](https://github.com/aramperes/onetun/releases) page.
You can also run onetun using [Docker](https://hub.docker.com/r/aramperes/onetun): You can also run onetun using [Docker](https://hub.docker.com/r/aramperes/onetun):
@ -37,7 +37,7 @@ docker run --rm --name onetun --user 1000 -p 8080:8080 aramperes/onetun \
0.0.0.0:8080:192.168.4.2:8080 [...options...] 0.0.0.0:8080:192.168.4.2:8080 [...options...]
``` ```
You can also build onetun locally, using Rust ≥1.78.0: You can also build onetun locally, using Rust ≥1.80.0:
```shell ```shell
git clone https://github.com/aramperes/onetun && cd onetun git clone https://github.com/aramperes/onetun && cd onetun
@ -319,4 +319,4 @@ Please consider opening a GitHub issue if you are unsure if your contribution is
## License ## License
MIT License. See `LICENSE` for details. Copyright &copy; 2023 Aram Peres. MIT License. See `LICENSE` for details. Copyright &copy; 2025 Aram Peres.

View file

@ -109,11 +109,11 @@ pub struct RxToken {
} }
impl smoltcp::phy::RxToken for RxToken { impl smoltcp::phy::RxToken for RxToken {
fn consume<R, F>(mut self, f: F) -> R fn consume<R, F>(self, f: F) -> R
where where
F: FnOnce(&mut [u8]) -> R, F: FnOnce(&[u8]) -> R,
{ {
f(&mut self.buffer) f(&self.buffer)
} }
} }

View file

@ -6,6 +6,7 @@ use crate::Bus;
use anyhow::Context; use anyhow::Context;
use async_trait::async_trait; use async_trait::async_trait;
use bytes::Bytes; use bytes::Bytes;
use smoltcp::iface::PollResult;
use smoltcp::{ use smoltcp::{
iface::{Config, Interface, SocketHandle, SocketSet}, iface::{Config, Interface, SocketHandle, SocketSet},
socket::tcp, socket::tcp,
@ -141,7 +142,7 @@ impl VirtualInterfacePoll for TcpVirtualInterface {
} }
}); });
if iface.poll(loop_start, &mut device, &mut self.sockets) { if iface.poll(loop_start, &mut device, &mut self.sockets) == PollResult::SocketStateChanged {
log::trace!("TCP virtual interface polled some packets to be processed"); log::trace!("TCP virtual interface polled some packets to be processed");
} }

View file

@ -6,6 +6,7 @@ use crate::{Bus, PortProtocol};
use anyhow::Context; use anyhow::Context;
use async_trait::async_trait; use async_trait::async_trait;
use bytes::Bytes; use bytes::Bytes;
use smoltcp::iface::PollResult;
use smoltcp::{ use smoltcp::{
iface::{Config, Interface, SocketHandle, SocketSet}, iface::{Config, Interface, SocketHandle, SocketSet},
socket::udp::{self, UdpMetadata}, socket::udp::{self, UdpMetadata},
@ -140,7 +141,7 @@ impl VirtualInterfacePoll for UdpVirtualInterface {
} => { } => {
let loop_start = smoltcp::time::Instant::now(); let loop_start = smoltcp::time::Instant::now();
if iface.poll(loop_start, &mut device, &mut self.sockets) { if iface.poll(loop_start, &mut device, &mut self.sockets) == PollResult::SocketStateChanged {
log::trace!("UDP virtual interface polled some packets to be processed"); log::trace!("UDP virtual interface polled some packets to be processed");
} }

View file

@ -1,4 +1,4 @@
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr}; use std::net::{IpAddr, SocketAddr};
use std::time::Duration; use std::time::Duration;
use crate::Bus; use crate::Bus;
@ -253,7 +253,7 @@ impl WireGuardTunnel {
Ok(IpVersion::Ipv4) => Ipv4Packet::new_checked(&packet) Ok(IpVersion::Ipv4) => Ipv4Packet::new_checked(&packet)
.ok() .ok()
// Only care if the packet is destined for this tunnel // Only care if the packet is destined for this tunnel
.filter(|packet| Ipv4Addr::from(packet.dst_addr()) == self.source_peer_ip) .filter(|packet| packet.dst_addr() == self.source_peer_ip)
.and_then(|packet| match packet.next_header() { .and_then(|packet| match packet.next_header() {
IpProtocol::Tcp => Some(PortProtocol::Tcp), IpProtocol::Tcp => Some(PortProtocol::Tcp),
IpProtocol::Udp => Some(PortProtocol::Udp), IpProtocol::Udp => Some(PortProtocol::Udp),
@ -263,7 +263,7 @@ impl WireGuardTunnel {
Ok(IpVersion::Ipv6) => Ipv6Packet::new_checked(&packet) Ok(IpVersion::Ipv6) => Ipv6Packet::new_checked(&packet)
.ok() .ok()
// Only care if the packet is destined for this tunnel // Only care if the packet is destined for this tunnel
.filter(|packet| Ipv6Addr::from(packet.dst_addr()) == self.source_peer_ip) .filter(|packet| packet.dst_addr() == self.source_peer_ip)
.and_then(|packet| match packet.next_header() { .and_then(|packet| match packet.next_header() {
IpProtocol::Tcp => Some(PortProtocol::Tcp), IpProtocol::Tcp => Some(PortProtocol::Tcp),
IpProtocol::Udp => Some(PortProtocol::Udp), IpProtocol::Udp => Some(PortProtocol::Udp),