falcon 0.42.3 → 0.44.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/bake/falcon/supervisor.rb +3 -1
- data/changes.md +22 -0
- data/lib/falcon/command/host.rb +7 -50
- data/lib/falcon/command/paths.rb +2 -19
- data/lib/falcon/command/proxy.rb +21 -33
- data/lib/falcon/command/redirect.rb +22 -33
- data/lib/falcon/command/serve.rb +44 -82
- data/lib/falcon/command/supervisor.rb +2 -19
- data/lib/falcon/command/top.rb +2 -19
- data/lib/falcon/command/virtual.rb +16 -41
- data/lib/falcon/command.rb +3 -19
- data/lib/falcon/configuration.rb +28 -142
- data/lib/falcon/endpoint.rb +2 -19
- data/lib/falcon/environment/application.rb +60 -0
- data/lib/falcon/environment/lets_encrypt_tls.rb +34 -0
- data/lib/falcon/environment/proxy.rb +109 -0
- data/lib/falcon/environment/rack.rb +20 -0
- data/lib/falcon/environment/rackup.rb +26 -0
- data/lib/falcon/environment/redirect.rb +50 -0
- data/lib/falcon/environment/self_signed_tls.rb +45 -0
- data/lib/falcon/environment/server.rb +69 -0
- data/lib/falcon/environment/supervisor.rb +40 -0
- data/lib/falcon/environment/tls.rb +97 -0
- data/lib/falcon/environment.rb +13 -0
- data/lib/falcon/middleware/proxy.rb +3 -20
- data/lib/falcon/middleware/redirect.rb +2 -19
- data/lib/falcon/middleware/verbose.rb +2 -19
- data/lib/falcon/proxy_endpoint.rb +2 -19
- data/lib/falcon/railtie.rb +10 -0
- data/lib/falcon/server.rb +2 -19
- data/lib/falcon/service/server.rb +84 -0
- data/lib/falcon/service/supervisor.rb +5 -21
- data/lib/falcon/{controller → service}/virtual.rb +72 -36
- data/lib/falcon/tls.rb +2 -19
- data/lib/falcon/version.rb +3 -20
- data/lib/falcon.rb +5 -19
- data/lib/rack/handler/falcon.rb +4 -0
- data/lib/rackup/handler/falcon.rb +83 -0
- data/license.md +41 -0
- data/readme.md +60 -0
- data.tar.gz.sig +0 -0
- metadata +37 -117
- metadata.gz.sig +0 -0
- data/lib/.DS_Store +0 -0
- data/lib/falcon/controller/host.rb +0 -72
- data/lib/falcon/controller/proxy.rb +0 -126
- data/lib/falcon/controller/redirect.rb +0 -76
- data/lib/falcon/controller/serve.rb +0 -126
- data/lib/falcon/environments/application.rb +0 -72
- data/lib/falcon/environments/lets_encrypt_tls.rb +0 -47
- data/lib/falcon/environments/proxy.rb +0 -37
- data/lib/falcon/environments/rack.rb +0 -50
- data/lib/falcon/environments/self_signed_tls.rb +0 -55
- data/lib/falcon/environments/supervisor.rb +0 -51
- data/lib/falcon/environments/tls.rb +0 -103
- data/lib/falcon/environments.rb +0 -31
- data/lib/falcon/service/application.rb +0 -115
- data/lib/falcon/service/generic.rb +0 -78
- data/lib/falcon/service/proxy.rb +0 -66
- data/lib/falcon/services.rb +0 -99
@@ -1,76 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
4
|
-
#
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
# of this software and associated documentation files (the "Software"), to deal
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
10
|
-
# furnished to do so, subject to the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be included in
|
13
|
-
# all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
# THE SOFTWARE.
|
22
|
-
|
23
|
-
require 'async/container/controller'
|
24
|
-
|
25
|
-
require_relative 'serve'
|
26
|
-
require_relative '../middleware/redirect'
|
27
|
-
require_relative '../service/proxy'
|
28
|
-
|
29
|
-
module Falcon
|
30
|
-
module Controller
|
31
|
-
# A controller for redirecting requests.
|
32
|
-
class Redirect < Serve
|
33
|
-
# Initialize the redirect controller.
|
34
|
-
# @parameter command [Command::Redirect] The user-specified command-line options.
|
35
|
-
def initialize(command, **options)
|
36
|
-
super(command, **options)
|
37
|
-
|
38
|
-
@hosts = {}
|
39
|
-
end
|
40
|
-
|
41
|
-
# Load the {Middleware::Redirect} application with the specified hosts.
|
42
|
-
def load_app
|
43
|
-
return Middleware::Redirect.new(Middleware::NotFound, @hosts, @command.redirect_endpoint)
|
44
|
-
end
|
45
|
-
|
46
|
-
# The name of the controller which is used for the process title.
|
47
|
-
def name
|
48
|
-
"Falcon Redirect Server"
|
49
|
-
end
|
50
|
-
|
51
|
-
# The endpoint the server will bind to.
|
52
|
-
def endpoint
|
53
|
-
@command.endpoint.with(
|
54
|
-
reuse_address: true,
|
55
|
-
)
|
56
|
-
end
|
57
|
-
|
58
|
-
# Builds a map of host redirections.
|
59
|
-
def start
|
60
|
-
configuration = @command.configuration
|
61
|
-
|
62
|
-
services = Services.new(configuration)
|
63
|
-
|
64
|
-
@hosts = {}
|
65
|
-
|
66
|
-
services.each do |service|
|
67
|
-
if service.is_a?(Service::Proxy)
|
68
|
-
@hosts[service.authority] = service
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
super
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
@@ -1,126 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright, 2019, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
4
|
-
#
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
# of this software and associated documentation files (the "Software"), to deal
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
10
|
-
# furnished to do so, subject to the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be included in
|
13
|
-
# all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
# THE SOFTWARE.
|
22
|
-
|
23
|
-
require_relative '../server'
|
24
|
-
|
25
|
-
require 'async/container/controller'
|
26
|
-
require 'async/io/trap'
|
27
|
-
|
28
|
-
require 'async/io/shared_endpoint'
|
29
|
-
|
30
|
-
module Falcon
|
31
|
-
module Controller
|
32
|
-
# A generic controller for serving an application.
|
33
|
-
# Uses {Server} for handling incoming requests.
|
34
|
-
class Serve < Async::Container::Controller
|
35
|
-
# Initialize the server controller.
|
36
|
-
# @parameter command [Command::Serve] The user-specified command-line options.
|
37
|
-
def initialize(command, **options)
|
38
|
-
@command = command
|
39
|
-
|
40
|
-
@endpoint = nil
|
41
|
-
@bound_endpoint = nil
|
42
|
-
@debug_trap = Async::IO::Trap.new(:USR1)
|
43
|
-
|
44
|
-
super(**options)
|
45
|
-
end
|
46
|
-
|
47
|
-
# Create the controller as specified by the command.
|
48
|
-
# e.g. `Async::Container::Forked`.
|
49
|
-
def create_container
|
50
|
-
@command.container_class.new
|
51
|
-
end
|
52
|
-
|
53
|
-
# The endpoint the server will bind to.
|
54
|
-
def endpoint
|
55
|
-
@command.endpoint
|
56
|
-
end
|
57
|
-
|
58
|
-
# @returns [Protocol::HTTP::Middleware] an instance of the application to be served.
|
59
|
-
def load_app
|
60
|
-
@command.load_app
|
61
|
-
end
|
62
|
-
|
63
|
-
# Prepare the bound endpoint for the server.
|
64
|
-
def start
|
65
|
-
@endpoint ||= self.endpoint
|
66
|
-
|
67
|
-
@bound_endpoint = Async do
|
68
|
-
Async::IO::SharedEndpoint.bound(@endpoint)
|
69
|
-
end.wait
|
70
|
-
|
71
|
-
Console.logger.info(self) { "Starting #{name} on #{@endpoint.to_url}" }
|
72
|
-
|
73
|
-
@debug_trap.ignore!
|
74
|
-
|
75
|
-
super
|
76
|
-
end
|
77
|
-
|
78
|
-
# The name of the controller which is used for the process title.
|
79
|
-
def name
|
80
|
-
"Falcon Server"
|
81
|
-
end
|
82
|
-
|
83
|
-
# Setup the container with the application instance.
|
84
|
-
# @parameter container [Async::Container::Generic]
|
85
|
-
def setup(container)
|
86
|
-
container.run(name: self.name, restart: true, **@command.container_options) do |instance|
|
87
|
-
Async do |task|
|
88
|
-
# Load one app instance per container:
|
89
|
-
app = self.load_app
|
90
|
-
|
91
|
-
task.async do
|
92
|
-
if @debug_trap.install!
|
93
|
-
Console.logger.info(instance) do
|
94
|
-
"- Per-process status: kill -USR1 #{Process.pid}"
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
@debug_trap.trap do
|
99
|
-
Console.logger.info(self) do |buffer|
|
100
|
-
task.reactor.print_hierarchy(buffer)
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
server = Falcon::Server.new(app, @bound_endpoint, protocol: @endpoint.protocol, scheme: @endpoint.scheme)
|
106
|
-
|
107
|
-
server.run
|
108
|
-
|
109
|
-
instance.ready!
|
110
|
-
|
111
|
-
task.children.each(&:wait)
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
# Close the bound endpoint.
|
117
|
-
def stop(*)
|
118
|
-
@bound_endpoint&.close
|
119
|
-
|
120
|
-
@debug_trap.default!
|
121
|
-
|
122
|
-
super
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|
126
|
-
end
|
@@ -1,72 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright, 2019, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
4
|
-
#
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
# of this software and associated documentation files (the "Software"), to deal
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
10
|
-
# furnished to do so, subject to the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be included in
|
13
|
-
# all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
# THE SOFTWARE.
|
22
|
-
|
23
|
-
require_relative '../proxy_endpoint'
|
24
|
-
require_relative '../server'
|
25
|
-
|
26
|
-
require_relative '../service/application'
|
27
|
-
|
28
|
-
# A general application environment.
|
29
|
-
# Suitable for use with any {Protocol::HTTP::Middleware}.
|
30
|
-
#
|
31
|
-
# @scope Falcon Environments
|
32
|
-
# @name application
|
33
|
-
environment(:application) do
|
34
|
-
# The middleware stack for the application.
|
35
|
-
# @attribute [Protocol::HTTP::Middleware]
|
36
|
-
middleware do
|
37
|
-
::Protocol::HTTP::Middleware::HelloWorld
|
38
|
-
end
|
39
|
-
|
40
|
-
# The scheme to use to communicate with the application.
|
41
|
-
# @attribute [String]
|
42
|
-
scheme 'https'
|
43
|
-
|
44
|
-
# The protocol to use to communicate with the application.
|
45
|
-
#
|
46
|
-
# Typically one of {Async::HTTP::Protocol::HTTP1} or {Async::HTTP::Protocl::HTTP2}.
|
47
|
-
#
|
48
|
-
# @attribute [Async::HTTP::Protocol]
|
49
|
-
protocol {Async::HTTP::Protocol::HTTP2}
|
50
|
-
|
51
|
-
# The IPC path to use for communication with the application.
|
52
|
-
# @attribute [String]
|
53
|
-
ipc_path {::File.expand_path("application.ipc", root)}
|
54
|
-
|
55
|
-
# The endpoint that will be used for communicating with the application server.
|
56
|
-
# @attribute [Async::IO::Endpoint]
|
57
|
-
endpoint do
|
58
|
-
::Falcon::ProxyEndpoint.unix(ipc_path,
|
59
|
-
protocol: protocol,
|
60
|
-
scheme: scheme,
|
61
|
-
authority: authority
|
62
|
-
)
|
63
|
-
end
|
64
|
-
|
65
|
-
# The service class to use for the application.
|
66
|
-
# @attribute [Class]
|
67
|
-
service ::Falcon::Service::Application
|
68
|
-
|
69
|
-
# Number of instances to start.
|
70
|
-
# @attribute [Integer | nil]
|
71
|
-
count nil
|
72
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright, 2019, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
4
|
-
#
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
# of this software and associated documentation files (the "Software"), to deal
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
10
|
-
# furnished to do so, subject to the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be included in
|
13
|
-
# all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
# THE SOFTWARE.
|
22
|
-
|
23
|
-
load(:tls)
|
24
|
-
|
25
|
-
# A Lets Encrypt SSL context environment.
|
26
|
-
#
|
27
|
-
# Derived from {.tls}.
|
28
|
-
#
|
29
|
-
# @scope Falcon Environments
|
30
|
-
# @name lets_encrypt_tls
|
31
|
-
environment(:lets_encrypt_tls, :tls) do
|
32
|
-
# The Lets Encrypt certificate store path.
|
33
|
-
# @parameter [String]
|
34
|
-
lets_encrypt_root '/etc/letsencrypt/live'
|
35
|
-
|
36
|
-
# The public certificate path.
|
37
|
-
# @attribute [String]
|
38
|
-
ssl_certificate_path do
|
39
|
-
File.join(lets_encrypt_root, authority, "fullchain.pem")
|
40
|
-
end
|
41
|
-
|
42
|
-
# The private key path.
|
43
|
-
# @attribute [String]
|
44
|
-
ssl_private_key_path do
|
45
|
-
File.join(lets_encrypt_root, authority, "privkey.pem")
|
46
|
-
end
|
47
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright, 2019, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
4
|
-
#
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
# of this software and associated documentation files (the "Software"), to deal
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
10
|
-
# furnished to do so, subject to the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be included in
|
13
|
-
# all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
# THE SOFTWARE.
|
22
|
-
|
23
|
-
# A HTTP proxy environment.
|
24
|
-
#
|
25
|
-
# Derived from {.application}.
|
26
|
-
#
|
27
|
-
# @scope Falcon Environments
|
28
|
-
# @name rack
|
29
|
-
environment(:proxy) do
|
30
|
-
# The upstream endpoint that will handle incoming requests.
|
31
|
-
# @attribute [Async::HTTP::Endpoint]
|
32
|
-
endpoint {::Async::HTTP::Endpoint.parse(url)}
|
33
|
-
|
34
|
-
# The service class to use for the proxy.
|
35
|
-
# @attribute [Class]
|
36
|
-
service ::Falcon::Service::Proxy
|
37
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright, 2019, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
4
|
-
#
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
# of this software and associated documentation files (the "Software"), to deal
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
10
|
-
# furnished to do so, subject to the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be included in
|
13
|
-
# all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
# THE SOFTWARE.
|
22
|
-
|
23
|
-
load :application
|
24
|
-
|
25
|
-
# A rack application environment.
|
26
|
-
#
|
27
|
-
# Derived from {.application}.
|
28
|
-
#
|
29
|
-
# @scope Falcon Environments
|
30
|
-
# @name rack
|
31
|
-
environment(:rack, :application) do
|
32
|
-
# The rack configuration path.
|
33
|
-
# @attribute [String]
|
34
|
-
config_path {::File.expand_path("config.ru", root)}
|
35
|
-
|
36
|
-
# Whether to enable the application layer cache.
|
37
|
-
# @attribute [String]
|
38
|
-
cache false
|
39
|
-
|
40
|
-
# The middleware stack for the rack application.
|
41
|
-
# @attribute [Protocol::HTTP::Middleware]
|
42
|
-
middleware do
|
43
|
-
app, _ = ::Rack::Builder.parse_file(config_path)
|
44
|
-
|
45
|
-
::Falcon::Server.middleware(app,
|
46
|
-
verbose: verbose,
|
47
|
-
cache: cache
|
48
|
-
)
|
49
|
-
end
|
50
|
-
end
|
@@ -1,55 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright, 2019, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
4
|
-
#
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
# of this software and associated documentation files (the "Software"), to deal
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
10
|
-
# furnished to do so, subject to the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be included in
|
13
|
-
# all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
# THE SOFTWARE.
|
22
|
-
|
23
|
-
require 'localhost/authority'
|
24
|
-
|
25
|
-
# A self-signed SSL context environment.
|
26
|
-
#
|
27
|
-
# @scope Falcon Environments
|
28
|
-
# @name self_signed_tls
|
29
|
-
environment(:self_signed_tls) do
|
30
|
-
# The default session identifier for the session cache.
|
31
|
-
# @attribute [String]
|
32
|
-
ssl_session_id {"falcon"}
|
33
|
-
|
34
|
-
# The SSL context to use for incoming connections.
|
35
|
-
# @attribute [OpenSSL::SSL::SSLContext]
|
36
|
-
ssl_context do
|
37
|
-
contexts = Localhost::Authority.fetch(authority)
|
38
|
-
|
39
|
-
contexts.server_context.tap do |context|
|
40
|
-
context.alpn_select_cb = lambda do |protocols|
|
41
|
-
if protocols.include? "h2"
|
42
|
-
return "h2"
|
43
|
-
elsif protocols.include? "http/1.1"
|
44
|
-
return "http/1.1"
|
45
|
-
elsif protocols.include? "http/1.0"
|
46
|
-
return "http/1.0"
|
47
|
-
else
|
48
|
-
return nil
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
context.session_id_context = ssl_session_id
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
@@ -1,51 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright, 2019, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
4
|
-
#
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
# of this software and associated documentation files (the "Software"), to deal
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
10
|
-
# furnished to do so, subject to the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be included in
|
13
|
-
# all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
# THE SOFTWARE.
|
22
|
-
|
23
|
-
require_relative '../service/supervisor'
|
24
|
-
|
25
|
-
# A application process monitor environment.
|
26
|
-
#
|
27
|
-
# @scope Falcon Environments
|
28
|
-
# @name supervisor
|
29
|
-
environment(:supervisor) do
|
30
|
-
# The name of the supervisor
|
31
|
-
# @attribute [String]
|
32
|
-
name "supervisor"
|
33
|
-
|
34
|
-
# The IPC path to use for communication with the supervisor.
|
35
|
-
# @attribute [String]
|
36
|
-
ipc_path do
|
37
|
-
::File.expand_path("supervisor.ipc", root)
|
38
|
-
end
|
39
|
-
|
40
|
-
# The endpoint the supervisor will bind to.
|
41
|
-
# @attribute [Async::IO::Endpoint]
|
42
|
-
endpoint do
|
43
|
-
Async::IO::Endpoint.unix(ipc_path)
|
44
|
-
end
|
45
|
-
|
46
|
-
# The service class to use for the supervisor.
|
47
|
-
# @attribute [Class]
|
48
|
-
service do
|
49
|
-
::Falcon::Service::Supervisor
|
50
|
-
end
|
51
|
-
end
|
@@ -1,103 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright, 2019, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
4
|
-
#
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
# of this software and associated documentation files (the "Software"), to deal
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
10
|
-
# furnished to do so, subject to the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be included in
|
13
|
-
# all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
# THE SOFTWARE.
|
22
|
-
|
23
|
-
require_relative '../controller/proxy'
|
24
|
-
require_relative '../tls'
|
25
|
-
|
26
|
-
# A general SSL context environment.
|
27
|
-
#
|
28
|
-
# @scope Falcon Environments
|
29
|
-
# @name tls
|
30
|
-
environment(:tls) do
|
31
|
-
# The default session identifier for the session cache.
|
32
|
-
# @attribute [String]
|
33
|
-
ssl_session_id "falcon"
|
34
|
-
|
35
|
-
# The supported ciphers.
|
36
|
-
# @attribute [Array(String)]
|
37
|
-
ssl_ciphers Falcon::TLS::SERVER_CIPHERS
|
38
|
-
|
39
|
-
# The public certificate path.
|
40
|
-
# @attribute [String]
|
41
|
-
ssl_certificate_path do
|
42
|
-
File.expand_path("ssl/certificate.pem", root)
|
43
|
-
end
|
44
|
-
|
45
|
-
# The list of certificates loaded from that path.
|
46
|
-
# @attribute [Array(OpenSSL::X509::Certificate)]
|
47
|
-
ssl_certificates do
|
48
|
-
OpenSSL::X509::Certificate.load_file(ssl_certificate_path)
|
49
|
-
end
|
50
|
-
|
51
|
-
# The main certificate.
|
52
|
-
# @attribute [OpenSSL::X509::Certificate]
|
53
|
-
ssl_certificate {ssl_certificates[0]}
|
54
|
-
|
55
|
-
# The certificate chain.
|
56
|
-
# @attribute [Array(OpenSSL::X509::Certificate)]
|
57
|
-
ssl_certificate_chain {ssl_certificates[1..-1]}
|
58
|
-
|
59
|
-
# The private key path.
|
60
|
-
# @attribute [String]
|
61
|
-
ssl_private_key_path do
|
62
|
-
File.expand_path("ssl/private.key", root)
|
63
|
-
end
|
64
|
-
|
65
|
-
# The private key.
|
66
|
-
# @attribute [OpenSSL::PKey::RSA]
|
67
|
-
ssl_private_key do
|
68
|
-
OpenSSL::PKey::RSA.new(File.read(ssl_private_key_path))
|
69
|
-
end
|
70
|
-
|
71
|
-
# The SSL context to use for incoming connections.
|
72
|
-
# @attribute [OpenSSL::SSL::SSLContext]
|
73
|
-
ssl_context do
|
74
|
-
OpenSSL::SSL::SSLContext.new.tap do |context|
|
75
|
-
context.add_certificate(ssl_certificate, ssl_private_key, ssl_certificate_chain)
|
76
|
-
|
77
|
-
context.session_cache_mode = OpenSSL::SSL::SSLContext::SESSION_CACHE_CLIENT
|
78
|
-
context.session_id_context = ssl_session_id
|
79
|
-
|
80
|
-
context.alpn_select_cb = lambda do |protocols|
|
81
|
-
if protocols.include? "h2"
|
82
|
-
return "h2"
|
83
|
-
elsif protocols.include? "http/1.1"
|
84
|
-
return "http/1.1"
|
85
|
-
elsif protocols.include? "http/1.0"
|
86
|
-
return "http/1.0"
|
87
|
-
else
|
88
|
-
return nil
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
# TODO Ruby 2.4 requires using ssl_version.
|
93
|
-
context.ssl_version = :TLSv1_2_server
|
94
|
-
|
95
|
-
context.set_params(
|
96
|
-
ciphers: ssl_ciphers,
|
97
|
-
verify_mode: OpenSSL::SSL::VERIFY_NONE,
|
98
|
-
)
|
99
|
-
|
100
|
-
context.setup
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
data/lib/falcon/environments.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
4
|
-
#
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
# of this software and associated documentation files (the "Software"), to deal
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
10
|
-
# furnished to do so, subject to the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be included in
|
13
|
-
# all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
# THE SOFTWARE.
|
22
|
-
|
23
|
-
require 'build/environment'
|
24
|
-
|
25
|
-
module Falcon
|
26
|
-
# Pre-defined environments for hosting web applications.
|
27
|
-
#
|
28
|
-
# See {Configuration::Loader#load} for more details.
|
29
|
-
module Environments
|
30
|
-
end
|
31
|
-
end
|