* To configure native mode use: configure --with-restconf=native, changed from: configure --with-restconf=evhtp

This commit is contained in:
Olof hagsand 2021-04-06 08:48:45 +02:00
parent d874a696f7
commit d8be601606
22 changed files with 76 additions and 70 deletions

View file

@ -19,7 +19,7 @@ default_crl_days = 9999
default_md = md5
[ req ]
default_bits = 1024
default_bits = ${CERTKEYLEN}
days = 1
distinguished_name = req_distinguished_name
attributes = req_attributes
@ -58,7 +58,7 @@ subjectAltName = DNS:clicon.org
EOF
# Generate server key
openssl genrsa -out $srvkey 1024
openssl genrsa -out $srvkey ${CERTKEYLEN}
# Generate CSR (signing request)
openssl req -new -config $dir/srv.cnf -key $srvkey -out $certdir/srv_csr.pem

View file

@ -23,7 +23,7 @@ set -eux # x
if [ $# -ne 2 ]; then
echo "usage: $0 <host> <restconf>"
echo " where <restconf> is fcgi or evhtp"
echo " where <restconf> is fcgi or native"
exit -1
fi

View file

@ -4,7 +4,7 @@ set -eux
if [ $# -ne 1 ]; then
echo "usage: $0 <restconf>"
echo " where <restconf> is fcgi or evhtp"
echo " where <restconf> is fcgi or native"
exit -1
fi
restconf=$1

View file

@ -33,11 +33,11 @@
# Generated from autotools, ie from the ./configure run,
# See configure.ac for source
# 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=evhtp Integration with embedded web server libevhtp
WITH_RESTCONF=@with_restconf@ # evhtp, fcgi or ""
# 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=@with_restconf@ # native, fcgi or ""
# This is for libxml2 XSD regex engine
# Note this only enables the compiling of the code. In order to actually

View file

@ -339,7 +339,7 @@ function stop_restconf(){
# Wait for restconf to stop sending 502 Bad Gateway
# @see start_restconf
# Reasons for not working: if you run evhtp is nginx running?
# Reasons for not working: if you run native is nginx running?
# @note assumes port=80 if RCPROTO=http and port=443 if RCPROTO=https
function wait_restconf(){
# echo "curl $CURLOPTS $* $RCPROTO://localhost/restconf"

View file

@ -28,3 +28,8 @@ IPv6=true
# This check is optional because some installs, such as vagrant make a non-systemd/direct
# start
NGINXCHECK=true
# Lenght of TSL RSA key
# Problem with small key such as 1024 not allowed in centos8 for example (why is this)
# Problem with long keys are they take time to generate, eg on ARM
CERTKEYLEN=2048

View file

@ -1,18 +1,18 @@
#!/usr/bin/env bash
# Restconf basic functionality also uri encoding using eth/0/0
# Note there are many variants: (1)fcgi/evhtp, (2) http/https, (3) IPv4/IPv6, (4)local or backend-config
# (1) fcgi/evhtp
# This is compile-time --with-restconf=fcgi or evhtp, so either or
# Note there are many variants: (1)fcgi/native, (2) http/https, (3) IPv4/IPv6, (4)local or backend-config
# (1) fcgi/native
# This is compile-time --with-restconf=fcgi or native, so either or
# - fcgi: Assume http server setup, such as nginx described in apps/restconf/README.md
# - evhtp: test both local config and get config from backend
# - native: test both local config and get config from backend
# (2) http/https
# - fcgi: relies on nginx has https setup
# - evhtp: generate self-signed server certs
# - native: generate self-signed server certs
# (3) IPv4/IPv6 (only loopback 127.0.0.1 / ::1)
# - The tests runs through both
# - IPv6 by default disabled since docker does not support it out-of-the box
# (4) local/backend config. Evhtp only
# - The tests runs through both (if compiled with evhtp)
# (4) local/backend config. Native only
# - The tests runs through both (if compiled with native)
# See also test_restconf2.sh
# See test_restconf_rpc.sh for cases when CLICON_BACKEND_RESTCONF_PROCESS is set
@ -40,7 +40,7 @@ else
cp /usr/local/share/clixon/$y $dir/
fi
if [ "${WITH_RESTCONF}" = "evhtp" ]; then
if [ "${WITH_RESTCONF}" = "native" ]; then
# Create server certs
certdir=$dir/certs
srvkey=$certdir/srv_key.pem
@ -402,12 +402,12 @@ function testrun()
# Go thru all combinations of IPv4/IPv6, http/https, local/backend config
protos="http"
if [ "${WITH_RESTCONF}" = "evhtp" ]; then
# http only relevant for evhtp (for fcgi: need nginx config)
if [ "${WITH_RESTCONF}" = "native" ]; then
# http only relevant for internal (for fcgi: need nginx config)
protos="$protos https"
fi
for proto in $protos; do
addrs="127.0.0.1"
# addrs="127.0.0.1"
if $IPv6 ; then
addrs="$addrs \[::1\]"
fi

View file

@ -3,7 +3,7 @@
# Note this is not supported by core clixon: you need ca-auth callback implemented a la the example
# For auth-type=none and auth-type=user,
# For auth-type=ssl-certs, See test_restconf.sh test_restconf_ssl_certs.sh
# evhtp? and http only
# native? and http only
# Use the following user settings:
# 1. none (eg no -u to curl)
# 2. anonymous - the registered anonymous user
@ -29,7 +29,7 @@ fyang=$dir/myexample.yang
# No ssl
RCPROTO=http
# Start with common config, then append fcgi/evhtp specific config
# Start with common config, then append fcgi/native specific config
cat <<EOF > $cfg
<clixon-config xmlns="http://clicon.org/config">
<CLICON_CONFIGFILE>$cfg</CLICON_CONFIGFILE>
@ -52,7 +52,7 @@ cat <<EOF > $cfg
</clixon-config>
EOF
# Start with common config, then append fcgi/evhtp specific config
# Start with common config, then append fcgi/native specific config
cat <<EOF > $cfg
<clixon-config xmlns="http://clicon.org/config">
<CLICON_CONFIGFILE>$cfg</CLICON_CONFIGFILE>
@ -195,7 +195,7 @@ function testrun()
# Change restconf configuration before start restconf daemon
restconf_config $auth false
# Start with common config, then append fcgi/evhtp specific config
# Start with common config, then append fcgi/native specific config
cat <<EOF > $cfg
<clixon-config xmlns="http://clicon.org/config">
<CLICON_CONFIGFILE>$cfg</CLICON_CONFIGFILE>

View file

@ -1,5 +1,5 @@
#!/usr/bin/env bash
# Restconf evhtp using socket network namespace (netns) support
# Restconf native using socket network namespace (netns) support
# Listen to a default and a separate netns
# Init running with a=42
# Get the config from default and netns namespace with/without SSL
@ -8,8 +8,8 @@
# Magic line must be first in script (see README.md)
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
# Skip if other than evhtp
if [ "${WITH_RESTCONF}" != "evhtp" ]; then
# Skip if other than native
if [ "${WITH_RESTCONF}" != "native" ]; then
if [ "$s" = $0 ]; then exit 0; else return 0; fi # skip
fi

View file

@ -7,8 +7,8 @@
# Magic line must be first in script (see README.md)
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
# Only works with evhtp and https
if [ "${WITH_RESTCONF}" != "evhtp" ]; then
# Only works with native and https
if [ "${WITH_RESTCONF}" != "native" ]; then
if [ "$s" = $0 ]; then exit 0; else return 0; fi # skip
fi

View file

@ -47,8 +47,8 @@ SHELL = /bin/sh
# VAGRANTS += freebsd/FreeBSD-12.1-STABLE
VAGRANTS =
# evhtp or fcgi
RESTCONF=evhtp
# internal or fcgi
RESTCONF=internal
-include site.mk

View file

@ -5,7 +5,7 @@
# 3. Compile and install clixon
# 4. Run tests
# Example run: ./vagrant.sh generic/centos8 2>&1 | tee cilog
# Default runs evhtp (not fcgi)
# Default runs native (not fcgi)
set -eux #
@ -17,7 +17,7 @@ fi
box=$1 # As defined in https://vagrantcloud.com/search
#with_restconf=fcgi
: ${with_restconf:=evhtp}
: ${with_restconf:=native}
echo "with-restconf:${with_restconf}"
VCPUS=1
@ -111,7 +111,7 @@ case $release in
fcgi)
$sshcmd sudo pkg install -y fcgi-devkit nginx
;;
evhtp)
native)
;;
esac
;;
@ -128,7 +128,7 @@ case $release in
fcgi)
$sshcmd sudo pkg install -y fcgi-devkit nginx
;;
evhtp)
native)
$sshcmd sudo pkg install -y libevent
;;
esac
@ -154,7 +154,7 @@ case $release in
# $sshcmd sudo yum update
$sshcmd sudo yum install -y nginx
;;
evhtp)
native)
$sshcmd sudo yum install -y libevent openssl
$sshcmd sudo yum install -y libevent-devel openssl-devel
;;
@ -177,7 +177,7 @@ case $release in
$sshcmd sudo zypper install -y nginx
buildfcgi=true # build fcgi from source
;;
evhtp)
native)
;;
esac
;;
@ -199,7 +199,7 @@ case $release in
buildfcgi=true # some ubuntu dont have fcgi-dev
$sshcmd sudo apt install -y nginx
;;
evhtp)
native)
# $sshcmd sudo apt install -y libevent-2.1
$sshcmd sudo apt install -y libevent-dev libssl-dev
;;
@ -215,7 +215,7 @@ case $release in
fcgi)
$sshcmd sudo apk add --update nginx fcgi-dev
;;
evhtp)
native)
;;
esac
;;
@ -230,7 +230,7 @@ case $release in
fcgi)
$sshcmd sudo pacman -Syu --noconfirm nginx fcgi
;;
evhtp)
native)
$sshcmd sudo pacman -Syu --noconfirm libevent
;;
esac
@ -253,7 +253,7 @@ case ${with_restconf} in
# Hide all complex nginx config in sub-script
. ./nginx.sh $dir $idfile $port $wwwuser
;;
evhtp)
native)
$sshcmd << EOF
test -d src || mkdir src
cd src