From 53d580dfabf853ceb33d7667b6d3d7aa63c55c8d Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Sat, 9 Jul 2022 22:07:45 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3msvc=E4=B8=8Bgetnameinfo?= =?UTF-8?q?=E9=93=BE=E6=8E=A5=E5=A4=B1=E8=B4=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- srt/Packet.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/srt/Packet.cpp b/srt/Packet.cpp index 0d1c2647..2e4bd8e1 100644 --- a/srt/Packet.cpp +++ b/srt/Packet.cpp @@ -1,6 +1,6 @@ -#include "Util/MD5.h" +#include +#include "Util/MD5.h" #include "Util/logger.h" -#include #include "Packet.hpp" @@ -463,15 +463,11 @@ uint32_t HandshakePacket::generateSynCookie( while (true) { // SYN cookie - char clienthost[NI_MAXHOST]; - char clientport[NI_MAXSERV]; - getnameinfo( - (struct sockaddr *)addr, sizeof(struct sockaddr_storage), clienthost, sizeof(clienthost), clientport, - sizeof(clientport), NI_NUMERICHOST | NI_NUMERICSERV); int64_t timestamp = (DurationCountMicroseconds(SteadyClock::now() - ts) / 60000000) + distractor.load() + correction; // secret changes every one minute std::stringstream cookiestr; - cookiestr << clienthost << ":" << clientport << ":" << timestamp; + cookiestr << SockUtil::inet_ntoa((struct sockaddr *)addr) << ":" << SockUtil::inet_port((struct sockaddr *)addr) + << ":" << timestamp; union { unsigned char cookie[16]; uint32_t cookie_val;