mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-23 20:03:31 +01:00
Link GetAdaptersAddresses, rather than loading it on-demand.
This function has been present since Windows XP.
This commit is contained in:
parent
42b3caa6ad
commit
3930416dec
4
changes/iphplapi
Normal file
4
changes/iphplapi
Normal file
@ -0,0 +1,4 @@
|
||||
o Removed features:
|
||||
- Tor no longer attempts to run on Windows environments without the
|
||||
GetAdaptersAddresses() function. This function has existed since
|
||||
Windows XP, which is itself already older than we support.
|
@ -1479,17 +1479,7 @@ ip_adapter_addresses_to_smartlist(const IP_ADAPTER_ADDRESSES *addresses)
|
||||
STATIC smartlist_t *
|
||||
get_interface_addresses_win32(int severity, sa_family_t family)
|
||||
{
|
||||
/*
|
||||
XXXX We can assume that this function exists now; we can't
|
||||
XXXX provide backward compatibility to pre-windows-XP.
|
||||
*/
|
||||
/* Windows XP began to provide GetAdaptersAddresses. Windows 2000 had a
|
||||
"GetAdaptersInfo", but that's deprecated; let's just try
|
||||
GetAdaptersAddresses and fall back to connect+getsockname.
|
||||
*/
|
||||
HANDLE lib = load_windows_system_library(TEXT("iphlpapi.dll"));
|
||||
smartlist_t *result = NULL;
|
||||
GetAdaptersAddresses_fn_t fn;
|
||||
ULONG size, res;
|
||||
IP_ADAPTER_ADDRESSES *addresses = NULL;
|
||||
|
||||
@ -1499,27 +1489,16 @@ get_interface_addresses_win32(int severity, sa_family_t family)
|
||||
GAA_FLAG_SKIP_MULTICAST | \
|
||||
GAA_FLAG_SKIP_DNS_SERVER)
|
||||
|
||||
if (!lib) {
|
||||
log_fn(severity, LD_NET, "Unable to load iphlpapi.dll");
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (!(fn = (GetAdaptersAddresses_fn_t)
|
||||
GetProcAddress(lib, "GetAdaptersAddresses"))) {
|
||||
log_fn(severity, LD_NET, "Unable to obtain pointer to "
|
||||
"GetAdaptersAddresses");
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* Guess how much space we need. */
|
||||
size = 15*1024;
|
||||
addresses = tor_malloc(size);
|
||||
res = fn(family, FLAGS, NULL, addresses, &size);
|
||||
/* Exists in windows XP and later. */
|
||||
res = GetAdaptersAddresses(family, FLAGS, NULL, addresses, &size);
|
||||
if (res == ERROR_BUFFER_OVERFLOW) {
|
||||
/* we didn't guess that we needed enough space; try again */
|
||||
tor_free(addresses);
|
||||
addresses = tor_malloc(size);
|
||||
res = fn(AF_UNSPEC, FLAGS, NULL, addresses, &size);
|
||||
res = GetAdaptersAddresses(AF_UNSPEC, FLAGS, NULL, addresses, &size);
|
||||
}
|
||||
if (res != NO_ERROR) {
|
||||
log_fn(severity, LD_NET, "GetAdaptersAddresses failed (result: %lu)", res);
|
||||
@ -1529,8 +1508,6 @@ get_interface_addresses_win32(int severity, sa_family_t family)
|
||||
result = ip_adapter_addresses_to_smartlist(addresses);
|
||||
|
||||
done:
|
||||
if (lib)
|
||||
FreeLibrary(lib);
|
||||
tor_free(addresses);
|
||||
return result;
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ src_or_tor_LDFLAGS = @TOR_LDFLAGS_zlib@ @TOR_LDFLAGS_openssl@ @TOR_LDFLAGS_libev
|
||||
src_or_tor_LDADD = $(TOR_INTERNAL_LIBS) \
|
||||
$(rust_ldadd) \
|
||||
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ @TOR_OPENSSL_LIBS@ \
|
||||
@TOR_LIB_WS32@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
|
||||
@TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
|
||||
@CURVE25519_LIBS@ @TOR_SYSTEMD_LIBS@ \
|
||||
@TOR_LZMA_LIBS@ @TOR_ZSTD_LIBS@
|
||||
|
||||
@ -173,7 +173,8 @@ src_or_tor_cov_CFLAGS = $(AM_CFLAGS) $(TEST_CFLAGS)
|
||||
src_or_tor_cov_LDFLAGS = @TOR_LDFLAGS_zlib@ @TOR_LDFLAGS_openssl@ @TOR_LDFLAGS_libevent@
|
||||
src_or_tor_cov_LDADD = $(TOR_INTERNAL_TESTING_LIBS) \
|
||||
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ @TOR_OPENSSL_LIBS@ \
|
||||
@TOR_LIB_WS32@ @TOR_LIB_GDI@ @CURVE25519_LIBS@ @TOR_SYSTEMD_LIBS@ \
|
||||
@TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_GDI@ \
|
||||
@CURVE25519_LIBS@ @TOR_SYSTEMD_LIBS@ \
|
||||
@TOR_LZMA_LIBS@ @TOR_ZSTD_LIBS@
|
||||
endif
|
||||
|
||||
|
@ -11,7 +11,7 @@ FUZZING_LIBS = \
|
||||
$(rust_ldadd) \
|
||||
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ \
|
||||
@TOR_LIBEVENT_LIBS@ @TOR_OPENSSL_LIBS@ \
|
||||
@TOR_LIB_WS32@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ @CURVE25519_LIBS@ \
|
||||
@TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ @CURVE25519_LIBS@ \
|
||||
@TOR_SYSTEMD_LIBS@ \
|
||||
@TOR_LZMA_LIBS@ \
|
||||
@TOR_ZSTD_LIBS@
|
||||
|
@ -221,7 +221,7 @@ src_test_test_switch_id_LDADD = \
|
||||
$(TOR_UTIL_TESTING_LIBS) \
|
||||
$(rust_ldadd) \
|
||||
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ \
|
||||
@TOR_LIB_WS32@ @TOR_LIB_USERENV@ \
|
||||
@TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_USERENV@ \
|
||||
@TOR_LZMA_LIBS@ @TOR_ZSTD_LIBS@
|
||||
|
||||
src_test_test_LDFLAGS = @TOR_LDFLAGS_zlib@ @TOR_LDFLAGS_openssl@ \
|
||||
@ -230,7 +230,7 @@ src_test_test_LDADD = \
|
||||
$(TOR_INTERNAL_TESTING_LIBS) \
|
||||
$(rust_ldadd) \
|
||||
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ \
|
||||
@TOR_OPENSSL_LIBS@ @TOR_LIB_WS32@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
|
||||
@TOR_OPENSSL_LIBS@ @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
|
||||
@CURVE25519_LIBS@ \
|
||||
@TOR_SYSTEMD_LIBS@ @TOR_LZMA_LIBS@ @TOR_ZSTD_LIBS@
|
||||
|
||||
@ -253,7 +253,7 @@ src_test_bench_LDADD = \
|
||||
$(TOR_INTERNAL_LIBS) \
|
||||
$(rust_ldadd) \
|
||||
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ \
|
||||
@TOR_OPENSSL_LIBS@ @TOR_LIB_WS32@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
|
||||
@TOR_OPENSSL_LIBS@ @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
|
||||
@CURVE25519_LIBS@ \
|
||||
@TOR_SYSTEMD_LIBS@ @TOR_LZMA_LIBS@ @TOR_ZSTD_LIBS@
|
||||
|
||||
@ -263,7 +263,7 @@ src_test_test_workqueue_LDADD = \
|
||||
$(TOR_INTERNAL_TESTING_LIBS) \
|
||||
$(rust_ldadd) \
|
||||
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ \
|
||||
@TOR_OPENSSL_LIBS@ @TOR_LIB_WS32@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
|
||||
@TOR_OPENSSL_LIBS@ @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
|
||||
@CURVE25519_LIBS@ \
|
||||
@TOR_LZMA_LIBS@ @TOR_ZSTD_LIBS@
|
||||
|
||||
@ -275,7 +275,7 @@ src_test_test_timers_LDADD = \
|
||||
$(TOR_UTIL_TESTING_LIBS) \
|
||||
$(rust_ldadd) \
|
||||
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ \
|
||||
@TOR_OPENSSL_LIBS@ @TOR_LIB_WS32@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
|
||||
@TOR_OPENSSL_LIBS@ @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
|
||||
@CURVE25519_LIBS@ \
|
||||
@TOR_LZMA_LIBS@
|
||||
src_test_test_timers_LDFLAGS = $(src_test_test_LDFLAGS)
|
||||
@ -305,7 +305,7 @@ src_test_test_ntor_cl_LDADD = \
|
||||
$(TOR_INTERNAL_LIBS) \
|
||||
$(rust_ldadd) \
|
||||
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ \
|
||||
@TOR_OPENSSL_LIBS@ @TOR_LIB_WS32@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
|
||||
@TOR_OPENSSL_LIBS@ @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
|
||||
@CURVE25519_LIBS@ @TOR_LZMA_LIBS@
|
||||
src_test_test_ntor_cl_AM_CPPFLAGS = \
|
||||
$(AM_CPPFLAGS)
|
||||
@ -315,7 +315,7 @@ src_test_test_hs_ntor_cl_LDFLAGS = @TOR_LDFLAGS_zlib@ @TOR_LDFLAGS_openssl@
|
||||
src_test_test_hs_ntor_cl_LDADD = \
|
||||
$(TOR_INTERNAL_LIBS) \
|
||||
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ \
|
||||
@TOR_OPENSSL_LIBS@ @TOR_LIB_WS32@ @TOR_LIB_GDI@ @CURVE25519_LIBS@
|
||||
@TOR_OPENSSL_LIBS@ @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_GDI@ @CURVE25519_LIBS@
|
||||
src_test_test_hs_ntor_cl_AM_CPPFLAGS = \
|
||||
$(AM_CPPFLAGS)
|
||||
|
||||
@ -326,7 +326,7 @@ src_test_test_bt_cl_LDADD = \
|
||||
$(TOR_UTIL_TESTING_LIBS) \
|
||||
$(rust_ldadd) \
|
||||
@TOR_LIB_MATH@ \
|
||||
@TOR_LIB_WS32@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@
|
||||
@TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@
|
||||
src_test_test_bt_cl_CFLAGS = $(AM_CFLAGS) $(TEST_CFLAGS)
|
||||
src_test_test_bt_cl_CPPFLAGS= $(src_test_AM_CPPFLAGS) $(TEST_CPPFLAGS)
|
||||
|
||||
|
@ -9,7 +9,7 @@ src_tools_tor_resolve_LDFLAGS =
|
||||
src_tools_tor_resolve_LDADD = \
|
||||
$(TOR_UTIL_LIBS) \
|
||||
$(rust_ldadd) \
|
||||
@TOR_LIB_MATH@ @TOR_LIB_WS32@ @TOR_LIB_USERENV@
|
||||
@TOR_LIB_MATH@ @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_USERENV@
|
||||
|
||||
if COVERAGE_ENABLED
|
||||
src_tools_tor_cov_resolve_SOURCES = src/tools/tor-resolve.c
|
||||
@ -27,7 +27,7 @@ src_tools_tor_gencert_LDADD = \
|
||||
$(TOR_UTIL_LIBS) \
|
||||
$(rust_ldadd) \
|
||||
@TOR_LIB_MATH@ @TOR_ZLIB_LIBS@ @TOR_OPENSSL_LIBS@ \
|
||||
@TOR_LIB_WS32@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ @CURVE25519_LIBS@
|
||||
@TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ @CURVE25519_LIBS@
|
||||
|
||||
if COVERAGE_ENABLED
|
||||
src_tools_tor_cov_gencert_SOURCES = src/tools/tor-gencert.c
|
||||
@ -38,7 +38,7 @@ src_tools_tor_cov_gencert_LDADD = \
|
||||
$(TOR_CRYPTO_TESTING_LIBS) \
|
||||
$(TOR_UTIL_TESTING_LIBS) \
|
||||
@TOR_LIB_MATH@ @TOR_ZLIB_LIBS@ @TOR_OPENSSL_LIBS@ \
|
||||
@TOR_LIB_WS32@ @TOR_LIB_GDI@ @CURVE25519_LIBS@
|
||||
@TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_GDI@ @CURVE25519_LIBS@
|
||||
endif
|
||||
|
||||
if BUILD_LIBTORRUNNER
|
||||
|
Loading…
Reference in New Issue
Block a user