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

Commit

Permalink
build script and service description
Browse files Browse the repository at this point in the history
  • Loading branch information
ylxdzsw committed Jul 13, 2019
1 parent e8bace5 commit 5e732f4
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 19 deletions.
19 changes: 19 additions & 0 deletions PKGBUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Maintainer: Shiwei Zhang <[email protected]>

pkgname=v2socks
pkgdesc="An opinioned lightweight socks5 server and vmess (v2ray) client."
pkgrel=1
pkgver=0.1.0
arch=(any)
url='https://github.com/ylxdzsw/v2socks'
license=(GPL3)
makedepends=(cargo)
source=("https://github.com/ylxdzsw/v2socks/archive/v$pkgver.tar.gz")
md5sums=(SKIP)

package() {
cd "$srcdir/v2socks"
cargo build --release
install -D "$srcdir"/v2socks-$pkgver/target/release/v2socks "$pkgdir"/usr/bin/v2socks
install -Dm644 "$srcdir"/v2socks-$pkgver/v2socks.service "$pkgdir"/usr/lib/systemd/system/v2socks.service
}
4 changes: 4 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
V2socks
=======

An opinioned lightweight socks5 server and vmess (v2ray) client.
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ fn vmess(server: &Socks5Server, proxy: String, user_id: [u8; 16]) {
let mut stream = stream.try_clone().unwrap();

std::thread::spawn(move || {
let mut reader = VmessReader::<std::net::TcpStream>::new(conn, key, IV);
let mut reader = VmessReader::new(conn, key, IV);
let mut buffer = [0; 1<<14];
loop {
let len = reader.read(&mut buffer).unwrap();
Expand Down
19 changes: 1 addition & 18 deletions src/vmess.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,6 @@ impl VmessReader<std::io::BufReader<std::net::TcpStream>> {
}
}

impl VmessReader<std::net::TcpStream> {
/// key and IV are just data key and iv in the request header, this function will calculate the md5 it selfs
#[allow(non_snake_case)]
pub fn new(conn: std::net::TcpStream, key: [u8; 16], IV: [u8; 16]) -> Self {
let mut reader = VmessReader {
reader: conn,
decoder: AES128CFB::new(md5!(&key), md5!(&IV))
};
reader.handshake();
reader
}

pub fn into_inner(self) -> std::net::TcpStream {
self.reader
}
}

impl<R: ReadExt> VmessReader<R> {
fn handshake(&mut self) {
let mut head = [0; 4];
Expand Down Expand Up @@ -211,7 +194,7 @@ impl<W: Write> Write for VmessWriter<W> {
}
}

fn fnv1a(x: &[u8]) -> u32 { // checked
fn fnv1a(x: &[u8]) -> u32 {
let prime = 16777619;
let mut hash = 0x811c9dc5;
for byte in x.iter() {
Expand Down
6 changes: 6 additions & 0 deletions v2socks.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[Unit]
Description=v2socks

[Service]
Type=simple
ExecStart=/usr/bin/v2socks plain

0 comments on commit 5e732f4

Please sign in to comment.