mirror of
https://github.com/dndx/phantun.git
synced 2025-10-15 18:25:36 +08:00
Compare commits
5 Commits
v0.8.1
...
dependabot
Author | SHA1 | Date | |
---|---|---|---|
|
850de2febe | ||
|
7f7da10b1b | ||
|
9d74a6bfeb | ||
|
9bdfd76819 | ||
|
d1c18c64f3 |
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@@ -64,7 +64,7 @@ jobs:
|
|||||||
- mipsel-unknown-linux-musl
|
- mipsel-unknown-linux-musl
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v5
|
||||||
- uses: actions-rs/toolchain@v1
|
- uses: actions-rs/toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: nightly
|
toolchain: nightly
|
||||||
|
6
Cargo.lock
generated
6
Cargo.lock
generated
@@ -884,12 +884,12 @@ checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "socket2"
|
name = "socket2"
|
||||||
version = "0.6.0"
|
version = "0.6.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "233504af464074f9d066d7b5416c5f9b894a5862a6506e306f7b816cdd6f1807"
|
checksum = "17129e116933cf371d018bb80ae557e889637989d8638274fb25622827b03881"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"windows-sys 0.59.0",
|
"windows-sys 0.60.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@@ -5,8 +5,7 @@ A lightweight and fast UDP to TCP obfuscator.
|
|||||||

|

|
||||||

|

|
||||||
|
|
||||||
Table of Contents
|
# Table of Contents
|
||||||
=================
|
|
||||||
|
|
||||||
* [Phantun](#phantun)
|
* [Phantun](#phantun)
|
||||||
* [Latest release](#latest-release)
|
* [Latest release](#latest-release)
|
||||||
@@ -35,7 +34,7 @@ Table of Contents
|
|||||||
|
|
||||||
# Latest release
|
# Latest release
|
||||||
|
|
||||||
[v0.8.0](https://github.com/dndx/phantun/releases/tag/v0.8.0)
|
[v0.8.1](https://github.com/dndx/phantun/releases/tag/v0.8.1)
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary>MIPS architecture support for Phantun</summary>
|
<summary>MIPS architecture support for Phantun</summary>
|
||||||
|
@@ -25,6 +25,10 @@ FROM debian:latest
|
|||||||
COPY --from=builder /usr/local/bin/phantun-server /usr/local/bin/
|
COPY --from=builder /usr/local/bin/phantun-server /usr/local/bin/
|
||||||
COPY --from=builder /usr/local/bin/phantun-client /usr/local/bin/
|
COPY --from=builder /usr/local/bin/phantun-client /usr/local/bin/
|
||||||
COPY docker/phantun.sh /usr/local/bin/
|
COPY docker/phantun.sh /usr/local/bin/
|
||||||
|
RUN apt-get update && apt-get install -y \
|
||||||
|
iproute2 \
|
||||||
|
iptables \
|
||||||
|
procps
|
||||||
|
|
||||||
ENV USE_IPTABLES_NFT_BACKEND=0
|
ENV USE_IPTABLES_NFT_BACKEND=0
|
||||||
ENV RUST_LOG=INFO
|
ENV RUST_LOG=INFO
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
|
|
||||||
# alias settings must be global, and must be defined before the function being called with the alias
|
# alias settings must be global, and must be defined before the function being called with the alias
|
||||||
if [ "$USE_IPTABLES_NFT_BACKEND" = 1 ]; then
|
if [ "$USE_IPTABLES_NFT_BACKEND" = 1 ]; then
|
||||||
@@ -70,17 +70,17 @@ _is_ipv4_only() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_get_tun_from_args() {
|
_get_tun_from_args() {
|
||||||
local tun=$(echo "$@" | awk -F '--tun' '{print $2}' | awk '{print $1}')
|
local tun=$(echo "$@" | awk -F '--tun ' '{print $2}' | awk '{print $1}')
|
||||||
echo ${tun:=tun0}
|
echo ${tun:=tun0}
|
||||||
}
|
}
|
||||||
|
|
||||||
_get_peer_from_args() {
|
_get_peer_from_args() {
|
||||||
local peer=$(echo "$@" | awk -F '--tun-peer' '{print $2}' | awk '{print $1}')
|
local peer=$(echo "$@" | awk -F '--tun-peer ' '{print $2}' | awk '{print $1}')
|
||||||
_is_server_mode "$1" && echo ${peer:=192.168.201.2} || echo ${peer:=192.168.200.2}
|
_is_server_mode "$1" && echo ${peer:=192.168.201.2} || echo ${peer:=192.168.200.2}
|
||||||
}
|
}
|
||||||
|
|
||||||
_get_peer6_from_args() {
|
_get_peer6_from_args() {
|
||||||
local peer=$(echo "$@" | awk -F '--tun-peer6' '{print $2}' | awk '{print $1}')
|
local peer=$(echo "$@" | awk -F '--tun-peer6 ' '{print $2}' | awk '{print $1}')
|
||||||
_is_server_mode "$1" && echo ${peer:=fcc9::2} || echo ${peer:=fcc8::2}
|
_is_server_mode "$1" && echo ${peer:=fcc9::2} || echo ${peer:=fcc8::2}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -62,13 +62,11 @@ pub async fn udp_recv_pktinfo(
|
|||||||
buf: &mut [u8],
|
buf: &mut [u8],
|
||||||
) -> std::io::Result<(usize, SocketAddr, IpAddr)> {
|
) -> std::io::Result<(usize, SocketAddr, IpAddr)> {
|
||||||
sock.async_io(Interest::READABLE, || {
|
sock.async_io(Interest::READABLE, || {
|
||||||
// according to documented struct definition in RFC 3542,
|
const CONTROL_MESSAGE_BUFFER_SIZE: usize = max_usize(
|
||||||
// sizeof(in6_pktinfo) should always be larger than sizeof(in_pktinfo),
|
cmsg_space::<nix::libc::in_pktinfo>(),
|
||||||
// this assert just double checks that. The goal is to avoid
|
cmsg_space::<nix::libc::in6_pktinfo>(),
|
||||||
// a heap allocation with Vec at runtime.
|
);
|
||||||
assert!(cmsg_space::<nix::libc::in6_pktinfo>() >= cmsg_space::<nix::libc::in_pktinfo>());
|
let mut control_message_buffer = [0u8; CONTROL_MESSAGE_BUFFER_SIZE];
|
||||||
|
|
||||||
let mut control_message_buffer = [0u8; cmsg_space::<nix::libc::in6_pktinfo>()];
|
|
||||||
let iov = &mut [std::io::IoSliceMut::new(buf)];
|
let iov = &mut [std::io::IoSliceMut::new(buf)];
|
||||||
let res = nix::sys::socket::recvmsg::<SockaddrStorage>(
|
let res = nix::sys::socket::recvmsg::<SockaddrStorage>(
|
||||||
sock.as_raw_fd(),
|
sock.as_raw_fd(),
|
||||||
@@ -151,3 +149,7 @@ pub fn assign_ipv6_address(device_name: &str, local: Ipv6Addr, peer: Ipv6Addr) {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
rtnl.send(&nl_header).unwrap();
|
rtnl.send(&nl_header).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const fn max_usize(a: usize, b: usize) -> usize {
|
||||||
|
if a > b { a } else { b }
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user