Git Product home page Git Product logo

tunnel-1's Introduction

##转发工具:

c语言写的端口转发工具
主要用来实现访问内网机器,当然也可以作为跳板工具使用。
写这个工具的原因是因为拉了N级运营商的宽带,没有外网ip,人在外面的时候无法访问家里的电脑。。。
端口转发有很多现成的工具,但自己写好玩点

ps:mem_pool.c 这个文件没用到,内存管理的代码是buffer.c

##Usage: 1、首先要有台外网ip的机器
2、在外网机器运行:tunnel -s port1[给内网机器连接的端口] prot2[给客户端连接的端口,比如secureCRT 这种ssh客户端] 如:tunnel -s 2222 3333
3、在内网机器上运行:tunnel -c port1[要连接的本机服务端口,比如家里的ssh服务22端口] prot2[外网机器的监听的端口] 如:tunnel -c 22 2222
4、任意机器连接外网的3333端口,发送的数据都将转发给内网机器22端口上(如secureCRT连接 外网ip:3333)

##INSTALL:

g++ -MMD -ggdb -Wall -lpthread -o tunnel  buffer.c socket_comm.c client.c server.c tunnel.c

##TODO:

man accept
RETURN VALUE
  On success, these system calls return a non-negative integer that is  a  descriptor
  for the accepted socket.  On error, -1 is returned, and errno is set appropriately.

1.fd改成0开始。通过man accept文档知道,合法的socket fd应该是从0开始的。。。我的代码fd默认值0,并以此作为初始状态,用来判断某些状态,在某些极端情况会出错。
2.和server建立连接后,server是等待客户端发包后再处理转发,但某些ssh客户端(如xshell)建立连接后在等待服务端返回数据前不发任何包,导致双方互相等待
3.内存管理buffer还可以优化,目前是单buff全分配, 在回环前的时候,极端情况分配出来的内存太小,解决方案是加个最小内存块数,当环尾剩余内存块太小时,直接跳到环头再分配

##我的邮箱:

[email protected]

tunnel-1's People

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.