Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
srvpro
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
srvpro
Commits
74e0ee58
Commit
74e0ee58
authored
Feb 14, 2026
by
水濑真白
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle ygopro message parse errors gracefully
parent
c73e0d03
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
6 deletions
+45
-6
YGOProMessages.js
YGOProMessages.js
+21
-3
YGOProMessages.ts
YGOProMessages.ts
+24
-3
No files found.
YGOProMessages.js
View file @
74e0ee58
...
...
@@ -6,10 +6,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports
.
YGOProMessagesHelper
=
exports
.
LegacyStruct
=
exports
.
LegacyStructInst
=
void
0
;
const
underscore_1
=
__importDefault
(
require
(
"
underscore
"
));
const
load_constants_1
=
__importDefault
(
require
(
"
./load-constants
"
));
const
bunyan_1
=
__importDefault
(
require
(
"
bunyan
"
));
const
ygopro_msg_encode_1
=
require
(
"
ygopro-msg-encode
"
);
const
ygopro_msg_struct_compat_1
=
require
(
"
./ygopro-msg-struct-compat
"
);
const
proto_structs_json_1
=
__importDefault
(
require
(
"
./data/proto_structs.json
"
));
const
utility_1
=
require
(
"
./utility
"
);
const
log
=
global
.
log
||
bunyan_1
.
default
.
createLogger
({
name
:
"
mycard
"
});
class
Handler
{
constructor
(
handler
,
synchronous
)
{
this
.
handler
=
handler
;
...
...
@@ -235,9 +237,25 @@ class YGOProMessagesHelper {
if
(
proto
&&
handlerCollection
.
has
(
bufferProto
))
{
for
(
const
handler
of
handlerCollection
.
get
(
bufferProto
))
{
const
protoCls
=
this
.
getProtoClass
(
bufferProto
,
direction
);
const
info
=
protoCls
?
(
0
,
ygopro_msg_struct_compat_1
.
applyYGOProMsgStructCompat
)(
new
protoCls
().
fromPayload
(
buffer
))
:
null
;
let
info
=
null
;
if
(
protoCls
)
{
try
{
info
=
(
0
,
ygopro_msg_struct_compat_1
.
applyYGOProMsgStructCompat
)(
new
protoCls
().
fromPayload
(
buffer
));
}
catch
(
e
)
{
// 解析失败不能卡死服务器:记录 warn,然后把 info 置为 {} 继续走 handler
log
.
warn
({
err
:
e
,
direction
,
proto
,
bufferProto
,
messageLength
,
protoCls
:
protoCls
?.
name
,
bufferHex
:
buffer
?.
toString
(
"
hex
"
)?.
slice
(
0
,
256
),
},
"
YGOPro message parse failed
"
);
info
=
{};
}
}
cancel
=
await
handler
.
handle
(
buffer
,
info
,
datas
,
params
);
if
(
cancel
)
{
if
(
Buffer
.
isBuffer
(
cancel
))
{
...
...
YGOProMessages.ts
View file @
74e0ee58
import
_
from
"
underscore
"
;
import
loadConstants
from
"
./load-constants
"
;
import
net
from
"
net
"
;
import
bunyan
from
"
bunyan
"
;
import
{
YGOProCtos
,
YGOProCtosBase
,
YGOProStoc
,
YGOProStocBase
}
from
"
ygopro-msg-encode
"
;
import
{
applyYGOProMsgStructCompat
,
fromPartialCompat
}
from
"
./ygopro-msg-struct-compat
"
;
import
legacyProtoStructs
from
"
./data/proto_structs.json
"
;
import
{
overwriteBuffer
}
from
"
./utility
"
;
const
log
:
bunyan
=
((
global
as
any
).
log
as
bunyan
)
||
bunyan
.
createLogger
({
name
:
"
mycard
"
});
class
Handler
{
constructor
(
...
...
@@ -286,9 +289,27 @@ export class YGOProMessagesHelper {
if
(
proto
&&
handlerCollection
.
has
(
bufferProto
))
{
for
(
const
handler
of
handlerCollection
.
get
(
bufferProto
))
{
const
protoCls
=
this
.
getProtoClass
(
bufferProto
,
direction
);
const
info
=
protoCls
?
applyYGOProMsgStructCompat
(
new
protoCls
().
fromPayload
(
buffer
))
:
null
;
let
info
:
any
=
null
;
if
(
protoCls
)
{
try
{
info
=
applyYGOProMsgStructCompat
(
new
protoCls
().
fromPayload
(
buffer
));
}
catch
(
e
:
any
)
{
// 解析失败不能卡死服务器:记录 warn,然后把 info 置为 {} 继续走 handler
log
.
warn
(
{
err
:
e
,
direction
,
proto
,
bufferProto
,
messageLength
,
protoCls
:
protoCls
?.
name
,
bufferHex
:
buffer
?.
toString
(
"
hex
"
)?.
slice
(
0
,
256
),
},
"
YGOPro message parse failed
"
);
info
=
{};
}
}
cancel
=
await
handler
.
handle
(
buffer
,
info
,
datas
,
params
);
if
(
cancel
)
{
if
(
Buffer
.
isBuffer
(
cancel
))
{
...
...
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