mongrel_in_a_tunnel 0.1

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.
data/COPYING ADDED
@@ -0,0 +1 @@
1
+ No copying restrictions/license given.
data/LICENSE ADDED
@@ -0,0 +1 @@
1
+ No license given.
data/README ADDED
@@ -0,0 +1,5 @@
1
+ == Mongrel_in_a_tunnel GemPlugin
2
+
3
+ You should document your project here.
4
+
5
+
data/Rakefile ADDED
@@ -0,0 +1,38 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/clean'
4
+ require 'rake/gempackagetask'
5
+ require 'rake/rdoctask'
6
+ require 'tools/rakehelp'
7
+ require 'fileutils'
8
+ include FileUtils
9
+
10
+ setup_tests
11
+ setup_clean ["pkg", "lib/*.bundle", "*.gem", ".config"]
12
+
13
+ setup_rdoc ['README', 'LICENSE', 'COPYING', 'lib/**/*.rb', 'doc/**/*.rdoc']
14
+
15
+ desc "Does a full compile, test run"
16
+ task :default => [:test, :package]
17
+
18
+ version="0.1"
19
+ name="mongrel_in_a_tunnel"
20
+
21
+ setup_gem(name, version) do |spec|
22
+ spec.summary = "Mongrel/GemPlugin to decrypt to SSL"
23
+ spec.description = "Wraps mongrel in an stunnel to decypt SSL requests"
24
+ spec.author="chrisfarms"
25
+ spec.add_dependency('gem_plugin', '>= 0.2.1')
26
+ spec.add_dependency('mongrel', '>= 0.3.13')
27
+ spec.files += Dir.glob("resources/**/*")
28
+ end
29
+
30
+
31
+ task :install => [:test, :package] do
32
+ sh %{sudo gem install pkg/#{name}-#{version}.gem}
33
+ end
34
+
35
+ task :uninstall => [:clean] do
36
+ sh %{sudo gem uninstall #{name}}
37
+ end
38
+
@@ -0,0 +1,62 @@
1
+ require 'gem_plugin'
2
+ require 'mongrel'
3
+
4
+ # give this class the name you want for your command mongrel_in_a_tunnel
5
+ module SSL
6
+
7
+ class Start < GemPlugin::Plugin "/commands"
8
+
9
+ include Mongrel::Command::Base
10
+
11
+ def configure
12
+ options [
13
+ ['', '--ssl-cert', 'Specify the SSL certificate to use', :@ssl_cert, '/opt/local/etc/stunnel/stunnel.pem'],
14
+ ['', '--ssl-port', 'Port to listen for HTTPS requests', :@ssl_port, 443],
15
+ ['', '--ssl-listen', 'IP address to listen on', :@ssl_listen, '127.0.0.1'],
16
+ ['-p', '--port', 'port for mongrel', :@port, 3000],
17
+ ['-e', '--environment', 'RAILS_ENV', :@environment, nil]
18
+ ]
19
+ end
20
+
21
+ def validate
22
+ @ssl_port = @ssl_port.to_i
23
+ valid? (@ssl_port > 0 && @ssl_port < 65000), true
24
+ return @valid
25
+ end
26
+
27
+ def stunnel_config
28
+ GemPlugin::Manager.instance.resource "mongrel_in_a_tunnel", "/stunnel.conf"
29
+ end
30
+
31
+ def run
32
+ # generate config file and pass the file descriptor to the stunnel process
33
+
34
+ # launch stunnel
35
+ puts "Listening for SSL requests on #{@ssl_listen}:#{@ssl_port}"
36
+ Kernel.fork do
37
+ `stunnel #{stunnel_config} -f`
38
+ end
39
+
40
+ args = []
41
+ args << "start"
42
+ args << "-e #{@environment}" if @environment
43
+ args << "-p #{@port}"
44
+
45
+ begin
46
+ command = GemPlugin::Manager.instance.create("/commands/mongrel::start", :argv => args)
47
+ rescue OptionParser::InvalidOption
48
+ STDERR.puts "#$! for command '#{cmd_name}'"
49
+ STDERR.puts "Try #{cmd_name} -h to get help."
50
+ return false
51
+ rescue
52
+ STDERR.puts "ERROR RUNNING '#{cmd_name}': #$!"
53
+ STDERR.puts "Use help command to get help"
54
+ return false
55
+ end
56
+ # run mongrel
57
+ command.run
58
+ end
59
+
60
+ end
61
+
62
+ end
@@ -0,0 +1,2 @@
1
+ ---
2
+ :debug: false
@@ -0,0 +1,16 @@
1
+ ; Certificate/key is needed in server mode and optional in client mode
2
+ cert = /opt/local/etc/stunnel/stunnel.pem
3
+ pid =
4
+ foreground = yes
5
+
6
+ ; Protocol version (all, SSLv2, SSLv3, TLSv1)
7
+ sslVersion = SSLv3
8
+
9
+ ; Some performance tunings
10
+ socket = l:TCP_NODELAY=1
11
+ socket = r:TCP_NODELAY=1
12
+ ;compression = rle
13
+
14
+ [3000]
15
+ accept = 127.0.0.1:443
16
+ connect = 127.0.0.1:3000
data/tools/rakehelp.rb ADDED
@@ -0,0 +1,105 @@
1
+
2
+ def make(makedir)
3
+ Dir.chdir(makedir) do
4
+ sh(PLATFORM =~ /win32/ ? 'nmake' : 'make')
5
+ end
6
+ end
7
+
8
+
9
+ def extconf(dir)
10
+ Dir.chdir(dir) do ruby "extconf.rb" end
11
+ end
12
+
13
+
14
+ def setup_tests
15
+ Rake::TestTask.new do |t|
16
+ t.libs << "test"
17
+ t.test_files = FileList['test/test*.rb']
18
+ t.verbose = true
19
+ end
20
+ end
21
+
22
+
23
+ def setup_clean otherfiles
24
+ files = ['build/*', '**/*.o', '**/*.so', '**/*.a', 'lib/*-*', '**/*.log'] + otherfiles
25
+ CLEAN.include(files)
26
+ end
27
+
28
+
29
+ def setup_rdoc files
30
+ Rake::RDocTask.new do |rdoc|
31
+ rdoc.rdoc_dir = 'doc/rdoc'
32
+ rdoc.options << '--line-numbers'
33
+ rdoc.rdoc_files.add(files)
34
+ end
35
+ end
36
+
37
+
38
+ def setup_extension(dir, extension)
39
+ ext = "ext/#{dir}"
40
+ ext_so = "#{ext}/#{extension}.#{Config::CONFIG['DLEXT']}"
41
+ ext_files = FileList[
42
+ "#{ext}/*.c",
43
+ "#{ext}/*.h",
44
+ "#{ext}/extconf.rb",
45
+ "#{ext}/Makefile",
46
+ "lib"
47
+ ]
48
+
49
+ task "lib" do
50
+ directory "lib"
51
+ end
52
+
53
+ desc "Builds just the #{extension} extension"
54
+ task extension.to_sym => ["#{ext}/Makefile", ext_so ]
55
+
56
+ file "#{ext}/Makefile" => ["#{ext}/extconf.rb"] do
57
+ extconf "#{ext}"
58
+ end
59
+
60
+ file ext_so => ext_files do
61
+ make "#{ext}"
62
+ cp ext_so, "lib"
63
+ end
64
+ end
65
+
66
+
67
+ def base_gem_spec(pkg_name, pkg_version)
68
+ pkg_version = pkg_version
69
+ pkg_name = pkg_name
70
+ pkg_file_name = "#{pkg_name}-#{pkg_version}"
71
+ Gem::Specification.new do |s|
72
+ s.name = pkg_name
73
+ s.version = pkg_version
74
+ s.platform = Gem::Platform::RUBY
75
+ s.has_rdoc = true
76
+ s.extra_rdoc_files = [ "README" ]
77
+
78
+ s.files = %w(COPYING LICENSE README Rakefile) +
79
+ Dir.glob("{bin,doc/rdoc,test,lib}/**/*") +
80
+ Dir.glob("ext/**/*.{h,c,rb}") +
81
+ Dir.glob("examples/**/*.rb") +
82
+ Dir.glob("tools/*.rb")
83
+
84
+ s.require_path = "lib"
85
+ s.extensions = FileList["ext/**/extconf.rb"].to_a
86
+ s.bindir = "bin"
87
+ end
88
+ end
89
+
90
+ def setup_gem(pkg_name, pkg_version)
91
+ spec = base_gem_spec(pkg_name, pkg_version)
92
+ yield spec if block_given?
93
+
94
+ Rake::GemPackageTask.new(spec) do |p|
95
+ p.gem_spec = spec
96
+ p.need_tar = true
97
+ end
98
+ end
99
+
100
+ def setup_win32_gem(pkg_name, pkg_version)
101
+ spec = base_gem_spec(pkg_name, pkg_version)
102
+ yield spec if block_given?
103
+
104
+ Gem::Builder.new(spec).build
105
+ end
metadata ADDED
@@ -0,0 +1,70 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.8.11
3
+ specification_version: 1
4
+ name: mongrel_in_a_tunnel
5
+ version: !ruby/object:Gem::Version
6
+ version: "0.1"
7
+ date: 2007-02-06 00:00:00 +00:00
8
+ summary: Mongrel/GemPlugin to decrypt to SSL
9
+ require_paths:
10
+ - lib
11
+ email:
12
+ homepage:
13
+ rubyforge_project:
14
+ description: Wraps mongrel in an stunnel to decypt SSL requests
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ authors:
29
+ - chrisfarms
30
+ files:
31
+ - COPYING
32
+ - LICENSE
33
+ - README
34
+ - Rakefile
35
+ - lib/mongrel_in_a_tunnel
36
+ - lib/mongrel_in_a_tunnel/init.rb
37
+ - tools/rakehelp.rb
38
+ - resources/defaults.yaml
39
+ - resources/stunnel.conf
40
+ test_files: []
41
+
42
+ rdoc_options: []
43
+
44
+ extra_rdoc_files:
45
+ - README
46
+ executables: []
47
+
48
+ extensions: []
49
+
50
+ requirements: []
51
+
52
+ dependencies:
53
+ - !ruby/object:Gem::Dependency
54
+ name: gem_plugin
55
+ version_requirement:
56
+ version_requirements: !ruby/object:Gem::Version::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 0.2.1
61
+ version:
62
+ - !ruby/object:Gem::Dependency
63
+ name: mongrel
64
+ version_requirement:
65
+ version_requirements: !ruby/object:Gem::Version::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: 0.3.13
70
+ version: