@@ -250,6 +250,27 @@ int ENetConnection::get_max_channels() const {
250250	return  host->channelLimit ;
251251}
252252
253+ IPAddress ENetConnection::get_local_address () const  {
254+ 	ERR_FAIL_NULL_V_MSG (host, IPAddress (), " The ENetConnection instance isn't currently active."  );
255+ 	ERR_FAIL_COND_V_MSG (!(host->socket ), IPAddress (), " The ENetConnection instance isn't currently bound."  );
256+ 	ENetAddress address;
257+ 	ERR_FAIL_COND_V_MSG (enet_socket_get_address (host->socket , &address), IPAddress (), " Unable to get socket address"  );
258+ 
259+ 	IPAddress out;
260+ #ifdef  GODOT_ENET
261+ 	out.set_ipv6 ((uint8_t  *)&(address.host ));
262+ 	if  (out == IPAddress (" ::"  )) {
263+ 		return  IPAddress (" *"  );
264+ 	}
265+ #else 
266+ 	out.set_ipv4 ((uint8_t  *)&(address.host ));
267+ #endif 
268+ 	if  (out == IPAddress (" 0.0.0.0"  )) {
269+ 		return  IPAddress (" *"  );
270+ 	}
271+ 	return  out;
272+ }
273+ 
253274int  ENetConnection::get_local_port () const  {
254275	ERR_FAIL_NULL_V_MSG (host, 0 , " The ENetConnection instance isn't currently active."  );
255276	ERR_FAIL_COND_V_MSG (!(host->socket ), 0 , " The ENetConnection instance isn't currently bound."  );
@@ -387,6 +408,7 @@ void ENetConnection::_bind_methods() {
387408	ClassDB::bind_method (D_METHOD (" refuse_new_connections"  , " refuse"  ), &ENetConnection::refuse_new_connections);
388409	ClassDB::bind_method (D_METHOD (" pop_statistic"  , " statistic"  ), &ENetConnection::pop_statistic);
389410	ClassDB::bind_method (D_METHOD (" get_max_channels"  ), &ENetConnection::get_max_channels);
411+ 	ClassDB::bind_method (D_METHOD (" get_local_address"  ), &ENetConnection::get_local_address);
390412	ClassDB::bind_method (D_METHOD (" get_local_port"  ), &ENetConnection::get_local_port);
391413	ClassDB::bind_method (D_METHOD (" get_peers"  ), &ENetConnection::_get_peers);
392414	ClassDB::bind_method (D_METHOD (" socket_send"  , " destination_address"  , " destination_port"  , " packet"  ), &ENetConnection::socket_send);
0 commit comments