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
57adc2f0
Commit
57adc2f0
authored
Oct 28, 2021
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
for attack things
parent
d5b64bd1
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
39 additions
and
14 deletions
+39
-14
YGOProMessages.js
YGOProMessages.js
+12
-5
YGOProMessages.ts
YGOProMessages.ts
+12
-6
ygopro-server.coffee
ygopro-server.coffee
+6
-1
ygopro-server.js
ygopro-server.js
+7
-1
ygopro.coffee
ygopro.coffee
+1
-1
ygopro.js
ygopro.js
+1
-0
No files found.
YGOProMessages.js
View file @
57adc2f0
...
...
@@ -180,12 +180,13 @@ class YGOProMessagesHelper {
}
handlerCollection
.
get
(
translatedProto
).
push
(
handlerObj
);
}
async
handleBuffer
(
messageBuffer
,
direction
,
protoFilter
,
params
,
disconnectIfInvalid
=
false
)
{
async
handleBuffer
(
messageBuffer
,
direction
,
protoFilter
,
params
,
preconnect
=
false
)
{
let
feedback
=
null
;
let
messageLength
=
0
;
let
bufferProto
=
0
;
let
datas
=
[];
for
(
let
l
=
0
;
l
<
this
.
singleHandleLimit
;
++
l
)
{
const
limit
=
preconnect
?
2
:
this
.
singleHandleLimit
;
for
(
let
l
=
0
;
l
<
limit
;
++
l
)
{
if
(
messageLength
===
0
)
{
if
(
messageBuffer
.
length
>=
2
)
{
messageLength
=
messageBuffer
.
readUInt16LE
(
0
);
...
...
@@ -216,7 +217,7 @@ class YGOProMessagesHelper {
if
(
messageBuffer
.
length
>=
2
+
messageLength
)
{
const
proto
=
this
.
constants
[
direction
][
bufferProto
];
let
cancel
=
proto
&&
protoFilter
&&
!
protoFilter
.
includes
(
proto
);
if
(
cancel
&&
disconnectIfInvalid
)
{
if
(
cancel
&&
preconnect
)
{
feedback
=
{
type
:
"
INVALID_PACKET
"
,
message
:
`
${
direction
}
proto not allowed`
...
...
@@ -240,6 +241,12 @@ class YGOProMessagesHelper {
for
(
let
handler
of
handlerCollection
.
get
(
bufferProto
))
{
cancel
=
await
handler
.
handle
(
buffer
,
info
,
datas
,
params
);
if
(
cancel
)
{
if
(
cancel
===
'
_cancel
'
)
{
return
{
datas
:
[],
feedback
};
}
break
;
}
}
...
...
@@ -262,10 +269,10 @@ class YGOProMessagesHelper {
break
;
}
}
if
(
l
===
this
.
singleHandleL
imit
-
1
)
{
if
(
l
===
l
imit
-
1
)
{
feedback
=
{
type
:
"
OVERSIZE
"
,
message
:
`Oversized
${
direction
}
`
message
:
`Oversized
${
direction
}
${
limit
}
`
};
}
}
...
...
YGOProMessages.ts
View file @
57adc2f0
...
...
@@ -8,13 +8,13 @@ import net from "net";
class
Handler
{
private
handler
:
(
buffer
:
Buffer
,
info
:
any
,
datas
:
Buffer
[],
params
:
any
)
=>
Promise
<
boolean
>
;
private
handler
:
(
buffer
:
Buffer
,
info
:
any
,
datas
:
Buffer
[],
params
:
any
)
=>
Promise
<
boolean
|
string
>
;
synchronous
:
boolean
;
constructor
(
handler
:
(
buffer
:
Buffer
,
info
:
any
,
datas
:
Buffer
[],
params
:
any
)
=>
Promise
<
boolean
>
,
synchronous
:
boolean
)
{
constructor
(
handler
:
(
buffer
:
Buffer
,
info
:
any
,
datas
:
Buffer
[],
params
:
any
)
=>
Promise
<
boolean
|
string
>
,
synchronous
:
boolean
)
{
this
.
handler
=
handler
;
this
.
synchronous
=
synchronous
||
false
;
}
async
handle
(
buffer
:
Buffer
,
info
:
any
,
datas
:
Buffer
[],
params
:
any
)
{
async
handle
(
buffer
:
Buffer
,
info
:
any
,
datas
:
Buffer
[],
params
:
any
)
:
Promise
<
boolean
|
string
>
{
if
(
this
.
synchronous
)
{
return
!!
(
await
this
.
handler
(
buffer
,
info
,
datas
,
params
));
}
else
{
...
...
@@ -208,7 +208,7 @@ export class YGOProMessagesHelper {
});
}
addHandler
(
protostr
:
string
,
handler
:
(
buffer
:
Buffer
,
info
:
any
,
datas
:
Buffer
[],
params
:
any
)
=>
Promise
<
boolean
>
,
synchronous
:
boolean
,
priority
:
number
)
{
addHandler
(
protostr
:
string
,
handler
:
(
buffer
:
Buffer
,
info
:
any
,
datas
:
Buffer
[],
params
:
any
)
=>
Promise
<
boolean
|
string
>
,
synchronous
:
boolean
,
priority
:
number
)
{
if
(
priority
<
0
||
priority
>
4
)
{
throw
"
Invalid priority:
"
+
priority
;
}
...
...
@@ -258,7 +258,7 @@ export class YGOProMessagesHelper {
}
else
{
if
(
messageBuffer
.
length
>=
2
+
messageLength
)
{
const
proto
=
this
.
constants
[
direction
][
bufferProto
];
let
cancel
=
proto
&&
protoFilter
&&
!
protoFilter
.
includes
(
proto
);
let
cancel
:
string
|
boolean
=
proto
&&
protoFilter
&&
!
protoFilter
.
includes
(
proto
);
if
(
cancel
&&
preconnect
)
{
feedback
=
{
type
:
"
INVALID_PACKET
"
,
...
...
@@ -283,6 +283,12 @@ export class YGOProMessagesHelper {
for
(
let
handler
of
handlerCollection
.
get
(
bufferProto
))
{
cancel
=
await
handler
.
handle
(
buffer
,
info
,
datas
,
params
);
if
(
cancel
)
{
if
(
cancel
===
'
_cancel
'
)
{
return
{
datas
:
[],
feedback
}
}
break
;
}
}
...
...
@@ -307,7 +313,7 @@ export class YGOProMessagesHelper {
if
(
l
===
limit
-
1
)
{
feedback
=
{
type
:
"
OVERSIZE
"
,
message
:
`Oversized
${
direction
}
`
message
:
`Oversized
${
direction
}
${
limit
}
`
};
}
}
...
...
ygopro-server.coffee
View file @
57adc2f0
...
...
@@ -1964,7 +1964,7 @@ netRequestHandler = (client) ->
ROOM_bad_ip
[
client
.
ip
]
=
1
CLIENT_kick
(
client
)
return
if
!
client
.
server
if
client
.
closed
||
!
client
.
server
return
if
client
.
established
client
.
server
.
write
buffer
for
buffer
in
handle_data
.
datas
...
...
@@ -2000,6 +2000,11 @@ deck_name_match = global.deck_name_match = (deck_name, player_name) ->
# return true to cancel a synchronous message
ygopro
.
ctos_follow
'PLAYER_INFO'
,
true
,
(
buffer
,
info
,
client
,
server
,
datas
)
->
# second PLAYER_INFO = attack
if
client
.
name
log
.
info
'DUP PLAYER_INFO'
,
client
.
ip
CLIENT_kick
client
return
'_cancel'
# checkmate use username$password, but here don't
# so remove the password
name_full
=
info
.
name
.
replace
(
/\\/g
,
""
).
split
(
"$"
)
...
...
ygopro-server.js
View file @
57adc2f0
...
...
@@ -2631,7 +2631,7 @@
return
;
}
}
if
(
!
client
.
server
)
{
if
(
client
.
closed
||
!
client
.
server
)
{
return
;
}
if
(
client
.
established
)
{
...
...
@@ -2686,6 +2686,12 @@
// return true to cancel a synchronous message
ygopro
.
ctos_follow
(
'
PLAYER_INFO
'
,
true
,
async
function
(
buffer
,
info
,
client
,
server
,
datas
)
{
var
geo
,
lang
,
name
,
name_full
,
struct
,
vpass
;
// second PLAYER_INFO = attack
if
(
client
.
name
)
{
log
.
info
(
'
DUP PLAYER_INFO
'
,
client
.
ip
);
CLIENT_kick
(
client
);
return
'
_cancel
'
;
}
// checkmate use username$password, but here don't
// so remove the password
name_full
=
info
.
name
.
replace
(
/
\\
/g
,
""
).
split
(
"
$
"
);
...
...
ygopro.coffee
View file @
57adc2f0
...
...
@@ -113,4 +113,4 @@ translateHandler = (handler) ->
if
client
client
.
system_kicked
=
true
client
.
destroy
()
return
return
'_cancel'
ygopro.js
View file @
57adc2f0
...
...
@@ -185,6 +185,7 @@
client
.
system_kicked
=
true
;
client
.
destroy
();
}
return
'
_cancel
'
;
};
}).
call
(
this
);
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