你的位置:首页 > 互联网IT

PortForwarder端口转发映射工具

系统:Windows/Linux

下载地址:

Windows下载:Forwarder_windows_32_64.rar

Linux下载:Forwarder_linux_amd64.rar

项目地址:https://github.com/HirbodBehnam/PortForwarde

项目下载地址其他版本:https://github.com/HirbodBehnam/PortForwarder/releases


优点:可以添加多条转发与映射,可以支持域名形式


配置:

custom_conf.json


{

  "SaveDuration": 600,

  "Timeout": -1,

  "Rules": [

    {

 "Name": "123",

      "Listen": 2400,

      "Forward": "127.0.0.1:1100",

      "Quota":9223372036854775807,

      "Simultaneous": 10

    }, 

    {

 "Name": "123456",

      "Listen": 2401,

      "Forward": "www.baidu.com:1101",

      "Quota":9223372036854775807,

      "Simultaneous": 10

    }

  ]

}


启动:

windows

开始.bat

start "" "Forwarder_windows_amd64.exe" --config custom_conf.json


linux

./Forwarder_windows_amd64.exe --config custom_conf.json




作者的配置文件:

{

  "SaveDuration": 600,

  "Timeout": -1,

  "Rules": [

    {

      "Listen": 5362,

      "Forward": "1.1.1.1:53",

      "Quota": 1073741824,

      "Simultaneous": 10

    }, 

    {

      "Name": "PortsNumber2",

      "Listen": 5363,

      "Forward": "8.8.8.8:8080",

      "Quota":9223372036854775807,

      "ExpireDate": 1566994231

    }

  ]

}


QQ截图20200509195040.jpg PortForwarder端口转发映射工具,中转服务 互联网IT


如何使用它?

您是否为您的操作系统下载了可执行文件?好!

根据需要编辑rules.json文件。这是备忘单:

  • SaveDuration:程序每秒钟将配额写入磁盘SaveDuration默认值为600秒或10分钟。

  • Timeout:连接可以保持活动状态而不传输任何数据的时间(以秒为单位)。默认设置为禁用。使用0禁用超时。

  • Rules 数组:每个元素代表一个转发规则及其配额。

    • Name:仅是此规则的名称。它对应用程序没有任何影响。

    • Listen:接受代理的传入连接的本地端口。

    • Forward:流量必须转发到的地址。输入像ip:port

    • Quota:用户可以传输的字节数。

    • Simultaneous:允许与此端口同时连接的数量。使用0,或将其无限删除。

    • ExpireDate:该规则何时必须过期?在Unix时代,UTC。您可以使用此站点将日期转换为unix纪元。

保存文件,然后打开主可执行文件以运行代理。

无限配额

好吧,你不能,但实际上你可以!

最大配额值为92233720368547758087您可以使用它。

争论

有两种选择:

  1. -h:打印出代理的帮助。

  2. --no-exit-save:禁用退出前规则保存

  3. -verbose:详细模式(0到4之间的数字)

  4. --config注意:如果要使用其他名称的配置文件,只需将其作为第一个参数传递给程序即可。例如:

./PortForwarder --config custom_conf.json




港口货运代理

一个使用配额选项进行转发的小程序

这是什么?

这是一个小程序,用于通过配额选项转发端口以控制用户使用的数据。该代码的一些功能是:

  • 轻量级:它没有依赖项,只有主文件和标准库。

  • 易于使用:只需编辑规则文件,即可使用代理

  • 高性能:使用iperf3,我在本地隧道中达到了14.9 Gbits / sec。

  • 同时连接限制:限制端口可以同时连接的数量

  • 软阻止:阻止新的传入连接,并在配额达到时使旧的连接保持活动状态。阅读更多

安装

只需前往发行版并为您的操作系统下载一个即可。

从源代码构建

建立这个并不难。首先,为您的操作系统安装golang克隆此存储库并运行以下命令:

去建立main.go

可执行文件将在当前目录中可用。

如何使用它?

您是否为您的操作系统下载了可执行文件?好!

根据需要编辑rules.json文件。这是备忘单:

  • SaveDuration:程序每秒钟将配额写入磁盘SaveDuration默认值为600秒或10分钟。

  • Timeout:连接可以保持活动状态而不传输任何数据的时间(以秒为单位)。默认设置为禁用。使用0禁用超时。

  • Rules 数组:每个元素代表一个转发规则及其配额。

    • Name:仅是此规则的名称。它对应用程序没有任何影响。

    • Listen:接受代理的传入连接的本地端口。

    • Forward:流量必须转发到的地址。输入像ip:port

    • Quota:用户可以传输的字节数。

    • Simultaneous:允许与此端口同时连接的数量。使用0,或将其无限删除。

    • ExpireDate:该规则何时必须过期?在Unix时代,UTC。您可以使用此站点将日期转换为unix纪元。

保存文件,然后打开主可执行文件以运行代理。

无限配额

好吧,你不能,但实际上你可以!

最大配额值为92233720368547758087您可以使用它。

争论

有两种选择:

  1. -h:打印出代理的帮助。

  2. --no-exit-save:禁用退出前规则保存

  3. -verbose:详细模式(0到4之间的数字)

  4. --config注意:如果要使用其他名称的配置文件,只需将其作为第一个参数传递给程序即可。例如:

./PortForwarder --config custom_conf.json

详细模式

您有5个选择

0 意味着应用程序大多数情况下都是静默的,并显示致命错误。

1表示显示常规错误和信息。(这是默认值)

2 表示当用户达到连接限制时也会打印

3 表示在连接超时时它还会打印日志

4表示它会打印所有可能的日志。用于调试

例:

./PortForwarder-详细2

怎么运行的?

基本代码是这个(谢谢!)。更改代码以测量传输的流量。

软阻塞

因此,这是您应该阅读的部分。代理使用io.Copyfunction(reference)来编写缓冲区。优点是缓冲区不与我同在,它与golang本身同在,没有循环。但是有一个陷阱:到达EOF或出现错误时,此函数将返回。

那这怎么了?好吧,我可以理解该函数返回时已传输了多少字节。因此,出现了软连接,并且不准确的成本快速上升。

函数返回后,配额将更改。

对于较软的连接,我意味着什么?达到配额后,客户端可以使用该程序。当客户端想要建立一个新的连接时,它将被服务器拒绝。另外,您可以管理多少客户已使用了超出其配额的数量。

其他的东西

波斯行会使用mtproto进行设置



英文


Port Forwarder

A small program to port forward with quota options

What is this?

This a small program to forward ports with a quota option to control the data users use. Some of the features of this code are:

  • Lightweight: It has no dependencies, just the main file, and standard library.

  • Easy to use: Just edit the rules file and you can use the proxy

  • High performance: With iperf3 I achieved 14.9 Gbits/sec in a local tunnel.

  • Simultaneous Connections Limit: Limit the amount of simultaneous connections that a port can have.

  • Soft Blocking: Block the new incoming connections and keep the old ones alive when the quota reaches. Read More

Install

Just head to releases and download one for your os.

Build from source

Building this is not that hard. At first install golang for your operating system. Clone this repository and run this command:

go build main.go

The executable file will be available at the present directory.

How to use it?

Did you download the executable for your os? Good!

Edit the rules.json file as you wish. Here is the cheatsheet for it:

  • SaveDuration: The program writes the quotas to disk every SaveDuration seconds. Default is 600 seconds or 10 minutes.

  • Timeout: The time in seconds that a connection can stay alive without transmitting any data. Default is disabled. Use 0 to disable the timeout.

  • Rules Array: Each element represents a forwarding rule and quota for it.

    • Name: Just a name for this rule. It does not have any effect on the application.

    • Listen: The local port to accept the incoming connections for proxy.

    • Forward: The address that the traffic must be forwarded to. Enter it like ip:port

    • Quota: The number of bytes the user can transfer.

    • Simultaneous: Amount of allowed simultaneous connections to this port. Use 0, or remove it for unlimited.

    • ExpireDate: When this rule must expire? In unix epoch, UTC. You can use this site to convert date to unix epoch.

Save the file and just open the main executable to run the proxy.

Unlimited Quota

Well, you can't but actually you can!

The max quota value is 92233720368547758087. You can use this.

Arguments

There are two options:

  1. -h: It prints out the help of the proxy.

  2. --no-exit-save: Disable the before exit rules saving

  3. -verbose: Verbose mode (a number between 0 to 4)

  4. --config: In case you want to use a config file with another name, just pass it to program as the first argument. For example:

./PortForwarder --config custom_conf.json

Verbose modes

You have 5 options

0 means that the applications is mostly silent and prints fatal errors.

1 means regular errors and infos are shown. (This is the default value)

2 means it also prints when a user hits connection limit

3 means it also prints a log when a connection timeouts

4 means it prints every log possible. Use to debug

Example:

./PortForwarder --verbose 2

How it works?

The base code is this(Thanks man!). The code is changed in order to measure the traffic transmitted.

Soft Blocking

So here is a part you should read. The proxy uses the io.Copy function(reference) in order to write the buffers. The good point is that the buffer is not with me and it is with the golang itself and there is no loop. But there is a catch: This function returns when it reaches the EOF or in case of an error.

So what's wrong with this? Well, I can understand how many bytes had been transferred when the function returns. So here comes soft connections and fast forward in cost of inaccuracy.

As soon as the function returns, the quota will change.

And what do I mean about the softer connections? The client can use the program after the quota is reached. When the client wants to establish a new connection it will be rejected from the server. Plus you can manage how much client has used more than its quota.

Other Stuff

Persian guild to setup this with mtproto



  • 发表评论
  • 查看评论
【暂无评论!】

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。