thin 1.7.1 → 1.8.0

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
- SHA1:
3
- metadata.gz: 31c955b827052e1932230bf04e3818d77ea20a06
4
- data.tar.gz: 4f21bb96c7a098ea400d5d788b900912e78e2231
2
+ SHA256:
3
+ metadata.gz: 285d7efc73ff2e6e29a8789706c605cc2a2b5a1d25313a53d72954dd5a8adbe7
4
+ data.tar.gz: 24642b42692477ba60cb63cb0ffa49dcf63cc0634708a349d8fac94d08989b74
5
5
  SHA512:
6
- metadata.gz: 4eb0b26d8523233a49ae1f68c63f765173f8f96d73066a53574aab352e1ccc9b89e4949399fd3e45bab13de08587232c05f7e91565b7ab9ac8fa4ca9f43d98fd
7
- data.tar.gz: cd0fe1693ed40ec399ca882ca33fecf7c7c14b4925ad462be7df16db89db380f03657e2dec026b0fd2bd0f9eaea8e7e4c7fc1e3484249ff1f43ca28100936030
6
+ metadata.gz: ab7de3338f8d8694ed44a04cf785e78a0ce85de874d7bde4d96c6801b1e85190a3cbd33d8fe16a32aedc09eab9f1caad4a37ce51dc5997c32b5550da6d2fcffc
7
+ data.tar.gz: 19c45bc3a6f403daffe6a6c66b89bca01c597edb5b8c6ada110834c52fac0f639746f9b51ce5a3ca42c8f2fa013c929929b64b3737819ce83e5dff257e8a328a
data/CHANGELOG CHANGED
@@ -1,3 +1,6 @@
1
+ == 1.7.2 Bachmanity
2
+ * Add config support for ssl_version and ssl_cipher_list [frameworked]
3
+
1
4
  == 1.7.1 Muffin Mode
2
5
  * Ruby 2.4 support (Fixnum deprecation) [nimish-mehta]
3
6
  * Allow ERB templates in config files [markets]
File without changes
File without changes
@@ -38,11 +38,11 @@ typedef struct http_parser {
38
38
 
39
39
  } http_parser;
40
40
 
41
- int http_parser_init(http_parser *parser);
42
- int http_parser_finish(http_parser *parser);
43
- size_t http_parser_execute(http_parser *parser, const char *data, size_t len, size_t off);
44
- int http_parser_has_error(http_parser *parser);
45
- int http_parser_is_finished(http_parser *parser);
41
+ int thin_http_parser_init(http_parser *parser);
42
+ int thin_http_parser_finish(http_parser *parser);
43
+ size_t thin_http_parser_execute(http_parser *parser, const char *data, size_t len, size_t off);
44
+ int thin_http_parser_has_error(http_parser *parser);
45
+ int thin_http_parser_is_finished(http_parser *parser);
46
46
 
47
47
  #define http_parser_nread(parser) (parser)->nread
48
48
 
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "thin"
4
+ require "thin/server"
5
+ require "thin/logging"
6
+ require "thin/backends/tcp_server"
7
+
8
+ module Rack
9
+ module Handler
10
+ class Thin
11
+ def self.run(app, **options)
12
+ environment = ENV['RACK_ENV'] || 'development'
13
+ default_host = environment == 'development' ? 'localhost' : '0.0.0.0'
14
+
15
+ host = options.delete(:Host) || default_host
16
+ port = options.delete(:Port) || 8080
17
+ args = [host, port, app, options]
18
+
19
+ server = ::Thin::Server.new(*args)
20
+ yield server if block_given?
21
+
22
+ server.start
23
+ end
24
+
25
+ def self.valid_options
26
+ environment = ENV['RACK_ENV'] || 'development'
27
+ default_host = environment == 'development' ? 'localhost' : '0.0.0.0'
28
+
29
+ {
30
+ "Host=HOST" => "Hostname to listen on (default: #{default_host})",
31
+ "Port=PORT" => "Port to listen on (default: 8080)",
32
+ }
33
+ end
34
+ end
35
+
36
+ register :thin, ::Rack::Handler::Thin
37
+ end
38
+ end
@@ -51,9 +51,11 @@ module Thin
51
51
  @maximum_connections = Server::DEFAULT_MAXIMUM_CONNECTIONS
52
52
  @maximum_persistent_connections = Server::DEFAULT_MAXIMUM_PERSISTENT_CONNECTIONS
53
53
  @no_epoll = false
54
+ @running = false
54
55
  @ssl = nil
55
- @threaded = nil
56
56
  @started_reactor = false
57
+ @stopping = false
58
+ @threaded = nil
57
59
  end
58
60
 
59
61
  # Start the backend and connect it.
@@ -55,7 +55,7 @@ module Thin
55
55
  # ssl support
56
56
  if @options[:ssl]
57
57
  server.ssl = true
58
- server.ssl_options = { :private_key_file => @options[:ssl_key_file], :cert_chain_file => @options[:ssl_cert_file], :verify_peer => !@options[:ssl_disable_verify] }
58
+ server.ssl_options = { :private_key_file => @options[:ssl_key_file], :cert_chain_file => @options[:ssl_cert_file], :verify_peer => !@options[:ssl_disable_verify], :ssl_version => @options[:ssl_version], :cipher_list => @options[:ssl_cipher_list]}
59
59
  end
60
60
 
61
61
  # Detach the process, after this line the current process returns
@@ -30,11 +30,17 @@ module Thin
30
30
  def self.included(base)
31
31
  base.extend ClassMethods
32
32
  end
33
-
33
+
34
34
  def pid
35
35
  File.exist?(pid_file) && !File.zero?(pid_file) ? open(pid_file).read.to_i : nil
36
36
  end
37
-
37
+
38
+ def kill(timeout = 60)
39
+ if File.exist?(@pid_file)
40
+ self.class.kill(@pid_file, timeout)
41
+ end
42
+ end
43
+
38
44
  # Turns the current script into a daemon process that detaches from the console.
39
45
  def daemonize
40
46
  raise PlatformNotSupported, 'Daemonizing is not supported on Windows' if Thin.win?
@@ -78,6 +84,10 @@ module Thin
78
84
  Process.initgroups(user, target_gid)
79
85
  Process::GID.change_privilege(target_gid)
80
86
  Process::UID.change_privilege(target_uid)
87
+
88
+ # Correct environment variables
89
+ ENV.store('USER', user)
90
+ ENV.store('HOME', File.expand_path("~#{user}"))
81
91
  end
82
92
  rescue Errno::EPERM => e
83
93
  log_info "Couldn't change user and group to #{user}:#{group}: #{e}"
@@ -116,14 +126,23 @@ module Thin
116
126
  def restart(pid_file)
117
127
  send_signal('HUP', pid_file)
118
128
  end
119
-
129
+
130
+ def monotonic_time
131
+ Process.clock_gettime(Process::CLOCK_MONOTONIC)
132
+ end
133
+
120
134
  # Send a +signal+ to the process which PID is stored in +pid_file+.
121
135
  def send_signal(signal, pid_file, timeout=60)
122
136
  if pid = read_pid_file(pid_file)
123
137
  Logging.log_info "Sending #{signal} signal to process #{pid} ... "
138
+
124
139
  Process.kill(signal, pid)
125
- Timeout.timeout(timeout) do
126
- sleep 0.1 while Process.running?(pid)
140
+
141
+ # This loop seems kind of racy to me...
142
+ started_at = monotonic_time
143
+ while Process.running?(pid)
144
+ sleep 0.1
145
+ raise Timeout::Error if (monotonic_time - started_at) > timeout
127
146
  end
128
147
  else
129
148
  raise PidFileNotFound, "Can't stop process, no PID found in #{pid_file}"
@@ -13,7 +13,7 @@ module Thin
13
13
  # Taken from ActiveSupport
14
14
  class SimpleFormatter < Logger::Formatter
15
15
  def call(severity, timestamp, progname, msg)
16
- "#{String === msg ? msg : msg.inspect}\n"
16
+ "#{timestamp} #{String === msg ? msg : msg.inspect}\n"
17
17
  end
18
18
  end
19
19
 
@@ -75,7 +75,9 @@ module Thin
75
75
  # Raises an +InvalidRequest+ if invalid.
76
76
  # Returns +true+ if the parsing is complete.
77
77
  def parse(data)
78
- if @parser.finished? # Header finished, can only be some more body
78
+ if data.size > 0 && finished? # headers and body already fully satisfied. more data is erroneous.
79
+ raise InvalidRequest, 'Content longer than specified'
80
+ elsif @parser.finished? # Header finished, can only be some more body
79
81
  @body << data
80
82
  else # Parse more header using the super parser
81
83
  @data << data
@@ -81,6 +81,8 @@ module Thin
81
81
  opts.on( "--ssl-key-file PATH", "Path to private key") { |path| @options[:ssl_key_file] = path }
82
82
  opts.on( "--ssl-cert-file PATH", "Path to certificate") { |path| @options[:ssl_cert_file] = path }
83
83
  opts.on( "--ssl-disable-verify", "Disables (optional) client cert requests") { @options[:ssl_disable_verify] = true }
84
+ opts.on( "--ssl-version VERSION", "TLSv1, TLSv1_1, TLSv1_2") { |version| @options[:ssl_version] = version }
85
+ opts.on( "--ssl-cipher-list STRING", "Example: HIGH:!ADH:!RC4:-MEDIUM:-LOW:-EXP:-CAMELLIA") { |cipher| @options[:ssl_cipher_list] = cipher }
84
86
 
85
87
  opts.separator ""
86
88
  opts.separator "Adapter options:"
@@ -33,12 +33,16 @@ module Thin
33
33
  413 => 'Request Entity Too Large',
34
34
  414 => 'Request-URI Too Large',
35
35
  415 => 'Unsupported Media Type',
36
- 422 => 'Unprocessable Entity',
37
- 500 => 'Internal Server Error',
36
+ 422 => 'Unprocessable Entity',
37
+ 428 => 'Precondition Required',
38
+ 429 => 'Too Many Requests',
39
+ 431 => 'Request Header Fields Too Large',
40
+ 500 => 'Internal Server Error',
38
41
  501 => 'Not Implemented',
39
42
  502 => 'Bad Gateway',
40
43
  503 => 'Service Unavailable',
41
44
  504 => 'Gateway Time-out',
42
- 505 => 'HTTP Version not supported'
45
+ 505 => 'HTTP Version not supported',
46
+ 511 => 'Network Authentication Required'
43
47
  }
44
- end
48
+ end
@@ -1,22 +1,22 @@
1
- module Thin
1
+ module Thin
2
2
  # Raised when a feature is not supported on the
3
3
  # current platform.
4
4
  class PlatformNotSupported < RuntimeError; end
5
5
 
6
6
  module VERSION #:nodoc:
7
7
  MAJOR = 1
8
- MINOR = 7
9
- TINY = 1
8
+ MINOR = 8
9
+ TINY = 0
10
10
 
11
11
  STRING = [MAJOR, MINOR, TINY].join('.')
12
12
 
13
- CODENAME = "Muffin Mode".freeze
13
+ CODENAME = "Possessed Pickle".freeze
14
14
 
15
15
  RACK = [1, 0].freeze # Rack protocol version
16
16
  end
17
17
 
18
18
  NAME = 'thin'.freeze
19
- SERVER = "#{NAME} #{VERSION::STRING} codename #{VERSION::CODENAME}".freeze
19
+ SERVER = "#{NAME} #{VERSION::STRING} codename #{VERSION::CODENAME}".freeze
20
20
 
21
21
  def self.win?
22
22
  RUBY_PLATFORM =~ /mswin|mingw/
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thin
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.1
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marc-Andre Cournoyer
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-13 00:00:00.000000000 Z
11
+ date: 2020-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -70,7 +70,7 @@ dependencies:
70
70
  - - ">="
71
71
  - !ruby/object:Gem::Version
72
72
  version: 1.0.9
73
- description: A thin and fast web server
73
+ description:
74
74
  email: macournoyer@gmail.com
75
75
  executables:
76
76
  - thin
@@ -104,6 +104,7 @@ files:
104
104
  - ext/thin_parser/thin.c
105
105
  - lib/rack/adapter/loader.rb
106
106
  - lib/rack/adapter/rails.rb
107
+ - lib/rack/handler/thin.rb
107
108
  - lib/thin.rb
108
109
  - lib/thin/backends/base.rb
109
110
  - lib/thin/backends/swiftiply_client.rb
@@ -126,12 +127,14 @@ files:
126
127
  - lib/thin/stats.rb
127
128
  - lib/thin/statuses.rb
128
129
  - lib/thin/version.rb
129
- homepage: http://code.macournoyer.com/thin/
130
+ homepage: https://github.com/macournoyer/thin
130
131
  licenses:
131
- - GPLv2+
132
- - Ruby 1.8
133
- metadata: {}
134
- post_install_message:
132
+ - GPL-2.0+
133
+ - Ruby
134
+ metadata:
135
+ source_code_uri: https://github.com/macournoyer/thin
136
+ changelog_uri: https://github.com/macournoyer/thin/blob/master/CHANGELOG
137
+ post_install_message:
135
138
  rdoc_options: []
136
139
  require_paths:
137
140
  - lib
@@ -146,9 +149,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
146
149
  - !ruby/object:Gem::Version
147
150
  version: '0'
148
151
  requirements: []
149
- rubyforge_project: thin
150
- rubygems_version: 2.5.1
151
- signing_key:
152
+ rubygems_version: 3.1.2
153
+ signing_key:
152
154
  specification_version: 4
153
155
  summary: A thin and fast web server
154
156
  test_files: []