Skip to content

Commit

Permalink
use LOG_DEBUG to prevent large amounts of log data due to DDOS
Browse files Browse the repository at this point in the history
  • Loading branch information
lichuan committed Jun 22, 2018
1 parent 6de5182 commit 2188ff3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/fly/net/acceptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ bool Acceptor<T>::start()
char host[INET_ADDRSTRLEN];
inet_ntop(AF_INET, &client_addr.sin_addr, host, INET_ADDRSTRLEN);
uint16 port = ntohs(client_addr.sin_port);
LOG_INFO("new connection from %s:%d arrived", host, port);
LOG_DEBUG("new connection from %s:%d arrived", host, port);
m_cb(std::make_shared<Connection<T>>(client_fd, Addr(host, port)));
}
});
Expand Down
20 changes: 10 additions & 10 deletions src/fly/net/connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ void Connection<Json>::parse()
after_parse_length:
if(m_cur_msg_length > m_max_msg_length)
{
LOG_ERROR("json message length(%lu) exceed max_msg_length(%u) from %s:%u", m_cur_msg_length, m_max_msg_length, \
LOG_DEBUG("json message length(%lu) exceed max_msg_length(%u) from %s:%u", m_cur_msg_length, m_max_msg_length, \
m_peer_addr.m_host.c_str(), m_peer_addr.m_port);
close();
return;
Expand Down Expand Up @@ -523,25 +523,25 @@ void Connection<Wsock>::parse()
}
else if(op_code == 0x08) //close
{
LOG_WARN("recv websocket close protocol from %s:%u", m_peer_addr.m_host.c_str(), m_peer_addr.m_port);
LOG_DEBUG("recv websocket close protocol from %s:%u", m_peer_addr.m_host.c_str(), m_peer_addr.m_port);
close();
return;
}
else if(op_code == 0x09) //ping
{
LOG_WARN("recv websocket ping protocol from %s:%u", m_peer_addr.m_host.c_str(), m_peer_addr.m_port);
LOG_DEBUG("recv websocket ping protocol from %s:%u", m_peer_addr.m_host.c_str(), m_peer_addr.m_port);
close();
return;
}
else if(op_code == 0x0a) //pong
{
LOG_WARN("recv websocket pong protocol from %s:%u", m_peer_addr.m_host.c_str(), m_peer_addr.m_port);
LOG_DEBUG("recv websocket pong protocol from %s:%u", m_peer_addr.m_host.c_str(), m_peer_addr.m_port);
close();
return;
}
else
{
LOG_WARN("recv websocket other protocol from %s:%u", m_peer_addr.m_host.c_str(), m_peer_addr.m_port);
LOG_DEBUG("recv websocket other protocol from %s:%u", m_peer_addr.m_host.c_str(), m_peer_addr.m_port);
close();
return;
}
Expand Down Expand Up @@ -669,7 +669,7 @@ void Connection<Wsock>::parse()

if(msg_length > m_max_msg_length)
{
LOG_ERROR("wsock message length(%lu) exceed max_msg_length(%u) from %s:%u", msg_length, m_max_msg_length, m_peer_addr.m_host.c_str(), m_peer_addr.m_port);
LOG_DEBUG("wsock message length(%lu) exceed max_msg_length(%u) from %s:%u", msg_length, m_max_msg_length, m_peer_addr.m_host.c_str(), m_peer_addr.m_port);
close();
return;
}
Expand Down Expand Up @@ -771,14 +771,14 @@ void Connection<Wsock>::parse()

if(doc.HasParseError())
{
LOG_ERROR("websocket parse json failed from %s:%u", m_peer_addr.m_host.c_str(), m_peer_addr.m_port);
LOG_DEBUG("websocket parse json failed from %s:%u", m_peer_addr.m_host.c_str(), m_peer_addr.m_port);
close();
return;
}

if(!doc.HasMember("msg_type"))
{
LOG_ERROR("websocket parse msg_type failed from %s:%u", m_peer_addr.m_host.c_str(), m_peer_addr.m_port);
LOG_DEBUG("websocket parse msg_type failed from %s:%u", m_peer_addr.m_host.c_str(), m_peer_addr.m_port);
close();
return;
}
Expand All @@ -795,7 +795,7 @@ void Connection<Wsock>::parse()

if(!doc.HasMember("msg_cmd"))
{
LOG_ERROR("websocket parse msg_cmd failed from %s:%u", m_peer_addr.m_host.c_str(), m_peer_addr.m_port);
LOG_DEBUG("websocket parse msg_cmd failed from %s:%u", m_peer_addr.m_host.c_str(), m_peer_addr.m_port);
close();
return;
}
Expand Down Expand Up @@ -944,7 +944,7 @@ void Connection<Proto>::parse()
after_parse_length:
if(m_cur_msg_length > m_max_msg_length)
{
LOG_ERROR("proto message length(%lu) exceed max_msg_length(%u) from %s:%u", m_cur_msg_length, m_max_msg_length, \
LOG_DEBUG("proto message length(%lu) exceed max_msg_length(%u) from %s:%u", m_cur_msg_length, m_max_msg_length, \
m_peer_addr.m_host.c_str(), m_peer_addr.m_port);
close();
return;
Expand Down
4 changes: 2 additions & 2 deletions src/fly/net/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Server<T>::Server(const Addr &addr,
else
{
close(connection->m_fd);
LOG_INFO("connection from %s:%d is not allowed", connection->peer_addr().m_host.c_str(), connection->peer_addr().m_port);
LOG_DEBUG("connection from %s:%d is not allowed", connection->peer_addr().m_host.c_str(), connection->peer_addr().m_port);
}
}));
}
Expand Down Expand Up @@ -86,7 +86,7 @@ Server<T>::Server(const Addr &addr,
else
{
close(connection->m_fd);
LOG_INFO("connection from %s:%d is not allowed", connection->peer_addr().m_host.c_str(), connection->peer_addr().m_port);
LOG_DEBUG("connection from %s:%d is not allowed", connection->peer_addr().m_host.c_str(), connection->peer_addr().m_port);
}
}));
}
Expand Down

0 comments on commit 2188ff3

Please sign in to comment.