Make libevent optional; move binaries into bin/

This commit is contained in:
Dmitri Tikhonov 2021-02-11 10:55:49 -05:00
parent 26e8f082c9
commit b54d1e6309
3 changed files with 109 additions and 94 deletions

View file

@ -234,13 +234,19 @@ ELSE()
MESSAGE(STATUS "zlib not found") MESSAGE(STATUS "zlib not found")
ENDIF() ENDIF()
IF (LSQUIC_BIN OR LSQUIC_TESTS) SET(LIBS lsquic ${BORINGSSL_LIB_ssl} ${BORINGSSL_LIB_crypto} ${ZLIB_LIB} ${LIBS})
IF (LSQUIC_BIN)
FIND_PATH(EVENT_INCLUDE_DIR NAMES event2/event.h) FIND_PATH(EVENT_INCLUDE_DIR NAMES event2/event.h)
IF (EVENT_INCLUDE_DIR) IF (EVENT_INCLUDE_DIR)
INCLUDE_DIRECTORIES(${EVENT_INCLUDE_DIR}) INCLUDE_DIRECTORIES(${EVENT_INCLUDE_DIR})
ELSE() ELSE()
MESSAGE(FATAL_ERROR "event2/event.h was not found") MESSAGE(WARNING "event2/event.h was not found: binaries won't be built")
SET(LSQUIC_BIN OFF)
ENDIF() ENDIF()
ENDIF()
IF (LSQUIC_BIN)
IF (CMAKE_SYSTEM_NAME STREQUAL Windows) IF (CMAKE_SYSTEM_NAME STREQUAL Windows)
FIND_LIBRARY(EVENT_LIB event) FIND_LIBRARY(EVENT_LIB event)
ELSE() ELSE()
@ -252,82 +258,21 @@ ENDIF()
IF(EVENT_LIB) IF(EVENT_LIB)
MESSAGE(STATUS "Found event: ${EVENT_LIB}") MESSAGE(STATUS "Found event: ${EVENT_LIB}")
ELSE() ELSE()
MESSAGE(STATUS "libevent not found") MESSAGE(WARNING "libevent not found: binaries won't be built")
SET(LSQUIC_BIN OFF)
ENDIF() ENDIF()
SET(LIBS lsquic ${EVENT_LIB} ${BORINGSSL_LIB_ssl} ${BORINGSSL_LIB_crypto} ${ZLIB_LIB} ${LIBS}) ENDIF()
IF(MSVC)
FIND_LIBRARY(PCRE_LIB pcre)
IF(PCRE_LIB) IF (NOT MSVC)
MESSAGE(STATUS "Found pcre: ${PCRE_LIB}") LIST(APPEND LIBS pthread m)
LIST(APPEND LIBS ${PCRE_LIB})
ELSE() ELSE()
MESSAGE(STATUS "pcre not found: http_server won't work")
ENDIF()
FIND_LIBRARY(PCREPOSIX_LIB pcreposix)
IF(PCREPOSIX_LIB)
MESSAGE(STATUS "Found pcreposix: ${PCREPOSIX_LIB}")
LIST(APPEND LIBS ${PCREPOSIX_LIB})
ELSE()
MESSAGE(STATUS "pcreposix not found: http_server won't work")
ENDIF()
LIST(APPEND LIBS ws2_32) LIST(APPEND LIBS ws2_32)
LIST(APPEND LIBS iphlpapi)
ENDIF() ENDIF()
ENDIF() # LSQUIC_BIN OR LSQUIC_TESTS
IF (LSQUIC_BIN) IF (LSQUIC_BIN)
IF(MSVC) ADD_SUBDIRECTORY(bin)
SET(GETOPT_C wincompat/getopt.c)
ENDIF() ENDIF()
add_executable(http_server bin/http_server.c bin/prog.c bin/test_common.c bin/test_cert.c ${GETOPT_C})
IF(NOT MSVC) # TODO: port MD5 server and client to Windows
add_executable(md5_server bin/md5_server.c bin/prog.c bin/test_common.c bin/test_cert.c ${GETOPT_C})
add_executable(md5_client bin/md5_client.c bin/prog.c bin/test_common.c bin/test_cert.c ${GETOPT_C})
ENDIF()
add_executable(echo_server bin/echo_server.c bin/prog.c bin/test_common.c bin/test_cert.c ${GETOPT_C})
add_executable(echo_client bin/echo_client.c bin/prog.c bin/test_common.c bin/test_cert.c ${GETOPT_C})
add_executable(duck_server bin/duck_server.c bin/prog.c bin/test_common.c bin/test_cert.c ${GETOPT_C})
add_executable(duck_client bin/duck_client.c bin/prog.c bin/test_common.c bin/test_cert.c ${GETOPT_C})
IF (NOT MSVC)
add_executable(http_client
bin/http_client.c
bin/prog.c
bin/test_common.c
bin/test_cert.c
)
LIST(APPEND LIBS pthread m)
#MSVC
ELSE()
add_executable(http_client
bin/http_client.c
bin/prog.c
bin/test_common.c
bin/test_cert.c
wincompat/getopt.c
wincompat/getopt1.c
)
LIST(APPEND LIBS ws2_32)
ENDIF()
TARGET_LINK_LIBRARIES(http_client ${LIBS})
TARGET_LINK_LIBRARIES(http_server ${LIBS})
IF(NOT MSVC)
TARGET_LINK_LIBRARIES(md5_server ${LIBS})
TARGET_LINK_LIBRARIES(md5_client ${LIBS})
ENDIF()
TARGET_LINK_LIBRARIES(echo_server ${LIBS})
TARGET_LINK_LIBRARIES(echo_client ${LIBS})
TARGET_LINK_LIBRARIES(duck_server ${LIBS})
TARGET_LINK_LIBRARIES(duck_client ${LIBS})
add_subdirectory(bin)
ENDIF() # LSQUIC_BIN
add_subdirectory(src) add_subdirectory(src)

View file

@ -45,21 +45,21 @@ Usage Examples
Fetch Google's home page: Fetch Google's home page:
./http_client -s www.google.com -p / ./bin/http_client -s www.google.com -p /
The default port number is 443, but it can be specified after colon The default port number is 443, but it can be specified after colon
using the -s flag. The value of the `host' header as well as the SNI using the -s flag. The value of the `host' header as well as the SNI
value defaults to the host part of the -s option. -H option can be value defaults to the host part of the -s option. -H option can be
used to override it. For example: used to override it. For example:
./http_client -H www.youtube.com -s www.google.com:443 -p / -M HEAD ./bin/http_client -H www.youtube.com -s www.google.com:443 -p / -M HEAD
The host part can be an IP address. Both IPv4 and IPv6 are supported. The host part can be an IP address. Both IPv4 and IPv6 are supported.
See ./http_client -h for a (long) list of different flags. See ./bin/http_client -h for a (long) list of different flags.
POST a file to calculate its CRC32 checksum: POST a file to calculate its CRC32 checksum:
./http_client -H www.litespeedtech.com -s 443 \ ./bin/http_client -H www.litespeedtech.com -s 443 \
-p /cgi-bin/crc32.cgi -P file-256M -M POST -p /cgi-bin/crc32.cgi -P file-256M -M POST
HTTP/1.1 200 OK HTTP/1.1 200 OK
@ -83,7 +83,7 @@ On the command line, I do
To submit several requests concurrently, one can use -n and -r options: To submit several requests concurrently, one can use -n and -r options:
./http_client -H www.litespeedtech.com -s 443 \ ./bin/http_client -H www.litespeedtech.com -s 443 \
-p /cgi-bin/crc32.cgi -P file-256M -M POST -n 3 -r 10 -p /cgi-bin/crc32.cgi -P file-256M -M POST -n 3 -r 10
This will open three parallel connections which will make ten POST This will open three parallel connections which will make ten POST
@ -92,9 +92,9 @@ requests together.
To perform load testing, it is good to mix sending and receiving data: To perform load testing, it is good to mix sending and receiving data:
for i in {1..100}; do for i in {1..100}; do
./http_client $COMMON_OPTS -p /cgi-bin/crc32.cgi -P file-256M \ ./bin/http_client $COMMON_OPTS -p /cgi-bin/crc32.cgi -P file-256M \
-M POST >out-post.$i & -M POST >out-post.$i &
./http_client $COMMON_OPTS -p /docs/file-256M >out-get.$i & ./bin/http_client $COMMON_OPTS -p /docs/file-256M >out-get.$i &
sleep 1 sleep 1
done done
@ -121,9 +121,9 @@ Running Instructions
of packet that the client will accept. of packet that the client will accept.
Example Usage Example Usage
./http_client -p /file-1M -H www.litespeedtech.com -s 192.168.0.85:5443 ./bin/http_client -p /file-1M -H www.litespeedtech.com -s 192.168.0.85:5443
-o version=FF000014 -o version=FF000014
./http_server -c www.litespeedtech.com,certschain,privkey ./bin/http_server -c www.litespeedtech.com,certschain,privkey
-s 0.0.0.0:5443 -W -o base_plpmtu=65535 -s 0.0.0.0:5443 -W -o base_plpmtu=65535
Additional Notes Additional Notes
@ -145,9 +145,9 @@ And so on.
For example, to test version negotiation: For example, to test version negotiation:
./http_server -c www.litespeedtech.com,certschain,privkey \ ./bin/http_server -c www.litespeedtech.com,certschain,privkey \
-o version=Q035 -L debug 2>server.out & -o version=Q035 -L debug 2>server.out &
./http_client -H www.litespeedtech.com -p Makefile -L debug 2>client.out ./bin/http_client -H www.litespeedtech.com -p Makefile -L debug 2>client.out
Above, the client will start with the default, which is the highest supported Above, the client will start with the default, which is the highest supported
QUIC version, which the server should negotiate down. You should see it from QUIC version, which the server should negotiate down. You should see it from

View file

@ -1,4 +1,74 @@
# Copyright (c) 2017 - 2021 LiteSpeed Technologies Inc. See LICENSE. # Copyright (c) 2017 - 2021 LiteSpeed Technologies Inc. See LICENSE.
LIST(APPEND LIBS ${EVENT_LIB})
IF(MSVC)
FIND_LIBRARY(PCRE_LIB pcre)
IF(PCRE_LIB)
MESSAGE(STATUS "Found pcre: ${PCRE_LIB}")
LIST(APPEND LIBS ${PCRE_LIB})
ELSE()
MESSAGE(STATUS "pcre not found: http_server won't work")
ENDIF()
FIND_LIBRARY(PCREPOSIX_LIB pcreposix)
IF(PCREPOSIX_LIB)
MESSAGE(STATUS "Found pcreposix: ${PCREPOSIX_LIB}")
LIST(APPEND LIBS ${PCREPOSIX_LIB})
ELSE()
MESSAGE(STATUS "pcreposix not found: http_server won't work")
ENDIF()
LIST(APPEND LIBS ws2_32)
LIST(APPEND LIBS iphlpapi)
ENDIF()
IF(MSVC)
SET(GETOPT_C ../wincompat/getopt.c)
ENDIF()
add_executable(http_server http_server.c prog.c test_common.c test_cert.c ${GETOPT_C})
IF(NOT MSVC) # TODO: port MD5 server and client to Windows
add_executable(md5_server md5_server.c prog.c test_common.c test_cert.c ${GETOPT_C})
add_executable(md5_client md5_client.c prog.c test_common.c test_cert.c ${GETOPT_C})
ENDIF()
add_executable(echo_server echo_server.c prog.c test_common.c test_cert.c ${GETOPT_C})
add_executable(echo_client echo_client.c prog.c test_common.c test_cert.c ${GETOPT_C})
add_executable(duck_server duck_server.c prog.c test_common.c test_cert.c ${GETOPT_C})
add_executable(duck_client duck_client.c prog.c test_common.c test_cert.c ${GETOPT_C})
IF (NOT MSVC)
add_executable(http_client
http_client.c
prog.c
test_common.c
test_cert.c
)
#MSVC
ELSE()
add_executable(http_client
http_client.c
prog.c
test_common.c
test_cert.c
../wincompat/getopt.c
../wincompat/getopt1.c
)
ENDIF()
TARGET_LINK_LIBRARIES(http_client ${LIBS})
TARGET_LINK_LIBRARIES(http_server ${LIBS})
IF(NOT MSVC)
TARGET_LINK_LIBRARIES(md5_server ${LIBS})
TARGET_LINK_LIBRARIES(md5_client ${LIBS})
ENDIF()
TARGET_LINK_LIBRARIES(echo_server ${LIBS})
TARGET_LINK_LIBRARIES(echo_client ${LIBS})
TARGET_LINK_LIBRARIES(duck_server ${LIBS})
TARGET_LINK_LIBRARIES(duck_client ${LIBS})
INCLUDE(CheckFunctionExists) INCLUDE(CheckFunctionExists)
CHECK_FUNCTION_EXISTS(sendmmsg HAVE_SENDMMSG) CHECK_FUNCTION_EXISTS(sendmmsg HAVE_SENDMMSG)
CHECK_FUNCTION_EXISTS(recvmmsg HAVE_RECVMMSG) CHECK_FUNCTION_EXISTS(recvmmsg HAVE_RECVMMSG)