全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
查看: 2794|回复: 29

[开源][C++]TCP转发工具

[复制链接]
发表于 2021-5-29 13:40:11 | 显示全部楼层 |阅读模式
本帖最后由 dunce 于 2021-6-1 19:34 编辑

仓库地址: https://github.com/zephyrchien/ZTUN

6/1 UPDATE: 已经支持了DNS和超时,顺便支持了ipv6,可以做到ipv4->ipv6 & ipv6->ipv4

写这个程序的起因是realm不支持零拷贝,当初想着如果要给realm实现零拷贝,不如用C++重新写一个。于是我就尝试着写了一下。。(目前仍处于重度施工中,还没实现timer和dns resolver),感兴趣的同学可以来测个速

本地iperf3简单测速结果:
使用buffer时速度跟realm相当(15G/s)
使用pipe时(零拷贝)速度跟Go程序差不多(40G/s)

快速开始:
本程序没有外部依赖(EDIT: 除了glibc),直接把代码下载下来编译就行了:
  1. git clone https://github.com/zephyrchien/ZTUN
  2. cd ZTUN && mkdir build && cd build
  3. cmake ..
  4. make
复制代码

用命令行参数输入一对地址,或者指定配置文件:
  1. ztun -l :5000 -r 1.1.1.1:443 # 省略本地ip,默认为0.0.0.0
  2. ztun -c ztun.conf
复制代码

配置文件格式:
  1. # comment, starting with #

  2. # set log level and output path
  3. # level = none|warn|info|debug, default is info
  4. # file = filename, default is stderr
  5. log_level = info
  6. log_file = ztun.log

  7. # set the precision of timer and operation timeout
  8. # value: 1~2147483647(INT_MAX) ms
  9. # timer_intv = xxx, default is 500
  10. # connect_timeout = xxx, default is 2000
  11. # resolve_intv = xxx, default is 60000
  12. # resolve_timeout = xxx, default is 2000
  13. timer_intv = 500
  14. connect_timeout = 2000
  15. resolve_intv = 60000
  16. resolve_timeout = 2000

  17. # group1
  18. local = 127.0.0.1:5000
  19. remote = 1.1.1.1:443

  20. # group2 (use ipv6)
  21. local = ::1:10000
  22. remote = 2.2.2.2:8080

  23. # group3 (use domain name)
  24. local = :15000
  25. remote = www.google.com:80

  26. # and more...
复制代码

       
发表于 2021-5-29 13:51:32 | 显示全部楼层
还是socat吧。。。
发表于 2021-5-29 13:47:29 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
 楼主| 发表于 2021-5-29 13:49:13 | 显示全部楼层
h20 发表于 2021-5-29 13:47
没有外部依赖?glibc不算?

= =也就glibc了,毕竟不用特地去装
发表于 2021-5-29 13:49:21 | 显示全部楼层
前排占位出售啤酒花生瓜子饮料
发表于 2021-5-29 13:57:16 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
发表于 2021-5-29 14:03:16 | 显示全部楼层
proxy protocol支持吗
发表于 2021-5-29 14:05:29 | 显示全部楼层
支持百家争鸣,但是
15G/s
还是@几个机场主来吧,一般用户感觉也用不到
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2024-3-29 18:31 , Processed in 0.064726 second(s), 9 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表