Skip to content

Commit

Permalink
- Added additional logging
Browse files Browse the repository at this point in the history
- Fixed bug that prevented clients using an older login system from connecting
  • Loading branch information
RElesgoe committed May 18, 2018
1 parent 64386a8 commit 69b4b7e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/bnetd/connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ namespace pvpgn

list_prepend_data(conn_head, temp);

eventlog(eventlog_level_info, __FUNCTION__, "[{}][{}] sessionkey=0x{:08} sessionnum=0x{:08}", temp->socket.tcp_sock, temp->socket.udp_sock, temp->protocol.sessionkey, temp->protocol.sessionnum);
eventlog(eventlog_level_debug, __FUNCTION__, "[{}][{}] sessionkey=0x{:08} sessionnum=0x{:08}", temp->socket.tcp_sock, temp->socket.udp_sock, temp->protocol.sessionkey, temp->protocol.sessionnum);

return temp;
}
Expand Down
14 changes: 10 additions & 4 deletions src/bnetd/handle_bnet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,7 @@ namespace pvpgn

conn_set_archtag(c, bn_int_get(packet->u.client_progident.archtag));
conn_set_clienttag(c, bn_int_get(packet->u.client_progident.clienttag));
conn_set_versionid(c, bn_int_get(packet->u.client_progident.versionid));

if ((rpacket = packet_create(packet_class_bnet)))
{
Expand All @@ -651,7 +652,7 @@ namespace pvpgn

// CheckRevision
std::tuple<std::string, std::string> checkrevision = select_checkrevision(bn_int_get(packet->u.client_progident.archtag), bn_int_get(packet->u.client_progident.clienttag), bn_int_get(packet->u.client_progident.versionid));
file_to_mod_time(c, std::get<0>(checkrevision).c_str(), &rpacket->u.server_authreq_109.timestamp); // Checkrevision file timestamp
file_to_mod_time(c, std::get<0>(checkrevision).c_str(), &rpacket->u.server_authreq1.timestamp); // Checkrevision file timestamp
packet_append_string(rpacket, std::get<0>(checkrevision).c_str()); // CheckRevision filename
packet_append_string(rpacket, std::get<1>(checkrevision).c_str()); // CheckRevision equation
eventlog(eventlog_level_debug, __FUNCTION__, "[{}] selected \"{}\" \"{}\"", conn_get_socket(c), std::get<0>(checkrevision), std::get<1>(checkrevision));
Expand Down Expand Up @@ -997,6 +998,8 @@ namespace pvpgn

static int _client_authreq1(t_connection * c, t_packet const *const packet)
{
eventlog(eventlog_level_trace, __FUNCTION__, "[{}] received AUTHREQ1(0x07) packet", conn_get_socket(c));

if (packet_get_size(packet) < sizeof(t_client_authreq1))
{
eventlog(eventlog_level_error, __FUNCTION__, "[{}] got bad AUTHREQ1 packet (expected {} bytes, got {})", conn_get_socket(c), sizeof(t_client_authreq1), packet_get_size(packet));
Expand Down Expand Up @@ -1026,20 +1029,23 @@ namespace pvpgn
// The client should have already sent this information in a previous packet and is resending it again in this packet
if (bn_int_get(packet->u.client_authreq1.archtag) != conn_get_archtag(c))
{
eventlog(eventlog_level_error, __FUNCTION__, "[{}] got bad AUTHREQ1 (mismatch architecture)", conn_get_socket(c));
send_failed_packet(c);
return 0;
return -1;
}

if (bn_int_get(packet->u.client_authreq1.clienttag) != conn_get_clienttag(c))
{
eventlog(eventlog_level_error, __FUNCTION__, "[{}] got bad AUTHREQ1 (mismatch client tag)", conn_get_socket(c));
send_failed_packet(c);
return 0;
return -1;
}

if (bn_int_get(packet->u.client_authreq1.versionid) != conn_get_versionid(c))
{
eventlog(eventlog_level_error, __FUNCTION__, "[{}] got bad AUTHREQ1 (mismatch version ID)", conn_get_socket(c));
send_failed_packet(c);
return 0;
return -1;
}


Expand Down

0 comments on commit 69b4b7e

Please sign in to comment.