Git Product home page Git Product logo

naiveproxy's Introduction

naiveproxy

一个基于C++的proxy程序。

C语言版本

功能

通过代理服务器的流量转发功能,实现内外网通信。

目前支持的协议:TCP

使用方法

安装:

mkdir build
cd build
cmake ../
make
sudo make install
sudo touch /etc/naiveproxy.conf

使用:配置naiveproxy.conf文件

sudo vi /etc/naiveproxy.conf
#参数说明:
#协议类型,目前只支持TCP
#proxy服务器IP地址
#proxy服务器端口
#目的IP地址
#目的端口
#例子:外网想通过proxy服务器(192.168.3.90)的6666号端口访问内网(192.168.100.233)的80端口(web服务)
TCP     192.168.3.90    6666    192.168.100.233 80

关闭进程:

killall -9 naiveproxy

技术原理

基本流程:创建守护进程,读取配置文件,每一条配置fork一个子进程进行处理。

每一个子进程accept对应proxy server IP和port上的连接请求,并根据其destination ip和port向目的地发出connect请求,建立两个连接。

多个连接使用epollIO复用模型,ET工作模式。

两个连接对应两个socket,使用哈希表进行映射,当一个socket可读的时候,读取数据,然后通过查询哈希表得到对端的socket,写入读到的数据。

TODO LIST

  • 扩充协议:UDP、HTTP等
  • dns解析
  • 完善日志系统
  • 添加信号处理
  • 零拷贝技术
  • 连接池
  • 细节处理
  • 兼容性问题
  • 完善安装脚本
  • 跨平台
  • ……

naiveproxy's People

Stargazers

 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.