CARVIEW |
Every repository with this icon (

Every repository with this icon (

Run the following if you haven't already:
gem sources -a https://gems.github.com
Install the gem(s):
sudo gem install mojombo-proxymachine
Description: | A simple TCP routing proxy built on EventMachine that lets you configure the routing logic in Ruby. |
Clone URL: |
git://github.com/mojombo/proxymachine.git
Give this clone URL to anyone.
git clone git://github.com/mojombo/proxymachine.git
|
tree 26b301b42d6dd77369cfa649b142e0aa6fdf8ecc
parent f195627999ad0132a876c4cfdffa1f3c4a86245f
name | age | message | |
---|---|---|---|
![]() |
.document | Fri Apr 24 16:48:18 -0700 2009 | Initial commit to proxymachine. [mojombo] |
![]() |
.gitignore | Fri Apr 24 16:48:18 -0700 2009 | Initial commit to proxymachine. [mojombo] |
![]() |
LICENSE | Fri Apr 24 16:48:18 -0700 2009 | Initial commit to proxymachine. [mojombo] |
![]() |
README.md | Mon Apr 27 18:22:34 -0700 2009 | let's make that alpha software for good measure [mojombo] |
![]() |
Rakefile | Mon Apr 27 18:07:09 -0700 2009 | add eventmachine dep to rakefile [mojombo] |
![]() |
VERSION.yml | Loading commit data... ![]() |
|
![]() |
bin/ | ||
![]() |
examples/ | Mon Apr 27 18:24:27 -0700 2009 | make the transparent proxy a bit more talky [mojombo] |
![]() |
lib/ | ||
![]() |
proxymachine.gemspec | ||
![]() |
test/ | Fri Apr 24 16:48:18 -0700 2009 | Initial commit to proxymachine. [mojombo] |
ProxyMachine
By Tom Preston-Werner (tom@mojombo.com)
WARNING: This software is alpha and should not be used in production without extensive testing. You should not consider this project production ready until it is released as 1.0.
Description
ProxyMachine is a simple content aware (layer 7) TCP routing proxy built on EventMachine that lets you configure the routing logic in Ruby.
If you need to proxy connections to different backend servers depending on the contents of the transmission, then ProxyMachine will make your life easy!
The idea here is simple. For each client connection, start receiving data chunks and placing them into a buffer. Each time a new chunk arrives, send the buffer to a user specified block. The block's job is to parse the buffer to determine where the connection should proxied. If the buffer contains enough data to make a determination, the block returns the address and port of the correct backend server. If not, it can choose to either do nothing and wait for more data to arrive, or close the connection. Once the block returns an address, a connection to the backend is made, the buffer is replayed to the backend, and the client and backend connections are hooked up to form a straight proxy. This bidirectional proxy continues to exist until with the client or backend close the connection.
Installation
gem install mojombo-proxymachine -s https://gems.github.com
Running
Usage:
proxymachine -c <config file> [-h <host>] [-p <port>]
Options:
-c, --config CONFIG Configuration file
-h, --host HOST Hostname to bind. Default 0.0.0.0
-p, --port PORT Port to listen on. Default 5432
Example routing config file
class GitRouter
# Look at the routing table and return the correct address for +name+
# Returns "<host>:<port>" e.g. "ae8f31c.example.com:9418"
def self.lookup(name)
...
end
end
# Perform content-aware routing based on the stream data. Here, the
# header information from the Git protocol is parsed to find the
# username and a lookup routine is run on the name to find the correct
# backend server. If no match can be made yet, do nothing with the
# connection yet.
proxy do |data|
if data =~ %r{^....git-upload-pack /([\w\.\-]+)/[\w\.\-]+\000host=\w+\000}
name = $1
GitRouter.lookup(name)
else
:noop
end
end
Contribute
If you'd like to hack on ProxyMachine, start by forking my repo on GitHub:
https://github.com/mojombo/proxymachine
To get all of the dependencies, install the gem first. The best way to get your changes merged back into core is as follows:
- Clone down your fork
- Create a topic branch to contain your change
- Hack away
- Add tests and make sure everything still passes by running
rake
- If you are adding new functionality, document it in the README.md
- Do not change the version number, I will do that on my end
- If necessary, rebase your commits into logical chunks, without errors
- Push the branch up to GitHub
- Send me (mojombo) a pull request for your branch
Copyright
Copyright (c) 2009 Tom Preston-Werner. See LICENSE for details.