Class: Falcon::Controller::Proxy
- Inherits:
-
Serve
- Object
- Async::Container::Controller
- Serve
- Falcon::Controller::Proxy
show all
- Defined in:
- lib/falcon/controller/proxy.rb
Constant Summary
collapse
- SERVER_CIPHERS =
"EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5".freeze
- DEFAULT_SESSION_ID =
"falcon"
Instance Method Summary
collapse
Methods inherited from Serve
#create_container, #setup, #stop
Constructor Details
#initialize(command, session_id: DEFAULT_SESSION_ID, **options) ⇒ Proxy
32
33
34
35
36
37
|
# File 'lib/falcon/controller/proxy.rb', line 32
def initialize(command, session_id: DEFAULT_SESSION_ID, **options)
super(command, **options)
@session_id = session_id
@hosts = {}
end
|
Instance Method Details
#endpoint ⇒ Object
78
79
80
81
82
83
|
# File 'lib/falcon/controller/proxy.rb', line 78
def endpoint
@command.endpoint.with(
ssl_context: self.ssl_context,
reuse_address: true,
)
end
|
#host_context(socket, hostname) ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/falcon/controller/proxy.rb', line 47
def host_context(socket, hostname)
if host = @hosts[hostname]
Async.logger.debug(self) {"Resolving #{hostname} -> #{host}"}
socket.hostname = hostname
return host.ssl_context
else
Async.logger.warn(self) {"Unable to resolve #{hostname}!"}
return nil
end
end
|
#load_app ⇒ Object
39
40
41
|
# File 'lib/falcon/controller/proxy.rb', line 39
def load_app
return Middleware::Proxy.new(Middleware::BadRequest, @hosts)
end
|
#name ⇒ Object
43
44
45
|
# File 'lib/falcon/controller/proxy.rb', line 43
def name
"Falcon Proxy Server"
end
|
#ssl_context ⇒ Object
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
# File 'lib/falcon/controller/proxy.rb', line 61
def ssl_context
@server_context ||= OpenSSL::SSL::SSLContext.new.tap do |context|
context.servername_cb = Proc.new do |socket, hostname|
self.host_context(socket, hostname)
end
context.session_id_context = @session_id
context.set_params(
ciphers: SERVER_CIPHERS,
verify_mode: OpenSSL::SSL::VERIFY_NONE,
)
context.setup
end
end
|
#start ⇒ Object
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
# File 'lib/falcon/controller/proxy.rb', line 85
def start
configuration = @command.configuration
services = Services.new(configuration)
@hosts = {}
services.each do |service|
if service.is_a?(Service::Application)
@hosts[service.authority] = service
end
end
super
end
|