1010
1111#pragma once
1212
13+ #include " ASE.h"
1314#include " version.h"
1415
1516struct SMasterServerDefinition
@@ -129,10 +130,15 @@ class CMasterServer : public CRefCountable
129130 if (m_Stage < ANNOUNCE_STAGE_REMINDER)
130131 {
131132 m_Stage = ANNOUNCE_STAGE_REMINDER;
133+
134+ CArgMap argMap;
135+ argMap.SetFromString (result.pData );
136+
137+ if (result.iErrorCode == 200 )
138+ m_remoteAddress = argMap.Get (" remote_addr" );
139+
132140 if (!m_Definition.bHideSuccess )
133141 {
134- CArgMap argMap;
135- argMap.SetFromString (result.pData );
136142 SString strOkMessage = argMap.Get (" ok_message" );
137143
138144 // Log successful initial announcement
@@ -178,6 +184,9 @@ class CMasterServer : public CRefCountable
178184
179185 const SMasterServerDefinition& GetDefinition () const { return m_Definition; }
180186
187+ bool HasRemoteAddress () const noexcept { return !m_remoteAddress.empty (); }
188+ const std::string& GetRemoteAddress () const noexcept { return m_remoteAddress; }
189+
181190 //
182191 // Get http downloader used for master server comms etc.
183192 //
@@ -192,6 +201,7 @@ class CMasterServer : public CRefCountable
192201 long long m_llLastAnnounceTime;
193202 long long m_llLastPushTime;
194203 const SMasterServerDefinition m_Definition;
204+ std::string m_remoteAddress;
195205};
196206
197207// //////////////////////////////////////////////////////////////////
@@ -270,6 +280,21 @@ class CMasterServerAnnouncer
270280 }
271281 }
272282
283+ /*
284+ * @brief Get remote address of the first master server that has it.
285+ */
286+ const std::string& GetRemoteAddress () const noexcept
287+ {
288+ for (CMasterServer* masterServer : m_MasterServerList)
289+ {
290+ if (masterServer->HasRemoteAddress ())
291+ return masterServer->GetRemoteAddress ();
292+ }
293+
294+ static std::string empty;
295+ return empty;
296+ }
297+
273298protected:
274299 std::vector<CMasterServer*> m_MasterServerList;
275300};
0 commit comments