raktr 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +1 -0
  3. data/LICENSE.md +29 -0
  4. data/README.md +77 -0
  5. data/Rakefile +53 -0
  6. data/lib/raktr/connection/callbacks.rb +71 -0
  7. data/lib/raktr/connection/error.rb +120 -0
  8. data/lib/raktr/connection/peer_info.rb +90 -0
  9. data/lib/raktr/connection/tls.rb +164 -0
  10. data/lib/raktr/connection.rb +339 -0
  11. data/lib/raktr/global.rb +24 -0
  12. data/lib/raktr/iterator.rb +249 -0
  13. data/lib/raktr/queue.rb +89 -0
  14. data/lib/raktr/tasks/base.rb +57 -0
  15. data/lib/raktr/tasks/delayed.rb +33 -0
  16. data/lib/raktr/tasks/one_off.rb +30 -0
  17. data/lib/raktr/tasks/periodic.rb +58 -0
  18. data/lib/raktr/tasks/persistent.rb +29 -0
  19. data/lib/raktr/tasks.rb +105 -0
  20. data/lib/raktr/version.rb +13 -0
  21. data/lib/raktr.rb +707 -0
  22. data/spec/raktr/connection/tls_spec.rb +348 -0
  23. data/spec/raktr/connection_spec.rb +74 -0
  24. data/spec/raktr/iterator_spec.rb +203 -0
  25. data/spec/raktr/queue_spec.rb +91 -0
  26. data/spec/raktr/tasks/base.rb +8 -0
  27. data/spec/raktr/tasks/delayed_spec.rb +71 -0
  28. data/spec/raktr/tasks/one_off_spec.rb +66 -0
  29. data/spec/raktr/tasks/periodic_spec.rb +57 -0
  30. data/spec/raktr/tasks/persistent_spec.rb +54 -0
  31. data/spec/raktr/tasks_spec.rb +155 -0
  32. data/spec/raktr_spec.rb +20 -0
  33. data/spec/raktr_tls_spec.rb +20 -0
  34. data/spec/spec_helper.rb +17 -0
  35. data/spec/support/fixtures/handlers/echo_client.rb +34 -0
  36. data/spec/support/fixtures/handlers/echo_client_tls.rb +10 -0
  37. data/spec/support/fixtures/handlers/echo_server.rb +12 -0
  38. data/spec/support/fixtures/handlers/echo_server_tls.rb +8 -0
  39. data/spec/support/fixtures/pems/cacert.pem +37 -0
  40. data/spec/support/fixtures/pems/client/cert.pem +37 -0
  41. data/spec/support/fixtures/pems/client/foo-cert.pem +39 -0
  42. data/spec/support/fixtures/pems/client/foo-key.pem +51 -0
  43. data/spec/support/fixtures/pems/client/key.pem +51 -0
  44. data/spec/support/fixtures/pems/server/cert.pem +37 -0
  45. data/spec/support/fixtures/pems/server/key.pem +51 -0
  46. data/spec/support/helpers/paths.rb +23 -0
  47. data/spec/support/helpers/utilities.rb +135 -0
  48. data/spec/support/lib/server_option_parser.rb +29 -0
  49. data/spec/support/lib/servers/runner.rb +13 -0
  50. data/spec/support/lib/servers.rb +133 -0
  51. data/spec/support/servers/echo.rb +14 -0
  52. data/spec/support/servers/echo_tls.rb +22 -0
  53. data/spec/support/servers/echo_unix.rb +14 -0
  54. data/spec/support/servers/echo_unix_tls.rb +22 -0
  55. data/spec/support/shared/connection.rb +696 -0
  56. data/spec/support/shared/raktr.rb +834 -0
  57. data/spec/support/shared/task.rb +21 -0
  58. metadata +140 -0
@@ -0,0 +1,51 @@
1
+ -----BEGIN RSA PRIVATE KEY-----
2
+ MIIJKAIBAAKCAgEAvSvk3+294jH4y+7DHlHWsW4rojy52OTOPs3nMWz8k2wcD/2l
3
+ V8Rfpjg0+URH/Qy89Q19fqq64A3ch0RbWDuid39+4jiIBFj9NKA+KkifqOTi/pjY
4
+ Dqc6ZSk7/fYlZkFwzcgXSowUZ9g6rn4PbSJZziX/A+RwfPjr/HxDHduedxcmLHYz
5
+ 8BL1HA0q3bpR7m0byw9j9yQyy8xt8xD5H7XmTXHpECcEgd6HxCwWUMUEZP4SYrMO
6
+ AIjjXM1qQqJL5m8nLZvIphP+vQ/jtHPHpg/nb6shWHVKWRbCMPoRtVye8NxbnasO
7
+ tyq2xKC6qJl+v7ZN36I5AG1RLZjmG1yN2KlFpUsugJjSrBfqLgkoaIvp89VOAhRF
8
+ 5k8V2TsIdUJUAAQOXfIYt7rCmoaicqTomMFkHKJbcQ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UbyU21Qle56H4KrSt1xa0dJLb
44
+ W1vaS8lOIWhMO5iG32shO90Vk06IhC2vJ1C/jRpAnJyT8XfwEW73hngrstdjyK/C
45
+ lD8GvxED3UpuLxDRrtuz3H13gNfqsotbGWsCggEAAnt56fTLGmTu9pdM3FtTEaLN
46
+ rmO9JbRDsxnXTN84hLci27HW0rU/AFGw+a6MHNiBNVfBqhMnZwPgAsNVf6TB//iE
47
+ FZTotJWcTHkbiBwpXvRHHQ0BwxKluDicLqzzvEW8fmiNVjDig2JeS/45r2x0S4M/
48
+ 3TVHK7A/vXQWvBgQi9a2ooViRjRXdhzlIkjNNsYieAwX7793Nw2KqZbHKXvelEOQ
49
+ I6nTIqNDZOZ7MmGKHnGpj4SIupCKdkalQgakkGFbpltsyKBC7gooHQuKjQsYnRgl
50
+ XzOy39QzIn0WF9AoyLg/W8yPsnhc1S5Ed6Lq8KL3HWV6a8n9QRSHVCX6dafBcg==
51
+ -----END RSA PRIVATE KEY-----
@@ -0,0 +1,23 @@
1
+ def spec_path
2
+ File.expand_path( "#{File.dirname( __FILE__ )}/../.." ) + '/'
3
+ end
4
+
5
+ def support_path
6
+ "#{spec_path}support/"
7
+ end
8
+
9
+ def fixtures_path
10
+ "#{support_path}fixtures/"
11
+ end
12
+
13
+ def pems_path
14
+ "#{fixtures_path}pems/"
15
+ end
16
+
17
+ def support_lib_path
18
+ "#{support_path}lib/"
19
+ end
20
+
21
+ def servers_path
22
+ "#{spec_path}support/servers/"
23
+ end
@@ -0,0 +1,135 @@
1
+ require 'socket'
2
+ require 'openssl'
3
+
4
+ def port_to_socket( port )
5
+ "/tmp/raktr-socket-#{port}"
6
+ end
7
+
8
+ def run_reactor_in_thread
9
+ t = Thread.new do
10
+ raktr.run
11
+ end
12
+ sleep 0.1
13
+ t
14
+ end
15
+
16
+ def tcp_connect( host, port )
17
+ TCPSocket.new( host, port )
18
+ end
19
+
20
+ def tcp_socket
21
+ socket = Socket.new(
22
+ Socket::Constants::AF_INET,
23
+ Socket::Constants::SOCK_STREAM,
24
+ Socket::Constants::IPPROTO_IP
25
+ )
26
+ socket.do_not_reverse_lookup = true
27
+ socket
28
+ end
29
+
30
+ def tcp_write( host, port, data )
31
+ s = tcp_connect( host, port )
32
+ s.write data
33
+ s
34
+ end
35
+
36
+ if Raktr.supports_unix_sockets?
37
+
38
+ def unix_connect( socket )
39
+ UNIXSocket.new( socket )
40
+ end
41
+
42
+ def unix_server( socket )
43
+ UNIXServer.new( socket )
44
+ end
45
+
46
+ end
47
+
48
+ def unix_write( socket, data )
49
+ s = unix_connect( socket )
50
+ s.write data
51
+ s
52
+ end
53
+
54
+ def tcp_server( host, port )
55
+ TCPServer.new( host, port )
56
+ end
57
+
58
+ def tcp_ssl_socket( host, port, options = {} )
59
+ convert_client_to_ssl( tcp_socket, options )
60
+ end
61
+
62
+ def tcp_ssl_connect( host, port, options = {} )
63
+ convert_client_to_ssl( tcp_connect( host, port ), options )
64
+ end
65
+
66
+ def unix_ssl_connect( socket, options = {} )
67
+ convert_client_to_ssl( unix_connect( socket ), options)
68
+ end
69
+
70
+ def tcp_ssl_write( host, port, data, options = {} )
71
+ s = tcp_ssl_connect( host, port, options )
72
+ s.write data
73
+ s
74
+ end
75
+
76
+ def unix_ssl_write( socket, data, options = {} )
77
+ s = unix_ssl_connect( socket, options )
78
+ s.write data
79
+ s
80
+ end
81
+
82
+ def unix_ssl_server( socket, options = {} )
83
+ convert_server_to_ssl( unix_server( socket ), options )
84
+ end
85
+
86
+ def tcp_ssl_server( host, port, options = {} )
87
+ convert_server_to_ssl( tcp_server( host, port ), options )
88
+ end
89
+
90
+ def ssl_context( options )
91
+ context = OpenSSL::SSL::SSLContext.new
92
+ context.cert = OpenSSL::X509::Certificate.new( File.open( options[:certificate] ) )
93
+ context.key = OpenSSL::PKey::RSA.new( File.open( options[:private_key] ) )
94
+
95
+ context.ca_file = options[:ca]
96
+ context.verify_mode =
97
+ OpenSSL::SSL::VERIFY_PEER | OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT
98
+
99
+ context
100
+ end
101
+
102
+ def convert_server_to_ssl( server, options = {} )
103
+ if options[:certificate] && options[:private_key]
104
+ context = ssl_context( options )
105
+ else
106
+ context = OpenSSL::SSL::SSLContext.new
107
+ context.key = OpenSSL::PKey::RSA.new( 2048 )
108
+ context.cert = OpenSSL::X509::Certificate.new
109
+ context.cert.subject = OpenSSL::X509::Name.new( [['CN', 'localhost']] )
110
+ context.cert.issuer = context.cert.subject
111
+ context.cert.public_key = context.key
112
+ context.cert.not_before = Time.now
113
+ context.cert.not_after = Time.now + 60 * 60 * 24
114
+ context.cert.version = 2
115
+ context.cert.serial = 1
116
+
117
+ context.cert.sign( context.key, OpenSSL::Digest::SHA256.new )
118
+ end
119
+
120
+ OpenSSL::SSL::SSLServer.new( server, context )
121
+ end
122
+
123
+ def convert_client_to_ssl( client, options = {} )
124
+ if options[:certificate] && options[:private_key]
125
+ context = ssl_context( options )
126
+ else
127
+ context = OpenSSL::SSL::SSLContext.new
128
+ context.verify_mode = OpenSSL::SSL::VERIFY_NONE
129
+ end
130
+
131
+ s = OpenSSL::SSL::SSLSocket.new( client, context )
132
+ s.sync_close = true
133
+ s.connect
134
+ s
135
+ end
@@ -0,0 +1,29 @@
1
+ require 'optparse'
2
+
3
+ class ServerOptionParser
4
+
5
+ DEFAULT = {
6
+ host: '0.0.0.0',
7
+ port: 4567
8
+ }
9
+
10
+ def self.parse
11
+ options = {}
12
+
13
+ OptionParser.new do |opts|
14
+
15
+ opts.on('-o', '--host [host]',
16
+ "Sets the host (default is #{options[:host]}).") do |host|
17
+ options[:host] = host
18
+ end
19
+
20
+ opts.on('-p', '--port [port]', Integer,
21
+ "Sets the port (default is #{options[:port]}).") do |port|
22
+ options[:port] = port
23
+ end
24
+
25
+ end.parse!
26
+
27
+ DEFAULT.merge(options)
28
+ end
29
+ end
@@ -0,0 +1,13 @@
1
+ require 'ap'
2
+ require_relative '../../../../lib/raktr'
3
+
4
+ Thread.abort_on_exception = true
5
+
6
+ Dir["#{File.expand_path(File.dirname(__FILE__) + '/../..' )}/**/*.rb"].each do |f|
7
+ next if f.include?( '/servers/' ) || f.include?( 'shared' )
8
+ require f
9
+ end
10
+
11
+ $options = ServerOptionParser.parse
12
+
13
+ load ARGV[0]
@@ -0,0 +1,133 @@
1
+ require 'singleton'
2
+ require 'net/http'
3
+
4
+ class Servers
5
+ include Singleton
6
+
7
+ RUNNER = "#{support_lib_path}/servers/runner.rb"
8
+
9
+ attr_reader :lib
10
+
11
+ def initialize
12
+ @lib = File.expand_path( File.dirname(__FILE__) + '/../servers' )
13
+ @servers = {}
14
+
15
+ Dir.glob(File.join(@lib + '/**', '*.rb')) do |path|
16
+ @servers[normalize_name( File.basename(path, '.rb') )] = {
17
+ port: available_port,
18
+ path: path
19
+ }
20
+ end
21
+ end
22
+
23
+ def start( name )
24
+ server_info = data_for( name )
25
+
26
+ return [host_for(name), port_for(name)] if server_info[:pid] && up?( name )
27
+
28
+ server_info[:pid] = Process.spawn(
29
+ RbConfig.ruby, RUNNER, server_info[:path], '-p', server_info[:port].to_s,
30
+ '-o', host_for( name )
31
+ )
32
+
33
+ Process.detach server_info[:pid]
34
+
35
+ sleep 0.1 while !up?( name )
36
+
37
+ [host_for(name), port_for(name)]
38
+ end
39
+
40
+ def address_for( name )
41
+ "#{host_for( name )}:#{port_for( name )}"
42
+ end
43
+
44
+ def host_for( name )
45
+ '127.0.0.1'
46
+ end
47
+
48
+ def port_for( name )
49
+ data_for( name )[:port]
50
+ end
51
+
52
+ def up?( name )
53
+ if name.to_s.include? 'unix'
54
+ return File.exist?( port_to_socket( port_for( name ) ) )
55
+ end
56
+
57
+ socket = Socket.new( Socket::Constants::AF_INET, Socket::Constants::SOCK_STREAM, 0 )
58
+ sockaddr = Socket.sockaddr_in( port_for( name ), host_for( name ) )
59
+
60
+ begin
61
+ socket.connect( sockaddr )
62
+ rescue Errno::ECONNREFUSED, Errno::EADDRINUSE
63
+ return false
64
+ end
65
+
66
+ socket.close
67
+
68
+ true
69
+ end
70
+
71
+ def data_for( name )
72
+ @servers[normalize_name( name )]
73
+ end
74
+
75
+ def kill( name )
76
+ server_info = data_for( name )
77
+ return if !server_info[:pid]
78
+
79
+ begin
80
+ Process.kill( 'KILL', server_info[:pid] ) while sleep 0.1
81
+ rescue Errno::ESRCH
82
+ server_info.delete(:pid)
83
+
84
+ socket = port_to_socket( server_info[:port] )
85
+ if File.exist?( socket )
86
+ File.delete socket
87
+ end
88
+
89
+ return true
90
+ end
91
+ end
92
+
93
+ def killall
94
+ @servers.keys.each { |n| kill n }
95
+ end
96
+
97
+ def available_port
98
+ loop do
99
+ port = 5555 + rand( 9999 )
100
+
101
+ begin
102
+ socket = ::Socket.new( :INET, :STREAM, 0 )
103
+ socket.bind( ::Socket.sockaddr_in( port, '127.0.0.1' ) )
104
+ socket.close
105
+
106
+ return port if !File.exist?( port_to_socket( port ) )
107
+ rescue Errno::EADDRINUSE
108
+ end
109
+ end
110
+ end
111
+
112
+ def normalize_name( name )
113
+ name.to_s.to_sym
114
+ end
115
+
116
+ def self.method_missing( sym, *args, &block )
117
+ if instance.respond_to?( sym )
118
+ instance.send( sym, *args, &block )
119
+ elsif super( sym, *args, &block )
120
+ end
121
+ end
122
+
123
+ def self.respond_to?( m )
124
+ super( m ) || instance.respond_to?( m )
125
+ end
126
+
127
+ private
128
+
129
+ def set_data_for( name, data )
130
+ @servers[normalize_name( name )] = data
131
+ end
132
+
133
+ end
@@ -0,0 +1,14 @@
1
+ server = tcp_server( $options[:host], $options[:port] )
2
+
3
+ loop do
4
+ Thread.new server.accept do |socket|
5
+ begin
6
+ loop do
7
+ next if (data = socket.gets).to_s.empty?
8
+ socket.write( data )
9
+ end
10
+ rescue EOFError, Errno::EPIPE, Errno::ECONNRESET
11
+ socket.close
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,22 @@
1
+ server = tcp_ssl_server( $options[:host], $options[:port] )
2
+
3
+ loop do
4
+ socket = nil
5
+ begin
6
+ socket = server.accept
7
+ rescue => e
8
+ # ap e
9
+ next
10
+ end
11
+
12
+ Thread.new do
13
+ begin
14
+ loop do
15
+ next if (data = socket.gets).to_s.empty?
16
+ socket.write( data )
17
+ end
18
+ rescue EOFError, Errno::EPIPE, Errno::ECONNRESET
19
+ socket.close
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,14 @@
1
+ server = unix_server( port_to_socket( $options[:port] ) )
2
+
3
+ loop do
4
+ Thread.new server.accept do |socket|
5
+ begin
6
+ loop do
7
+ next if (data = socket.gets).to_s.empty?
8
+ socket.write( data )
9
+ end
10
+ rescue EOFError, Errno::EPIPE, Errno::ECONNRESET
11
+ socket.close
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,22 @@
1
+ server = unix_ssl_server( port_to_socket( $options[:port] ) )
2
+
3
+ loop do
4
+ socket = nil
5
+ begin
6
+ socket = server.accept
7
+ rescue => e
8
+ # ap e
9
+ next
10
+ end
11
+
12
+ Thread.new do
13
+ begin
14
+ loop do
15
+ next if (data = socket.gets).to_s.empty?
16
+ socket.write( data )
17
+ end
18
+ rescue EOFError, Errno::EPIPE, Errno::ECONNRESET
19
+ socket.close
20
+ end
21
+ end
22
+ end