Skip to content

Commit

Permalink
Rewrite to use custom udp routing & dispatch, bump to v1.0.0
Browse files Browse the repository at this point in the history
- Remove `udp_stream` dependency
- Rewrite to use custom udp adresses translation and dispatch system.
- Add `first` parameter to obfuscation
- Rename `servers.proxy` -> `servers.relay`
- Rename `servers.downstream` -> `servers.upstream`
  • Loading branch information
mrsobakin committed Jul 16, 2024
1 parent 5f00625 commit 5ac4f6c
Show file tree
Hide file tree
Showing 7 changed files with 221 additions and 133 deletions.
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
[package]
name = "dpimyass"
version = "0.3.0"
version = "1.0.0"
edition = "2021"

[dependencies]
tokio = { version = "1", features = ["full"] }
serde = { version = "1", features = ["derive"] }
serde_with = "3.5.0"
toml = "0.8"
udp-stream = "0.0.10"
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM rustlang/rust:nightly-slim AS builder
FROM rust:1.79.0-slim AS builder
WORKDIR /build
COPY . .
RUN rustup target add x86_64-unknown-linux-musl
Expand Down
2 changes: 1 addition & 1 deletion PKGBUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pkgname=dpimyass
pkgver=0.3.0
pkgver=1.0.0
pkgrel=1
pkgdesc="Simple UDP proxy for bypassing the DPI"
arch=('x86_64')
Expand Down
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,28 +49,29 @@ DPIMyAss uses a TOML configuration file to specify its settings. Below is an exa
name = "Example bridge"
key = [239, 42, 13, 69]

[servers.proxy]
[servers.relay]
address = "0.0.0.0:1337"
buffer = 16384
buffer = 65536
timeout = 60

[servers.downstream]
[servers.upstream]
address = "example.com:1337"
buffer = 16384
buffer = 65536
timeout = 60

[[servers]]
name = "Another bridge"
key = [4, 5, 11]
first = 64 # Obfuscate only the first 64 bytes

[servers.proxy]
[servers.relay]
address = "0.0.0.0:1338"
buffer = 16384
buffer = 65536
timeout = 120

[servers.downstream]
[servers.upstream]
address = "endpoint2.exmaple.com:443"
buffer = 16384
buffer = 65536
timeout = 120
```

Expand All @@ -79,9 +80,9 @@ You might encounter a problem when trying to use VPN over DPIMyAss hosted on the

### Wireguard-specific solution

If your downstream address falls inside the ips listed in wireguard's `AllowedIPs`, the packets DPIMyAss sends will be routed over VPN too, and thus they will be stuck in a network loop.
If your upstream address falls inside the ips listed in wireguard's `AllowedIPs`, the packets DPIMyAss sends will be routed over VPN too, and thus they will be stuck in a network loop.

The simplest way to fix this is to exclude your downstream endpoint ip address from the wireguard's `AllowedIPs`. This can be done with any wireguard allowed ips calculator, for example with [this one](https://www.procustodibus.com/blog/2021/03/wireguard-allowedips-calculator/).
The simplest way to fix this is to exclude your upstream endpoint ip address from the wireguard's `AllowedIPs`. This can be done with any wireguard allowed ips calculator, for example with [this one](https://www.procustodibus.com/blog/2021/03/wireguard-allowedips-calculator/).


### Windows
Expand Down
17 changes: 9 additions & 8 deletions config/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,27 @@
name = "Example bridge"
key = [239, 42, 13, 69]

[servers.proxy]
[servers.relay]
address = "0.0.0.0:1337"
buffer = 16384
buffer = 65536
timeout = 60

[servers.downstream]
[servers.upstream]
address = "example.com:1337"
buffer = 16384
buffer = 65536
timeout = 60

[[servers]]
name = "Another bridge"
key = [4, 5, 11]
first = 64 # Obfuscate only the first 64 bytes

[servers.proxy]
[servers.relay]
address = "0.0.0.0:1338"
buffer = 16384
buffer = 65536
timeout = 120

[servers.downstream]
[servers.upstream]
address = "endpoint2.exmaple.com:443"
buffer = 16384
buffer = 65536
timeout = 120
51 changes: 51 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
use std::{
net::SocketAddr,
net::ToSocketAddrs,
time::Duration
};

use serde::Deserialize;
use serde::de::Deserializer;
use serde_with::DurationSeconds;
use serde_with::serde_as;


fn resolve_address<'de, D>(de: D) -> Result<SocketAddr, D::Error>
where D: Deserializer<'de> {
let addr = <String>::deserialize(de)?;

addr.to_socket_addrs()
.map_err(serde::de::Error::custom)?
.next()
.ok_or(serde::de::Error::custom("No address"))
}

#[derive(Deserialize, Debug)]
pub struct Config {
pub servers: Vec<ServerConfig>
}

#[derive(Deserialize, Debug)]
pub struct ServerConfig {
pub name: String,
#[serde(flatten)]
pub obfs: ObfsConfig,
pub relay: EndpointConfig,
pub upstream: EndpointConfig,
}

#[derive(Deserialize, Debug)]
pub struct ObfsConfig {
pub key: Vec<u8>,
pub first: Option<usize>,
}

#[serde_as]
#[derive(Deserialize, Debug)]
pub struct EndpointConfig {
#[serde(deserialize_with = "resolve_address")]
pub address: SocketAddr,
pub buffer: usize,
#[serde_as(as = "DurationSeconds<u64>")]
pub timeout: Duration,
}
Loading

0 comments on commit 5ac4f6c

Please sign in to comment.