Commit caabc5aa authored by nanahira's avatar nanahira

check chat messages for post watcher

parent cce4b17f
......@@ -180,7 +180,7 @@ class YGOProMessagesHelper {
const proto = this.constants[direction][bufferProto];
let cancel = proto && protoFilter && _.indexOf(protoFilter, proto) === -1;
let buffer = messageBuffer.slice(3, 2 + messageLength);
console.log(l, direction, proto, cancel);
//console.log(l, direction, proto, cancel);
for (let priority = 0; priority < 4; ++priority) {
if (cancel) {
break;
......
......@@ -1732,7 +1732,22 @@ net.createServer (client) ->
client.on 'data', (ctos_buffer) ->
if client.is_post_watcher
room=ROOM_all[client.rid]
room.watcher.write ctos_buffer if room and !CLIENT_is_banned_by_mc(client)
if room
handle_data = await ygopro.helper.handleBuffer(ctos_buffer, "CTOS", ["CHAT"], {
client: client,
server: client.server
})
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
bad_ip_count = ROOM_bad_ip[client.ip]
if bad_ip_count
ROOM_bad_ip[client.ip] = bad_ip_count + 1
else
ROOM_bad_ip[client.ip] = 1
CLIENT_kick(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
handle_data = await ygopro.helper.handleBuffer(ctos_buffer, "CTOS", ctos_filter, {
......
......@@ -2326,11 +2326,32 @@
// 客户端到服务端(ctos)协议分析
client.pre_establish_buffers = new Array();
client.on('data', async function(ctos_buffer) {
var bad_ip_count, buffer, ctos_filter, handle_data, len3, len4, n, o, ref3, ref4, room;
var bad_ip_count, buffer, ctos_filter, handle_data, len3, len4, len5, n, o, p, ref3, ref4, ref5, room;
if (client.is_post_watcher) {
room = ROOM_all[client.rid];
if (room && !CLIENT_is_banned_by_mc(client)) {
room.watcher.write(ctos_buffer);
if (room) {
handle_data = (await ygopro.helper.handleBuffer(ctos_buffer, "CTOS", ["CHAT"], {
client: client,
server: client.server
}));
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) {
bad_ip_count = ROOM_bad_ip[client.ip];
if (bad_ip_count) {
ROOM_bad_ip[client.ip] = bad_ip_count + 1;
} else {
ROOM_bad_ip[client.ip] = 1;
}
CLIENT_kick(client);
return;
}
}
ref3 = handle_data.datas;
for (n = 0, len3 = ref3.length; n < len3; n++) {
buffer = ref3[n];
room.watcher.write(buffer);
}
}
} else {
ctos_filter = settings.modules.reconnect.enabled && client.pre_reconnecting ? ["UPDATE_DECK"] : null;
......@@ -2339,7 +2360,7 @@
server: client.server
}));
if (handle_data.feedback) {
log.warn(handle_data.feedback, client.name, client.ip);
log.warn(handle_data.feedback.message, client.name, client.ip);
if (handle_data.feedback.type === "OVERSIZE" || ROOM_bad_ip[client.ip] > 5) {
bad_ip_count = ROOM_bad_ip[client.ip];
if (bad_ip_count) {
......@@ -2355,15 +2376,15 @@
return;
}
if (client.established) {
ref3 = handle_data.datas;
for (n = 0, len3 = ref3.length; n < len3; n++) {
buffer = ref3[n];
client.server.write(buffer);
}
} else {
ref4 = handle_data.datas;
for (o = 0, len4 = ref4.length; o < len4; o++) {
buffer = ref4[o];
client.server.write(buffer);
}
} else {
ref5 = handle_data.datas;
for (p = 0, len5 = ref5.length; p < len5; p++) {
buffer = ref5[p];
client.pre_establish_buffers.push(buffer);
}
}
......@@ -2377,7 +2398,7 @@
server: server
}));
if (handle_data.feedback) {
log.warn(handle_data.feedback, server.client.name, server.client.ip);
log.warn(handle_data.feedback.message, server.client.name, server.client.ip);
if (handle_data.feedback.type === "OVERSIZE") {
server.destroy();
return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment