Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
srvpro2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
srvpro2
Commits
a3e235cc
Commit
a3e235cc
authored
Feb 19, 2026
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix zombie client thing
parent
2de215e8
Pipeline
#43332
passed with stages
in 1 minute and 4 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
6 deletions
+33
-6
src/client/client-handler.ts
src/client/client-handler.ts
+33
-6
No files found.
src/client/client-handler.ts
View file @
a3e235cc
...
...
@@ -16,12 +16,25 @@ import {
merge
,
map
,
take
,
startWith
,
switchMap
,
timer
,
}
from
'
rxjs
'
;
import
{
YGOProCtosDisconnect
}
from
'
../utility/ygopro-ctos-disconnect
'
;
export
class
ClientHandler
{
private
static
readonly
CLIENT_IDLE_TIMEOUT_MS
=
5
*
60
*
1000
;
constructor
(
private
ctx
:
Context
)
{}
private
isPreHandshakeMsg
(
msg
:
YGOProCtosBase
):
boolean
{
return
[
YGOProCtosExternalAddress
,
YGOProCtosPlayerInfo
,
YGOProCtosJoinGame
,
].
some
((
allowed
)
=>
(
msg
instanceof
allowed
)
as
boolean
);
}
async
init
()
{
this
.
ctx
.
middleware
(
YGOProCtosExternalAddress
,
async
(
msg
,
client
,
next
)
=>
{
...
...
@@ -63,12 +76,7 @@ export class ClientHandler {
return
next
();
}
const
isPreHandshakeMsg
=
[
YGOProCtosExternalAddress
,
YGOProCtosPlayerInfo
,
YGOProCtosJoinGame
,
].
some
((
allowed
)
=>
(
msg
instanceof
allowed
)
as
boolean
);
if
(
client
.
established
===
isPreHandshakeMsg
)
{
if
(
client
.
established
===
this
.
isPreHandshakeMsg
(
msg
))
{
// disallow any messages before handshake is complete, except for the ones needed for handshake
return
undefined
;
}
...
...
@@ -133,6 +141,7 @@ export class ClientHandler {
.
then
(()
=>
{
this
.
logger
.
debug
({
client
:
client
.
name
},
'
Handshake completed
'
);
client
.
established
=
true
;
this
.
installIdleDisconnectGuard
(
client
);
return
true
;
})
.
catch
((
error
)
=>
{
...
...
@@ -149,6 +158,24 @@ export class ClientHandler {
return
false
;
});
}
private
installIdleDisconnectGuard
(
client
:
Client
)
{
client
.
receive$
.
pipe
(
filter
((
msg
)
=>
!
this
.
isPreHandshakeMsg
(
msg
)),
startWith
(
undefined
),
switchMap
(()
=>
timer
(
ClientHandler
.
CLIENT_IDLE_TIMEOUT_MS
)),
take
(
1
),
takeUntil
(
client
.
disconnect$
),
)
.
subscribe
(()
=>
{
this
.
logger
.
info
(
{
client
:
client
.
name
||
client
.
loggingIp
(),
ip
:
client
.
loggingIp
()
},
'
Disconnecting idle client due to inactivity timeout
'
,
);
client
.
disconnect
();
});
}
}
declare
module
'
ygopro-msg-encode
'
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment