Sha256: 3f60a0bdb441d4912e44c9fbc7668dfd7e5df9c785ed41aa8d19278433590f4c

Contents?: true

Size: 927 Bytes

Versions: 12

Compression:

Stored size: 927 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)
    $logger.info "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

12 entries across 12 versions & 1 rubygems

Version Path
fizx-proxymachine-1.8.0 examples/git.rb
fizx-proxymachine-1.7.1 examples/git.rb
fizx-proxymachine-1.7.0 examples/git.rb
fizx-proxymachine-1.6.1 examples/git.rb
fizx-proxymachine-1.6.0 examples/git.rb
fizx-proxymachine-1.5.4 examples/git.rb
fizx-proxymachine-1.5.3 examples/git.rb
fizx-proxymachine-1.5.2 examples/git.rb
fizx-proxymachine-1.5.1 examples/git.rb
fizx-proxymachine-1.5.0 examples/git.rb
fizx-proxymachine-1.4.0 examples/git.rb
fizx-proxymachine-1.3.0 examples/git.rb