Sha256: d75d8732e906ed939a2d9c2702763a81360e9d945e72ad835ae7f3917fde88e4

Contents?: true

Size: 892 Bytes

Versions: 4

Compression:

Stored size: 892 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
    GitRouter.lookup(name)
  else
    :noop
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mojombo-proxymachine-0.1.0 examples/git.rb
mojombo-proxymachine-0.1.1 examples/git.rb
mojombo-proxymachine-0.1.2 examples/git.rb
mojombo-proxymachine-0.1.3 examples/git.rb