Git Product home page Git Product logo

port-forwarding's Introduction

port-forwarding

tcp port forwarding based on netty / 基于Netty的TCP端口流量转发

this project may be helpful when you are not familiar with iptables or other port forwarding techs.

this project may be helpful when you want to do some stuff on data flow, based on this project's source code, you can write your own code to handle data flow before forwarding.

configuration

this project will read config from java system properties and system env, properties first.

  • mappingFilePath, port mapping file
  • timeout, io timeout in mills for read/write idle timeout, if you connection is long-connection you may need to set timeout to bigger one
  • connectTimeout, io timeout in mills for connection to target remote port
  • ioAcceptThreadNumber, accept thread number default system cores
  • ioWorkThreadNumber, work thread number default system cores
  • ioMaxBacklog, socket backlog default 64
  • openLoggingHandler, detail netty debug logging

mapping file

default port mapping file is mapping.txt, in this file you add multi port mapping lines.

this file format must be "one line for one mapping, local address(host:port) and remote address(host:port) split by ,"

use # to add comment

eg:

# mapping local host 80 to local host 8080, port 80's any data will forward to 8080

127.0.0.1:80,127.0.0.1:8080

127.0.0.1:9090,xxx.xxx.xx.xx:1234

127.0.0.1:9091,xxx.xxx.xx.xx:1235

how to use

1. use released jar

jar -Xmx256m -DmappingFilePath=mapping.txt -jar portfowarding-jar-with-dependencies.jar

2. use docker image

docker image: blueoom/portforwarding

docker run -tdi --network=host -e mappingFilePath=mapping.txt -v mapping.txt:/home/portforwarding/mapping.txt blueoom/portforwarding 

suggest to use host network for multi port mapping

use -v to set mapping.txt

use -e to set configs, use -e JVM_ARGS="-Xmx512m" to set jvm args

suggest to use docker compose to manage service containers

port-forwarding's People

Contributors

anexplore 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.