termfront 0.1.8 → 0.1.9
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.md +6 -0
- data/lib/termfront/network/server.rb +24 -14
- data/lib/termfront/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5396a2b08e03e482e2e5c8015a05399380e9e95ccee69389ca3969d41f3a1061
|
|
4
|
+
data.tar.gz: 9899861875106c3edb5db94f3b046abe1759168674e8223d5ee73ec7a943e22b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2637febc2bf4863cf446692a837622353084558ee15c385e5d81081aeb022b791decce8c52f5a2a000e085e828a425bb7e78d815f503b4d54ae9c4104cbb69f7
|
|
7
|
+
data.tar.gz: ee9d71def5cbb215ff4a83573cfe665acd033ce9c8fc3a99d1a501e74f91f37a7765f57aafedf81cb5887bdb08d0714eb6ebcaba2fd7065736d19b85f73d4445
|
data/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,12 @@ The format is based on Keep a Changelog, and this project follows Semantic Versi
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.1.9] - 2026-05-28
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
- Move the TLS handshake off the multiplayer server's accept loop. `OpenSSL::SSL::SSLServer#start_immediately` is now `false`, so `accept` returns as soon as the TCP accept completes and the `SSLSocket#accept` handshake runs inside the per-connection thread under a new `TLS_HANDSHAKE_TIMEOUT` deadline (5 s). Previously every TLS handshake — the RSA private-key operation, the cert-chain bytes, and any network waits — ran serially on the single accept-loop thread, so a synchronized join of N players took roughly N × per-handshake-time before the last one was usable; a stalled mid-handshake client also blocked every other pending connection (head-of-line blocking at the TLS layer). With the handshake hoisted into its own thread, connections only contend on the GVL for the actual CPU work, a slow client only blocks itself, and `configure_client` is applied before the handshake so TCP_NODELAY is in effect for the handshake's own small records
|
|
14
|
+
|
|
9
15
|
## [0.1.8] - 2026-05-26
|
|
10
16
|
|
|
11
17
|
### Fixed
|
|
@@ -4,6 +4,7 @@ require "socket"
|
|
|
4
4
|
require "openssl"
|
|
5
5
|
require "json"
|
|
6
6
|
require "set"
|
|
7
|
+
require "timeout"
|
|
7
8
|
|
|
8
9
|
module Termfront
|
|
9
10
|
module Network
|
|
@@ -11,6 +12,7 @@ module Termfront
|
|
|
11
12
|
TEAM_SIZES = [1, 2, 4].freeze
|
|
12
13
|
MAX_QUEUE_PER_MODE = 64
|
|
13
14
|
QUEUE_HANDSHAKE_TIMEOUT = 5
|
|
15
|
+
TLS_HANDSHAKE_TIMEOUT = 5
|
|
14
16
|
MAX_MSG_BYTES = 16 * 1024
|
|
15
17
|
MATCH_MAX_DURATION = 30 * 60
|
|
16
18
|
MATCH_IDLE_TIMEOUT = 5 * 60
|
|
@@ -77,28 +79,36 @@ module Termfront
|
|
|
77
79
|
|
|
78
80
|
tcp_server = TCPServer.new("0.0.0.0", @port)
|
|
79
81
|
ssl_server = OpenSSL::SSL::SSLServer.new(tcp_server, ctx)
|
|
80
|
-
ssl_server.start_immediately =
|
|
82
|
+
ssl_server.start_immediately = false
|
|
81
83
|
|
|
82
84
|
puts "Termfront PvP server listening on 0.0.0.0:#{@port}"
|
|
83
85
|
|
|
84
86
|
loop do
|
|
85
87
|
begin
|
|
86
88
|
client = ssl_server.accept
|
|
87
|
-
configure_client(client)
|
|
88
|
-
Thread.new(client) do |c|
|
|
89
|
-
enqueue_player(c)
|
|
90
|
-
rescue StandardError => e
|
|
91
|
-
puts "Connection handler error: #{e.class}"
|
|
92
|
-
begin
|
|
93
|
-
c.close
|
|
94
|
-
rescue StandardError
|
|
95
|
-
nil
|
|
96
|
-
end
|
|
97
|
-
end
|
|
98
|
-
rescue OpenSSL::SSL::SSLError => e
|
|
99
|
-
puts "SSL handshake failed: #{e.class}"
|
|
100
89
|
rescue StandardError => e
|
|
101
90
|
puts "Accept error: #{e.class}"
|
|
91
|
+
next
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
Thread.new(client) do |c|
|
|
95
|
+
configure_client(c)
|
|
96
|
+
Timeout.timeout(TLS_HANDSHAKE_TIMEOUT) { c.accept }
|
|
97
|
+
enqueue_player(c)
|
|
98
|
+
rescue OpenSSL::SSL::SSLError, Timeout::Error => e
|
|
99
|
+
puts "SSL handshake failed: #{e.class}"
|
|
100
|
+
begin
|
|
101
|
+
c.close
|
|
102
|
+
rescue StandardError
|
|
103
|
+
nil
|
|
104
|
+
end
|
|
105
|
+
rescue StandardError => e
|
|
106
|
+
puts "Connection handler error: #{e.class}"
|
|
107
|
+
begin
|
|
108
|
+
c.close
|
|
109
|
+
rescue StandardError
|
|
110
|
+
nil
|
|
111
|
+
end
|
|
102
112
|
end
|
|
103
113
|
end
|
|
104
114
|
end
|
data/lib/termfront/version.rb
CHANGED