diff --git a/CHANGELOG.md b/CHANGELOG.md index 647d36105..c27e67036 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,43 @@ +# Release 0.19.12 + +## What's New + +* Revert dial error messages to what sdks are expecting. Add error codes so future sdks don't have to parse error text +* Add router events +* Allow filters with no predicate if sort or paging clauses are provided + * Ex: instead of `true limit 5` you could have just `limit 5`. Or instead of `true sort by name` you could have `sort by name` +* Corrected host.v1 configuration type schema to prevent empty port range objects + +## Router events + +To enable: + +``` +events: + jsonLogger: + subscriptions: + - type: fabric.routers +``` + +Example JSON output: + +``` +{ + "namespace": "fabric.routers", + "event_type": "router-online", + "timestamp": "2021-04-22T11:26:31.99299884-04:00", + "router_id": "JAoyjafljO", + "router_online": true +} +{ + "namespace": "fabric.routers", + "event_type": "router-offline", + "timestamp": "2021-04-22T11:26:41.335114358-04:00", + "router_id": "JAoyjafljO", + "router_online": false +} +``` + # Release 0.19.11 ## What's New diff --git a/etc/ctrl.with.edge.yml b/etc/ctrl.with.edge.yml index 589717a9d..b7648b6d8 100644 --- a/etc/ctrl.with.edge.yml +++ b/etc/ctrl.with.edge.yml @@ -41,7 +41,7 @@ mgmt: # the number of milliseconds to wait before a hello synchronization fails and closes the connection (30ms to 60000ms, default: 1000ms) #connectTimeoutMs: 3000 -metrics: +#metrics: #file: #path: /tmp/ziti-controller-metrics.log #maxsizemb: 100:wq @@ -55,6 +55,7 @@ metrics: #events: # jsonLogger: # subscriptions: +# - type: fabric.routers # - type: fabric.terminators # - type: metrics # sourceFilter: .* diff --git a/go.mod b/go.mod index 8a941efad..8c589009d 100644 --- a/go.mod +++ b/go.mod @@ -27,10 +27,10 @@ require ( github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d github.com/keybase/go-ps v0.0.0-20190827175125-91aafc93ba19 github.com/michaelquigley/pfxlog v0.3.7 - github.com/openziti/edge v0.19.83 - github.com/openziti/fabric v0.16.54 - github.com/openziti/foundation v0.15.48 - github.com/openziti/sdk-golang v0.15.40 + github.com/openziti/edge v0.19.90 + github.com/openziti/fabric v0.16.56 + github.com/openziti/foundation v0.15.49 + github.com/openziti/sdk-golang v0.15.43 github.com/pborman/uuid v1.2.0 github.com/pkg/errors v0.9.1 github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 diff --git a/go.sum b/go.sum index 4af1f6ee3..5112b2431 100644 --- a/go.sum +++ b/go.sum @@ -614,14 +614,14 @@ github.com/openziti/bbolt v1.3.6-0.20210317142109-547da822475e h1:ST9+54UtCr96S5 github.com/openziti/bbolt v1.3.6-0.20210317142109-547da822475e/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= github.com/openziti/dilithium v0.3.3 h1:PLgQ6PMNLSTzCFbX/h98cmudgz/cU6TmjdSv5NAPD8k= github.com/openziti/dilithium v0.3.3/go.mod h1:vsCjI2AU/hon9e+dLhUFbCNGesJDj2ASgkySOcpmvjo= -github.com/openziti/edge v0.19.83 h1:+DgptVlQIN9j95uX2LmUBgJmCS7qnBEKVCTeirNT/Vw= -github.com/openziti/edge v0.19.83/go.mod h1:atmbRzo8tAXatznFhQaM3BZlFJZxTq12OIGZazKz7J8= -github.com/openziti/fabric v0.16.54 h1:jfuAv5p73Uu7E2L26TBFoO+ZF5mzeAHgA9CSU8d+rfE= -github.com/openziti/fabric v0.16.54/go.mod h1:fb5zFkB3YQxusAmsQLKKzEk7MmPodqDkqmOVTB+J3eE= -github.com/openziti/foundation v0.15.48 h1:NnL/xY684XeFiLBi5z0+uKf2tpPhlClbMeVmUQPF8Jo= -github.com/openziti/foundation v0.15.48/go.mod h1:NnSBTp9ZkcYsv6nYxZR0/NzoHfkIo6tjpBHDvBsPFqw= -github.com/openziti/sdk-golang v0.15.40 h1:AXAE4qeWf5TLO1ZCamaTTOdfCmWITWyeM4g+RVZDO5U= -github.com/openziti/sdk-golang v0.15.40/go.mod h1:yo85e6HhAL1+PrRjgrsL/ZgkyAcdqVxy4Ws1UMrogss= +github.com/openziti/edge v0.19.90 h1:hMNoyVsw2VaYikfCLwvlHJnzTCCUiZtKJ7Zw2lpPPhg= +github.com/openziti/edge v0.19.90/go.mod h1:PFQ6g4shFA4WWUQW5O6DZBDyxW51bSkQyUFtGbz1feM= +github.com/openziti/fabric v0.16.56 h1:qUYmU3EvppPzivpHo8FxjbyTupMeBauDxlwQG2eAh6c= +github.com/openziti/fabric v0.16.56/go.mod h1:Okz2xHYivh3N1UovAcQt0xSx2Kb8QWA0VpQ20zB2xD4= +github.com/openziti/foundation v0.15.49 h1:dXyqQFD4myl+ILCnj4+024peoT3RR1UTZZx974v6wlU= +github.com/openziti/foundation v0.15.49/go.mod h1:NnSBTp9ZkcYsv6nYxZR0/NzoHfkIo6tjpBHDvBsPFqw= +github.com/openziti/sdk-golang v0.15.43 h1:Lz65VocDRtdt0aR0JmK767UkRvtEz4Wm4PG4/bvJuDM= +github.com/openziti/sdk-golang v0.15.43/go.mod h1:UN6ECAN/VdwApuIQg8+zudTL5Si4PgbN73xhQXKc4o0= github.com/oracle/oci-go-sdk v24.2.0+incompatible/go.mod h1:VQb79nF8Z2cwLkLS35ukwStZIg5F66tcBccjip/j888= github.com/orcaman/concurrent-map v0.0.0-20190826125027-8c72a8bb44f6/go.mod h1:Lu3tH6HLW3feq74c2GC+jIMS/K2CFcDWnWD9XkenwhI= github.com/orcaman/concurrent-map v0.0.0-20210106121528-16402b402231 h1:fa50YL1pzKW+1SsBnJDOHppJN9stOEwS+CRWyUtyYGU= diff --git a/quickstart/local/.gitignore b/quickstart/local/.gitignore new file mode 100644 index 000000000..53775df99 --- /dev/null +++ b/quickstart/local/.gitignore @@ -0,0 +1 @@ +/dnsmasq.conf diff --git a/quickstart/local/docker-compose.yml b/quickstart/local/docker-compose.yml new file mode 100644 index 000000000..e4e23ebc5 --- /dev/null +++ b/quickstart/local/docker-compose.yml @@ -0,0 +1,10 @@ +version: '3.3' +services: + dns: + restart: "no" + image: strm/dnsmasq + volumes: + - ./dnsmasq.conf:/etc/dnsmasq.conf + network_mode: host + cap_add: + - NET_ADMIN diff --git a/quickstart/local/env.sh b/quickstart/local/env.sh index 113c74895..ca6a0ba97 100755 --- a/quickstart/local/env.sh +++ b/quickstart/local/env.sh @@ -4,7 +4,7 @@ export PFXLOG_NO_JSON=true # make the quickstart home folder where all the config files, logs, etc will go -export ZITI_HOME=~/.ziti/quickstart/${network_name} +export ZITI_HOME=${HOME}/.ziti/quickstart/${network_name} export ZITI_POSTGRES_HOST="localhost" export ZITI_NETWORK=${network_name} export ZITI_USER="admin" diff --git a/quickstart/local/init.sh b/quickstart/local/init.sh index 116a7a0ff..5b86763fe 100755 --- a/quickstart/local/init.sh +++ b/quickstart/local/init.sh @@ -64,6 +64,9 @@ echo " example:" echo " 127.0.0.1 ${ZITI_CONTROLLER_HOSTNAME} ${ZITI_EDGE_HOSTNAME} ${ZITI_ZAC_HOSTNAME} ${ZITI_EDGE_ROUTER_HOSTNAME} ${ZITI_EDGE_WSS_ROUTER_HOSTNAME} ${ZITI_ROUTER_BR_HOSTNAME} ${ZITI_ROUTER_BLUE_HOSTNAME} ${ZITI_ROUTER_RED_HOSTNAME}" echo "" +DIRNAME=$(dirname $0) +[[ ${USE_DNSMASQ:-} -eq 1 ]] && source ${DIRNAME}/run-dns.sh + while true; do read -p "Are the hosts in your hosts file? " yn case $yn in @@ -93,16 +96,16 @@ fi . ${curdir}/start-ziti.sh . ${curdir}/test-ziti.sh -echo "staring a new bash shell to retain all environment variables without polluting the initial shell" +echo "starting a new bash shell to retain all environment variables without polluting the initial shell" bash --rcfile <(cat << HERE -. ~/.bashrc +. ~/.bashrc . ~/.bash_aliases export PS1="ZITI IS RUNNING ${network_name}: " echo "adding pki-functions to bash shell" . ${curdir}/pki-functions.sh -alias zec='ziti edge controller' +alias zec='ziti edge' alias zlogin='ziti edge controller login "${ZITI_EDGE_API_HOSTNAME}" -u "${ZITI_USER}" -p "${ZITI_PWD}" -c "${ZITI_PKI}/${ZITI_EDGE_ROOTCA_NAME}/certs/${ZITI_EDGE_INTERMEDIATE_NAME}.cert"' alias psz='ps -ef | grep ziti' diff --git a/quickstart/local/restart-ziti.sh b/quickstart/local/restart-ziti.sh index 318bf53b4..0e6cb36ec 100755 --- a/quickstart/local/restart-ziti.sh +++ b/quickstart/local/restart-ziti.sh @@ -1,9 +1,18 @@ +#!/usr/bin/env bash +set -euo pipefail # set a variable to the location of the script running in case it's needed export curdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -export network_name="${USER}" +if [[ $# -ne 0 ]]; then + export network_name=$1 +else + export network_name="${USER}" +fi -. ${curdir}/env.sh +source ${curdir}/env.sh + +DIRNAME=$(dirname $0) +[[ ${USE_DNSMASQ:-} -eq 1 ]] && source ${DIRNAME}/run-dns.sh ziti-controller -v run "${ZITI_HOME}/controller.yaml" > "${ZITI_HOME}/ziti-controller.log" 2>&1 & # sleep 2 diff --git a/quickstart/local/run-dns.sh b/quickstart/local/run-dns.sh new file mode 100755 index 000000000..1bd6fd17c --- /dev/null +++ b/quickstart/local/run-dns.sh @@ -0,0 +1,44 @@ +#!/dev/null +# +# blame(ken) +# +# source this after sourcing env.sh to append required domain names to the dnsmasq.conf in the same dir which is mounted on dnsmasq server by docker-compose.yml + +# DIRNAME defined by init.sh before sourcing this because it's problematic to determine the value of the sourced file in a shell-portable manner +[[ ! -z ${DIRNAME:-} ]] || { + echo "ERROR: not configuring dnsmasq because DIRNAME is not defined." >&2 +} + +# expected in same directory as docker-compose.yml +[[ -s ${DIRNAME}/docker-compose.yml ]] || { + echo "ERROR: missing ${DIRNAME}/docker-compose" +} + +DNSCONF=${DIRNAME}/dnsmasq.conf +[[ -s ${DNSCONF} ]] && { + echo "WARN: clobbered ${DNSCONF}" >&2 +} || { + echo "INFO: created ${DNSCONF}" +} + +cat <| ${DNSCONF} +port=53 +listen-address=${NAMESERVER1:-127.0.0.123} +bind-interfaces +#log all dns queries +log-queries +#don't use host's nameservers in /etc/resolv.conf, only use upstreams define in this conf +no-resolv +# don't forward plain names, only FQDNs +domain-needed +#use google as default nameservers +server=1.1.1.1 +server=8.8.8.8 +#explicitly defines host-ip mappings appended by init.sh +EOF + +for DOMAIN_NAME in ${ZITI_CONTROLLER_HOSTNAME} ${ZITI_EDGE_HOSTNAME} ${ZITI_ZAC_HOSTNAME} ${ZITI_EDGE_ROUTER_HOSTNAME} ${ZITI_EDGE_WSS_ROUTER_HOSTNAME} ${ZITI_ROUTER_BR_HOSTNAME} ${ZITI_ROUTER_BLUE_HOSTNAME} ${ZITI_ROUTER_RED_HOSTNAME}; do + echo "address=/${DOMAIN_NAME}/127.0.0.1" >> ${DNSCONF} +done + +docker-compose --file ${DIRNAME}/docker-compose.yml up --detach dns \ No newline at end of file diff --git a/ziti-tunnel/docker/BUILD.md b/ziti-tunnel/docker/BUILD.md index 2e4ff82fd..95f8c9b86 100644 --- a/ziti-tunnel/docker/BUILD.md +++ b/ziti-tunnel/docker/BUILD.md @@ -1,4 +1,4 @@ -The Dockerfile and scripts in this directory build a ziti-tunnel Docker image. +The Dockerfile and scripts in this directory build a `ziti-tunnel` (Go tunneler) Docker image. This procedure is highly similar to that of the `ziti-edge-tunnel` (C tunneler) Docker image [documented here](https://github.com/openziti/ziti-tunnel-sdk-c/blob/main/docker/BUILD.md). Ziti binaries are downloaded from https://netfoundry.artifactory.io/netfoundry/ziti-release by default. The following build arguments are supported: @@ -47,13 +47,13 @@ the image to a public registry. 3. Create a Builder Instance - $ docker buildx create --use + $ docker buildx create --use --name=ziti-builder ## Building Run `docker buildx` like this: - $ ziti_version="0.15.3" + $ ziti_version="0.19.11" $ docker buildx build \ --platform linux/amd64,linux/arm/v7,linux/aarch64 \ --build-arg ZITI_VERSION="${ziti_version}" \ @@ -66,10 +66,10 @@ Notes: Unfortunately `buildx` doesn't currently support building images directly into the local docker cache. Although the `--load` and `--output=type=docker` options - exist, the underlying capability will be implemented in a future docker release - (see https://github.com/docker/buildx/issues/59). In the meantime, you'll need - to push your image builds (with the `--push` build option) and then pull them to - run the image locally when building with `buildx`. + exist, the underlying capability to load a multi-platform image (OCI) will be + implemented in a future Docker release (see https://github.com/docker/buildx/issues/59). + In the meantime, you'll need to push your image builds (with the `--push` build option) + and then pull them to run the image locally when building with `buildx`. - The armv8 image uses armv7 (32-bit) ziti executables. The 32-bit compatibility libraries are installed in the image, but your Arm CPU must support 32-bit emulation. @@ -87,7 +87,26 @@ This build method produces an image for the CPU that is running the build host (typically amd64), and places the resulting image into your local Docker image cache. - $ ziti_version="0.15.3" \ + $ git fetch --tags && git tag -l | sort -Vr | head -1 + v0.19.11 + $ ziti_version="0.19.11" \ $ docker build \ --build-arg ZITI_VERSION="${ziti_version}" \ -t "netfoundry/ziti-tunnel:${ziti_version}" . + +## Shell Script for Linux + + $ ./buildx.sh -h + Usage: VARIABLES ./buildx.sh [OPTION]... + + Build multi-platform Docker container image on Linux. + + VARIABLES + ZITI_VERSION e.g. "0.16.1" corresponding to Git tag "v0.16.1" + + OPTIONS + -r REPO container image repository e.g. netfoundry/ziti-edge-tunnel + -c don't check out v${ZITI_VERSION} (use Git working copy) + + EXAMPLES + ZITI_VERSION=0.19.11 ./buildx.sh -r netfoundry/ziti-tunnel diff --git a/ziti-tunnel/docker/buildx.sh b/ziti-tunnel/docker/buildx.sh new file mode 100755 index 000000000..03d327b76 --- /dev/null +++ b/ziti-tunnel/docker/buildx.sh @@ -0,0 +1,79 @@ +#!/usr/bin/env bash +set -euo pipefail + +_usage(){ + cat >&2 <<-EOF +Usage: VARIABLES ./buildx.sh [OPTION]... + +Build multi-platform Docker container image on Linux. + +VARIABLES + ZITI_VERSION e.g. "0.16.1" corresponding to Git tag "v0.16.1" + +OPTIONS + -r REPO container image repository e.g. netfoundry/ziti-edge-tunnel + -c don't check out v\${ZITI_VERSION} (use Git working copy) + + +EXAMPLES + ZITI_VERSION=0.16.1 ./buildx.sh -c + +REFERENCE + https://github.com/openziti/ziti-tunnel-sdk-c/blob/main/docker/BUILD.md +EOF + [[ $# -eq 1 ]] && { + return $1 + } || { + return 0 + } +} + +BASENAME=$(basename $0) || exit $? +DIRNAME=$(dirname $0) || exit $? + +while getopts :r:c OPT;do + case $OPT in + r) CONTAINER_REPO=$OPTARG + ;; + c) FLAGS+=$OPT # don't checkout vZITI_VERSION + ;; + h) _usage; exit 0 # not an error + ;; + *|\?) _usage 1 # error + ;; + esac +done +shift "$((OPTIND-1))" + +# default to latest +: ${ZITI_VERSION:=$(git fetch --quiet --tags && git tag -l|sort -Vr|head -1|sed -E 's/^v(.*)/\1/')} + +# required opts +[[ ! -z ${CONTAINER_REPO:+true} ]] || { + echo "ERROR: missing -r REPO option to define container image repository name for image push" >&2 + _usage; exit 1 +} + +if [[ ${FLAGS:-} =~ c ]]; then + echo "WARN: not checking out Git tag v${ZITI_VERSION}" +else + git diff --exit-code # bail if unstaged differences + git fetch --tags + git checkout v${ZITI_VERSION} +fi + +docker run --rm --privileged docker/binfmt:a7996909642ee92942dcd6cff44b9b95f08dad64 +egrep -q enabled /proc/sys/fs/binfmt_misc/qemu-arm +docker run --rm arm64v8/alpine uname -a|egrep -q 'aarch64 Linux' +docker run --rm arm32v7/alpine uname -a|egrep -q 'armv7l Linux' + +docker buildx create --use --name=ziti-builder 2>/dev/null || docker buildx use --default ziti-builder + +docker buildx build $DIRNAME \ + --platform linux/amd64,linux/arm/v7,linux/arm64 \ + --build-arg ZITI_VERSION=${ZITI_VERSION} \ + --tag ${CONTAINER_REPO}:${ZITI_VERSION} \ + --tag ${CONTAINER_REPO}:latest \ + --push + +docker buildx stop ziti-builder