instrumental_agent 0.12.7 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
data/spec/test.crt ADDED
@@ -0,0 +1,16 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIICkzCCAfwCCQDzjnx2K+MAEDANBgkqhkiG9w0BAQUFADCBjTELMAkGA1UEBhMC
3
+ VVMxEDAOBgNVBAgTB0luZGlhbmExFTATBgNVBAcTDEluZGlhbmFwb2xpczEfMB0G
4
+ A1UEChMWRXhwZWN0ZWQgQmVoYXZpb3IsIExMQzEVMBMGA1UECxMMSW5zdHJ1bWVu
5
+ dGFsMR0wGwYDVQQDExRpbnN0cnVtZW50YWxhcHAudGVzdDAeFw0xNTA3MTUxODMz
6
+ NTlaFw0xODA3MTQxODMzNTlaMIGNMQswCQYDVQQGEwJVUzEQMA4GA1UECBMHSW5k
7
+ aWFuYTEVMBMGA1UEBxMMSW5kaWFuYXBvbGlzMR8wHQYDVQQKExZFeHBlY3RlZCBC
8
+ ZWhhdmlvciwgTExDMRUwEwYDVQQLEwxJbnN0cnVtZW50YWwxHTAbBgNVBAMTFGlu
9
+ c3RydW1lbnRhbGFwcC50ZXN0MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDW
10
+ LiEUeH0RWIQR9iVXiUiGk9dYmjJloyrKUSZrOHt7b5Y0bHVI9t/tRVf01DyPyL63
11
+ C8JEthMkdLDfsmgezSbNyTt4tMqAQmVEjxuCgZXnXeWlumXyfEjSMmuzaa1r5/WW
12
+ 602ibA2dN6CV7BpqWXLmvNX/C8kRmD1xPcJJ9T/jcwIDAQABMA0GCSqGSIb3DQEB
13
+ BQUAA4GBAMiApS8danJ6AZgk9e6bhXBYFEME6PbIiY3yg8db2fC1gwEIb9TG59Mm
14
+ 34NWn4xo8csw6zpcca3+FpPwpAQ8hy/gmktbliSg7QzAgLIt+1XFYSKODP7BQL91
15
+ Y85vWi4FJglY3JnwGyArCAGzpoB8+M4XtMbfbE+TQv/KjYcIi/yi
16
+ -----END CERTIFIC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h3hIi0dwZj2mgiMtG/EBrSf2DW68FUupjDALe
6
+ yUc0ys2F91pPZ+CBNysy+1Q7M7KTqk0XLFjokIKWt8EQ4FB3t+UCFtK5PLdqWjqx
7
+ ygZnj5n0fTtDyU2t2omO78AhL+m4AVRvGn55K7Aq8OgnMkkCQQDzimBLa9TZ+D0f
8
+ UQhkjEuNpMJ7yx8UyIJBo8oT6vbWUcUJaTjBJ8fACKsJs+WjMOlvUxB5pyubAjDn
9
+ b0fh9XuvAkEA4SM5USgiBaXRztGvst8Sd9usYLEjW6YvXqt5U3LG9STdOOStOQ1g
10
+ 8tBICxKT9Fvan+w2yEkr1+AobCaUdyoxfQJBAJ5424IYT6/qJTO8kd6DoCIyJM9S
11
+ 9A2dD41Q3Ayr5yS8np8qFeEyVntx6IHuyq2vBScIgP74NZqvCU1/juHM0EcCQGw2
12
+ 7xz4SmomixN7LJWwrYLZHyEW4+Twm0JI77dRqxo4DvGC0VRj/t6XiJlx45YH9Kz7
13
+ 8FUS/rTz9NoPLTueF00CQQDnObuc/Wn6p8tcg4iOoZz/NcBdqd/GIIcI7D8WJubv
14
+ d77dOAhilAxypMjmIr+YfKlb13sLDWwufx4urAIGZJ9S
15
+ -----END RSA PRIVATE KEY-----
data/spec/test_server.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require 'openssl'
2
+
1
3
  class TestServer
2
4
  attr_accessor :host, :port, :connect_count, :commands
3
5
 
@@ -6,12 +8,17 @@ class TestServer
6
8
  :listen => true,
7
9
  :authenticate => true,
8
10
  :response => true,
11
+ :secure => false
9
12
  }
10
13
  @options = default_options.merge(options)
11
14
 
15
+ dir = File.expand_path(File.dirname(__FILE__))
16
+ @certificate = OpenSSL::X509::Certificate.new(File.open(File.join(dir, "test.crt")))
17
+ @key = OpenSSL::PKey::RSA.new(File.open(File.join(dir, "test.key")))
12
18
  @connect_count = 0
13
19
  @connections = []
14
20
  @commands = []
21
+ @mutex = Mutex.new
15
22
  @host = 'localhost'
16
23
  @main_thread = nil
17
24
  @client_threads = []
@@ -23,25 +30,33 @@ class TestServer
23
30
  def listen
24
31
  @port ||= 10001
25
32
  @server = TCPServer.new(@port)
33
+ if @options[:secure]
34
+ context = OpenSSL::SSL::SSLContext.new
35
+ context.cert = @certificate
36
+ context.key = @key
37
+ context.set_params(:verify_mode => OpenSSL::SSL::VERIFY_NONE)
38
+ @server = OpenSSL::SSL::SSLServer.new(@server, context)
39
+ end
26
40
  @main_thread = Thread.new do
27
41
  begin
28
42
  # puts "listening"
29
43
  loop do
30
44
  client = @server.accept
45
+ if @options[:secure]
46
+ client.sync_close = true
47
+ end
31
48
  @connections << client
32
49
  @connect_count += 1
33
- @fd_to_thread[client.to_i] = Thread.new(client) do |socket|
34
- # puts "connection received"
50
+ @fd_to_thread[fd_for_socket(client)] = Thread.new(client) do |socket|
35
51
  loop do
36
52
  begin
37
- command = ""
38
- while (c = socket.read(1)) != "\n"
39
- command << c unless c.nil?
40
- end
53
+ command = socket.gets.to_s.chomp.strip
41
54
  if !command.empty?
42
- # puts "got: #{command}"
43
- commands << command
44
- if %w[hello authenticate].include?(command.split(' ')[0])
55
+ @mutex.synchronize do
56
+ commands << command
57
+ end
58
+ cmd, _ = command.split
59
+ if %w[hello authenticate].include?(cmd)
45
60
  if @options[:response]
46
61
  if @options[:authenticate]
47
62
  socket.puts "ok"
@@ -51,12 +66,14 @@ class TestServer
51
66
  end
52
67
  end
53
68
  end
69
+ rescue EOFError
70
+ retry
54
71
  rescue Exception => e
55
72
  break
56
73
  end
57
74
  end
58
75
  end
59
- @client_threads << @fd_to_thread[client.to_i]
76
+ @client_threads << @fd_to_thread[fd_for_socket(client)]
60
77
  end
61
78
  rescue Exception => err
62
79
  unless @stopping
@@ -90,13 +107,32 @@ class TestServer
90
107
  end
91
108
  end
92
109
 
110
+ def fd_for_socket(socket)
111
+ case socket
112
+ when OpenSSL::SSL::SSLSocket
113
+ socket.io.to_i
114
+ else
115
+ socket.to_i
116
+ end
117
+ end
118
+
93
119
  def disconnect_all
94
- @connections.each { |c|
95
- if (thr = @fd_to_thread[c.to_i])
120
+ @connections.each { |c|
121
+ fd = fd_for_socket(c)
122
+ if (thr = @fd_to_thread[fd])
96
123
  thr.kill
97
124
  end
98
- @fd_to_thread.delete(c.to_i)
99
- c.close rescue false
125
+ @fd_to_thread.delete(fd)
126
+ begin
127
+ if c.respond_to?(:sync_close=)
128
+ c.sync_close = true
129
+ end
130
+ c.flush
131
+ c.close
132
+ rescue Exception => e
133
+ puts e.message
134
+ puts e.backtrace.join("\n")
135
+ end
100
136
  }
101
137
  @connections = []
102
138
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: instrumental_agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.7
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elijah Miller
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2014-09-03 00:00:00.000000000 Z
14
+ date: 2015-08-03 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rake
@@ -55,62 +55,6 @@ dependencies:
55
55
  - - ">="
56
56
  - !ruby/object:Gem::Version
57
57
  version: '0'
58
- - !ruby/object:Gem::Dependency
59
- name: guard
60
- requirement: !ruby/object:Gem::Requirement
61
- requirements:
62
- - - ">="
63
- - !ruby/object:Gem::Version
64
- version: '0'
65
- type: :development
66
- prerelease: false
67
- version_requirements: !ruby/object:Gem::Requirement
68
- requirements:
69
- - - ">="
70
- - !ruby/object:Gem::Version
71
- version: '0'
72
- - !ruby/object:Gem::Dependency
73
- name: guard-rspec
74
- requirement: !ruby/object:Gem::Requirement
75
- requirements:
76
- - - ">="
77
- - !ruby/object:Gem::Version
78
- version: '0'
79
- type: :development
80
- prerelease: false
81
- version_requirements: !ruby/object:Gem::Requirement
82
- requirements:
83
- - - ">="
84
- - !ruby/object:Gem::Version
85
- version: '0'
86
- - !ruby/object:Gem::Dependency
87
- name: growl
88
- requirement: !ruby/object:Gem::Requirement
89
- requirements:
90
- - - ">="
91
- - !ruby/object:Gem::Version
92
- version: '0'
93
- type: :development
94
- prerelease: false
95
- version_requirements: !ruby/object:Gem::Requirement
96
- requirements:
97
- - - ">="
98
- - !ruby/object:Gem::Version
99
- version: '0'
100
- - !ruby/object:Gem::Dependency
101
- name: rb-fsevent
102
- requirement: !ruby/object:Gem::Requirement
103
- requirements:
104
- - - ">="
105
- - !ruby/object:Gem::Version
106
- version: '0'
107
- type: :development
108
- prerelease: false
109
- version_requirements: !ruby/object:Gem::Requirement
110
- requirements:
111
- - - ">="
112
- - !ruby/object:Gem::Version
113
- version: '0'
114
58
  description: Track anything.
115
59
  email:
116
60
  - support@instrumentalapp.com
@@ -127,6 +71,9 @@ files:
127
71
  - LICENSE
128
72
  - README.md
129
73
  - Rakefile
74
+ - certs/equifax.ca.pem
75
+ - certs/geotrust.ca.pem
76
+ - certs/rapidssl.ca.pem
130
77
  - instrumental_agent.gemspec
131
78
  - lib/instrumental/agent.rb
132
79
  - lib/instrumental/capistrano.rb
@@ -135,8 +82,11 @@ files:
135
82
  - lib/instrumental_agent.rb
136
83
  - spec/agent_spec.rb
137
84
  - spec/spec_helper.rb
85
+ - spec/test.crt
86
+ - spec/test.csr
87
+ - spec/test.key
138
88
  - spec/test_server.rb
139
- homepage: http://github.com/fastestforward/instrumental_agent
89
+ homepage: http://github.com/expectedbehavior/instrumental_agent
140
90
  licenses:
141
91
  - MIT
142
92
  metadata: {}
@@ -156,11 +106,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
156
106
  version: '0'
157
107
  requirements: []
158
108
  rubyforge_project:
159
- rubygems_version: 2.2.2
109
+ rubygems_version: 2.4.8
160
110
  signing_key:
161
111
  specification_version: 4
162
112
  summary: Agent for reporting data to instrumentalapp.com
163
113
  test_files:
164
114
  - spec/agent_spec.rb
165
115
  - spec/spec_helper.rb
116
+ - spec/test.crt
117
+ - spec/test.csr
118
+ - spec/test.key
166
119
  - spec/test_server.rb