GithubHelp home page GithubHelp logo

hero1s / tcp-proxy Goto Github PK

View Code? Open in Web Editor NEW

This project forked from 0xekez/tcp-proxy

0.0 0.0 0.0 7 KB

A TCP proxy in 30 lines of Rust.

Home Page: https://zmedley.com/tcp-proxy.html

Shell 54.72% Rust 45.28%

tcp-proxy's Introduction

Proxy

A simple Rust TCP proxy. Intended to be educational - don't use this in production.

Terminoligy

server - the listener we'd like to proxy tcp connections to. client - the initiator of connections to the server.

Benchmarking

Using localhost:

  1. Start the proxy in one terminal window
    cargo run -- -c 0.0.0.0:1212 -s 127.0.0.1:1313
  2. Listen on the origin port in another window
    nc -l 1313 > /dev/null
    
  3. Send a bunch of traffic from another window
    dd if=/dev/zero bs=1024 count=900000 | nc -v 127.0.0.1 1212
    

Using network namespaces:

If you have a debian linux machine you can use ns_test.sh to run a benchmark using three network namespaces.

Local Results

Using the proxy:

~ dd if=/dev/zero bs=1024 count=900000 | nc -v 127.0.0.1 1212
Connection to 127.0.0.1 port 1212 [tcp/lupa] succeeded!
900000+0 records in
900000+0 records out
921600000 bytes transferred in 4.369209 secs (210930626 bytes/sec)

Connecting directly to the server:

~ dd if=/dev/zero bs=1024 count=900000 | nc -v 127.0.0.1 1313
Connection to 127.0.0.1 port 1313 [tcp/bmc_patroldb] succeeded!
900000+0 records in
900000+0 records out
921600000 bytes transferred in 3.612901 secs (255085873 bytes/sec)

Results

(* 100 (/ 210930626.0 255085873.0))
=> 82.69004610851186

The tcp proxy is 82% the speed of a regular connection.

Network Namespace Results

Using the proxy:

921600000 bytes (922 MB, 879 MiB) copied, 25.4762 s, 36.2 MB/s

Connecting directly to the server:

921600000 bytes (922 MB, 879 MiB) copied, 5.17278 s, 178 MB/s

Results:

(* 100 (/ 36.2 178))
=> 20.337078651685395

the tcp proxy is 20% the speed of a regular connection.

tcp-proxy's People

Contributors

0xekez avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.