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 ]
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.
93 94 95 96 97 98 99 100 |
# File 'lib/cztop/proxy.rb', line 93 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.
103 104 105 |
# File 'lib/cztop/proxy.rb', line 103 def proxy @proxy end |
#side ⇒ String (readonly)
Returns the side, either “FRONTEND” or “BACKEND”.
106 107 108 |
# File 'lib/cztop/proxy.rb', line 106 def side @side end |
Instance Method Details
#bind(socket_type, endpoint) ⇒ void
This method returns an undefined value.
Creates and binds a serverish socket.
113 114 115 116 117 118 119 |
# File 'lib/cztop/proxy.rb', line 113 def bind(socket_type, endpoint) unless SOCKET_TYPES.include?(socket_type) raise ArgumentError, "invalid socket type: #{socket_type}" end @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.
139 140 141 142 143 144 145 146 |
# File 'lib/cztop/proxy.rb', line 139 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.
123 124 125 126 |
# File 'lib/cztop/proxy.rb', line 123 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.
130 131 132 133 |
# File 'lib/cztop/proxy.rb', line 130 def PLAIN_server! @proxy.actor << [ "PLAIN", @side ] @proxy.actor.wait end |