falcon 0.14.1 → 0.14.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8fb22e9e65dae2598de9366fd050ce711c1c506186e4de000ece3ac391ba9291
4
- data.tar.gz: df1e5a1a889fb7867c088212f2849bc7639e7d63189745fac275fa45d3aa7d9a
3
+ metadata.gz: f847d041f11cc2854a3e2fd3e7d7568c0113b6530df89460599df8fb204204cf
4
+ data.tar.gz: a348fd0255c62fe12df681649bb4b9055f23f705c068115af7a8039075f4fae7
5
5
  SHA512:
6
- metadata.gz: b2433bbc082ac1cb8a354f8ae73f34b35d6ac7e39976b58d320c690dc97793e5f72f647b1cadaafe1eac6a0be12136a6777bf4ba2c9cebd5d845279078cfc541
7
- data.tar.gz: aaa936fdfa1e22b1ba9c1dc98c4edd4d77fb74a8135b62d9e3cfedbc7d11141f7681a56a1956992e2465f9c9790f7fac159e6d65ae8ea918b5fb197442c5b49e
6
+ metadata.gz: 335772ebca6b5e93a7c9de54c614e9a61522547ac06fba52d3014457644b9d74f7bc2530da6414f4a15e39b3da48289e36109d9776ecee4ce2d1cdfc0df55677
7
+ data.tar.gz: 1b696f587b0f3e9ba85be31bc740e81f377968d7bf9b183347629402ba0742e5c81a39dd524d55dcd7e4024bc7e65393fdfbf634978adb2272a77ffbcfed8ec3
data/lib/falcon/hosts.rb CHANGED
@@ -27,6 +27,8 @@ module Falcon
27
27
  @endpoint = nil
28
28
  @ssl_certificate = nil
29
29
  @ssl_key = nil
30
+
31
+ @ssl_context = nil
30
32
  end
31
33
 
32
34
  attr_accessor :app
@@ -35,6 +37,15 @@ module Falcon
35
37
 
36
38
  attr_accessor :ssl_certificate
37
39
  attr_accessor :ssl_key
40
+ attr_accessor :ssl_context
41
+
42
+ def freeze
43
+ return if frozen?
44
+
45
+ ssl_context
46
+
47
+ super
48
+ end
38
49
 
39
50
  def ssl_certificate_path= path
40
51
  @ssl_certificate = OpenSSL::X509::Certificate.new(File.read(path))
@@ -45,13 +56,15 @@ module Falcon
45
56
  end
46
57
 
47
58
  def ssl_context
48
- if @ssl_key
49
- OpenSSL::SSL::SSLContext.new.tap do |context|
50
- context.cert = @ssl_certificate
51
- context.key = @ssl_key
52
-
53
- context.set_params
54
- end
59
+ @ssl_context ||= OpenSSL::SSL::SSLContext.new(:TLSv1).tap do |context|
60
+ context.cert = @ssl_certificate
61
+ context.key = @ssl_key
62
+
63
+ context.session_id_context = "falcon"
64
+
65
+ context.set_params
66
+
67
+ context.freeze
55
68
  end
56
69
  end
57
70
 
@@ -81,21 +94,25 @@ module Falcon
81
94
 
82
95
  def endpoint
83
96
  @server_endpoint ||= Async::HTTP::URLEndpoint.parse(
84
- 'https://0.0.0.0',
97
+ 'https://[::]',
85
98
  ssl_context: self.ssl_context,
86
99
  reuse_address: true
87
100
  )
88
101
  end
89
102
 
90
103
  def ssl_context
91
- @server_context ||= OpenSSL::SSL::SSLContext.new.tap do |context|
104
+ @server_context ||= OpenSSL::SSL::SSLContext.new(:TLSv1).tap do |context|
92
105
  context.servername_cb = Proc.new do |socket, hostname|
93
106
  self.host_context(socket, hostname)
94
107
  end
95
108
 
109
+ context.session_id_context = "falcon"
110
+
96
111
  context.alpn_protocols = DEFAULT_ALPN_PROTOCOLS
97
112
 
98
113
  context.set_params
114
+
115
+ context.freeze
99
116
  end
100
117
  end
101
118
 
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module Falcon
22
- VERSION = "0.14.1"
22
+ VERSION = "0.14.2"
23
23
  end
data/server.rb CHANGED
@@ -8,23 +8,24 @@ require 'async/container/controller'
8
8
  require 'async/container/forked'
9
9
 
10
10
  require 'async/clock'
11
+ require 'ruby-prof'
11
12
 
12
13
  Async.logger.level = Logger::INFO
13
14
 
14
15
  hosts = Falcon::Hosts.new
15
16
 
16
- hosts.add('map.local') do |host|
17
+ hosts.add('mc.oriontransfer.co.nz') do |host|
17
18
  host.endpoint = Async::HTTP::URLEndpoint.parse('http://hana.local:8123')
18
19
 
19
- # host.ssl_certificate_path = '/etc/letsencrypt/live/mc.oriontransfer.co.nz/fullchain.pem'
20
- # host.ssl_key_path = '/etc/letsencrypt/live/mc.oriontransfer.co.nz/privkey.pem'
20
+ host.ssl_certificate_path = '/etc/letsencrypt/live/mc.oriontransfer.co.nz/fullchain.pem'
21
+ host.ssl_key_path = '/etc/letsencrypt/live/mc.oriontransfer.co.nz/privkey.pem'
21
22
  end
22
23
 
23
- hosts.add('chick.local') do |host|
24
+ hosts.add('chick.nz') do |host|
24
25
  host.endpoint = Async::HTTP::URLEndpoint.parse('http://hana.local:8765')
25
26
 
26
- # host.ssl_certificate_path = '/etc/letsencrypt/live/chick.nz/fullchain.pem'
27
- # host.ssl_key_path = '/etc/letsencrypt/live/chick.nz/privkey.pem'
27
+ host.ssl_certificate_path = '/etc/letsencrypt/live/chick.nz/fullchain.pem'
28
+ host.ssl_key_path = '/etc/letsencrypt/live/chick.nz/privkey.pem'
28
29
  end
29
30
 
30
31
  controller = Async::Container::Controller.new
@@ -35,59 +36,60 @@ hosts.each do |name, host|
35
36
  end
36
37
  end
37
38
 
38
- #proxy = Falcon::Verbose.new(
39
- proxy = Falcon::Proxy.new(Falcon::BadRequest, hosts.client_endpoints)
40
- #)
41
-
39
+ proxy = Falcon::Proxy.new(Falcon::BadRequest, hosts.client_endpoints)
42
40
  debug_trap = Async::IO::Trap.new(:USR1)
43
41
 
44
- require 'ruby-prof'
42
+ profile = RubyProf::Profile.new(merge_fibers: true)
45
43
 
46
- #controller << Async::Container::Forked.new do
44
+ #controller << Async::Container::Forked.new do |task|
47
45
  Process.setproctitle("Falcon Proxy")
48
46
 
49
- server = Falcon::Server.new(proxy, Async::HTTP::URLEndpoint.parse(
50
- 'http://0.0.0.0:4433',
51
- reuse_address: true
52
- ))
53
-
54
- # profile the code
55
- profile = RubyProf::Profile.new(merge_fibers: true)
47
+ server = Falcon::Server.new(
48
+ proxy,
49
+ Async::HTTP::URLEndpoint.parse(
50
+ 'https://0.0.0.0',
51
+ reuse_address: true,
52
+ ssl_context: hosts.ssl_context
53
+ )
54
+ )
55
+
56
+ begin
57
+ #profile.start
56
58
 
57
- # begin
58
- # profile.start
59
-
60
- Async::Reactor.run do |task|
61
- task.async do
62
- debug_trap.install!
63
- $stderr.puts "Send `kill -USR1 #{Process.pid}` for detailed status :)"
64
-
65
- debug_trap.trap do
66
- task.reactor.print_hierarchy($stderr)
67
- # Async.logger.level = Logger::DEBUG
68
- end
69
- end
59
+ Async::Reactor.run do |task|
60
+ task.async do
61
+ debug_trap.install!
62
+ $stderr.puts "Send `kill -USR1 #{Process.pid}` for detailed status :)"
70
63
 
71
- task.async do |task|
72
- start_time = Async::Clock.now
73
-
74
- while true
75
- task.sleep(600)
76
- duration = Async::Clock.now - start_time
77
- puts "Handled #{proxy.count} requests; #{(proxy.count.to_f / duration.to_f).round(1)} requests per second."
78
- end
64
+ debug_trap.trap do
65
+ task.reactor.print_hierarchy($stderr)
66
+ # Async.logger.level = Logger::DEBUG
79
67
  end
68
+ end
69
+
70
+ task.async do |task|
71
+ start_time = Async::Clock.now
80
72
 
81
- server.run
73
+ while true
74
+ task.sleep(600)
75
+ duration = Async::Clock.now - start_time
76
+ puts "Handled #{proxy.count} requests; #{(proxy.count.to_f / duration.to_f).round(1)} requests per second."
77
+ end
82
78
  end
83
- # ensure
84
- # profile.stop
85
- #
86
- # # print a flat profile to text
87
- # printer = RubyProf::FlatPrinter.new(profile)
88
- # printer.print($stdout)
89
- # end
90
- #end
79
+
80
+ $stderr.puts "Starting server"
81
+ server.run
82
+ end
83
+ ensure
84
+ if profile.running?
85
+ profile.stop
86
+
87
+ # print a flat profile to text
88
+ printer = RubyProf::FlatPrinter.new(profile)
89
+ printer.print($stdout)
90
+ end
91
+ end
91
92
 
92
93
  #Process.setproctitle("Falcon Controller")
93
94
  #controller.wait
95
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: falcon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.1
4
+ version: 0.14.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams