GithubHelp home page GithubHelp logo

stupid-proxy's Introduction

stupid-proxy

A simple routing proxy in Go. Accepts incoming connections on ports 80 and 443.

  • Connections on port 80 are assumed to be HTTP. A hostname is extracted from each using the HTTP "Host" header.
  • Connections on port 443 are assumed to be TLS. A hostname is extracted from the server name indication in the ClientHello bytes. Currently non-TLS SSL connections and TLS connections without SNIs are dropped messily.

Once a hostname has been extracted from the incoming connection, the proxy looks up a set of backends on a redis server, which is assumed to be running on 127.0.0.1:6379. The key for the set is hostnames:<the hostname from the connection>:backends. If there is no set stored in redis for the backend, it will check hostnames:httpDefault:backends for HTTP connections, or hostnames:httpsDefault:backends for HTTPS. If these latter two lookups fail or return empty sets, it will drop the connection.

A backend is then selected at random from the list that was supplied by redis, and the whole client connection is sent down to the appropriate port on that backend. The proxy will keep proxying data back and forth until one of the endpoints closes the connection.

Uses Juhani Åhman's radix client to access redis: https://github.com/fzzy/radix

MIT licensed, in case you're crazy enough to want to use it for something :-)

stupid-proxy's People

Contributors

gpjt 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  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.