class CZTop::Proxy::Configurator
Used to configure the socket on one side of a {Proxy}.
Constants
- SOCKET_TYPES
@return [Array<Symbol>] supported socket types
Attributes
proxy[R]
@return [Proxy] the proxy this {Configurator} works on
side[R]
@return [String] the side, either “FRONTEND” or “BACKEND”
Public Class Methods
new(proxy, side)
click to toggle source
@param proxy [Proxy] the proxy instance @param side [Symbol] :frontend or :backend
# File lib/cztop/proxy.rb, line 104 def initialize(proxy, side) @proxy = proxy @side = case side when :frontend then 'FRONTEND' when :backend then 'BACKEND' else raise ArgumentError, "invalid side: #{side.inspect}" end end
Public Instance Methods
CURVE_server!(cert)
click to toggle source
Configure CURVE authentication on this socket. @note You’ll have to use a {CZTop::Authenticator}. @param cert [Certificate] this server’s certificate,
so remote clients are able to authenticate this server
# File lib/cztop/proxy.rb, line 152 def CURVE_server!(cert) public_key = cert.public_key secret_key = cert.secret_key or raise ArgumentError, 'no secret key in certificate' @proxy.actor << ['CURVE', @side, public_key, secret_key] @proxy.actor.wait end
PLAIN_server!()
click to toggle source
Configure PLAIN authentication on this socket. @note You’ll have to use a {CZTop::Authenticator}.
# File lib/cztop/proxy.rb, line 142 def PLAIN_server! @proxy.actor << ['PLAIN', @side] @proxy.actor.wait end
bind(socket_type, endpoint)
click to toggle source
Creates and binds a serverish socket. @param socket_type [Symbol] one of {SOCKET_TYPES} @param endpoint [String] endpoint to bind to @raise [ArgumentError] if the given socket type is invalid @return [void]
# File lib/cztop/proxy.rb, line 124 def bind(socket_type, endpoint) raise ArgumentError, "invalid socket type: #{socket_type}" unless SOCKET_TYPES.include?(socket_type) @proxy.actor << [@side, socket_type.to_s, endpoint] @proxy.actor.wait end