Commit 72a038bf authored by Geoff Simmons's avatar Geoff Simmons

initial commit, passes tests for an initial version of regex.match()

and the config_*() functions
parents
((nil . ((indent-tabs-mode . t)))
(c-mode . ((c-file-style . "BSD"))))
Makefile
Makefile.in
.deps/
.libs/
*.o
*.lo
*.la
*~
*.[1-9]
/aclocal.m4
/autom4te.cache/
/compile
/config.guess
/config.h
/config.h.in
/config.log
/config.status
/config.sub
/configure
/depcomp
/install-sh
/libtool
/ltmain.sh
/missing
/stamp-h1
/m4/libtool.m4
/m4/lt*.m4
/src/vcc_if.c
/src/vcc_if.h
/src/vmod_*rst
CONTRIBUTING
============
To contribute code or documentation, submit a pull request at the
`source repository website
<https://code.uplex.de/uplex-varnish/libvmod-pcre2>`_.
If you have a problem or discover a bug, you can post an `issue
<https://code.uplex.de/uplex-varnish/libvmod-pcre2/issues>`_ at
the website. You can also write to <varnish-support@uplex.de>.
For developers
--------------
The build specifies C99 conformance, all compiler warnings turned on,
and all warnings considered errors (compiler options ``-std=c99
-Werror -Wall -Wextra``).
The VMOD has been tested with both the gcc and clang compilers, and
should always compile and test successfully with both of them.
By default, ``CFLAGS`` is set to ``-g -O2``, so that symbols are
included in the shared library, and optimization is at level
``O2``. To change or disable these options, set ``CFLAGS`` explicitly
before calling ``make`` (it may be set to the empty string).
For development/debugging cycles, the ``configure`` option
``--enable-debugging`` is recommended (off by default). This will turn
off optimizations and function inlining, so that a debugger will step
through the code as expected.
See LICENSE for details.
INSTALLATION
============
The VMOD is built against a Varnish installation, and the autotools
use ``pkg-config(1)`` to locate the necessary header files and other
resources. This sequence will install the VMOD::
> ./autogen.sh # for builds from the git repo
> ./configure
> make
> make check # to run unit tests in src/tests/*.vtc
> sudo make install
If you have installed Varnish in a non-standard directory, call
``autogen.sh`` and ``configure`` with the ``PKG_CONFIG_PATH``
environment variable pointing to the appropriate path. For example,
when varnishd configure was called with ``--prefix=$PREFIX``, use::
> PKG_CONFIG_PATH=${PREFIX}/lib/pkgconfig
> export PKG_CONFIG_PATH
By default, the vmod ``configure`` script installs the vmod in
the same directory as Varnish, determined via ``pkg-config(1)``. The
vmod installation directory can be overridden by passing the
``VMOD_DIR`` variable to ``configure``.
Other files such as the man-page are installed in the locations
determined by ``configure``, which inherits its default ``--prefix``
setting from Varnish.
Copyright (c) 2017 UPLEX Nils Goroll Systemoptimierung
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
ACLOCAL_AMFLAGS = -I m4 -I ${LIBVARNISHAPI_DATAROOTDIR}/aclocal
SUBDIRS = src
DISTCHECK_CONFIGURE_FLAGS = \
VMOD_DIR='$${libdir}/varnish/vmods'
EXTRA_DIST = README.rst LICENSE COPYING
doc_DATA = README.rst LICENSE COPYING
dist_man_MANS = vmod_pcre2.3
MAINTAINERCLEANFILES = $(dist_man_MANS)
vmod_pcre2.3: README.rst
README.rst: src/vmod_pcre2.man.rst
cp src/vmod_pcre2.man.rst README.rst
src/vmod_pcre2.man.rst:
make -C src vmod_pcre2.man.rst
%.1 %.2 %.3 %.4 %.5 %.6 %.7 %.8 %.9:
if HAVE_RST2MAN
${RST2MAN} $< $@
else
@echo "========================================"
@echo "You need rst2man installed to make dist"
@echo "========================================"
@false
endif
..
.. NB: This file is machine generated, DO NOT EDIT!
..
.. Edit vmod.vcc and run make instead
..
.. role:: ref(emphasis)
.. _vmod_pcre2(3):
==========
vmod_pcre2
==========
-------------------------------------------
access the pcre2 regular expression library
-------------------------------------------
:Manual section: 3
SYNOPSIS
========
import pcre2 [from "path"] ;
::
new OBJECT = ...
DESCRIPTION
===========
This Varnish Module (VMOD) provides access to the PCRE2 regular
expresion library.
CONTENTS
========
* regex(STRING, ENUM {LIB8,LIB16,LIB32}, BOOL, BOOL, ENUM {ANYCRLF,UNICODE}, BOOL, BOOL, BOOL, BOOL, BOOL, BOOL, BOOL, BOOL, BOOL, STRING, BOOL, INT, BOOL, BOOL, BOOL, BOOL, ENUM {CR,LF,CRLF,ANYCRLF,ANY}, BOOL, BOOL, BOOL, BOOL, BOOL, INT, BOOL, BOOL, BOOL, BOOL)
* BOOL config_bool(ENUM {JIT,STACKRECURSE,UNICODE}, ENUM {LIB8,LIB16,LIB32})
* STRING config_str(ENUM {BSR,JITTARGET,NEWLINE,UNICODE_VERSION,VERSION}, ENUM {LIB8,LIB16,LIB32})
* INT config_int(ENUM {LINKSIZE,MATCHLIMIT,PARENSLIMIT,RECURSIONLIMIT}, ENUM {LIB8,LIB16,LIB32})
* STRING version()
.. _obj_regex:
regex
-----
::
new OBJ = regex(STRING pattern, ENUM {LIB8,LIB16,LIB32} lib=0, BOOL allow_empty_class=0, BOOL anchored=0, ENUM {ANYCRLF,UNICODE} bsr=0, BOOL alt_bsux=0, BOOL alt_circumflex=0, BOOL alt_verbnames=0, BOOL caseless=0, BOOL dotall=0, BOOL dollar_endonly=0, BOOL dupnames=0, BOOL extended=0, BOOL firstline=0, STRING locale=0, BOOL match_unset_backref=0, INT max_pattern_len=0, BOOL multiline=0, BOOL never_backslash_c=0, BOOL never_ucp=0, BOOL never_utf=0, ENUM {CR,LF,CRLF,ANYCRLF,ANY} newline=0, BOOL no_auto_capture=0, BOOL no_auto_possess=0, BOOL no_dotstar_anchor=0, BOOL no_start_optimize=0, BOOL no_utf_check=0, INT parens_nest_limit=0, BOOL ucp=0, BOOL ungreedy=0, BOOL use_offset_limit=0, BOOL utf=0)
# XXX options for dfa_match, jit fast path, start_offset
.. _func_regex.match:
regex.match
-----------
::
BOOL regex.match(PRIV_TASK, STRING, INT len=0, BOOL anchored=0, INT match_limit=0, INT offset_limit=0, BOOL notbol=0, BOOL noteol=0, BOOL notempty=0, BOOL notempty_atstart=0, BOOL no_jit=0, BOOL no_utf_check=0, ENUM {HARD,SOFT} partial=0, INT recursion_limit=0)
.. _func_config_bool:
config_bool
-----------
::
BOOL config_bool(ENUM {JIT,STACKRECURSE,UNICODE}, ENUM {LIB8,LIB16,LIB32} lib=0)
.. _func_config_str:
config_str
----------
::
STRING config_str(ENUM {BSR,JITTARGET,NEWLINE,UNICODE_VERSION,VERSION}, ENUM {LIB8,LIB16,LIB32} lib=0)
.. _func_config_int:
config_int
----------
::
INT config_int(ENUM {LINKSIZE,MATCHLIMIT,PARENSLIMIT,RECURSIONLIMIT}, ENUM {LIB8,LIB16,LIB32} lib=0)
.. _func_version:
version
-------
::
STRING version()
Returns the version string for this VMOD.
Example::
std.log("Using VMOD pcre2 version " + pcre2.version());
REQUIREMENTS
============
This VMOD requires Varnish ...
LIMITATIONS
===========
...
INSTALLATION
============
See `INSTALL.rst <INSTALL.rst>`_ in the source repository.
SEE ALSO
========
* varnishd(1)
* vcl(7)
* source repository: https://code.uplex.de/uplex-varnish/libvmod-pcre2
COPYRIGHT
=========
::
This document is licensed under the same conditions
as the libvmod-pcre2 project. See LICENSE for details.
Author: Geoffrey Simmons <geoffrey.simmons@uplex.de>
#!/bin/sh
warn() {
echo "WARNING: $@" 1>&2
}
case `uname -s` in
Darwin)
LIBTOOLIZE=glibtoolize
;;
FreeBSD)
LIBTOOLIZE=libtoolize
;;
Linux)
LIBTOOLIZE=libtoolize
;;
SunOS)
LIBTOOLIZE=libtoolize
;;
*)
warn "unrecognized platform:" `uname -s`
LIBTOOLIZE=libtoolize
esac
automake_version=`automake --version | tr ' ' '\n' | egrep '^[0-9]\.[0-9a-z.-]+'`
if [ -z "$automake_version" ] ; then
warn "unable to determine automake version"
else
case $automake_version in
0.*|1.[0-8]|1.[0-8][.-]*)
warn "automake ($automake_version) detected; 1.9 or newer recommended"
;;
*)
;;
esac
fi
# check for varnishapi.m4 in custom paths
dataroot=$(pkg-config --variable=datarootdir varnishapi 2>/dev/null)
if [ -z "$dataroot" ] ; then
cat >&2 <<'EOF'
Package varnishapi was not found in the pkg-config search path.
Perhaps you should add the directory containing `varnishapi.pc'
to the PKG_CONFIG_PATH environment variable
EOF
exit 1
fi
set -ex
aclocal -I m4 -I ${dataroot}/aclocal
$LIBTOOLIZE --copy --force
autoheader
automake --add-missing --copy --foreign
autoconf
AC_PREREQ(2.59)
AC_COPYRIGHT([Copyright (c) 2017 UPLEX - Nils Goroll Systemoptimierung])
AC_INIT([VMOD pcre2], [trunk], [varnish-support@uplex.de], [libvmod-pcre2],
[https://code.uplex.de/uplex-varnish/libvmod-pcre2])
AC_CONFIG_MACRO_DIR([m4])
m4_ifndef([VARNISH_VMOD_INCLUDES],
AC_MSG_ERROR([Need varnish.m4 -- see README.rst]))
AC_CONFIG_SRCDIR(src/vmod_pcre2.vcc)
AM_CONFIG_HEADER(config.h)
AC_CANONICAL_SYSTEM
AC_LANG(C)
AM_INIT_AUTOMAKE([foreign])
AC_GNU_SOURCE
AC_PROG_CC
AC_PROG_CC_C99
if test "x$ac_cv_prog_cc_c99" = xno; then
AC_MSG_ERROR([Could not find a C99 compatible compiler])
fi
AC_PROG_CPP
AX_PTHREAD(,[AC_MSG_ERROR([Could not configure pthreads support])])
LIBS="$PTHREAD_LIBS $LIBS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
CC="$PTHREAD_CC"
# Checks for libtool
LT_INIT([disable-static])
AC_PROG_INSTALL
AC_PROG_LIBTOOL
AC_PROG_MAKE_SET
# Checks for header files.
AC_HEADER_STDC
# Checks for C sources
AC_CHECK_FUNCS([strdup])
AC_C_INLINE
AC_C_RESTRICT
AC_FUNC_MALLOC
AC_TYPE_SIZE_T
AC_TYPE_UINT32_T
# backwards compat with older pkg-config
# - pull in AC_DEFUN from pkg.m4
m4_ifndef([PKG_CHECK_VAR], [
# PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
# -------------------------------------------
# Retrieves the value of the pkg-config variable for the given module.
AC_DEFUN([PKG_CHECK_VAR],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
_PKG_CONFIG([$1], [variable="][$3]["], [$2])
AS_VAR_COPY([$1], [pkg_cv_][$1])
AS_VAR_IF([$1], [""], [$5], [$4])dnl
])# PKG_CHECK_VAR
])
PKG_CHECK_MODULES([libvarnishapi], [varnishapi])
PKG_CHECK_VAR([LIBVARNISHAPI_PREFIX], [varnishapi], [prefix])
PKG_CHECK_VAR([LIBVARNISHAPI_DATAROOTDIR], [varnishapi], [datarootdir])
PKG_CHECK_VAR([LIBVARNISHAPI_BINDIR], [varnishapi], [bindir])
PKG_CHECK_VAR([LIBVARNISHAPI_SBINDIR], [varnishapi], [sbindir])
AC_SUBST([LIBVARNISHAPI_DATAROOTDIR])
# Varnish include files tree
VARNISH_VMOD_INCLUDES
VARNISH_VMOD_DIR
VARNISH_VMODTOOL
# inherit the prefix from Varnish.
# acessing ac_ variable because AC_PREFIX_DEFAULT acts too early
ac_default_prefix=$LIBVARNISHAPI_PREFIX
AC_PATH_PROG([VARNISHTEST], [varnishtest], [],
[$LIBVARNISHAPI_BINDIR:$LIBVARNISHAPI_SBINDIR:$PATH])
AC_PATH_PROG([VARNISHD], [varnishd], [],
[$LIBVARNISHAPI_SBINDIR:$LIBVARNISHAPI_BINDIR:$PATH])
# Check for rst utilities
AC_CHECK_PROGS(RST2MAN, [rst2man rst2man.py], "no")
if test "x$RST2MAN" = "xno"; then
AC_MSG_WARN([rst2man not found - not building man pages])
fi
AM_CONDITIONAL(HAVE_RST2MAN, [test "x$RST2MAN" != "xno"])
## Build for all pcre2 libs found via pkg-config, except for those
## excluded with a --without-X configure option.
PKG_CHECK_EXISTS([libpcre2-8], [have_lib8=yes], [have_lib8=no])
PKG_CHECK_EXISTS([libpcre2-16], [have_lib16=yes], [have_lib16=no])
PKG_CHECK_EXISTS([libpcre2-32], [have_lib32=yes], [have_lib32=no])
# Fail if none of the pcre2 libs can be found
AS_IF([test "x$have_lib8" != "xyes"], [
AS_IF([test "x$have_lib16" != "xyes"], [
AS_IF([test "x$have_lib32" != "xyes"],
[AC_MSG_ERROR([Could not find any pcre2 lib via pkg-config])]
)],
)]
)
AC_ARG_WITH([libpcre2-8], [
AS_HELP_STRING([--without-libpcre2-8],
[disable the pcre2 8-bit lib (enabled by default if present)])
])
AC_ARG_WITH([libpcre2-16], [
AS_HELP_STRING([--without-libpcre2-16],
[disable the pcre2 16-bit lib (enabled by default if present)])
])
AC_ARG_WITH([libpcre2-32], [
AS_HELP_STRING([--without-libpcre2-32],
[disable the pcre2 32-bit lib (enabled by default if present)])
])
# Fail if a --with option explicitly chose a lib that is not present
AS_IF([test "x$with_libpcre2_8" = "xyes"], [
AS_IF([test "x$have_lib8" != "xyes"],
[AC_MSG_ERROR([libpcre2-8 not found via pkg-config])]
)]
)
AS_IF([test "x$with_libpcre2_16" = "xyes"], [
AS_IF([test "x$have_lib16" != "xyes"],
[AC_MSG_ERROR([libpcre2-16 not found via pkg-config])]
)]
)
AS_IF([test "x$with_libpcre2_32" = "xyes"], [
AS_IF([test "x$have_lib32" != "xyes"],
[AC_MSG_ERROR([libpcre2-32 not found via pkg-config])]
)]
)
# Set up use of the pcre2 libs
PCRE2_CFLAGS=""
PCRE2_LIBS=""
AS_IF([test "x$have_lib8" != "xno"], [
AS_IF([test "x$with_libpcre2_8" != "xno"], [
PKG_CHECK_MODULES([PCRE2_8], [libpcre2-8])
AC_SUBST([PCRE2_8_CFLAGS])
AC_SUBST([PCRE2_8_LIBS])
PCRE2_CFLAGS=${PCRE2_8_CFLAGS}
PCRE2_LIBS=${PCRE2_8_LIBS}
AC_DEFINE([HAVE_PCRE2_8], [1],
[Define to 1 if the 8-bit pcre2 library is used])
])
])
AS_IF([test "x$have_lib16" != "xno"], [
AS_IF([test "x$with_libpcre2_16" != "xno"], [
PKG_CHECK_MODULES([PCRE2_16], [libpcre2-16])
AC_SUBST([PCRE2_16_CFLAGS])
AC_SUBST([PCRE2_16_LIBS])
PCRE2_CFLAGS="${PCRE2_CFLAGS} ${PCRE2_16_CFLAGS}"
PCRE2_LIBS="${PCRE2_LIBS} ${PCRE2_16_LIBS}"
AC_DEFINE([HAVE_PCRE2_16], [1],
[Define to 1 if the 16-bit pcre2 library is used])
])
])
AS_IF([test "x$have_lib32" != "xno"], [
AS_IF([test "x$with_libpcre2_32" != "xno"], [
PKG_CHECK_MODULES([PCRE2_32], [libpcre2-32])
AC_SUBST([PCRE2_32_CFLAGS])
AC_SUBST([PCRE2_32_LIBS])
PCRE2_CFLAGS="${PCRE2_CFLAGS} ${PCRE2_32_CFLAGS}"
PCRE2_LIBS="${PCRE2_LIBS} ${PCRE2_32_LIBS}"
AC_DEFINE([HAVE_PCRE2_32], [1],
[Define to 1 if the 32-bit pcre2 library is used])
])
])
AS_IF([test -z "$PCRE2_LIBS"], [
AC_MSG_ERROR([You must enable at least one available pcre2 lib])
])
AC_SUBST([PCRE2_CFLAGS])
AC_SUBST([PCRE2_LIBS])
# --enable-stack-protector
AC_ARG_ENABLE(stack-protector,
AS_HELP_STRING([--enable-stack-protector],[enable stack protector (default is YES)]),
[],
[enable_stack_protector=yes])
if test "x$enable_stack_protector" != "xno"; then
AX_CHECK_COMPILE_FLAG([-fstack-protector],
AX_CHECK_LINK_FLAG([-fstack-protector],
[CFLAGS="${CFLAGS} -fstack-protector"], [], []),
[], [])
fi
# --enable-debugging
AC_ARG_ENABLE(debugging,
AS_HELP_STRING([--enable-debugging],[enable debugging (default is NO)]),
[],
[enable_debugging=no])
# AC_PROG_CC sets CFLAGS to '-g -O2' unless it is already set, so
# there's no need to add -g. Disable or change by explicitly setting
# CFLAGS. If this option is enabled, then -Og or -O0 becomes the last
# optimization option, and hence takes precedence.
if test "x$enable_debugging" != "xno"; then
CFLAGS="${CFLAGS} -fno-inline"
AX_CHECK_COMPILE_FLAG([-Og],
[CFLAGS="${CFLAGS} -Og"],
[CFLAGS="${CFLAGS} -O0"],
[])
fi
AC_CONFIG_FILES([
Makefile
src/Makefile
])
AC_OUTPUT
AM_CPPFLAGS = @VMOD_INCLUDES@ -Wall -Werror -Wextra -std=c99 @PCRE2_CFLAGS@
vmoddir = @VMOD_DIR@
vmod_LTLIBRARIES = libvmod_pcre2.la
libvmod_pcre2_la_LDFLAGS = -module -export-dynamic -avoid-version -shared
libvmod_pcre2_la_SOURCES = \
vmod_pcre2.c \
vmod_pcre2.h \
pcre2_compat.h
nodist_libvmod_pcre2_la_SOURCES = \
vcc_if.c \
vcc_if.h
libvmod_pcre2_la_LIBADD = @PCRE2_LIBS@
vmod_pcre2.lo: vcc_if.c vcc_if.h
vcc_if.c: vcc_if.h
vcc_if.h vmod_pcre2.man.rst: @VMODTOOL@ $(top_srcdir)/src/vmod_pcre2.vcc
@VMODTOOL@ $(top_srcdir)/src/vmod_pcre2.vcc
VMOD_TESTS = $(top_srcdir)/src/tests/*.vtc
.PHONY: $(VMOD_TESTS)
$(top_srcdir)/src/tests/*.vtc: libvmod_pcre2.la
PATH=@LIBVARNISHAPI_SBINDIR@:$$PATH \
@VARNISHTEST@ -Dvmod_topbuild=$(abs_top_builddir) $@
check: $(VMOD_TESTS)
EXTRA_DIST = \
vmod_pcre2.vcc \
$(VMOD_TESTS)
CLEANFILES = \
$(builddir)/vcc_if.c \
$(builddir)/vcc_if.h \
$(builddir)/vmod_pcre2.rst \
$(builddir)/vmod_pcre2.man.rst
This diff is collapsed.
# looks like -*- vcl -*-
varnishtest "vcl.use and .discard, and version string"
server s1 {} -start
varnish v1 -vcl+backend {
import pcre2 from "${vmod_topbuild}/src/.libs/libvmod_pcre2.so";
} -start
varnish v1 -vcl+backend {}
varnish v1 -cli "vcl.list"
varnish v1 -cli "vcl.use vcl1"
varnish v1 -cli "vcl.use vcl2"
varnish v1 -cli "vcl.use vcl1"
varnish v1 -cli "vcl.show vcl1"
varnish v1 -cli "vcl.use vcl2"
varnish v1 -cli "vcl.discard vcl1"
varnish v1 -cli "vcl.list"
varnish v1 -vcl {
import pcre2 from "${vmod_topbuild}/src/.libs/libvmod_pcre2.so";
backend b { .host = "${bad_ip}"; }
sub vcl_recv {
return(synth(200));
}
sub vcl_synth {
set resp.http.x-version = pcre2.version();
if (!resp.http.x-version) {
set resp.status = 500;
}
return(deliver);
}
}
client c1 {
txreq -url "/"
rxresp
expect resp.status == 200
expect resp.http.x-version ~ "^.+$"
} -run
# looks like -*- vcl -*-
varnishtest "regex constructor"
varnish v1 -vcl {
import pcre2 from "${vmod_topbuild}/src/.libs/libvmod_pcre2.so";
backend b { .host = "${bad_ip}"; }
sub vcl_init {
new r = pcre2.regex("foo");
}
sub vcl_recv {
return(synth(200));
}
sub vcl_synth {
set resp.http.fmatch = r.match("foo");
set resp.http.gmatch = r.match("goo");
}
} -start
client c1 {
txreq
rxresp
expect resp.http.fmatch == "true"
expect resp.http.gmatch == "false"
} -run
# looks like -*- vcl -*-
varnishtest "functions config_bool, _int and _str"
varnish v1 -vcl {
import pcre2 from "${vmod_topbuild}/src/.libs/libvmod_pcre2.so";
backend b { .host = "${bad_ip}"; }
sub vcl_recv {
return(synth(200));
}
sub vcl_synth {
set resp.http.jit = pcre2.config_bool(JIT);
set resp.http.stackrecurse = pcre2.config_bool(STACKRECURSE);
set resp.http.unicode = pcre2.config_bool(UNICODE);
set resp.http.bsr = pcre2.config_str(BSR);
set resp.http.jittarget = pcre2.config_str(JITTARGET);
set resp.http.newline = pcre2.config_str(NEWLINE);
set resp.http.unicode-version
= pcre2.config_str(UNICODE_VERSION);
set resp.http.version = pcre2.config_str(VERSION);
set resp.http.linksize = pcre2.config_int(LINKSIZE);
set resp.http.matchlimit = pcre2.config_int(MATCHLIMIT);
set resp.http.parenslimit = pcre2.config_int(PARENSLIMIT);
set resp.http.recursionlimit = pcre2.config_int(RECURSIONLIMIT);
}
} -start
client c1 {
txreq
rxresp
expect resp.status == 200
expect resp.http.jit ~ "^(true|false)$"
expect resp.http.stackrecurse ~ "^(true|false)$"
expect resp.http.unicode ~ "^(true|false)$"
expect resp.http.bsr ~ "^(UNICODE|ANYCRLF)$"
expect resp.http.jittarget ~ ".+"
expect resp.http.newline ~ "^(CR|LF|CRLF|ANY|ANYCRLF)$"
expect resp.http.unicode-version ~ ".+"
expect resp.http.version ~ ".+"
expect resp.http.linksize ~ "^\\d+$"
expect resp.http.matchlimit ~ "^\\d+$"
expect resp.http.parenslimit ~ "^\\d+$"
expect resp.http.recursionlimit ~ "^\\d+$"
} -run
varnish v1 -vcl {
import pcre2 from "${vmod_topbuild}/src/.libs/libvmod_pcre2.so";
backend b { .host = "${bad_ip}"; }
sub vcl_recv {
return(synth(200));
}
sub vcl_synth {
set resp.http.jit = pcre2.config_bool(JIT, lib=LIB8);
set resp.http.stackrecurse = pcre2.config_bool(STACKRECURSE);
set resp.http.unicode = pcre2.config_bool(UNICODE);
set resp.http.bsr = pcre2.config_str(BSR);
set resp.http.jittarget = pcre2.config_str(JITTARGET);
set resp.http.newline = pcre2.config_str(NEWLINE);
set resp.http.unicode-version
= pcre2.config_str(UNICODE_VERSION);
set resp.http.version = pcre2.config_str(VERSION);
set resp.http.linksize = pcre2.config_int(LINKSIZE);
set resp.http.matchlimit = pcre2.config_int(MATCHLIMIT);
set resp.http.parenslimit = pcre2.config_int(PARENSLIMIT);
set resp.http.recursionlimit = pcre2.config_int(RECURSIONLIMIT);
}
}
client c1 {
txreq
rxresp
expect resp.status == 200
expect resp.http.jit ~ "^(true|false)$"
expect resp.http.stackrecurse ~ "^(true|false)$"
expect resp.http.unicode ~ "^(true|false)$"
expect resp.http.bsr ~ "^(UNICODE|ANYCRLF)$"
expect resp.http.jittarget ~ ".+"
expect resp.http.newline ~ "^(CR|LF|CRLF|ANY|ANYCRLF)$"
expect resp.http.unicode-version ~ ".+"
expect resp.http.version ~ ".+"
expect resp.http.linksize ~ "^\\d+$"
expect resp.http.matchlimit ~ "^\\d+$"
expect resp.http.parenslimit ~ "^\\d+$"
expect resp.http.recursionlimit ~ "^\\d+$"
} -run
This diff is collapsed.
#-
# This document is licensed under the same conditions
# as the libvmod-pcre2 project. See LICENSE for details.
#
# Author: Geoffrey Simmons <geoffrey.simmons@uplex.de>
#
$Module pcre2 3 access the pcre2 regular expression library
::
new OBJECT = ...
DESCRIPTION
===========
This Varnish Module (VMOD) provides access to the PCRE2 regular
expresion library.
$Object regex(STRING pattern, ENUM {LIB8, LIB16, LIB32} lib=0,
BOOL allow_empty_class=0, BOOL anchored=0,
ENUM {ANYCRLF, UNICODE} bsr=0, BOOL alt_bsux=0,
BOOL alt_circumflex=0, BOOL alt_verbnames=0, BOOL caseless=0,
BOOL dotall=0, BOOL dollar_endonly=0, BOOL dupnames=0,
BOOL extended=0, BOOL firstline=0, STRING locale=0,
BOOL match_unset_backref=0, INT max_pattern_len=0,
BOOL multiline=0, BOOL never_backslash_c=0, BOOL never_ucp=0,
BOOL never_utf=0, ENUM {CR, LF, CRLF, ANYCRLF, ANY} newline=0,
BOOL no_auto_capture=0, BOOL no_auto_possess=0,
BOOL no_dotstar_anchor=0, BOOL no_start_optimize=0,
BOOL no_utf_check=0, INT parens_nest_limit=0, BOOL ucp=0,
BOOL ungreedy=0, BOOL use_offset_limit=0, BOOL utf=0)
# XXX options for dfa_match, jit fast path, start_offset
$Method BOOL .match(PRIV_TASK, STRING, INT len=0, BOOL anchored=0,
INT match_limit=0, INT offset_limit=0, BOOL notbol=0,
BOOL noteol=0, BOOL notempty=0, BOOL notempty_atstart=0,
BOOL no_jit=0, BOOL no_utf_check = 0,
ENUM {HARD, SOFT} partial=0, INT recursion_limit=0)
$Function BOOL config_bool(ENUM {JIT, STACKRECURSE, UNICODE},
ENUM {LIB8, LIB16, LIB32} lib=0)
$Function STRING config_str(ENUM {BSR, JITTARGET, NEWLINE,
UNICODE_VERSION, VERSION},
ENUM {LIB8, LIB16, LIB32} lib=0)
$Function INT config_int(ENUM {LINKSIZE, MATCHLIMIT, PARENSLIMIT,
RECURSIONLIMIT}, ENUM {LIB8, LIB16, LIB32} lib=0)
$Function STRING version()
Returns the version string for this VMOD.
Example::
std.log("Using VMOD pcre2 version " + pcre2.version());
REQUIREMENTS
============
This VMOD requires Varnish ...
LIMITATIONS
===========
...
INSTALLATION
============
See `INSTALL.rst <INSTALL.rst>`_ in the source repository.
SEE ALSO
========
* varnishd(1)
* vcl(7)
* source repository: https://code.uplex.de/uplex-varnish/libvmod-pcre2
$Event event
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment