Class: CZTop::Proxy::Configurator
- Inherits:
-
Object
- Object
- CZTop::Proxy::Configurator
- Defined in:
- lib/cztop/proxy.rb
Overview
Used to configure the socket on one side of a CZTop::Proxy.
Constant Summary collapse
- SOCKET_TYPES =
Returns supported socket types.
%i[ PAIR PUB SUB REQ REP DEALER ROUTER PULL PUSH XPUB XSUB ].freeze
Instance Attribute Summary collapse
-
#proxy ⇒ Proxy
readonly
The proxy this Configurator works on.
-
#side ⇒ String
readonly
The side, either “FRONTEND” or “BACKEND”.
Instance Method Summary collapse
-
#bind(socket_type, endpoint) ⇒ void
Creates and binds a serverish socket.
-
#CURVE_server!(cert) ⇒ Object
Configure CURVE authentication on this socket.
-
#domain=(domain) ⇒ Object
Set ZAP domain for authentication.
-
#initialize(proxy, side) ⇒ Configurator
constructor
A new instance of Configurator.
-
#PLAIN_server! ⇒ Object
Configure PLAIN authentication on this socket.
Constructor Details
#initialize(proxy, side) ⇒ Configurator
Returns a new instance of Configurator.
104 105 106 107 108 109 110 111 |
# 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 |
Instance Attribute Details
#proxy ⇒ Proxy (readonly)
Returns the proxy this CZTop::Proxy::Configurator works on.
114 115 116 |
# File 'lib/cztop/proxy.rb', line 114 def proxy @proxy end |
#side ⇒ String (readonly)
Returns the side, either “FRONTEND” or “BACKEND”.
117 118 119 |
# File 'lib/cztop/proxy.rb', line 117 def side @side end |
Instance Method Details
#bind(socket_type, endpoint) ⇒ void
This method returns an undefined value.
Creates and binds a serverish socket.
124 125 126 127 128 129 |
# 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 |
#CURVE_server!(cert) ⇒ Object
You’ll have to use a Authenticator.
Configure CURVE authentication on this socket.
152 153 154 155 156 157 158 159 |
# 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 |
#domain=(domain) ⇒ Object
Set ZAP domain for authentication.
134 135 136 137 |
# File 'lib/cztop/proxy.rb', line 134 def domain=(domain) @proxy.actor << ['DOMAIN', @side, domain] @proxy.actor.wait end |
#PLAIN_server! ⇒ Object
You’ll have to use a Authenticator.
Configure PLAIN authentication on this socket.
142 143 144 145 |
# File 'lib/cztop/proxy.rb', line 142 def PLAIN_server! @proxy.actor << ['PLAIN', @side] @proxy.actor.wait end |