thin 1.2.2 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of thin might be problematic. Click here for more details.

data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ == 1.2.3
2
+ * Fix a few issues in thin to make it a better "gem citizen" [josh]
3
+ * Fix test for rack based Rails in adapter under Ruby >= 1.8.7 [#109 state:resolved]
4
+ * Fix Remote address spoofing vulnerability in Connection#remote_address [Alexey Borzenkov]
5
+ * Fix uninitialized constant ActionController::Dispatcher error with Rails 1.2.3 [Chris Anderton] [#103 state:resolved]
6
+
1
7
  == 1.2.2 I Find Your Lack of Sauce Disturbing release
2
8
  * Fix force kill under 1.9 [Alexey Chebotar]
3
9
  * Fix regression when --only option is used w/ --socket.
data/README CHANGED
@@ -20,20 +20,12 @@ For the latest stable version:
20
20
 
21
21
  sudo gem install thin
22
22
 
23
- or using my mirror (might be more recent and unstable):
24
-
25
- sudo gem install thin --source http://code.macournoyer.com
26
-
27
23
  Or from source:
28
24
 
29
25
  git clone git://github.com/macournoyer/thin.git
30
26
  cd thin
31
27
  rake install
32
28
 
33
- To use Thin with UNIX domain sockets you need EventMachine 0.11.0 from my gem server:
34
-
35
- gem install eventmachine --source http://code.macournoyer.com
36
-
37
29
  === Usage
38
30
  A +thin+ script offers an easy way to start your Rails application:
39
31
 
data/Rakefile CHANGED
@@ -4,10 +4,33 @@ SUDO = (WIN ? "" : "sudo")
4
4
 
5
5
  require 'rake'
6
6
  require 'rake/clean'
7
- require 'lib/thin'
7
+ require 'rake/extensiontask' # from rake-compiler gem
8
8
 
9
+ $: << File.join(File.dirname(__FILE__), 'lib')
10
+ require 'thin'
11
+
12
+ # Load tasks in tasks/
9
13
  Dir['tasks/**/*.rake'].each { |rake| load rake }
10
14
 
11
15
  task :default => :spec
12
16
 
13
- ext_task :thin_parser
17
+ Rake::ExtensionTask.new('thin_parser', Thin::GemSpec) do |ext|
18
+ ext.cross_compile = true # enable cross compilation (requires cross compile toolchain)
19
+ ext.cross_platform = 'i386-mswin32' # forces the Windows platform instead of the default one
20
+ # configure options only for cross compile
21
+ end
22
+
23
+ CLEAN.include %w(**/*.{o,bundle,jar,so,obj,pdb,lib,def,exp,log} ext/*/Makefile ext/*/conftest.dSYM)
24
+
25
+ desc "Compile the Ragel state machines"
26
+ task :ragel do
27
+ Dir.chdir 'ext/thin_parser' do
28
+ target = "parser.c"
29
+ File.unlink target if File.exist? target
30
+ sh "ragel parser.rl | rlgen-cd -G2 -o #{target}"
31
+ raise "Failed to compile Ragel state machine" unless File.exist? target
32
+ end
33
+ end
34
+
35
+ desc "Release version #{Thin::VERSION::STRING} gems to rubyforge"
36
+ task :release => [:clean, :cross, :native, :gem, :tag, "gem:upload"]
@@ -6,7 +6,10 @@
6
6
  #
7
7
  # ruby simple.rb [num of request] [print|graph] [concurrency levels]
8
8
  #
9
- require File.dirname(__FILE__) + '/../lib/thin'
9
+
10
+ $: << File.join(File.dirname(__FILE__), '..', 'lib')
11
+ require 'thin'
12
+
10
13
  require File.dirname(__FILE__) + '/benchmarker'
11
14
  require 'optparse'
12
15
 
data/bin/thin CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  # Thin command line interface script.
3
3
  # Run <tt>thin -h</tt> to get more usage.
4
- require File.dirname(__FILE__) + '/../lib/thin'
5
4
 
6
- Thin::Runner.new(ARGV).run!
5
+ require 'thin'
6
+ Thin::Runner.new(ARGV).run!
@@ -1,7 +1,7 @@
1
1
  # Run with: ruby adapter.rb
2
2
  # Then browse to http://localhost:3000/test
3
3
  # and http://localhost:3000/files/adapter.rb
4
- require File.dirname(__FILE__) + '/../lib/thin'
4
+ require 'thin'
5
5
 
6
6
  class SimpleAdapter
7
7
  def call(env)
@@ -5,8 +5,7 @@
5
5
  #
6
6
  # Check Rack::Builder doc for more details on this file format:
7
7
  # http://rack.rubyforge.org/doc/classes/Rack/Builder.html
8
-
9
- require ::File.dirname(__FILE__) + '/../lib/thin'
8
+ require 'thin'
10
9
 
11
10
  app = proc do |env|
12
11
  # Response body has to respond to each and yield strings
@@ -22,7 +22,7 @@ module Rack
22
22
 
23
23
  load_application
24
24
 
25
- @rails_app = if ActionController::Dispatcher.instance_methods.include?(:call)
25
+ @rails_app = if rack_based?
26
26
  ActionController::Dispatcher.new
27
27
  else
28
28
  CgiApp.new
@@ -31,6 +31,12 @@ module Rack
31
31
  @file_app = Rack::File.new(::File.join(RAILS_ROOT, "public"))
32
32
  end
33
33
 
34
+ def rack_based?
35
+ ActionController.const_defined?(:Dispatcher) &&
36
+ (ActionController::Dispatcher.instance_methods.include?(:call)
37
+ || ActionController::Dispatcher.instance_methods.include?("call"))
38
+ end
39
+
34
40
  def load_application
35
41
  ENV['RAILS_ENV'] = @env
36
42
 
@@ -1,12 +1,9 @@
1
- $:.unshift File.expand_path(File.dirname(__FILE__))
2
-
3
1
  require 'fileutils'
4
2
  require 'timeout'
5
3
  require 'stringio'
6
4
  require 'time'
7
5
  require 'forwardable'
8
6
 
9
- require 'rubygems'
10
7
  require 'openssl'
11
8
  require 'eventmachine'
12
9
 
@@ -126,7 +126,7 @@ module Thin
126
126
  end
127
127
 
128
128
  def close_request_response
129
- @request.async_close.succeed
129
+ @request.async_close.succeed if @request.async_close
130
130
  @request.close rescue nil
131
131
  @response.close rescue nil
132
132
  end
@@ -180,7 +180,7 @@ module Thin
180
180
 
181
181
  # IP Address of the remote client.
182
182
  def remote_address
183
- @request.forwarded_for || socket_address
183
+ socket_address
184
184
  rescue Exception
185
185
  log_error
186
186
  nil
@@ -21,7 +21,6 @@ module Thin
21
21
  HTTP_VERSION = 'HTTP_VERSION'.freeze
22
22
  HTTP_1_0 = 'HTTP/1.0'.freeze
23
23
  REMOTE_ADDR = 'REMOTE_ADDR'.freeze
24
- FORWARDED_FOR = 'HTTP_X_FORWARDED_FOR'.freeze
25
24
  CONTENT_LENGTH = 'CONTENT_LENGTH'.freeze
26
25
  CONNECTION = 'HTTP_CONNECTION'.freeze
27
26
  KEEP_ALIVE_REGEXP = /\bkeep-alive\b/i.freeze
@@ -123,10 +122,6 @@ module Thin
123
122
  @env[REMOTE_ADDR] = address
124
123
  end
125
124
 
126
- def forwarded_for
127
- @env[FORWARDED_FOR]
128
- end
129
-
130
125
  def threaded=(value)
131
126
  @env[RACK_MULTITHREAD] = value
132
127
  end
@@ -6,11 +6,11 @@ module Thin
6
6
  module VERSION #:nodoc:
7
7
  MAJOR = 1
8
8
  MINOR = 2
9
- TINY = 2
9
+ TINY = 3
10
10
 
11
11
  STRING = [MAJOR, MINOR, TINY].join('.')
12
12
 
13
- CODENAME = "I Find Your Lack of Sauce Disturbing".freeze
13
+ CODENAME = "Flaming Astroboy".freeze
14
14
 
15
15
  RACK = [1, 0].freeze # Rack protocol version
16
16
  end
Binary file
@@ -40,9 +40,10 @@ describe Connection do
40
40
  @connection.process
41
41
  end
42
42
 
43
- it "should return HTTP_X_FORWARDED_FOR as remote_address" do
43
+ it "should not return HTTP_X_FORWARDED_FOR as remote_address" do
44
44
  @connection.request.env['HTTP_X_FORWARDED_FOR'] = '1.2.3.4'
45
- @connection.remote_address.should == '1.2.3.4'
45
+ @connection.stub!(:socket_address).and_return("127.0.0.1")
46
+ @connection.remote_address.should == "127.0.0.1"
46
47
  end
47
48
 
48
49
  it "should return nil on error retreiving remote_address" do
@@ -1,5 +1,5 @@
1
1
  require 'rubygems'
2
- require File.dirname(__FILE__) + '/../lib/thin'
2
+ require 'thin'
3
3
  require 'spec'
4
4
  require 'benchmark'
5
5
  require 'timeout'
@@ -1,14 +1,11 @@
1
1
  namespace :deploy do
2
2
  task :site => %w(site:upload rdoc:upload)
3
3
 
4
- desc 'Deploy on code.macournoyer.com'
5
- task :alpha => %w(gem:upload deploy:site)
6
-
7
4
  desc 'Deploy on rubyforge'
8
- task :public => %w(gem:upload_rubyforge deploy:site)
5
+ task :gem => %w(gem:upload_rubyforge deploy:site)
9
6
  end
10
7
  desc 'Deploy on all servers'
11
- task :deploy => %w(deploy:alpha deploy:public)
8
+ task :deploy => "deploy:gem"
12
9
 
13
10
  def upload(file, to, options={})
14
11
  sh %{ssh macournoyer@code.macournoyer.com "rm -rf code.macournoyer.com/#{to}"} if options[:replace]
@@ -1,11 +1,11 @@
1
1
  require 'rake/gempackagetask'
2
2
  require 'yaml'
3
3
 
4
- WIN_SUFFIX = ENV['WIN_SUFFIX'] || 'i386-mswin32'
4
+ WIN_SUFFIX = ENV['WIN_SUFFIX'] || 'x86-mswin32'
5
5
 
6
6
  task :clean => :clobber_package
7
7
 
8
- spec = Gem::Specification.new do |s|
8
+ Thin::GemSpec = Gem::Specification.new do |s|
9
9
  s.name = Thin::NAME
10
10
  s.version = Thin::VERSION::STRING
11
11
  s.platform = WIN ? Gem::Platform::CURRENT : Gem::Platform::RUBY
@@ -40,8 +40,8 @@ spec = Gem::Specification.new do |s|
40
40
  s.bindir = "bin"
41
41
  end
42
42
 
43
- Rake::GemPackageTask.new(spec) do |p|
44
- p.gem_spec = spec
43
+ Rake::GemPackageTask.new(Thin::GemSpec) do |p|
44
+ p.gem_spec = Thin::GemSpec
45
45
  end
46
46
 
47
47
  task :tag_warn do
@@ -61,48 +61,14 @@ task :gem => :tag_warn
61
61
  namespace :gem do
62
62
  desc "Update the gemspec for GitHub's gem server"
63
63
  task :github do
64
- File.open("thin.gemspec", 'w') { |f| f << YAML.dump(spec) }
64
+ File.open("thin.gemspec", 'w') { |f| f << YAML.dump(Thin::GemSpec) }
65
65
  end
66
66
 
67
- desc 'Upload gem to code.macournoyer.com'
67
+ desc 'Upload gems (ruby & win32) to rubyforge.org'
68
68
  task :upload => :gem do
69
- upload "pkg/#{spec.full_name}.gem", 'gems'
70
- system 'ssh macournoyer@code.macournoyer.com "cd code.macournoyer.com && gem generate_index"'
71
- end
72
-
73
- namespace :upload do
74
- desc 'Upload the precompiled win32 gem to code.macournoyer.com'
75
- task :win do
76
- upload "pkg/#{spec.full_name}-#{WIN_SUFFIX}.gem", 'gems'
77
- system 'ssh macournoyer@code.macournoyer.com "cd code.macournoyer.com && gem generate_index"'
78
- end
79
-
80
- desc 'Upload gems (ruby & win32) to rubyforge.org'
81
- task :rubyforge => :gem do
82
- sh 'rubyforge login'
83
- sh "rubyforge add_release thin thin #{Thin::VERSION::STRING} pkg/#{spec.full_name}.gem"
84
- sh "rubyforge add_file thin thin #{Thin::VERSION::STRING} pkg/#{spec.full_name}.gem"
85
- sh "rubyforge add_file thin thin #{Thin::VERSION::STRING} pkg/#{spec.full_name}-#{WIN_SUFFIX}.gem"
86
- end
87
- end
88
-
89
- desc 'Download the Windows gem from Kevin repo'
90
- task 'download:win' => 'pkg' do
91
- cd 'pkg' do
92
- `wget http://rubygems.bantamtech.com/ruby18/gems/#{spec.full_name}-#{WIN_SUFFIX}.gem`
93
- end
69
+ sh 'rubyforge login'
70
+ sh "rubyforge add_release thin thin #{Thin::VERSION::STRING} pkg/#{Thin::GemSpec.full_name}.gem"
71
+ sh "rubyforge add_file thin thin #{Thin::VERSION::STRING} pkg/#{Thin::GemSpec.full_name}.gem"
72
+ sh "rubyforge add_file thin thin #{Thin::VERSION::STRING} pkg/#{Thin::GemSpec.full_name}-#{WIN_SUFFIX}.gem"
94
73
  end
95
74
  end
96
-
97
- task :install => [:clobber, :compile, :package] do
98
- sh "#{SUDO} #{gem} install pkg/#{spec.full_name}.gem"
99
- end
100
-
101
- task :uninstall => :clean do
102
- sh "#{SUDO} #{gem} uninstall -v #{Thin::VERSION::STRING} -x #{Thin::NAME}"
103
- end
104
-
105
-
106
- def gem
107
- RUBY_1_9 ? 'gem19' : 'gem'
108
- end
@@ -23,6 +23,7 @@ else
23
23
 
24
24
  def spec_task(name, specs)
25
25
  Spec::Rake::SpecTask.new(name) do |t|
26
+ t.libs << 'lib'
26
27
  t.spec_opts = %w(-fs -c)
27
28
  t.spec_files = specs
28
29
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thin
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marc-Andre Cournoyer
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-05-21 00:00:00 -04:00
12
+ date: 2009-09-05 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -101,7 +101,7 @@ files:
101
101
  - lib/thin/statuses.rb
102
102
  - lib/thin/version.rb
103
103
  - lib/thin.rb
104
- - lib/thin_parser.bundle
104
+ - lib/thin_parser.so
105
105
  - spec/backends
106
106
  - spec/backends/swiftiply_client_spec.rb
107
107
  - spec/backends/tcp_server_spec.rb
@@ -204,7 +204,6 @@ files:
204
204
  - tasks/announce.rake
205
205
  - tasks/deploy.rake
206
206
  - tasks/email.erb
207
- - tasks/ext.rake
208
207
  - tasks/gem.rake
209
208
  - tasks/rdoc.rake
210
209
  - tasks/site.rake
Binary file
@@ -1,42 +0,0 @@
1
- CLEAN.include %w(**/*.{o,bundle,jar,so,obj,pdb,lib,def,exp,log} ext/*/Makefile ext/*/conftest.dSYM)
2
-
3
- def ext_task(name)
4
- ext_dir = "ext/#{name}"
5
- ext_bundle = "#{ext_dir}/#{name}.#{Config::CONFIG['DLEXT']}"
6
- ext_files = FileList[
7
- "#{ext_dir}/*.c",
8
- "#{ext_dir}/*.h",
9
- "#{ext_dir}/*.rl",
10
- "#{ext_dir}/extconf.rb",
11
- "#{ext_dir}/Makefile",
12
- "lib"
13
- ]
14
-
15
- task "compile:#{name}" => ["#{ext_dir}/Makefile", ext_bundle]
16
- task :compile => "compile:#{name}"
17
-
18
- file "#{ext_dir}/Makefile" => ["#{ext_dir}/extconf.rb"] do
19
- cd(ext_dir) { ruby "extconf.rb" }
20
- end
21
-
22
- file ext_bundle => ext_files do
23
- cd ext_dir do
24
- sh(WIN ? 'nmake' : 'make')
25
- end
26
- cp ext_bundle, 'lib/'
27
- end
28
- end
29
-
30
- desc "Compile the Ragel state machines"
31
- task :ragel do
32
- Dir.chdir 'ext/thin_parser' do
33
- target = "parser.c"
34
- File.unlink target if File.exist? target
35
- sh "ragel parser.rl | rlgen-cd -G2 -o #{target}"
36
- raise "Failed to compile Ragel state machine" unless File.exist? target
37
- end
38
- end
39
-
40
- desc "Compile the extensions"
41
- task :compile
42
- task :package => :compile