Parent

OpenShift::Runtime::Frontend::Http::Plugins::HaproxySNIProxy

Attributes

sni_ports[R]

Public Class Methods

new(*args) click to toggle source
# File lib/openshift/runtime/frontend/http/plugins/haproxy-sni-proxy.rb, line 37
def initialize(*args)
  @sni_ports = HaproxySNIProxyDB.get_ports

  super(*args)
end
purge_by_fqdn(fqdn) click to toggle source
# File lib/openshift/runtime/frontend/http/plugins/haproxy-sni-proxy.rb, line 47
def self.purge_by_fqdn(fqdn)
  HaproxySNIProxyDB.open(HaproxySNIProxyDB::WRCREAT) do |d|
    d.delete(fqdn)
  end
end

Public Instance Methods

add_alias(name) click to toggle source
# File lib/openshift/runtime/frontend/http/plugins/haproxy-sni-proxy.rb, line 128
def add_alias(name)
  with_create do |d|
    d[@fqdn]["aliases"] << name
  end
end
aliases() click to toggle source
# File lib/openshift/runtime/frontend/http/plugins/haproxy-sni-proxy.rb, line 121
def aliases
  reader_if_exists do |d|
    return d[@fqdn]["aliases"].clone
  end
  nil
end
connect(*elements) click to toggle source
# File lib/openshift/runtime/frontend/http/plugins/haproxy-sni-proxy.rb, line 60
def connect(*elements)
  reported_urls=[]
  with_create do |d|
    elements.each do |path, uri, options|

      next unless options["protocols"] and options["protocols"].include?("tls")

      if path.empty?
        reqport = @sni_ports[0]
      elsif path =~ /^TLS_PORT_(\d+)$/
        idx = $~[1].to_i - 1
        if idx >=0
          reqport = @sni_ports[idx]
        end
      elsif @sni_ports.include?(path.to_i)
        reqport = path.to_i
      end

      if not reqport
        raise PluginException.new("Invalid port specified for SNI proxy \"#{path}\" (must either be \"\", or TLS_PORT_1, TLS_PORT_2, etc...)", @container_uuid, @fqdn)
      end

      if uri !~ /^\d+\.\d+\.\d+\.\d+\:\d+$/
        raise PluginException.new("SNI proxy target must be IP:PORT", @container_uuid, @fqdn)
      end

      d[@fqdn]["connections"][reqport]=uri

      reported_urls << "tls:#{@fqdn}:#{reqport}"

    end
  end
  reported_urls
end
connections() click to toggle source
# File lib/openshift/runtime/frontend/http/plugins/haproxy-sni-proxy.rb, line 95
def connections
  reader_if_exists do |d|
    return d[@fqdn]["connections"].select { |port, backend|
      backend.to_s != ""
    }.map { |port, backend|
      ["TLS_PORT_#{@sni_ports.index(port.to_i).to_i+1}", backend, { "protocols"=>["tls"] } ]
    }
  end
  []
end
create() click to toggle source
# File lib/openshift/runtime/frontend/http/plugins/haproxy-sni-proxy.rb, line 43
def create
  with_create
end
destroy() click to toggle source
# File lib/openshift/runtime/frontend/http/plugins/haproxy-sni-proxy.rb, line 53
def destroy
  writer_if_exists do |d|
    d.delete(@fqdn)
  end
end
disconnect(*paths) click to toggle source
# File lib/openshift/runtime/frontend/http/plugins/haproxy-sni-proxy.rb, line 106
def disconnect(*paths)
  writer_if_exists do |d|
    paths.each do |path|
      reqport = path
      if path=~/^TLS_PORT_(\d+)$/
        idx = $~[1].to_i - 1
        if idx >=0
          reqport = @sni_ports[idx]
        end
      end
      d[@fqdn]["connections"].delete(reqport)
    end
  end
end
remove_alias(name) click to toggle source
# File lib/openshift/runtime/frontend/http/plugins/haproxy-sni-proxy.rb, line 134
def remove_alias(name)
  writer_if_exists do |d|
    d[@fqdn]["aliases"].delete(name)
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.