Skip to content

Commit 091ccc3

Browse files
committed
The evhttp_connection_get_peer function from libevent changes the type of the second parameter. Fixing the problem.
1 parent e7507f3 commit 091ccc3

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

configure.ac

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1510,6 +1510,16 @@ if test x$build_bitcoin_cli$build_bitcoind$bitcoin_enable_qt$use_tests$use_bench
15101510
fi
15111511
fi
15121512

1513+
AC_MSG_CHECKING([if evhttp_connection_get_peer expects const char**])
1514+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1515+
#include <cstdint>
1516+
#include <event2/http.h>
1517+
]],
1518+
[[ evhttp_connection_get_peer((evhttp_connection*) nullptr,(const char**) nullptr,(uint16_t*) nullptr); ]])],
1519+
[ AC_MSG_RESULT([yes]); AC_DEFINE([HAVE_EVHTTP_CONNECTION_GET_PEER_CONST_CHAR], [1], [Define this symbol if evhttp_connection_get_peer expects const char**]) ],
1520+
[ AC_MSG_RESULT([no]); AC_DEFINE([HAVE_EVHTTP_CONNECTION_GET_PEER_CONST_CHAR], [0], [Define this symbol if evhttp_connection_get_peer expects const char**]) ]
1521+
)
1522+
15131523
dnl QR Code encoding library check
15141524

15151525
if test "x$use_qr" != xno; then
@@ -1870,6 +1880,7 @@ AC_SUBST(HAVE_BUILTIN_PREFETCH)
18701880
AC_SUBST(HAVE_MM_PREFETCH)
18711881
AC_SUBST(HAVE_STRONG_GETAUXVAL)
18721882
AC_SUBST(ANDROID_ARCH)
1883+
AC_SUBST(HAVE_EVHTTP_CONNECTION_GET_PEER_CONST_CHAR)
18731884
AC_CONFIG_FILES([Makefile src/Makefile doc/man/Makefile share/setup.nsi share/qt/Info.plist test/config.ini])
18741885
AC_CONFIG_FILES([contrib/devtools/split-debug.sh],[chmod +x contrib/devtools/split-debug.sh])
18751886
AM_COND_IF([HAVE_DOXYGEN], [AC_CONFIG_FILES([doc/Doxyfile])])

src/httpserver.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

5+
#if defined(HAVE_CONFIG_H)
6+
#include <config/bitcoin-config.h>
7+
#endif
8+
59
#include <httpserver.h>
610

711
#include <chainparamsbase.h>
@@ -597,7 +601,13 @@ CService HTTPRequest::GetPeer() const
597601
// evhttp retains ownership over returned address string
598602
const char* address = "";
599603
uint16_t port = 0;
604+
605+
#if HAVE_EVHTTP_CONNECTION_GET_PEER_CONST_CHAR
606+
evhttp_connection_get_peer(con, &address, &port);
607+
#else
600608
evhttp_connection_get_peer(con, (char**)&address, &port);
609+
#endif // HAVE_EVHTTP_CONNECTION_GET_PEER_CONST_CHAR
610+
601611
peer = LookupNumeric(address, port);
602612
}
603613
return peer;

0 commit comments

Comments
 (0)