mirror of
https://github.com/EQEmu/Server.git
synced 2026-04-19 16:52:25 +00:00
Add some pointer safety checks to underlying data service call [skip ci]
This commit is contained in:
parent
dff23793c6
commit
ed7ce38fe0
@ -224,6 +224,10 @@ std::string EQ::Net::TCPConnection::RemoteIP() const
|
||||
|
||||
int EQ::Net::TCPConnection::RemotePort() const
|
||||
{
|
||||
if (!m_socket) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
sockaddr_storage addr;
|
||||
int addr_len = sizeof(addr);
|
||||
uv_tcp_getpeername(m_socket, (sockaddr*)&addr, &addr_len);
|
||||
@ -240,3 +244,11 @@ int EQ::Net::TCPConnection::RemotePort() const
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
bool EQ::Net::TCPConnection::IsConnected() const
|
||||
{
|
||||
return m_socket != nullptr;
|
||||
}
|
||||
|
||||
@ -24,10 +24,12 @@ namespace EQ
|
||||
void Read(const char *data, size_t count);
|
||||
void Write(const char *data, size_t count);
|
||||
|
||||
bool IsConnected() const;
|
||||
std::string LocalIP() const;
|
||||
int LocalPort() const;
|
||||
std::string RemoteIP() const;
|
||||
int RemotePort() const;
|
||||
|
||||
private:
|
||||
TCPConnection();
|
||||
|
||||
|
||||
@ -32,6 +32,10 @@ void callGetZoneList(Json::Value &response)
|
||||
for (auto &zone : zoneserver_list.getZoneServerList()) {
|
||||
Json::Value row;
|
||||
|
||||
if (!zone->IsConnected()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
row["booting_up"] = zone->IsBootingUp();
|
||||
row["client_address"] = zone->GetCAddress();
|
||||
row["client_local_address"] = zone->GetCLocalAddress();
|
||||
|
||||
@ -57,6 +57,7 @@ public:
|
||||
const char* GetCompileTime() const{ return compiled; }
|
||||
void SetCompile(char* in_compile){ strcpy(compiled,in_compile); }
|
||||
inline uint32 GetZoneID() const { return zone_server_zone_id; }
|
||||
inline bool IsConnected() const { return tcpc->Handle() ? tcpc->Handle()->IsConnected() : false; }
|
||||
inline std::string GetIP() const { return tcpc->Handle() ? tcpc->Handle()->RemoteIP() : ""; }
|
||||
inline uint16 GetPort() const { return tcpc->Handle() ? tcpc->Handle()->RemotePort() : 0; }
|
||||
inline const char* GetCAddress() const { return client_address; }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user