Skip to content
This repository was archived by the owner on Sep 20, 2024. It is now read-only.

Commit 4b6834f

Browse files
committed
.
1 parent 1bd1aa0 commit 4b6834f

File tree

5 files changed

+10
-13
lines changed

5 files changed

+10
-13
lines changed

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
[package]
22
name = "v2socks"
3-
version = "0.2.3"
3+
version = "0.2.4"
44
authors = ["ylxdzsw <[email protected]>"]
5-
edition = "2018"
5+
edition = "2021"
66

77
[profile.release]
88
panic = "abort"
99
lto = true
1010

1111
[dependencies]
12-
oh-my-rust = { git = "https://github.com/ylxdzsw/oh-my-rust", default-features = false, features = ["std"]}
12+
absurd = { git = "https://github.com/ylxdzsw/absurd" }
1313
rust-crypto = "0.2"
1414
rand = "0.8"
1515
anyhow = "1.0"

PKGBUILD

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
pkgname=v2socks
44
pkgdesc="An opinioned lightweight socks5 server and vmess (v2ray) client."
55
pkgrel=1
6-
pkgver=0.2.3
6+
pkgver=0.2.4
77
arch=(any)
88
url='https://github.com/ylxdzsw/v2socks'
99
license=(GPL3)
@@ -16,4 +16,4 @@ package() {
1616
cargo build --release
1717
install -D "$srcdir"/v2socks-$pkgver/target/release/v2socks "$pkgdir"/usr/bin/v2socks
1818
install -Dm644 "$srcdir"/v2socks-$pkgver/v2socks.service "$pkgdir"/usr/lib/systemd/system/v2socks.service
19-
}
19+
}

src/main.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
use v2socks::*;
2-
use oh_my_rust::*;
2+
use absurd::*;
33
use rand::prelude::*;
44
use std::io::prelude::*;
55

6-
// basic logic:
76
// 1. main thread listen for socks5 connections
87
// 2. spawn a child thread for each connection, perform the sock5 and vmess handshake respectively
98
// 3. after the handshake succeed, spawn a pair of threads to pipe the two connections forward and backward
10-
119
// todo: use thread pool or async io
1210

1311
const USAGE: &str = "

src/socks.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use super::*;
2-
use oh_my_rust::*;
2+
use absurd::*;
33
use anyhow::{Context, Result, anyhow};
44
use std::net::{TcpListener, TcpStream};
55
use std::io::prelude::*;
@@ -58,7 +58,7 @@ fn initialize(stream: &mut (impl ReadExt + Write)) -> Result<()> {
5858
return Err(anyhow!("unsupported socks version {}. Hint: {}", header[0], hint))
5959
}
6060

61-
let list: Vec<u8> = stream.read_exact_alloc(header[1] as usize).context("read methods failed")?;
61+
let list = stream.read_exact_alloc(header[1] as usize).context("read methods failed")?;
6262

6363
if !list.contains(&0) {
6464
stream.write(&[5, 0xff]).context("write response failed")?;
@@ -85,7 +85,7 @@ fn read_request(stream: &mut (impl ReadExt + Write)) -> Result<(Addr, u16)> {
8585
0x04 => Addr::V6(read_exact!(stream, [0; 16]).context("read v6 address failed")?),
8686
0x03 => {
8787
let len = read_exact!(stream, [0]).context("read domain length failed")?[0];
88-
Addr::Domain(stream.read_exact_alloc(len as usize).context("read domain failed")?.into_boxed_slice())
88+
Addr::Domain(stream.read_exact_alloc(len as usize).context("read domain failed")?)
8989
},
9090
_ => return Err(anyhow!("unknown ATYP"))
9191
};
@@ -123,4 +123,3 @@ fn reply_request(stream: &mut (impl ReadExt + Write), addr: Addr, port: u16) ->
123123

124124
Ok(())
125125
}
126-

src/vmess.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use super::*;
2-
use oh_my_rust::*;
2+
use absurd::*;
33
use crypto::digest::Digest;
44
use crypto::symmetriccipher::BlockEncryptor;
55
use crypto::mac::Mac;

0 commit comments

Comments
 (0)