@@ -893,19 +893,23 @@ void serverslice(uint timeout) // main server update, called from main loop in
893893 if (enet_address_get_host (&c.peer ->address , c.hostname , sizeof (c.hostname )) >= 0 )
894894 {
895895 ENetAddress address;
896- string hostname;
897- if (enet_address_set_host (&address, c.hostname ) < 0 || enet_address_get_host_ip (&address, hostname, sizeof (hostname)) < 0 || strcmp (hostname, c.hostname ))
896+ string ip;
897+ conoutf (" checking reverse lookup of %s (%s)" , c.hostip , c.hostname );
898+ if (enet_address_set_host (&address, c.hostname ) < 0 || enet_address_get_host_ip (&address, ip, sizeof (ip)) < 0 || strcmp (ip, c.hostip ))
899+ {
900+ conoutf (" reverse lookup of %s (%s) failed (%s), using ip address" , c.hostip , c.hostname , ip);
898901 copystring (c.hostname , c.hostip );
902+ }
899903 }
900- else copystring (c.hostname , c.hostip );
901- }
902- else
903- {
904- copystring (c.hostname , " unknown" );
905- copystring (c.hostip , " 0.0.0.0" );
904+ else
905+ {
906+ conoutf (" reverse lookup of %s failed, using ip address" , c.hostip );
907+ copystring (c.hostname , c.hostip );
908+ }
909+ int reason = server::clientconnect (c.num , c.peer ->address .host );
910+ if (reason) disconnect_client (c.num , reason);
906911 }
907- int reason = server::clientconnect (c.num , c.peer ->address .host );
908- if (reason) disconnect_client (c.num , reason);
912+ else disconnect_client (c.num , DISC_MSGERR);
909913 break ;
910914 }
911915 case ENET_EVENT_TYPE_RECEIVE:
0 commit comments