added option to completely disable compression support

This commit is contained in:
Nikos Mavrogiannopoulos
2015-03-01 09:50:24 +01:00
parent bbe272a0b4
commit 65c83c6e84
3 changed files with 29 additions and 7 deletions

View File

@@ -348,6 +348,18 @@ LIBS="$oldlibs"
fi
AM_CONDITIONAL(LOCAL_HTTP_PARSER, test "x$with_local_http_parser" != xno)
dnl compression
AC_ARG_ENABLE(compression,
AS_HELP_STRING([--disable-compression], [Disable compression support]),
enable_compression=$enableval,
enable_compression=yes)
if test "$enable_compression" = yes;then
AC_DEFINE([ENABLE_COMPRESSION], [], [compression enabled]),
fi
AM_CONDITIONAL(ENABLE_COMPRESSION, test "$enable_compression" = yes)
dnl LZ4
AC_ARG_WITH(lz4,
AS_HELP_STRING([--without-lz4], [disable support for LZ4 compression]),
@@ -355,7 +367,8 @@ AC_ARG_WITH(lz4,
test_for_lz4=yes)
enable_lz4=no
if test "$test_for_lz4" = yes;then
if test "$test_for_lz4" = yes && test "$enable_compression" = yes;then
PKG_CHECK_MODULES([LIBLZ4], [liblz4], [
enable_lz4=yes
AC_DEFINE([HAVE_LZ4], [], [LZ4 was found])
@@ -475,6 +488,7 @@ Summary of build options:
systemd: ${systemd_enabled}
(socket activation)
seccomp: ${seccomp_enabled}
Compression: ${enable_compression}
LZ4 compression: ${enable_lz4}
readline: ${have_readline}
libnl3: ${have_libnl3}

View File

@@ -81,12 +81,16 @@ ocserv_SOURCES = main.c main-auth.c worker-vpn.c worker-auth.c tlslib.c \
sup-config/file.c sup-config/file.h main-sec-mod-cmd.c \
sup-config/radius.c sup-config/radius.h \
worker-bandwidth.c worker-bandwidth.h ctl.h main-ctl.h \
vasprintf.c vasprintf.h lzs.c lzs.h cfg.h \
vasprintf.c vasprintf.h cfg.h \
proc-search.c proc-search.h http-heads.h \
main-ban.c main-ban.h \
str.c str.h gettime.h $(CCAN_SOURCES) $(HTTP_PARSER_SOURCES) \
$(PROTOBUF_SOURCES) sec-mod-acct.h
if ENABLE_COMPRESSION
ocserv_SOURCES += lzs.c lzs.h
endif
if HAVE_GSSAPI
ocserv_SOURCES += kkdcp_asn1_tab.c kkdcp.asn
endif

View File

@@ -24,10 +24,12 @@
#include <stdio.h>
#include <string.h>
#ifdef HAVE_LZ4
# include <lz4.h>
#ifdef ENABLE_COMPRESSION
# ifdef HAVE_LZ4
# include <lz4.h>
# endif
# include "lzs.h"
#endif
#include "lzs.h"
#include <base64.h>
#include <c-strcase.h>
@@ -130,6 +132,7 @@ int lz4_compress(void *dst, int dstlen, const void *src, int srclen)
}
#endif
#ifdef ENABLE_COMPRESSION
struct compression_method_st comp_methods[] = {
#ifdef HAVE_LZ4
{
@@ -148,6 +151,7 @@ struct compression_method_st comp_methods[] = {
.server_prio = 80,
}
};
#endif
static
void header_value_check(struct worker_st *ws, struct http_req_st *req)
@@ -273,7 +277,7 @@ void header_value_check(struct worker_st *ws, struct http_req_st *req)
req->selected_ciphersuite = cand;
break;
#ifdef ENABLE_COMPRESSION
case HEADER_DTLS_ENCODING:
case HEADER_CSTP_ENCODING:
if (ws->config->enable_compression == 0)
@@ -302,8 +306,8 @@ void header_value_check(struct worker_st *ws, struct http_req_st *req)
str = NULL;
}
*selected_comp = comp_cand;
break;
#endif
case HEADER_CSTP_BASE_MTU:
req->base_mtu = atoi((char *)value);