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
6b0fc57c
Commit
6b0fc57c
authored
Oct 28, 2021
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
disallow other packets before client join
parent
5b86e25b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
9 deletions
+30
-9
YGOProMessages.ts
YGOProMessages.ts
+9
-2
ygopro-server.coffee
ygopro-server.coffee
+9
-3
ygopro-server.js
ygopro-server.js
+12
-4
No files found.
YGOProMessages.ts
View file @
6b0fc57c
...
...
@@ -226,7 +226,7 @@ export class YGOProMessagesHelper {
handlerCollection
.
get
(
translatedProto
).
push
(
handlerObj
);
}
async
handleBuffer
(
messageBuffer
:
Buffer
,
direction
:
string
,
protoFilter
?:
string
[],
params
?:
any
):
Promise
<
HandleResult
>
{
async
handleBuffer
(
messageBuffer
:
Buffer
,
direction
:
string
,
protoFilter
?:
string
[],
params
?:
any
,
disconnectIfInvalid
=
false
):
Promise
<
HandleResult
>
{
let
feedback
:
Feedback
=
null
;
let
messageLength
=
0
;
let
bufferProto
=
0
;
...
...
@@ -257,7 +257,14 @@ export class YGOProMessagesHelper {
}
else
{
if
(
messageBuffer
.
length
>=
2
+
messageLength
)
{
const
proto
=
this
.
constants
[
direction
][
bufferProto
];
let
cancel
=
proto
&&
protoFilter
&&
_
.
indexOf
(
protoFilter
,
proto
)
===
-
1
;
let
cancel
=
proto
&&
protoFilter
&&
!
protoFilter
.
includes
(
proto
);
if
(
cancel
&&
disconnectIfInvalid
)
{
feedback
=
{
type
:
"
INVALID_PACKET
"
,
message
:
`
${
direction
}
proto not allowed`
};
break
;
}
let
buffer
=
messageBuffer
.
slice
(
3
,
2
+
messageLength
);
//console.log(l, direction, proto, cancel);
for
(
let
priority
=
0
;
priority
<
4
;
++
priority
)
{
...
...
ygopro-server.coffee
View file @
6b0fc57c
...
...
@@ -1943,14 +1943,20 @@ netRequestHandler = (client) ->
return
room
.
watcher
.
write
(
buffer
)
for
buffer
in
handle_data
.
datas
else
ctos_filter
=
if
settings
.
modules
.
reconnect
.
enabled
and
client
.
pre_reconnecting
then
[
"UPDATE_DECK"
]
else
null
ctos_filter
=
null
disconnectIfInvalid
=
false
if
settings
.
modules
.
reconnect
.
enabled
and
client
.
pre_reconnecting_to_room
ctos_filter
=
[
"UPDATE_DECK"
]
if
!
client
.
name
ctos_filter
=
[
"JOIN_GAME"
,
"PLAYER_INFO"
]
disconnectIfInvalid
=
true
handle_data
=
await
ygopro
.
helper
.
handleBuffer
(
ctos_buffer
,
"CTOS"
,
ctos_filter
,
{
client
:
client
,
server
:
client
.
server
})
}
,
disconnectIfInvalid
)
if
handle_data
.
feedback
log
.
warn
(
handle_data
.
feedback
.
message
,
client
.
name
,
client
.
ip
)
if
handle_data
.
feedback
.
type
==
"OVERSIZE"
or
ROOM_bad_ip
[
client
.
ip
]
>
5
if
handle_data
.
feedback
.
type
==
"OVERSIZE"
or
handle_data
.
feedback
.
type
==
"INVALID_PACKET"
or
ROOM_bad_ip
[
client
.
ip
]
>
5
bad_ip_count
=
ROOM_bad_ip
[
client
.
ip
]
if
bad_ip_count
ROOM_bad_ip
[
client
.
ip
]
=
bad_ip_count
+
1
...
...
ygopro-server.js
View file @
6b0fc57c
...
...
@@ -2578,7 +2578,7 @@
// 客户端到服务端(ctos)协议分析
client
.
pre_establish_buffers
=
new
Array
();
client
.
on
(
'
data
'
,
async
function
(
ctos_buffer
)
{
var
bad_ip_count
,
buffer
,
ctos_filter
,
handle_data
,
j
,
l
,
len
,
len1
,
len2
,
m
,
ref
,
ref1
,
ref2
,
room
;
var
bad_ip_count
,
buffer
,
ctos_filter
,
disconnectIfInvalid
,
handle_data
,
j
,
l
,
len
,
len1
,
len2
,
m
,
ref
,
ref1
,
ref2
,
room
;
if
(
client
.
is_post_watcher
)
{
room
=
ROOM_all
[
client
.
rid
];
if
(
room
)
{
...
...
@@ -2606,14 +2606,22 @@
}
}
}
else
{
ctos_filter
=
settings
.
modules
.
reconnect
.
enabled
&&
client
.
pre_reconnecting
?
[
"
UPDATE_DECK
"
]
:
null
;
ctos_filter
=
null
;
disconnectIfInvalid
=
false
;
if
(
settings
.
modules
.
reconnect
.
enabled
&&
client
.
pre_reconnecting_to_room
)
{
ctos_filter
=
[
"
UPDATE_DECK
"
];
}
if
(
!
client
.
name
)
{
ctos_filter
=
[
"
JOIN_GAME
"
,
"
PLAYER_INFO
"
];
disconnectIfInvalid
=
true
;
}
handle_data
=
(
await
ygopro
.
helper
.
handleBuffer
(
ctos_buffer
,
"
CTOS
"
,
ctos_filter
,
{
client
:
client
,
server
:
client
.
server
}));
}
,
disconnectIfInvalid
));
if
(
handle_data
.
feedback
)
{
log
.
warn
(
handle_data
.
feedback
.
message
,
client
.
name
,
client
.
ip
);
if
(
handle_data
.
feedback
.
type
===
"
OVERSIZE
"
||
ROOM_bad_ip
[
client
.
ip
]
>
5
)
{
if
(
handle_data
.
feedback
.
type
===
"
OVERSIZE
"
||
handle_data
.
feedback
.
type
===
"
INVALID_PACKET
"
||
ROOM_bad_ip
[
client
.
ip
]
>
5
)
{
bad_ip_count
=
ROOM_bad_ip
[
client
.
ip
];
if
(
bad_ip_count
)
{
ROOM_bad_ip
[
client
.
ip
]
=
bad_ip_count
+
1
;
...
...
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