Sync from GitHub main #1
@@ -0,0 +1,34 @@
|
|||||||
|
#include "co_gns_server_bridge.h"
|
||||||
|
|
||||||
|
#include <steam/steamnetworkingsockets.h>
|
||||||
|
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
int co_gns_server_remote_ipv4(
|
||||||
|
co_gns_server_handle handle,
|
||||||
|
uint32_t connection_id,
|
||||||
|
uint32_t* out_ipv4_host_order,
|
||||||
|
uint16_t* out_port)
|
||||||
|
{
|
||||||
|
if (handle == nullptr || connection_id == 0 || out_ipv4_host_order == nullptr || out_port == nullptr) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto* networking = SteamNetworkingSockets();
|
||||||
|
if (networking == nullptr) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
SteamNetConnectionInfo_t info{};
|
||||||
|
if (!networking->GetConnectionInfo(static_cast<HSteamNetConnection>(connection_id), &info)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (!info.m_addrRemote.IsIPv4()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
*out_ipv4_host_order = info.m_addrRemote.GetIPv4();
|
||||||
|
*out_port = info.m_addrRemote.m_port;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user