Permalink
Browse files

Created initial autoconf setup

  • Loading branch information...
1 parent ce68f76 commit e9c48d36909d2d090daab038a62ab744c96cdb11 Aurelien Guillaume committed Jul 2, 2011
Showing with 1,116 additions and 0 deletions.
  1. +23 −0 LICENSE
  2. +3 −0 Makefile.am
  3. +45 −0 autogen.sh
  4. +59 −0 configure.ac
  5. BIN examples/.generate-hash.sh.swp
  6. +29 −0 examples/generate-hash.sh
  7. +30 −0 examples/trivial.vcl
  8. +1 −0 m4/PLACEHOLDER
  9. +34 −0 src/Makefile.am
  10. +381 −0 src/md5.c
  11. +91 −0 src/md5.h
  12. +139 −0 src/md5main.c
  13. +45 −0 src/vcc_if.c
  14. +14 −0 src/vcc_if.h
  15. +31 −0 src/vmod.vcc
  16. +191 −0 src/vmod_secdown.c
View
23 LICENSE
@@ -0,0 +1,23 @@
+Copyright (c) 2011 Aurelien Guillaume
+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.
View
@@ -0,0 +1,3 @@
+ACLOCAL_AMFLAGS = -I m4
+
+SUBDIRS = src
View
@@ -0,0 +1,45 @@
+!/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
+
+set -ex
+
+aclocal -I m4
+$LIBTOOLIZE --copy --force
+autoheader
+automake --add-missing --copy --foreign
+autoconf
+
View
@@ -0,0 +1,59 @@
+AC_PREREQ(2.59)
+AC_COPYRIGHT([Copyright (c) 2011 ZephirWorks])
+AC_INIT([libvmod-redis], [0.1])
+AC_CONFIG_MACRO_DIR([m4])
+AC_CONFIG_SRCDIR(src/vmod_redis.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_STDC
+if test "x$ac_cv_prog_cc_c99" = xno; then
+ AC_MSG_ERROR([Could not find a C99 compatible compiler])
+fi
+AC_PROG_CPP
+
+AC_PROG_INSTALL
+AC_PROG_LIBTOOL
+AC_PROG_MAKE_SET
+
+# Check for pkg-config
+PKG_PROG_PKG_CONFIG
+
+# Checks for header files.
+AC_HEADER_STDC
+AC_CHECK_HEADERS([sys/stdlib.h])
+
+# Check for python
+AC_CHECK_PROGS(PYTHON, [python3 python3.1 python3.2 python2.7 python2.6 python2.5 python2 python], [AC_MSG_ERROR([Python is needed to build this vmod, please install python.])])
+
+# Varnish source tree
+AC_ARG_VAR([VARNISHSRC], [path to Varnish source tree (mandatory)])
+if test "x$VARNISHSRC" = x; then
+ AC_MSG_ERROR([No Varnish source tree specified])
+fi
+VARNISHSRC=`cd $VARNISHSRC && pwd`
+AC_CHECK_FILE([$VARNISHSRC/include/varnishapi.h],
+ [],
+ [AC_MSG_FAILURE(["$VARNISHSRC" is not a Varnish source directory])]
+)
+
+# vmod installation dir
+AC_ARG_VAR([VMODDIR], [vmod installation directory @<:@LIBDIR/varnish/vmods@:>@])
+if test "x$VMODDIR" = x; then
+ VMODDIR=`pkg-config --variable=vmoddir varnishapi`
+ if test "x$VMODDIR" = x; then
+ AC_MSG_FAILURE([Can't determine vmod installation directory])
+ fi
+fi
+
+AC_CONFIG_FILES([
+ Makefile
+ src/Makefile
+])
+AC_OUTPUT
Binary file not shown.
View
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+if [[ -z "$1" || -z "$2" || -z "$3" ]]; then
+ echo "Usage: $0 [secret] [filepath] [time]"
+ echo "Time is the URL validity time in seconds."
+ exit 1
+fi
+
+date=`date +%s`
+
+secret="$1"
+url="$2"
+expire=$(($date + $3))
+
+echo " -> Expires in $3 secs, $date -> $expire."
+
+hextime=$(printf "%x" $expire)
+
+echo " -> Expiry time is $hextime."
+
+string="$url/$secret/$hextime"
+
+echo " -> Hash string is $string"
+
+hash=$(echo -n "${string}" | md5sum | cut '-d ' -f1)
+
+echo " -> Hash is $hash"
+
+echo "The full protected file path is: $url/$hash/$hextime"
View
@@ -0,0 +1,30 @@
+#
+# A trivial example of how to use vmod_secdown to protect a particular directory
+# See generate-hash.sh to get yourself a valid download link.
+#
+# E.g.:
+# # ./generate-hash.sh h4ackm3 /protected/1024.rnd 30
+# -> Expires in 30 secs, 1309636072 -> 1309636102.
+# -> Expiry time is 4e0f7606.
+# -> Hash string is /protected/1024.rnd/h4ackm3/4e0f7606
+# -> Hash is 90e4c5513880d97e3a83cb5cd3a20bbd
+# The full protected file path is: /protected/1024.rnd/90e4c5513880d97e3a83cb5cd3a20bbd/4e0f7606
+#
+# You can enter in your browser, to access your file:
+# http://<cache_url>/protected/1024.rnd/90e4c5513880d97e3a83cb5cd3a20bbd/4e0f7606
+#
+
+import secdown;
+
+backend default {
+ .host = "127.0.0.1";
+ .port = "8080";
+}
+
+sub vcl_recv {
+ # Apply only to files in /protected on the backend.
+ if (req.url ~ "^/protected/") {
+ set req.url = secdown.check_url(req.url, "h4ckm3", "/expired.html", "/error.html");
+ }
+}
+
View
@@ -0,0 +1 @@
+
View
@@ -0,0 +1,34 @@
+
+INCLUDES = -I$(VARNISHSRC)/include -I$(VARNISHSRC) -I/usr/include
+
+dist_man_MANS = vmod_secdown.3
+
+vmoddir = $(VMODDIR)
+vmod_LTLIBRARIES = libvmod_secdown.la
+
+libvmod_secdown_la_LDFLAGS = -module -export-dynamic -version-info 1:0:0
+
+libvmod_secdown_la_SOURCES = \
+ vcc_if.c \
+ vcc_if.h \
+ vmod_secdown.c \
+ md5.c
+
+vcc_if.c vcc_if.h: $(VARNISHSRC)/lib/libvmod_std/vmod.py $(top_srcdir)/src/vmod.vcc
+ @PYTHON@ $(VARNISHSRC)/lib/libvmod_std/vmod.py $(top_srcdir)/src/vmod.vcc
+
+EXTRA_DIST = vmod.vcc
+
+CLEANFILES = $(builddir)/vcc_if.c $(builddir)/vcc_if.h
+
+vmod_secdown.3: $(top_srcdir)/README.rst
+
+if HAVE_RST2MAN
+ ${RST2MAN} $? $@
+else
+ @echo "========================================"
+ @echo "You need rst2man installed to make dist"
+ @echo "========================================"
+ @false
+endif
+
Oops, something went wrong.

0 comments on commit e9c48d3

Please sign in to comment.