Sha256: 253f6a716815a9b096a3d9b119f6cadeca41dd5c9c56b13c4cf390855cb295ad

Contents?: true

Size: 919 Bytes

Versions: 7

Compression:

Stored size: 919 Bytes

Contents

# This is a config file for ProxyMachine. It pulls the username out of
# the Git stream and can proxy to different locations based on that value
# Run with `proxymachine -c examples/git.rb`

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)
    puts "Proxying for user #{name}"
    "localhost:9418"
  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=(.+)\000}
    name, host = $1, $2
    { :remote => GitRouter.lookup(name) }
  else
    { :noop => true }
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
mojombo-proxymachine-0.2.0 examples/git.rb
mojombo-proxymachine-0.2.1 examples/git.rb
mojombo-proxymachine-0.2.2 examples/git.rb
mojombo-proxymachine-0.2.3 examples/git.rb
proxymachine-0.2.7 examples/git.rb
proxymachine-0.2.6 examples/git.rb
proxymachine-0.2.3 examples/git.rb