serverengine 2.2.0 → 2.2.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 +4 -4
- data/Changelog +5 -0
- data/lib/serverengine/socket_manager_unix.rb +21 -12
- data/lib/serverengine/version.rb +1 -1
- data/spec/socket_manager_spec.rb +21 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 934c5957de987807cb9a28cf740ee002cfa1c64d54c82b21acb16c464bfd8da0
|
4
|
+
data.tar.gz: aef6141bd22834eb0f9fb837d374ec69b5681cb31bddc0fa1afda5cd82c3ec38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb93190b271548e433d9dcc9ce2d7b4f8358a4bd96079b24c1417bc43e86567840733265df4931d79beacd1ba31dbe23bd1e29c1d205982e036dc29861d68c2a
|
7
|
+
data.tar.gz: '09f3589a04c3bbea01c619216066e7bbb9ac2e4414cd8345713315aa416cbe2600d537bec860034423bb4566881c5febc4efb33bfd28a376953c078aeee524fb'
|
data/Changelog
CHANGED
@@ -50,21 +50,30 @@ module ServerEngine
|
|
50
50
|
private
|
51
51
|
|
52
52
|
def listen_tcp_new(bind_ip, port)
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
53
|
+
if ENV['SERVERENGINE_USE_SOCKET_REUSEPORT'] == '1'
|
54
|
+
# Based on Addrinfo#listen
|
55
|
+
tsock = Socket.new(bind_ip.ipv6? ? ::Socket::AF_INET6 : ::Socket::AF_INET, ::Socket::SOCK_STREAM, 0)
|
56
|
+
tsock.ipv6only! if bind_ip.ipv6?
|
57
|
+
tsock.setsockopt(:SOCKET, :REUSEPORT, true)
|
58
|
+
tsock.setsockopt(:SOCKET, :REUSEADDR, true)
|
59
|
+
tsock.bind(Addrinfo.tcp(bind_ip.to_s, port))
|
60
|
+
tsock.listen(::Socket::SOMAXCONN)
|
61
|
+
tsock.autoclose = false
|
62
|
+
TCPServer.for_fd(tsock.fileno)
|
63
|
+
else
|
64
|
+
# TCPServer.new doesn't set IPV6_V6ONLY flag, so use Addrinfo class instead.
|
65
|
+
# TODO: make backlog configurable if necessary
|
66
|
+
tsock = Addrinfo.tcp(bind_ip.to_s, port).listen(::Socket::SOMAXCONN)
|
67
|
+
tsock.autoclose = false
|
68
|
+
TCPServer.for_fd(tsock.fileno)
|
69
|
+
end
|
58
70
|
end
|
59
71
|
|
60
72
|
def listen_udp_new(bind_ip, port)
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
end
|
66
|
-
sock.bind(bind_ip.to_s, port)
|
67
|
-
return sock
|
73
|
+
# UDPSocket.new doesn't set IPV6_V6ONLY flag, so use Addrinfo class instead.
|
74
|
+
usock = Addrinfo.udp(bind_ip.to_s, port).bind
|
75
|
+
usock.autoclose = false
|
76
|
+
UDPSocket.for_fd(usock.fileno)
|
68
77
|
end
|
69
78
|
|
70
79
|
def start_server(path)
|
data/lib/serverengine/version.rb
CHANGED
data/spec/socket_manager_spec.rb
CHANGED
@@ -155,7 +155,27 @@ describe ServerEngine::SocketManager do
|
|
155
155
|
test_state(:is_udp_socket).should == 1
|
156
156
|
test_state(:udp_data_sent).should == 1
|
157
157
|
end
|
158
|
-
end if (TCPServer.open("::1",0) rescue nil)
|
158
|
+
end if (TCPServer.open("::1", 0) rescue nil)
|
159
|
+
|
160
|
+
unless ServerEngine.windows?
|
161
|
+
context 'using ipv4/ipv6' do
|
162
|
+
it 'can bind ipv4/ipv6 together' do
|
163
|
+
server = SocketManager::Server.open(server_path)
|
164
|
+
client = ServerEngine::SocketManager::Client.new(server_path)
|
165
|
+
|
166
|
+
tcp_v4 = client.listen_tcp('0.0.0.0', test_port)
|
167
|
+
udp_v4 = client.listen_udp('0.0.0.0', test_port)
|
168
|
+
tcp_v6 = client.listen_tcp('::', test_port)
|
169
|
+
udp_v6 = client.listen_udp('::', test_port)
|
170
|
+
|
171
|
+
tcp_v4.close
|
172
|
+
udp_v4.close
|
173
|
+
tcp_v6.close
|
174
|
+
udp_v6.close
|
175
|
+
server.close
|
176
|
+
end
|
177
|
+
end if (TCPServer.open("::", 0) rescue nil)
|
178
|
+
end
|
159
179
|
end
|
160
180
|
|
161
181
|
if ServerEngine.windows?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: serverengine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sadayuki Furuhashi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sigdump
|