Code Monkey home page Code Monkey logo

tinyportmapper's Introduction

tinyPortMapper (or tinyPortForwarder)

A Lightweight High-Performance Port Mapping/Forwarding Utility using epoll, Supports both TCP and UDP

Supported Platforms

Linux host (including desktop Linux,Android phone/tablet, OpenWRT router, or Raspberry PI). Binaries of amd64 x86 mips_be mips_le arm are provided.

Getting Started

Installing

Download binary release from https://github.com/wangyu-/tinyPortMapper/releases

Running

Assume you want to map/forward local port 1234 to 10.222.2.1:443

# for both TCP and UDP
./tinymapper_amd64 -l0.0.0.0:1234 -r10.222.2.1:443 -t -u

# for TCP only
./tinymapper_amd64 -l0.0.0.0:1234 -r10.222.2.1:443 -t

# for UDP only
./tinymapper_amd64 -l0.0.0.0:1234 -r10.222.2.1:443 -u

# for ipv6, both TCP and UDP
# ipv6 address must be surrounded with `[]`, ipv4 address must NOT be surrounded with `[]`
./tinymapper_amd64 -l[::]:1234 -r[2001:19f0:7001:1111:00:ff:11:22]:443 -t -u
NOTE
# local port and remote port can be the same
./tinymapper_amd64 -l0.0.0.0:443 -r10.222.2.1:443 -u

# you can also use 6-to-4 or 4-to-6 forward
./tinymapper_amd64 -l0.0.0.0:1234 -r[2001:19f0:7001:1111:00:ff:11:22]:443 -t -u
./tinymapper_amd64 -l[::]:1234 -r44.55.66.77:443 -t -u

# you can also use ipv4-mapped ipv6 address
# this is especially useful if you want to play with ipv6 and you dont have a real ipv6 address
./tinymapper_amd64 -l[::]:4433 -r[::ffff:10.222.2.1]:443 -t -u
./tinymapper_amd64 -l[::ffff:0.0.0.0]:4433 -r[::ffff:10.222.2.1]:443 -t -u

Options

tinyPortMapper
git version:25ea4ec047    build date:Nov  4 2017 22:55:23
repository: https://github.com/wangyu-/tinyPortMapper

usage:
    ./this_program  -l <listen_ip>:<listen_port> -r <remote_ip>:<remote_port>  [options]

main options:
    -t                                    enable TCP forwarding/mapping
    -u                                    enable UDP forwarding/mapping

other options:
    --sock-buf            <number>        buf size for socket, >=10 and <=10240, unit: kbyte, default: 1024
    --log-level           <number>        0: never    1: fatal   2: error   3: warn
                                          4: info (default)      5: debug   6: trace
    --log-position                        enable file name, function name, line number in log
    --disable-color                       disable log color
    -h,--help                             print this help message

Peformance Test

root@debian9:~# iperf3 -c 127.0.0.1 -p5202
Connecting to host 127.0.0.1, port 5202
[  4] local 127.0.0.1 port 37604 connected to 127.0.0.1 port 5202
[ ID] Interval           Transfer     Bandwidth       Retr  Cwnd
[  4]   0.00-1.00   sec   696 MBytes  5.84 Gbits/sec    0    639 KBytes
[  4]   1.00-2.00   sec   854 MBytes  7.17 Gbits/sec    0    639 KBytes
[  4]   2.00-3.00   sec   727 MBytes  6.10 Gbits/sec    0    639 KBytes
[  4]   3.00-4.00   sec   670 MBytes  5.62 Gbits/sec    0    639 KBytes
[  4]   4.00-5.00   sec   644 MBytes  5.40 Gbits/sec    0    639 KBytes
[  4]   5.00-6.00   sec   957 MBytes  8.03 Gbits/sec    0    639 KBytes
[  4]   6.00-7.00   sec   738 MBytes  6.19 Gbits/sec    0    639 KBytes
[  4]   7.00-8.00   sec   714 MBytes  5.99 Gbits/sec    0    639 KBytes
[  4]   8.00-9.00   sec   817 MBytes  6.85 Gbits/sec    0    639 KBytes
[  4]   9.00-10.00  sec   619 MBytes  5.19 Gbits/sec    0    639 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth       Retr
[  4]   0.00-10.00  sec  7.26 GBytes  6.24 Gbits/sec    0             sender
[  4]   0.00-10.00  sec  7.26 GBytes  6.24 Gbits/sec                  receiver

Details and more test results at:

https://github.com/wangyu-/tinyPortMapper/wiki/Performance-Test

tinyportmapper's People

Contributors

harukama avatar wangyu- avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tinyportmapper's Issues

Feature Request: URL Resolve

Dear wangyu-

I have been trying tinyPortMapper, it's great and working well, but can you please add URL resolve feature so I don't have to input IP address each time I start it, and I can prevent issues when I change my IP without changing URL.

Please consider!

Thanks!

VMware OpenWrt虚拟机 SMB端口转发 性能受限

直接访问NAS的读写性能
,win7--ipv6(ScopeLink)直接访问-unraid

主机访问OpenWrt虚拟机(桥接网络)445端口,转发到另一台NAS主机某端口(该端口不受ISP和防火墙限制,可在公网访问),实际转发(读和写)性能约为直接访问NAS的一半
win7--ipv6(ScopeLink)访问tinyPortMapper(openwrt18 06 8-vmware 未分配防火墙区域并关闭防火墙)6to6-unraid

另一台Window7虚拟机访问OpenWrt虚拟机445端口,实际转发性能为:读为直接访问的约90%,写为直接访问的约60%
win7(vmware桥接网络)--ipv6(ScopeLink)访问tinyPortMapper(openwrt18 06 8-vmware 未分配防火墙区域并关闭防火墙)6to6-unraid

mac ./tinymapper: command not found

luozhan@luozhandeMacBook-Pro 临时文件 % sudo ./tinymapper -l192.192.2.101:1070 -r10.211.55.3:1070 -t -u

result:

sudo: ./tinymapper: command not found

multi-port

Can support multi-port forwarding at the same time

Do not open multiple tinyPortMapper

Hope this function

udp2raw (client 出发地)-> tinymapper(当tcp中继) -> udp2raw(server 目的地)

你好 Mr.wangyu,

我尝试透过 tinymapper 转 udp2raw, 无法成功连接:
Dec 15 12:00:56 raspbian udp2raw_arm[231706]: [2021-12-15 12:00:56][INFO]using port 64365
Dec 15 12:00:56 raspbian udp2raw_arm[231706]: [2021-12-15 12:00:56][INFO]state changed from client_idle to client_tcp_handshake
Dec 15 12:00:56 raspbian udp2raw_arm[231706]: [2021-12-15 12:00:56]INFOsent tcp syn
Dec 15 12:00:56 raspbian udp2raw_arm[231706]: [2021-12-15 12:00:56][INFO]state changed from client_tcp_handshake to client_handshake1
Dec 15 12:00:56 raspbian udp2raw_arm[231706]: [2021-12-15 12:00:56]INFOsent handshake1
Dec 15 12:00:57 raspbian udp2raw_arm[231706]: [2021-12-15 12:00:57]INFOsent handshake1
Dec 15 12:00:58 raspbian udp2raw_arm[231706]: [2021-12-15 12:00:58]INFOsent handshake1
Dec 15 12:01:00 raspbian udp2raw_arm[231706]: [2021-12-15 12:01:00]INFOsent handshake1
Dec 15 12:01:01 raspbian udp2raw_arm[231706]: [2021-12-15 12:01:01]INFOsent handshake1
Dec 15 12:01:01 raspbian udp2raw_arm[231706]: [2021-12-15 12:01:01][INFO]state back to client_idle from client_handshake1

同样的配置, udp2raw (client) -> udp2raw (server), 是可以顺利连接。tinymapper 是在一个固定ip的机器上,如果按以下,是可以连接:
udp2raw(client 出发地) -> [ tinymapper 的位置,改为: ] udp2raw(server 当中继) -> udp2raw(client 当中继) -> udp2raw(server 目的地)
上次你关于 speederv2, tinyvpn 用 mode 0 的指教,使我对udp2raw,speederv2进一步认识,希望你能指导tinymapper当udp2raw中继 的应用。
sk

转发TCP给$$tap加速无效并夸张占用

用tinyportmapper转发远程服务器的端口给$$tap配合udp2raw加速游戏。但tinyportmapper转发tcp后让$$tap链接会出现tPM大量连接刷屏并造成CPU100%占用,而且网络全断。
所用命令为tinymapper.exe -l0.0.0.0:3333 -r****:37371 -t ****为服务器地址
default

stop script issue

hi.After a while the script works without problems, it randomly stops and gives this error
[FATAL][tcp]create new_remote_fd failed

FreeBSD 14.0 errno=55:No buffer space available

After compiling, when trying to start, I get this error

running in a virtual machine (kvm)

SO_SNDBUF fail socket_buf_size=2097152 errno=55:No buffer space available

full output

./tinymapper -l10.18.19.201:2222 -r10.18.19.202:22 -t
[2024-03-18 16:03:00][INFO]argc=4 ./tinymapper -l10.18.19.201:2222 -r10.18.19.202:22 -t
[2024-03-18 16:03:00][INFO]parsing address: 10.18.19.201:2222
[2024-03-18 16:03:00][INFO]its an ipv4 adress
[2024-03-18 16:03:00][INFO]ip_address is {10.18.19.201}, port is {2222}
[2024-03-18 16:03:00][INFO]parsing address: 10.18.19.202:22
[2024-03-18 16:03:00][INFO]its an ipv4 adress
[2024-03-18 16:03:00][INFO]ip_address is {10.18.19.202}, port is {22}
[2024-03-18 16:03:00][FATAL]SO_SNDBUF fail socket_buf_size=2097152 errno=55:No buffer space available

any hint?

--
compiled with
make freebsd
echo "const char *gitversion = "";" > git_version.h
rm -f tinymapper
g++ -o tinymapper -I. main.cpp log.cpp common.cpp fd_manager.cpp my_ev.cpp -isystem libev -std=c++11 -Wall -Wextra -Wno-unused-variable -Wno-unused-parameter -Wno-missing-field-initializers -lrt -ggdb -static -O2

请问如何编译,我想加一个新功能

windows cmake可以编译吗?
我希望是在client连接上tinyPortMapper后,在加上client的原始ip地址。
这样服务端收到被转发后的请求可以从中得到client的真实ip地址,而不是转发器的ip地址

在mac机器上,make遇错

hello.

git clone https://github.com/wangyu-/tinyPortMapper/ tinyPortMapper-by-wangyu-
cd tinyPortMapper-by-wangyu-
make
显示:
...
ld: library not found for -lcrt0.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [all] Error 1
yudeMacBook-Air:tinyPortMapper-by-wangyu- brite$ which clang
/usr/local/opt/llvm/bin/clang
yudeMacBook-Air:tinyPortMapper-by-wangyu- brite$

怎么解决?

Using Hostname

Can i port forward using hostname example : ./tinymapper_amd64 -l0.0.0.0:1234 -r example.com:443 -t

or you have plan to add hostname ?

tinyPortMapper 一键安装脚本

要求:Ubuntu/Debian,CentOS 系统的小鸡鸡
使用 root 用户输入下面命令安装或卸载

bash <(curl -s -L https://233blog.com/tinyPortMapper.sh)

备注,此脚本仅负责安装和卸载

大佬,不要打我,我不是打广告的

Windows - Run as as service

It would be nice to be able to configure tinyPortMapper to run as a service. I recognize that multiple services would be required for multiple ports.

[tcp]socket bind failed, 10049:

[2019-05-10 15:20:10][INFO]argc=9 tinymapper_wepoll.exe -l 10.66.160.250:10012 -
r 10.65.128.1:10013 -t -u --log-level 6
[2019-05-10 15:20:10][INFO]parsing address: 10.66.160.250:10012
[2019-05-10 15:20:10][INFO]its an ipv4 adress
[2019-05-10 15:20:10][INFO]ip_address is {10.66.160.250}, port is {10012}
[2019-05-10 15:20:10][INFO]parsing address: 10.65.128.1:10013
[2019-05-10 15:20:10][INFO]its an ipv4 adress
[2019-05-10 15:20:10][INFO]ip_address is {10.65.128.1}, port is {10013}
[2019-05-10 15:20:10][FATAL][tcp]socket bind failed, 10049:

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.