| 259 | } |
| 260 | |
| 261 | void CRegister::CProtocol::SendRegister() |
| 262 | { |
| 263 | int64_t Now = time_get(); |
| 264 | int64_t Freq = time_freq(); |
| 265 | |
| 266 | char aAddress[64]; |
| 267 | str_format(aAddress, sizeof(aAddress), "%sconnecting-address.invalid:%d", ProtocolToScheme(m_Protocol), m_pParent->m_ServerPort); |
| 268 | |
| 269 | char aSecret[UUID_MAXSTRSIZE]; |
| 270 | FormatUuid(m_pParent->m_Secret, aSecret, sizeof(aSecret)); |
| 271 | |
| 272 | char aChallengeUuid[UUID_MAXSTRSIZE]; |
| 273 | FormatUuid(m_pParent->m_ChallengeSecret, aChallengeUuid, sizeof(aChallengeUuid)); |
| 274 | char aChallengeSecret[64]; |
| 275 | str_format(aChallengeSecret, sizeof(aChallengeSecret), "%s:%s", aChallengeUuid, ProtocolToString(m_Protocol)); |
| 276 | int InfoSerial; |
| 277 | bool SendInfo; |
| 278 | |
| 279 | { |
| 280 | const CLockScope LockScope(m_pShared->m_pGlobal->m_Lock); |
| 281 | InfoSerial = m_pShared->m_pGlobal->m_InfoSerial; |
| 282 | SendInfo = InfoSerial > m_pShared->m_pGlobal->m_LatestSuccessfulInfoSerial; |
| 283 | } |
| 284 | |
| 285 | std::unique_ptr<CHttpRequest> pRegister; |
| 286 | if(SendInfo) |
| 287 | { |
| 288 | pRegister = HttpPostJson(m_pParent->m_pConfig->m_SvRegisterUrl, m_pParent->m_aServerInfo); |
| 289 | } |
| 290 | else |
| 291 | { |
| 292 | pRegister = HttpPost(m_pParent->m_pConfig->m_SvRegisterUrl, (unsigned char *)"", 0); |
| 293 | } |
| 294 | pRegister->HeaderString("Address", aAddress); |
| 295 | pRegister->HeaderString("Secret", aSecret); |
| 296 | if(m_Protocol == PROTOCOL_TW7_IPV6 || m_Protocol == PROTOCOL_TW7_IPV4) |
| 297 | { |
| 298 | pRegister->HeaderString("Connless-Token", m_pParent->m_aConnlessTokenHex); |
| 299 | } |
| 300 | pRegister->HeaderString("Challenge-Secret", aChallengeSecret); |
| 301 | if(m_HaveChallengeToken) |
| 302 | { |
| 303 | pRegister->HeaderString("Challenge-Token", m_aChallengeToken); |
| 304 | } |
| 305 | pRegister->HeaderInt("Info-Serial", InfoSerial); |
| 306 | if(m_pParent->m_GotCommunityToken) |
| 307 | { |
| 308 | pRegister->HeaderString("Community-Token", m_pParent->m_aCommunityToken); |
| 309 | } |
| 310 | for(int i = 0; i < m_pParent->m_NumExtraHeaders; i++) |
| 311 | { |
| 312 | pRegister->Header(m_pParent->m_aaExtraHeaders[i]); |
| 313 | } |
| 314 | pRegister->LogProgress(HTTPLOG::FAILURE); |
| 315 | pRegister->IpResolve(ProtocolToIpresolve(m_Protocol)); |
| 316 | pRegister->FailOnErrorStatus(false); |
| 317 | |
| 318 | int RequestIndex; |
no test coverage detected