io-endpoint 0.10.1 → 0.10.3

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: 38306bd23243b3a887ade16d518ed42e15d716bb71d3a8ab264e18e2d0fe0502
4
- data.tar.gz: 50830ba30ca726fc75f02e641f21165b7790179cff22046f9ad58f26f603f34f
3
+ metadata.gz: afbc41c1af461a0f589ca44c76c181ee916aa15cf3942f6c36f28abfe4074a0e
4
+ data.tar.gz: 4befca414c4f7ab1d3981f3849371f44d9cd2bed59452224decef2c9f49ca476
5
5
  SHA512:
6
- metadata.gz: 2c9a1013a086f55b015ee37a9cecfa01739f2c6f4066cfd12c24b6ec345235a5e6f2510f09ad7947c234aada8ec3beb7bb0369dc516fae1a524084c7e9876f6f
7
- data.tar.gz: 8c19203762bd36f40fffe3870a907e6b21119fea7d0293627e441ac7829bf023dfc7aee30b6eb24e2bb9ea26a1f929e20689dfb95bb31a8893bae356318bba03
6
+ metadata.gz: 86e753b79efe7ad2438a5ac795db34a10887635835eb80767022cf0228370c6c6e2850f51afccf6d82d6f1f80b79290ecbc44807b6237d0d12d1d1f0d4df000d
7
+ data.tar.gz: 5f5a734cff764e4928d87fdce912278fd49820c4e864a49d092f13df6f4ea7944a28b6a35bae837a6803f381ddbaa9f5b5f6f22e0329af86cc18c9097202b105
checksums.yaml.gz.sig CHANGED
Binary file
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2023, by Samuel Williams.
4
+ # Copyright, 2024, by Samuel Williams.
5
5
 
6
6
  require_relative 'generic'
7
7
  require_relative 'composite_endpoint'
@@ -12,15 +12,8 @@ module IO::Endpoint
12
12
  def self.bound(endpoint, backlog: Socket::SOMAXCONN, close_on_exec: false)
13
13
  sockets = endpoint.bind
14
14
 
15
- sockets.each do |server|
16
- # This is somewhat optional. We want to have a generic interface as much as possible so that users of this interface can just call it without knowing a lot of internal details. Therefore, we ignore errors here if it's because the underlying socket does not support the operation.
17
- begin
18
- server.listen(backlog)
19
- rescue Errno::EOPNOTSUPP
20
- # Ignore.
21
- end
22
-
23
- server.close_on_exec = close_on_exec
15
+ sockets.each do |socket|
16
+ socket.close_on_exec = close_on_exec
24
17
  end
25
18
 
26
19
  return self.new(endpoint, sockets, **endpoint.options)
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2023, by Samuel Williams.
4
+ # Copyright, 2023-2024, by Samuel Williams.
5
5
 
6
6
  require_relative 'generic'
7
7
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2023, by Samuel Williams.
4
+ # Copyright, 2024, by Samuel Williams.
5
5
 
6
6
  require_relative 'generic'
7
7
  require_relative 'composite_endpoint'
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2023, by Samuel Williams.
4
+ # Copyright, 2023-2024, by Samuel Williams.
5
5
 
6
6
  # require_relative 'address'
7
7
  require 'uri'
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2024, by Samuel Williams.
4
+ # Copyright, 2023-2024, by Samuel Williams.
5
5
 
6
6
  require_relative 'bound_endpoint'
7
7
  require_relative 'connected_endpoint'
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2023, by Samuel Williams.
4
+ # Copyright, 2023-2024, by Samuel Williams.
5
5
 
6
6
  require_relative 'host_endpoint'
7
7
  require_relative 'generic'
@@ -10,6 +10,14 @@ require 'openssl'
10
10
 
11
11
  module OpenSSL
12
12
  module SSL
13
+ class SSLSocket
14
+ unless method_defined?(:start)
15
+ def start
16
+ self.accept
17
+ end
18
+ end
19
+ end
20
+
13
21
  module SocketForwarder
14
22
  unless method_defined?(:close_on_exec=)
15
23
  def close_on_exec=(value)
@@ -113,7 +121,9 @@ module IO::Endpoint
113
121
  end
114
122
 
115
123
  def make_server(io)
116
- ::OpenSSL::SSL::SSLServer.new(io, self.context)
124
+ ::OpenSSL::SSL::SSLServer.new(io, self.context).tap do |server|
125
+ server.start_immediately = false
126
+ end
117
127
  end
118
128
 
119
129
  def make_socket(io)
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2023, by Samuel Williams.
4
+ # Copyright, 2023-2024, by Samuel Williams.
5
5
 
6
6
  class IO
7
7
  module Endpoint
8
- VERSION = "0.10.1"
8
+ VERSION = "0.10.3"
9
9
  end
10
10
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2023, by Samuel Williams.
4
+ # Copyright, 2023-2024, by Samuel Williams.
5
5
 
6
6
  require 'socket'
7
7
 
@@ -128,7 +128,12 @@ module IO::Endpoint
128
128
  socket.bind(local_address.to_sockaddr)
129
129
 
130
130
  if backlog
131
- socket.listen(backlog)
131
+ begin
132
+ # Generally speaking, bind/listen is a common pattern, but it's not applicable to all socket types. We ignore the error if it's not supported as the alternative is exposing this upstream, which seems less desirable than handling it here. In other words, `bind` in this context means "prepare it to accept connections", whatever that means for the given socket type.
133
+ socket.listen(backlog)
134
+ rescue Errno::EOPNOTSUPP
135
+ # Ignore.
136
+ end
132
137
  end
133
138
  rescue
134
139
  socket&.close
@@ -160,6 +165,16 @@ module IO::Endpoint
160
165
  end
161
166
 
162
167
  async do
168
+ # Some sockets, notably SSL sockets, need application level negotiation before they are ready:
169
+ if socket.respond_to?(:start)
170
+ begin
171
+ socket.start
172
+ rescue
173
+ socket.close
174
+ raise
175
+ end
176
+ end
177
+
163
178
  yield socket, address
164
179
  end
165
180
  end
data/lib/io/endpoint.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2023, by Samuel Williams.
4
+ # Copyright, 2023-2024, by Samuel Williams.
5
5
 
6
6
  require_relative "endpoint/version"
7
7
  require_relative "endpoint/generic"
data/license.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # MIT License
2
2
 
3
- Copyright, 2023, by Samuel Williams.
3
+ Copyright, 2023-2024, by Samuel Williams.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: io-endpoint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.1
4
+ version: 0.10.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -37,7 +37,7 @@ cert_chain:
37
37
  Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
38
38
  voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
39
39
  -----END CERTIFICATE-----
40
- date: 2024-04-23 00:00:00.000000000 Z
40
+ date: 2024-05-10 00:00:00.000000000 Z
41
41
  dependencies: []
42
42
  description:
43
43
  email:
@@ -65,6 +65,7 @@ licenses:
65
65
  - MIT
66
66
  metadata:
67
67
  documentation_uri: https://socketry.github.io/io-endpoint
68
+ source_code_uri: https://github.com/socketry/io-endpoint.git
68
69
  post_install_message:
69
70
  rdoc_options: []
70
71
  require_paths:
@@ -73,7 +74,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
73
74
  requirements:
74
75
  - - ">="
75
76
  - !ruby/object:Gem::Version
76
- version: '3.0'
77
+ version: '3.1'
77
78
  required_rubygems_version: !ruby/object:Gem::Requirement
78
79
  requirements:
79
80
  - - ">="
metadata.gz.sig CHANGED
Binary file