From b8fbbc56a742d74782d22eeb212213182a564193 Mon Sep 17 00:00:00 2001 From: Sektor van Skijlen Date: Fri, 26 Jul 2024 13:47:16 +0200 Subject: [PATCH 1/6] Fixed a case when the address is NULL (found on Cygwin) --- srtcore/common.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/srtcore/common.cpp b/srtcore/common.cpp index 6a18afcce..9b950c4f6 100644 --- a/srtcore/common.cpp +++ b/srtcore/common.cpp @@ -502,7 +502,8 @@ vector GetLocalInterfaces() while (pUnicast) { LocalInterface a; - a.addr = pUnicast->Address.lpSockaddr; + if (pUnicast->Address.lpSockaddr) + a.addr = pUnicast->Address.lpSockaddr; if (a.addr.len > 0) { // DO NOT collect addresses that are not of @@ -527,7 +528,8 @@ vector GetLocalInterfaces() for (pif = pifa; pif; pif = pif->ifa_next) { LocalInterface i; - i.addr = pif->ifa_addr; + if (pif->ifa_addr) + i.addr = pif->ifa_addr; if (i.addr.len > 0) { // DO NOT collect addresses that are not of From d51262ba82aa4f8db341ecf698589efe47a1d1cb Mon Sep 17 00:00:00 2001 From: Sektor van Skijlen Date: Fri, 26 Jul 2024 13:49:17 +0200 Subject: [PATCH 2/6] Fixed mistake in workflofs/cxx11-win --- .github/workflows/cxx11-win.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cxx11-win.yaml b/.github/workflows/cxx11-win.yaml index 3beff7740..15d275aac 100644 --- a/.github/workflows/cxx11-win.yaml +++ b/.github/workflows/cxx11-win.yaml @@ -17,7 +17,7 @@ jobs: - name: configure run: | md _build && cd _build - cmake ../ -DENABLE_STDCXX_SYNC=ON -DENABLE_ENCRYPTION=OFF -DENABLE_UNITTESTS=ON -DENABLE_BONDING=ON -DENABLE_LOCALIF_WIN32 + cmake ../ -DENABLE_STDCXX_SYNC=ON -DENABLE_ENCRYPTION=OFF -DENABLE_UNITTESTS=ON -DENABLE_BONDING=ON -DENABLE_LOCALIF_WIN32=ON - name: build run: cd _build && cmake --build ./ --config Release - name: test From 7b53f6f17c488e7568e350a858c8070e2ef3539a Mon Sep 17 00:00:00 2001 From: Mikolaj Malecki Date: Fri, 26 Jul 2024 13:58:26 +0200 Subject: [PATCH 3/6] Added printing device on listener in verbose mode --- testing/testmedia.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/testing/testmedia.cpp b/testing/testmedia.cpp index 55cadda8a..53c04669d 100755 --- a/testing/testmedia.cpp +++ b/testing/testmedia.cpp @@ -612,13 +612,17 @@ void SrtCommon::AcceptNewClient() } sockaddr_any agentaddr(AF_INET6); - string agent = ""; + string agent = "", dev; if (-1 != srt_getsockname(m_sock, (agentaddr.get()), (&agentaddr.len))) { agent = agentaddr.str(); + char name[256]; + size_t len = 255; + if (srt_getsockdevname(m_sock, name, &len) == SRT_SUCCESS) + dev.assign(name, len); } - Verb() << " connected [" << agent << "] <-- " << peer; + Verb() << " connected [" << agent << "] <-- " << peer << " [" << dev << "]"; } ::transmit_throw_on_interrupt = false; From 8fe7b3a3c47020e60c2c7783b70286dd7c7d1c7f Mon Sep 17 00:00:00 2001 From: Mikolaj Malecki Date: Fri, 26 Jul 2024 14:20:34 +0200 Subject: [PATCH 4/6] Fixed build break on Windows --- srtcore/common.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srtcore/common.cpp b/srtcore/common.cpp index 9b950c4f6..16397a719 100644 --- a/srtcore/common.cpp +++ b/srtcore/common.cpp @@ -495,7 +495,7 @@ vector GetLocalInterfaces() ULONG st = GetAdaptersAddresses(AF_UNSPEC, flags, NULL, pAddresses, &outBufLen); if (st == ERROR_SUCCESS) { - for (PIP_ADAPTER_ADDRESSES* i = pAddresses; i; i = pAddresses->Next) + for (PIP_ADAPTER_ADDRESSES i = pAddresses; i; i = pAddresses->Next) { std::string name = i->AdapterName; PIP_ADAPTER_UNICAST_ADDRESS pUnicast = pAddresses->FirstUnicastAddress; From 0488b2513012b3f1267b1ed031466686d752e48b Mon Sep 17 00:00:00 2001 From: Sektor van Skijlen Date: Fri, 26 Jul 2024 15:08:16 +0200 Subject: [PATCH 5/6] Merged and fixed --- CMakeLists.txt | 19 +++++++++++++------ srtcore/common.cpp | 2 +- testing/testmedia.cpp | 8 ++------ 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 347703022..8e73832f4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -162,6 +162,7 @@ option(ENABLE_PKTINFO "Enable using IP_PKTINFO to allow the listener extracting option(ENABLE_RELATIVE_LIBPATH "Should application contain relative library paths, like ../lib" OFF) option(ENABLE_GETNAMEINFO "In-logs sockaddr-to-string should do rev-dns" OFF) option(ENABLE_UNITTESTS "Enable unit tests" OFF) +option(ENABLE_UNITTESTS_AUTO "Enable unit tests" OFF) option(ENABLE_ENCRYPTION "Enable encryption in SRT" ON) option(ENABLE_AEAD_API_PREVIEW "Enable AEAD API preview in SRT" Off) option(ENABLE_MAXREXMITBW "Enable SRTO_MAXREXMITBW (v1.6.0 API preview)" Off) @@ -175,7 +176,7 @@ option(USE_OPENSSL_PC "Use pkg-config to find OpenSSL libraries" ON) option(OPENSSL_USE_STATIC_LIBS "Link OpenSSL libraries statically." OFF) option(USE_BUSY_WAITING "Enable more accurate sending times at a cost of potentially higher CPU load" OFF) option(USE_GNUSTL "Get c++ library/headers from the gnustl.pc" OFF) -option(ENABLE_LOCALIF_WIN32 "Enable rendezvous-connect-to-self prevention on Windows (adds Iphlpapi.lib dep)" OFF) +option(ENABLE_LOCALIF_WIN32 "Enable local interface check ability on Windows (adds Iphlpapi.lib dep)" OFF) option(ENABLE_SOCK_CLOEXEC "Enable setting SOCK_CLOEXEC on a socket" ON) option(ENABLE_SHOW_PROJECT_CONFIG "Enable show Project Configuration" OFF) @@ -1282,6 +1283,10 @@ macro(srt_add_program_dont_install name) add_executable(${name} ${ARGN}) target_include_directories(${name} PRIVATE apps) target_include_directories(${name} PRIVATE common) + if (MICROSOFT AND ENABLE_LOCALIF_WIN32) + target_link_libraries(${name} Iphlpapi) + add_definitions(-DSRT_ENABLE_LOCALIF_WIN32) + endif() endmacro() macro(srt_add_program name) @@ -1293,10 +1298,6 @@ macro(srt_add_program name) else() message(WARNING "No location to install program ${name}") endif() - if (MICROSOFT AND ENABLE_LOCALIF_WIN32) - target_link_libraries(${name} Iphlpapi) - add_definitions(-DSRT_ENABLE_LOCALIF_WIN32) - endif() endmacro() macro(srt_make_application name) @@ -1479,6 +1480,10 @@ endif() srt_add_example(testcapi-connect.c) endif() +if (ENABLE_UNITTESTS_AUTO) + set (ENABLE_UNITTESTS ON) +endif() + if (ENABLE_UNITTESTS AND ENABLE_CXX11) @@ -1534,7 +1539,9 @@ if (ENABLE_UNITTESTS AND ENABLE_CXX11) #set_tests_properties(test-srt PROPERTIES RUN_SERIAL TRUE) else() set_tests_properties(${tests_srt} PROPERTIES RUN_SERIAL TRUE) - gtest_discover_tests(test-srt) + if (ENABLE_UNITTESTS_AUTO) + gtest_discover_tests(test-srt) + endif() endif() enable_testing() diff --git a/srtcore/common.cpp b/srtcore/common.cpp index 16397a719..9b950c4f6 100644 --- a/srtcore/common.cpp +++ b/srtcore/common.cpp @@ -495,7 +495,7 @@ vector GetLocalInterfaces() ULONG st = GetAdaptersAddresses(AF_UNSPEC, flags, NULL, pAddresses, &outBufLen); if (st == ERROR_SUCCESS) { - for (PIP_ADAPTER_ADDRESSES i = pAddresses; i; i = pAddresses->Next) + for (PIP_ADAPTER_ADDRESSES* i = pAddresses; i; i = pAddresses->Next) { std::string name = i->AdapterName; PIP_ADAPTER_UNICAST_ADDRESS pUnicast = pAddresses->FirstUnicastAddress; diff --git a/testing/testmedia.cpp b/testing/testmedia.cpp index 53c04669d..55cadda8a 100755 --- a/testing/testmedia.cpp +++ b/testing/testmedia.cpp @@ -612,17 +612,13 @@ void SrtCommon::AcceptNewClient() } sockaddr_any agentaddr(AF_INET6); - string agent = "", dev; + string agent = ""; if (-1 != srt_getsockname(m_sock, (agentaddr.get()), (&agentaddr.len))) { agent = agentaddr.str(); - char name[256]; - size_t len = 255; - if (srt_getsockdevname(m_sock, name, &len) == SRT_SUCCESS) - dev.assign(name, len); } - Verb() << " connected [" << agent << "] <-- " << peer << " [" << dev << "]"; + Verb() << " connected [" << agent << "] <-- " << peer; } ::transmit_throw_on_interrupt = false; From 42666ca6506ce383a7bc365457f29626ea8c6208 Mon Sep 17 00:00:00 2001 From: Sektor van Skijlen Date: Fri, 26 Jul 2024 15:29:21 +0200 Subject: [PATCH 6/6] Fixing wrong withdrawn changes --- srtcore/common.cpp | 2 +- testing/testmedia.cpp | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/srtcore/common.cpp b/srtcore/common.cpp index 9b950c4f6..16397a719 100644 --- a/srtcore/common.cpp +++ b/srtcore/common.cpp @@ -495,7 +495,7 @@ vector GetLocalInterfaces() ULONG st = GetAdaptersAddresses(AF_UNSPEC, flags, NULL, pAddresses, &outBufLen); if (st == ERROR_SUCCESS) { - for (PIP_ADAPTER_ADDRESSES* i = pAddresses; i; i = pAddresses->Next) + for (PIP_ADAPTER_ADDRESSES i = pAddresses; i; i = pAddresses->Next) { std::string name = i->AdapterName; PIP_ADAPTER_UNICAST_ADDRESS pUnicast = pAddresses->FirstUnicastAddress; diff --git a/testing/testmedia.cpp b/testing/testmedia.cpp index 55cadda8a..53c04669d 100755 --- a/testing/testmedia.cpp +++ b/testing/testmedia.cpp @@ -612,13 +612,17 @@ void SrtCommon::AcceptNewClient() } sockaddr_any agentaddr(AF_INET6); - string agent = ""; + string agent = "", dev; if (-1 != srt_getsockname(m_sock, (agentaddr.get()), (&agentaddr.len))) { agent = agentaddr.str(); + char name[256]; + size_t len = 255; + if (srt_getsockdevname(m_sock, name, &len) == SRT_SUCCESS) + dev.assign(name, len); } - Verb() << " connected [" << agent << "] <-- " << peer; + Verb() << " connected [" << agent << "] <-- " << peer << " [" << dev << "]"; } ::transmit_throw_on_interrupt = false;