socket_duplex 1.0.0 → 1.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cf86bc3bcc2e7134ebbb05833da75421b521d2f3
4
- data.tar.gz: 716448a796d76653a9c27e376871428c041d7f17
3
+ metadata.gz: d5f3a6a99568a1bc408e5ca9756c4f5a0193e1cd
4
+ data.tar.gz: 33014f7ffe2d49cadb35f39ab1b4d38667c7a0b8
5
5
  SHA512:
6
- metadata.gz: b5f3fc1fda60758d11e2200e31fc737c40be0e02940cf5a9940e8bfe341183a79fb39189f0bb65f4fef2ed0b3fc74e4107a0a9e62885301e3a2be2f2c964a425
7
- data.tar.gz: 6cf09a8a93af86ca0d38d153213c5ed1c5f8abb4b9ff7efcade7f26316b50b309c5155af58a0b6311f0c32057b79f6e5c3dd16abc58d88d7bc5652252efde873
6
+ metadata.gz: d6c5276bbfaab46d51af00f5aa1aa8f243f282a2d5384efebe47d53dbef749c06ac34b2866cbf01b86e67954eef690460a878a4b00045d0b6e2033c91b28014c
7
+ data.tar.gz: a64e598c9a666c9ea5b1313163df02cd6f96353ea813d8012a590f94e9fb33e7e9524a8c92405e16be5ed3b3b0f8f4c778f870881e45a6bda777027c3194e92b
data/lib/socket_duplex.rb CHANGED
@@ -12,6 +12,7 @@ module Rack
12
12
  def initialize(app, socket_path, secful_key, verify_mode=OpenSSL::SSL::VERIFY_PEER)
13
13
  @app, @socket_path, @verify_mode = app, socket_path, verify_mode
14
14
  begin
15
+ puts 'initialize'
15
16
  @secful_key = secful_key
16
17
  @agent_identifier = SecureRandom.hex
17
18
  @machine_ip = Socket.ip_address_list.detect(&:ipv4_private?).try(:ip_address)
@@ -58,14 +59,17 @@ module Rack
58
59
 
59
60
  def connect_to_ws(thr)
60
61
  begin
62
+ puts 'connect_to_ws'
61
63
  ws = @threads_to_sockets[thr]
62
64
  if !ws
65
+ puts 'creating ws'
63
66
  headers = { 'Agent-Type' => 'Ruby',
64
67
  'Agent-Version' => '1.0',
65
68
  'Agent-Identifier' => @agent_identifier,
66
69
  'Authorization' => 'Bearer ' + @secful_key }
67
70
  ws = WebSocket::Client::Simple.connect @socket_path, verify_mode: @verify_mode, headers: headers
68
71
  sleep(3)
72
+ puts 'connected to ws'
69
73
  end
70
74
  if !ws.open?
71
75
  sleep(60)
@@ -82,11 +86,15 @@ module Rack
82
86
  def handle_request(env)
83
87
  request_hash = {}
84
88
  if env['rack.url_scheme'] == 'http'
89
+ puts 'writing env'
85
90
  write_env(request_hash, env)
86
91
  ws = @threads_to_sockets[Thread.current]
87
92
  begin
93
+ puts 'sending'
88
94
  ws.send request_hash.to_json
95
+ puts 'sent'
89
96
  rescue Exception
97
+ puts 'error on sending'
90
98
  if ws
91
99
  ws.close()
92
100
  end rescue nil
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
4
  Gem::Specification.new do |spec|
5
5
  spec.name = "socket_duplex"
6
- spec.version = '1.0.0'
6
+ spec.version = '1.1.1'
7
7
  spec.authors = ["Secful"]
8
8
  spec.description = %q{Rack middleware that duplexes HTTP traffic}
9
9
  spec.summary = spec.description
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: socket_duplex
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Secful
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-19 00:00:00.000000000 Z
11
+ date: 2016-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -140,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
140
  version: '0'
141
141
  requirements: []
142
142
  rubyforge_project:
143
- rubygems_version: 2.4.5.1
143
+ rubygems_version: 2.5.2
144
144
  signing_key:
145
145
  specification_version: 4
146
146
  summary: Rack middleware that duplexes HTTP traffic