* HTTP/1 native parser as part of the RESTCONF client
* Fixed memory error in opendir/readdir in clicon_file_dirent * Remove MAXPATH in parsers * New string-del function
This commit is contained in:
parent
0ed34b4fab
commit
dadf4a778a
53 changed files with 1061 additions and 1273 deletions
|
|
@ -114,7 +114,7 @@ For example, in FreeBSD, add:
|
|||
|
||||
For fcgi/nginx you need to setup https in the nginx config file, independently of clixon.
|
||||
|
||||
If you use evhtp with `configure --with-restconf=evhtp`, you can prepend the tests with RCPROTO=https which will run all restconf tests with SSL https and server certs.
|
||||
If you use native with `configure --with-restconf=http1`, you can prepend the tests with RCPROTO=https which will run all restconf tests with SSL https and server certs.
|
||||
|
||||
Ensure the server keys are in order, as follows.
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ SHELL = /bin/sh
|
|||
# eg :
|
||||
# HOSTS += vandal.hagsand.com # i86_32 ubuntu
|
||||
# ...
|
||||
# You can also set RESTCONF to fcgi or evhtp
|
||||
# You can also set RESTCONF to fcgi or native
|
||||
RESTCONF=fcgi
|
||||
HOSTS=
|
||||
-include site.mk
|
||||
|
|
|
|||
|
|
@ -42,12 +42,6 @@ ssh -t $h "test -d src/cligen || (cd src;git clone https://github.com/clicon/cli
|
|||
ssh -t $h "(cd src/cligen;git pull origin master)"
|
||||
ssh -t $h "(cd src/cligen;./configure)"
|
||||
ssh -t $h "(cd src/cligen; /tmp/cligen-mk.sh)"
|
||||
# pull git changes and build clixon-libevhtp
|
||||
ssh -t $h "test -d src || mkdir src"
|
||||
ssh -t $h "test -d src/clixon-libevhtp || (cd src;git clone https://github.com/clicon/clixon-libevhtp.git)"
|
||||
ssh -t $h "(cd src/clixon-libevhtp;git pull origin master)"
|
||||
ssh -t $h "(cd src/clixon-libevhtp;./configure)"
|
||||
ssh -t $h "(cd src/clixon-libevhtp; /tmp/cligen-mk.sh)" # re-use cligen
|
||||
# pull git changes and build clixon
|
||||
ssh -t $h "test -d src/clixon || (cd src;git clone https://github.com/clicon/clixon.git)"
|
||||
ssh -t $h "(cd src/clixon;git pull origin master)"
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
#
|
||||
# Copyright (C) 2020-2021 Olof Hagsand and Rubicon Communications, LLC
|
||||
# Copyright (C) 2020-2022 Olof Hagsand and Rubicon Communications, LLC
|
||||
#
|
||||
# This file is part of CLIXON
|
||||
#
|
||||
|
|
@ -37,11 +37,11 @@
|
|||
# This is for RESTCONF. There are three options:
|
||||
# --without-restconf No restconf support
|
||||
# --with-restconf=fcgi FCGI interface for separate web reverse proxy like nginx
|
||||
# --with-restconf=native Integration with embedded web server libevhtp
|
||||
# --with-restconf=native Integration with embedded web server
|
||||
WITH_RESTCONF=@with_restconf@ # native, fcgi or ""
|
||||
|
||||
HAVE_LIBNGHTTP2=@HAVE_LIBNGHTTP2@
|
||||
HAVE_LIBEVHTP=@HAVE_LIBEVHTP@
|
||||
HAVE_HTTP1=@HAVE_HTTP1@
|
||||
|
||||
# This is for libxml2 XSD regex engine
|
||||
# Note this only enables the compiling of the code. In order to actually
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ Make a modification to how Clixon sends internal messages in `include/clixon_cus
|
|||
|
||||
Build clixon statically with the afl-clang compiler:
|
||||
```
|
||||
CC=/usr/bin/afl-clang-fast LINKAGE=static ./configure --with-restconf=evhtp
|
||||
CC=/usr/bin/afl-clang-fast LINKAGE=static ./configure --with-restconf=native
|
||||
make clean
|
||||
make
|
||||
sudo make install
|
||||
|
|
|
|||
|
|
@ -102,11 +102,11 @@ DEFAULTHELLO="<?xml version=\"1.0\" encoding=\"UTF-8\"?><hello $DEFAULTNS><capab
|
|||
# Set HTTP version 1.1 or 2
|
||||
if ${HAVE_LIBNGHTTP2}; then
|
||||
HVER=2
|
||||
if ${HAVE_LIBEVHTP}; then
|
||||
# This is if evhtp is enabled (unset proto=HTTP_2 in restconf_accept_client)
|
||||
if ${HAVE_HTTP1}; then
|
||||
# This is if http/1 is enabled (unset proto=HTTP_2 in restconf_accept_client)
|
||||
CURLOPTS="${CURLOPTS} --http2"
|
||||
else
|
||||
# This is if evhtp is disabled (set proto=HTTP_2 in restconf_accept_client)
|
||||
# This is if http/1 is disabled (set proto=HTTP_2 in restconf_accept_client)
|
||||
CURLOPTS="${CURLOPTS} --http2-prior-knowledge"
|
||||
fi
|
||||
else
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ sed '/Connection:/d' $foutput > $foutput2 && mv $foutput2 $foutput
|
|||
|
||||
# Create a file to compare with
|
||||
if ${HAVE_LIBNGHTTP2}; then
|
||||
if [ ${HAVE_LIBEVHTP} -a ${RCPROTO} = http ]; then
|
||||
if [ ${HAVE_HTTP1} -a ${RCPROTO} = http ]; then
|
||||
# Add 101 switch protocols for http 1->2 upgrade
|
||||
echo "HTTP/1.1 101 Switching Protocols
" > $ftest
|
||||
echo "Upgrade: h2c
" >> $ftest
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ function testrun()
|
|||
fi
|
||||
|
||||
#------------------------------------------------------- HTTP/1 + HTTP/2
|
||||
if [ ${HAVE_LIBNGHTTP2} = true -a ${HAVE_LIBEVHTP} = true ]; then
|
||||
if [ ${HAVE_LIBNGHTTP2} = true -a ${HAVE_HTTP1} = true ]; then
|
||||
|
||||
if [ $proto = http ]; then # No plain http/2
|
||||
HVER=1.1
|
||||
|
|
@ -213,7 +213,7 @@ function testrun()
|
|||
fi
|
||||
|
||||
#------------------------------------------------------- HTTP/2 ONLY
|
||||
elif [ ${HAVE_LIBNGHTTP2} = true -a ${HAVE_LIBEVHTP} = false ]; then
|
||||
elif [ ${HAVE_LIBNGHTTP2} = true -a ${HAVE_HTTP1} = false ]; then
|
||||
HVER=2
|
||||
|
||||
new "wait restconf"
|
||||
|
|
@ -539,7 +539,7 @@ function testrun()
|
|||
# Go thru all combinations of IPv4/IPv6, http/https, local/backend config
|
||||
if [ "${WITH_RESTCONF}" = "fcgi" ]; then
|
||||
protos="http"
|
||||
elif ${HAVE_LIBEVHTP}; then
|
||||
elif ${HAVE_HTTP1}; then
|
||||
protos="http" # No plain http for http/2 only
|
||||
fi
|
||||
if [ "${WITH_RESTCONF}" = "native" ]; then
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@
|
|||
# Magic line must be first in script (see README.md)
|
||||
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
|
||||
if ! ${HAVE_LIBEVHTP}; then
|
||||
echo "...skipped: LIBEVHTP is false, must run with http/1 (evhtp)"
|
||||
if ! ${HAVE_HTTP1}; then
|
||||
echo "...skipped: Must run with http/1"
|
||||
if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
fi
|
||||
|
||||
|
|
|
|||
|
|
@ -23,9 +23,9 @@
|
|||
# Magic line must be first in script (see README.md)
|
||||
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
|
||||
# Does not work with evhtpnative http/2-only
|
||||
if [ "${WITH_RESTCONF}" = "native" -a ${HAVE_LIBEVHTP} = false ]; then
|
||||
echo "...skipped: LIBEVHTP is false, must run with http/1 (evhtp)"
|
||||
# Does not work with native http/2-only
|
||||
if [ "${WITH_RESTCONF}" = "native" -a ${HAVE_HTTP1} = false ]; then
|
||||
echo "...skipped: must run with http/1"
|
||||
if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
fi
|
||||
|
||||
|
|
@ -206,7 +206,7 @@ expectpart "$(curl $CURLOPTS -X GET -H 'Accept: application/yang-data+xml' $RCPR
|
|||
if [ false -a ! ${HAVE_LIBNGHTTP2} ] ; then
|
||||
# Look for netcat or nc for direct socket http calls
|
||||
if [ -n "$(type netcat 2> /dev/null)" ]; then
|
||||
netcat="netcat -w 1" # -N works on evhtp but not fcgi
|
||||
netcat="netcat -w 1" # -N does not work on fcgi
|
||||
elif [ -n "$(type nc 2> /dev/null)" ]; then
|
||||
netcat=nc
|
||||
else
|
||||
|
|
@ -241,9 +241,8 @@ Host: localhost
|
|||
Accept: application/yang-data+xml
|
||||
|
||||
EOF
|
||||
)" 0 "HTTP/$HVER 405" kalle # nginx uses "method not allowed" evhtp "not allowed"
|
||||
)" 0 "HTTP/$HVER 405" kalle # nginx uses "method not allowed"
|
||||
|
||||
# XXX error from evhtp parsing, should pick up error code
|
||||
new "restconf GET wrong http version raw"
|
||||
expectpart "$(${netcat} 127.0.0.1 80 <<EOF
|
||||
GET /restconf/data/example:a=0 HTTP/a.1
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@ if [ "${WITH_RESTCONF}" != "native" ]; then
|
|||
fi
|
||||
|
||||
# Cant make it work in sum.sh...
|
||||
if ! ${HAVE_LIBEVHTP}; then
|
||||
echo "...skipped: LIBEVHTP is false, must run with http/1 (evhtp)"
|
||||
if ! ${HAVE_HTTP1}; then
|
||||
echo "...skipped: must run with http/1"
|
||||
if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
fi
|
||||
|
||||
|
|
@ -85,7 +85,7 @@ function testrun()
|
|||
|
||||
|
||||
|
||||
if [ ${HAVE_LIBNGHTTP2} = false -a ${HAVE_LIBEVHTP} = true ]; then # http/1 only
|
||||
if [ ${HAVE_LIBNGHTTP2} = false -a ${HAVE_HTTP1} = true ]; then # http/1 only
|
||||
|
||||
new "wait restconf"
|
||||
wait_restconf
|
||||
|
|
@ -106,7 +106,7 @@ function testrun()
|
|||
echo "curl -Ssik --http2-prior-knowledge -X GET http://localhost/.well-known/host-meta"
|
||||
expectpart "$(curl -Ssik --http2-prior-knowledge -X GET http://localhost/.well-known/host-meta 2>&1)" "16 52 55"
|
||||
|
||||
elif [ ${HAVE_LIBNGHTTP2} = true -a ${HAVE_LIBEVHTP} = false ]; then # http/2 only
|
||||
elif [ ${HAVE_LIBNGHTTP2} = true -a ${HAVE_HTTP1} = false ]; then # http/2 only
|
||||
|
||||
sleep 2 # Cannot do wait restconf
|
||||
|
||||
|
|
@ -141,7 +141,7 @@ function testrun()
|
|||
expectpart "$(curl -Ssik --http2-prior-knowledge -X GET http://localhost/.well-known/host-meta 2>&1)" 0 "HTTP/2 405"
|
||||
fi
|
||||
|
||||
elif [ ${HAVE_LIBNGHTTP2} = true -a ${HAVE_LIBEVHTP} = true ]; then # http/1 + http/2
|
||||
elif [ ${HAVE_LIBNGHTTP2} = true -a ${HAVE_HTTP1} = true ]; then # http/1 + http/2
|
||||
|
||||
new "wait restconf"
|
||||
wait_restconf
|
||||
|
|
|
|||
|
|
@ -14,9 +14,9 @@
|
|||
# Magic line must be first in script (see README.md)
|
||||
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
|
||||
# Does not work with evhtpnative http/2-only
|
||||
if [ "${WITH_RESTCONF}" = "native" -a ${HAVE_LIBEVHTP} = false ]; then
|
||||
echo "...skipped: LIBEVHTP is false, must run with http/1 (evhtp)"
|
||||
# Does not work with native http/2-only
|
||||
if [ "${WITH_RESTCONF}" = "native" -a ${HAVE_HTTP1} = false ]; then
|
||||
echo "...skipped: Must run with http/1"
|
||||
if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
fi
|
||||
|
||||
|
|
|
|||
|
|
@ -25,9 +25,9 @@
|
|||
# Magic line must be first in script (see README.md)
|
||||
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
|
||||
# Does not work with evhtpnative http/2-only
|
||||
if [ "${WITH_RESTCONF}" = "native" -a ${HAVE_LIBEVHTP} = false ]; then
|
||||
echo "...skipped: LIBEVHTP is false, must run with http/1 (evhtp)"
|
||||
# Does not work with native http/2-only
|
||||
if [ "${WITH_RESTCONF}" = "native" -a ${HAVE_HTTP1} = false ]; then
|
||||
echo "...skipped: Must run with http/1"
|
||||
if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
fi
|
||||
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@ if [ "${WITH_RESTCONF}" != "native" ]; then
|
|||
if [ "$s" = $0 ]; then exit 0; else return 0; fi # skip
|
||||
fi
|
||||
|
||||
if ! ${HAVE_LIBEVHTP}; then
|
||||
echo "...skipped: LIBEVHTP is false, must run with http/1 (evhtp)"
|
||||
if ! ${HAVE_HTTP1}; then
|
||||
echo "...skipped: HAVE_HTTP1 is false, must run with http/1"
|
||||
if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
fi
|
||||
|
||||
|
|
@ -197,7 +197,7 @@ new "netconf commit"
|
|||
expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO<rpc $DEFAULTNS><commit/></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$"
|
||||
|
||||
# NOTE http/1.1
|
||||
if ${HAVE_LIBEVHTP}; then
|
||||
if ${HAVE_HTTP1}; then
|
||||
new "restconf http get config on default netns"
|
||||
expectpart "$(curl $CURLOPTS -X GET -H 'Accept: application/yang-data+xml' http://127.0.0.1/restconf/data/clixon-example:table)" 0 "HTTP/1.1 200" '<table xmlns="urn:example:clixon"><parameter><name>a</name><value>42</value></parameter></table>'
|
||||
fi
|
||||
|
|
@ -211,7 +211,7 @@ expectpart "$(sudo ip netns exec $netns curl $CURLOPTS -X GET -H 'Accept: applic
|
|||
new "restconf https/SSL put table b"
|
||||
expectpart "$(sudo ip netns exec $netns curl $CURLOPTS -X POST -H 'Content-Type: application/yang-data+xml' -d '<parameter xmlns="urn:example:clixon"><name>b</name><value>99</value></parameter>' https://$vaddr/restconf/data/clixon-example:table)" 0 "HTTP/$HVER 201"
|
||||
|
||||
if ${HAVE_LIBEVHTP}; then
|
||||
if ${HAVE_HTTP1}; then
|
||||
# NOTE http/1.1
|
||||
new "restconf http get table b on default ns"
|
||||
expectpart "$(curl $CURLOPTS -X GET -H 'Accept: application/yang-data+xml' http://127.0.0.1/restconf/data/clixon-example:table/parameter=b)" 0 "HTTP/1.1 200" '<parameter xmlns="urn:example:clixon"><name>b</name><value>99</value></parameter>'
|
||||
|
|
|
|||
|
|
@ -215,7 +215,6 @@ case $release in
|
|||
;;
|
||||
native)
|
||||
$sshcmd sudo apt install -y libssl-dev
|
||||
$sshcmd sudo apt install -y libevent-dev # evhtp
|
||||
$sshcmd sudo apt install -y libnghttp2-dev # nghttp2
|
||||
;;
|
||||
esac
|
||||
|
|
@ -269,15 +268,6 @@ case ${with_restconf} in
|
|||
. ./nginx.sh $dir $idfile $port $wwwuser
|
||||
;;
|
||||
native)
|
||||
$sshcmd << EOF
|
||||
test -d src || mkdir src
|
||||
cd src
|
||||
test -d clixon-libevhtp || git clone https://github.com/clicon/clixon-libevhtp.git
|
||||
cd clixon-libevhtp;
|
||||
./configure --libdir=/usr/lib # otherwise in /usr/local/lib where RH dont look
|
||||
make
|
||||
sudo make install
|
||||
EOF
|
||||
;;
|
||||
esac
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue