io_request 2.3.0 → 2.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 39b0e0eb362ea37ce9f2b7359ec439bfc422ca12b2f89ba4483a8cba20c99a2f
4
- data.tar.gz: 7c7fc713e6de0386789cabbde9a68183d52c8cba268bce30ca9a76c503cb8f3b
3
+ metadata.gz: e57d41dbda1d6665dd595e36da99ce52b60fd2d979957583570224e752b6e8ae
4
+ data.tar.gz: eb50b39358a127a3b6b231d37606a4835b92030b682987bdd6f5a973d3c5b8bd
5
5
  SHA512:
6
- metadata.gz: 5473de710bff683d5dc610a8eb43207353853280c5a4d5a81eccefb1cf40ea924811b5cc7ad16b9b155ebc43186a8691a32c0648cd6dc80c1bb44ba697b38507
7
- data.tar.gz: 8121c16e2f3e3d1b8776aff30d34415a1d29699d9725208621c5af62b17f2664011cea4a03f7b2de370c676dfd0c3f3ec274de9700ba1980ad4e749864cb5bb6
6
+ metadata.gz: d9680f420318ec5d177ada3d79cccd5bab722e1993f541e802d877603bfa9011fb22cd0df5b9f01602a7a4ba54131203d1f2a7645950cdc4ef0adc151fb85c15
7
+ data.tar.gz: 92ea531ada90eda834b847d86009c4ede9594185540acbe7f76a65d0f579b62ff739b9a5ef01acc3d3b08657b97a7ab3a8e36c0dacc90024bd60c53c53b85866
@@ -4,6 +4,9 @@
4
4
  module IORequest
5
5
  # Client received message of zero size.
6
6
  class ZeroSizeMessageError < RuntimeError; end
7
+
8
+ # Authorization failed.
9
+ class AuthorizationFailureError < RuntimeError; end
7
10
  end
8
11
 
9
12
  require_relative 'io_request/version'
@@ -130,10 +130,7 @@ module IORequest
130
130
  @authorizer.authorize(@io_r, @io_w)
131
131
  end
132
132
  end
133
- unless auth_successful
134
- IORequest.logger.debug(prog_name) { 'Authorization failed' }
135
- raise 'Authorization failed'
136
- end
133
+ raise AuthorizationFailureError unless auth_successful
137
134
 
138
135
  IORequest.logger.debug(prog_name) { "New client authorized with data #{@authorizer.data}" }
139
136
  end
@@ -84,12 +84,12 @@ module IORequest
84
84
  client.on_close do
85
85
  @clients.select!(&:open?)
86
86
  end
87
- rescue StandardError
88
- IORequest.debug "Failed to open client: #{e}"
87
+ rescue StandardError => e
88
+ IORequest.logger.debug "Failed to open client: #{e}"
89
89
  ssl_socket.close
90
90
  end
91
91
  rescue StandardError => e
92
- IORequest.warn "Unknown error while handling sockets: #{e}"
92
+ IORequest.logger.warn "Unknown error while handling sockets: #{e}"
93
93
  end
94
94
  end
95
95
 
@@ -108,9 +108,15 @@ module IORequest
108
108
  @authorizer = authorizer
109
109
  @requests_handler = requests_handler
110
110
 
111
+ @client = nil
112
+
111
113
  initialize_ssl_context(certificate, key)
112
114
  end
113
115
 
116
+ def connected?
117
+ !@client.nil?
118
+ end
119
+
114
120
  # Connect to server.
115
121
  # @param host [String] host of server.
116
122
  # @param port [Integer] port of server.
@@ -2,5 +2,5 @@
2
2
 
3
3
  module IORequest
4
4
  # Gem version.
5
- VERSION = '2.3.0'
5
+ VERSION = '2.3.1'
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: io_request
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fizvlad