Skip to content

Commit

Permalink
Add support for session-cache in config file and as cmdline option #166
Browse files Browse the repository at this point in the history
  • Loading branch information
dmatetelki committed Oct 20, 2017
1 parent 99ef536 commit 0c2935b
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 1 deletion.
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ if test x"$use_shctx" != xno; then
if test ! -e 'src/ebtree/ebtree.h'; then
AC_MSG_ERROR([Must clone https://github.com/haproxy/ebtree to src/ebtree/])
fi
AC_DEFINE([USE_SHARED_CACHE], [1], [sessioncache is enabled])
fi
AM_CONDITIONAL(USE_SHCTX, test xno != x"$use_shctx")

Expand Down
2 changes: 1 addition & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ hitch_LDADD = \
libforeign.a

if USE_SHCTX
hitch_CFLAGS += -DUSE_SHARED_CACHE -DUSE_SYSCALL_FUTEX -Iebtree
hitch_CFLAGS += -DUSE_SYSCALL_FUTEX -Iebtree
hitch_SOURCES += shctx.c
hitch_LDADD += ebtree/libebtree.a
endif
4 changes: 4 additions & 0 deletions src/cfg_lex.l
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ char input_line[512];
"ocsp-resp-tmo" { return (TOK_OCSP_RESP_TMO); }
"ocsp-connect-tmo" { return (TOK_OCSP_CONN_TMO); }
"ocsp-dir" { return (TOK_OCSP_DIR); }
"session-cache" { return (TOK_SESSION_CACHE); }
"shared-cache-listen" { return (TOK_SHARED_CACHE_LISTEN); }
"shared-cache-peer" { return (TOK_SHARED_CACHE_PEER); }
"shared-cache-if" { return (TOK_SHARED_CACHE_IF); }

(?i:"yes"|"y"|"on"|"true"|"t"|\"yes\"|\"y\"|\"on\"|\"true\"|\"t\") {
yylval.i = 1;
Expand Down
59 changes: 59 additions & 0 deletions src/cfg_parser.y
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
%{
#include "config.h"

#include <stdio.h>
#include <stdlib.h>

#include "configuration.h"
#include "foreign/vas.h"
#include "foreign/miniobj.h"
Expand Down Expand Up @@ -50,6 +53,8 @@ extern char input_line[512];
%token TOK_MATCH_GLOBAL TOK_PB_CERT TOK_PB_OCSP_FILE TOK_OCSP_VERIFY
%token TOK_OCSP_DIR TOK_OCSP_RESP_TMO TOK_OCSP_CONN_TMO TOK_ALPN_PROTOS
%token TOK_TLS_PROTOS TOK_SSLv3 TOK_TLSv1_0 TOK_TLSv1_1 TOK_TLSv1_2
%token TOK_SESSION_CACHE TOK_SHARED_CACHE_LISTEN TOK_SHARED_CACHE_PEER
%token TOK_SHARED_CACHE_IF

%parse-param { hitch_config *cfg }

Expand Down Expand Up @@ -94,6 +99,10 @@ CFG_RECORD
| OCSP_RESP_TMO
| OCSP_CONN_TMO
| OCSP_DIR
| SESSION_CACHE_REC
| SHARED_CACHE_LISTEN_REC
| SHARED_CACHE_PEER_REC
| SHARED_CACHE_IF_REC
;

FRONTEND_REC
Expand Down Expand Up @@ -446,6 +455,56 @@ SYSLOG_FACILITY_REC: TOK_SYSLOG_FACILITY '=' STRING
YYABORT;
};

SESSION_CACHE_REC: TOK_SESSION_CACHE '=' UINT
{
#ifdef USE_SHARED_CACHE
cfg->SHARED_CACHE = $3;
#else
fprintf(stderr, "Hitch needs to be compiled with --enable-sessioncache "
"for '%s'", input_line);
YYABORT;
#endif
};

SHARED_CACHE_LISTEN_REC: TOK_SHARED_CACHE_LISTEN '=' STRING
{
#ifdef USE_SHARED_CACHE
if ($3 && config_param_validate("shared-cache-listen", $3, cfg,
/* XXX: */ "", yyget_lineno()) != 0)
YYABORT;
#else
fprintf(stderr, "Hitch needs to be compiled with --enable-sessioncache "
"for '%s'", input_line);
YYABORT;
#endif
};

SHARED_CACHE_PEER_REC: TOK_SHARED_CACHE_PEER '=' STRING
{
#ifdef USE_SHARED_CACHE
if ($3 && config_param_validate("shared-cache-peer", $3, cfg,
/* XXX: */ "", yyget_lineno()) != 0)
YYABORT;
#else
fprintf(stderr, "Hitch needs to be compiled with --enable-sessioncache "
"for '%s'", input_line);
YYABORT;
#endif
};

SHARED_CACHE_IF_REC: TOK_SHARED_CACHE_IF '=' STRING
{
#ifdef USE_SHARED_CACHE
if ($3 && config_param_validate("shared-cache-if", $3, cfg,
/* XXX: */ "", yyget_lineno()) != 0)
YYABORT;
#else
fprintf(stderr, "Hitch needs to be compiled with --enable-sessioncache "
"for '%s'", input_line);
YYABORT;
#endif
};

%%

void
Expand Down

0 comments on commit 0c2935b

Please sign in to comment.