Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro
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
baichixing
ygopro
Commits
9a55d543
Commit
9a55d543
authored
May 21, 2024
by
Chen Bill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
NetServer: discard too large packet
parent
fdbfce40
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
4 deletions
+12
-4
gframe/netserver.cpp
gframe/netserver.cpp
+10
-3
gframe/netserver.h
gframe/netserver.h
+2
-1
No files found.
gframe/netserver.cpp
View file @
9a55d543
...
@@ -10,6 +10,7 @@ event* NetServer::broadcast_ev = 0;
...
@@ -10,6 +10,7 @@ event* NetServer::broadcast_ev = 0;
evconnlistener
*
NetServer
::
listener
=
0
;
evconnlistener
*
NetServer
::
listener
=
0
;
DuelMode
*
NetServer
::
duel_mode
=
0
;
DuelMode
*
NetServer
::
duel_mode
=
0
;
unsigned
char
NetServer
::
net_server_read
[
SIZE_NETWORK_BUFFER
];
unsigned
char
NetServer
::
net_server_read
[
SIZE_NETWORK_BUFFER
];
int
NetServer
::
read_len
=
0
;
unsigned
char
NetServer
::
net_server_write
[
SIZE_NETWORK_BUFFER
];
unsigned
char
NetServer
::
net_server_write
[
SIZE_NETWORK_BUFFER
];
unsigned
short
NetServer
::
last_sent
=
0
;
unsigned
short
NetServer
::
last_sent
=
0
;
...
@@ -124,9 +125,15 @@ void NetServer::ServerEchoRead(bufferevent *bev, void *ctx) {
...
@@ -124,9 +125,15 @@ void NetServer::ServerEchoRead(bufferevent *bev, void *ctx) {
evbuffer_copyout
(
input
,
&
packet_len
,
2
);
evbuffer_copyout
(
input
,
&
packet_len
,
2
);
if
(
len
<
(
size_t
)
packet_len
+
2
)
if
(
len
<
(
size_t
)
packet_len
+
2
)
return
;
return
;
evbuffer_remove
(
input
,
net_server_read
,
packet_len
+
2
);
if
(
packet_len
+
2
>
SIZE_NETWORK_BUFFER
)
{
if
(
packet_len
)
evbuffer_drain
(
input
,
packet_len
+
2
);
HandleCTOSPacket
(
&
users
[
bev
],
&
net_server_read
[
2
],
packet_len
);
read_len
=
0
;
}
else
{
read_len
=
evbuffer_remove
(
input
,
net_server_read
,
packet_len
+
2
);
}
if
(
read_len
>
0
)
HandleCTOSPacket
(
&
users
[
bev
],
&
net_server_read
[
2
],
read_len
-
2
);
len
-=
packet_len
+
2
;
len
-=
packet_len
+
2
;
}
}
}
}
...
...
gframe/netserver.h
View file @
9a55d543
...
@@ -19,6 +19,7 @@ private:
...
@@ -19,6 +19,7 @@ private:
static
evconnlistener
*
listener
;
static
evconnlistener
*
listener
;
static
DuelMode
*
duel_mode
;
static
DuelMode
*
duel_mode
;
static
unsigned
char
net_server_read
[
SIZE_NETWORK_BUFFER
];
static
unsigned
char
net_server_read
[
SIZE_NETWORK_BUFFER
];
static
int
read_len
;
static
unsigned
char
net_server_write
[
SIZE_NETWORK_BUFFER
];
static
unsigned
char
net_server_write
[
SIZE_NETWORK_BUFFER
];
static
unsigned
short
last_sent
;
static
unsigned
short
last_sent
;
...
@@ -50,7 +51,7 @@ public:
...
@@ -50,7 +51,7 @@ public:
auto
p
=
net_server_write
;
auto
p
=
net_server_write
;
int
blen
=
sizeof
(
ST
);
int
blen
=
sizeof
(
ST
);
if
(
blen
>
MAX_DATA_SIZE
)
if
(
blen
>
MAX_DATA_SIZE
)
blen
=
MAX_DATA_SIZE
;
return
;
BufferIO
::
WriteInt16
(
p
,
(
short
)(
1
+
blen
));
BufferIO
::
WriteInt16
(
p
,
(
short
)(
1
+
blen
));
BufferIO
::
WriteInt8
(
p
,
proto
);
BufferIO
::
WriteInt8
(
p
,
proto
);
memcpy
(
p
,
&
st
,
blen
);
memcpy
(
p
,
&
st
,
blen
);
...
...
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