Merge pull request #583 from openziti/release-next

Release v0.24.5
This commit is contained in:
Andrew
2022-02-01 11:26:37 -05:00
committed by GitHub
37 changed files with 1171 additions and 730 deletions
+1
View File
@@ -0,0 +1 @@
/release/
+5 -4
View File
@@ -5,7 +5,6 @@ on:
branches:
- main
- release-v*
- builx-action # TODO: prune after initial testing
pull_request:
workflow_dispatch:
@@ -105,9 +104,11 @@ jobs:
$(go env GOPATH)/bin/ziti-ci configure-git
$(go env GOPATH)/bin/ziti-ci generate-build-info common/version/info_generated.go version
go install github.com/mitchellh/gox@latest
CGO_ENABLED=true $(go env GOPATH)/bin/gox -os=linux -arch=amd64 -output=$GOX_OUTPUT ./...
CC=arm-linux-gnueabihf-gcc CGO_ENABLED=true gox -cgo -os=linux -arch=arm -output=$GOX_OUTPUT ./...
CC=aarch64-linux-gnu-gcc CGO_ENABLED=true gox -cgo -os=linux -arch=arm64 -output=$GOX_OUTPUT ./...
$(go env GOPATH)/bin/gox -cgo -os=linux -arch=amd64 -output=${GOX_OUTPUT} ./...
CC=arm-linux-gnueabihf-gcc \
$(go env GOPATH)/bin/gox -cgo -os=linux -arch=arm -output=${GOX_OUTPUT} ./...
CC=aarch64-linux-gnu-gcc \
$(go env GOPATH)/bin/gox -cgo -os=linux -arch=arm64 -output=${GOX_OUTPUT} ./...
aws s3 sync --no-progress s3://ziti-cmd-build-tmp/${{ github.run_id }} release/
aws s3 rm --recursive s3://ziti-cmd-build-tmp/${{ github.run_id }}
+570 -265
View File
File diff suppressed because it is too large Load Diff
+22 -60
View File
@@ -1,70 +1,32 @@
FROM ubuntu:18.04
FROM debian:bullseye-slim
#
# this file mirrors the build params used in the GitHub Actions and enables
# reproducible builds for downstream forks and Ziti contributors
# reproducible builds for downstream forks for Ziti contributors
#
ARG latest_golang=1.17.2
ARG go_distribution_file=go${latest_golang}.linux-amd64.tar.gz
ARG GOPATH=/root/go
ARG GOROOT=/usr/local/go
RUN apt-get update
RUN apt-get -yq install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf gcc-aarch64-linux-gnu
RUN apt-get -yq install wget build-essential
RUN wget -q https://golang.org/dl/${go_distribution_file}
ARG go_path=/usr/share/go
ARG go_root=/usr/local/go
ARG go_cache=/usr/share/go_cache
ARG uid=1000
ARG gid=1000
RUN apt-get -y update
RUN apt-get -y install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf gcc-aarch64-linux-gnu
RUN apt-get -y install wget build-essential
RUN wget -q https://go.dev/dl/${go_distribution_file}
RUN tar -xzf ${go_distribution_file} -C /usr/local/
RUN mkdir ${GOPATH}
ENV GOPATH=${GOPATH}
ENV GOROOT=${GOROOT}
ENV PATH=$GOPATH/bin:$GOROOT/bin:$PATH
RUN mkdir ${go_path} ${go_cache}
RUN chown -R ${uid}:${gid} ${go_path} ${go_cache}
USER ${uid}:${gid}
ENV GOPATH=${go_path}
ENV GOROOT=${go_root}
ENV GOCACHE=${go_cache}
ENV PATH=${go_path}/bin:${go_root}/bin:$PATH
RUN go install github.com/mitchellh/gox@latest
WORKDIR /mnt
CMD ["./linux-build.sh"]
ENTRYPOINT ["./linux-build.sh"]
##
# build this Dockerfile
##
#
# MINIMUM_GOLANG=$(grep -Po '^go\s+\K\d+\.\d+(\.\d+)?$' go.mod)
# LATEST_GOLANG=$(curl -sSf "https://golang.org/VERSION?m=text" | /bin/grep -Po '^go(\s+)?\K\d+\.\d+\.\d+$')
# docker build --tag=zitibuilder --file=Dockerfile.linux-build --build-arg latest_golang=${LATEST_GOLANG} .
##
# build Ziti
##
# docker run --rm --name=zitibuilder --volume=$PWD:/mnt zitibuilder
# $ tree ./release
# ./release
# ├── amd64
# │   └── linux
# │   ├── ziti
# │   ├── ziti-controller
# │   ├── ziti-fabric
# │   ├── ziti-fabric-gw
# │   ├── ziti-fabric-test
# │   ├── ziti-probe
# │   ├── ziti-router
# │   └── ziti-tunnel
# ├── arm
# │   └── linux
# │   ├── ziti
# │   ├── ziti-controller
# │   ├── ziti-fabric
# │   ├── ziti-fabric-gw
# │   ├── ziti-fabric-test
# │   ├── ziti-probe
# │   ├── ziti-router
# │   └── ziti-tunnel
# └── arm64
# └── linux
# ├── ziti
# ├── ziti-controller
# ├── ziti-fabric
# ├── ziti-fabric-gw
# ├── ziti-fabric-test
# ├── ziti-probe
# ├── ziti-router
# └── ziti-tunnel
# 6 directories, 24 files
+85 -2
View File
@@ -5,7 +5,12 @@ configuration files that are maintained with the source code as well as Docker t
## Dependencies
- Go 1.12+
You may verify the currently-required version of Go with this command, or by peeking inside the file named `go.mod`.
```bash
$ /bin/grep -Po '^go\s+\K\d+\.\d+$' go.mod
1.17
```
## Debugging
@@ -19,8 +24,86 @@ This guide can be used to run all of the Ziti applications via command line or i
- `git clone https://github.com/openziti/ziti.git`
2. Change into the `ziti` dirrectory
- `cd ziti`
3. Build
3. Build all commands
- `go install ./...`
4. Build one command
```bash
ZITI_CMD=ziti-tunnel
rm -f ./build/${ZITI_CMD} \
&& mkdir -p ./build \
&& go build -o ./build/${ZITI_CMD} ./${ZITI_CMD}/cmd/${ZITI_CMD}/ \
&& ls -lARh ./build/${ZITI_CMD}
```
### Multi-Platform Linux Builder Container
The purpose of this container is to document the process of building locally the Linux executables in the same way as the GitHub Actions workflow (CI) which automation is not accessible to downstream contributors. By default, this produces three executables for each Ziti component, one for each platform architecture: amd64, arm, arm64. You may instead build for one or more of these by specifying the architecture as a parameter to the `docker run` command as shown below.
#### Build the Container Image
You only need to build the container image once unless you change the Dockerfile or `./linux-build.sh` (the container's entrypoint).
```bash
# find the latest Go distribution's semver
LATEST_GOLANG=$(curl -sSfL "https://go.dev/VERSION?m=text" | /bin/grep -Po '^go(\s+)?\K\d+\.\d+\.\d+$')
# build a container image named "zitibuilder" with the Dockerfile in the top-level of this repo
docker build \
--tag=zitibuilder \
--file=Dockerfile.linux-build \
--build-arg latest_golang=${LATEST_GOLANG} \
--build-arg uid=$UID \
--build-arg gid=$GID .
```
#### Run the Container to Build Executables for the Desired Architectures
Executing the following `docker run` command will:
1. Mount the top-level of this repo on the container's `/mnt`
2. Run `./linux-build.sh ${@}` inside the container
3. Deposit built executables in `./release`
```bash
# build for all three architectures: amd64 arm arm64
docker run \
--rm \
--name=zitibuilder \
--volume=$PWD:/mnt \
zitibuilder
# build only amd64
docker run \
--rm \
--name=zitibuilder \
--volume=$PWD:/mnt \
zitibuilder \
amd64
```
You will find the built artifacts in `./release`.
```bash
$ tree ./release
./release
├── amd64
│   └── linux
│   ├── ziti
│   ├── ziti-controller
│   ├── ziti-router
│   └── ziti-tunnel
├── arm
│   └── linux
│   ├── ziti
│   ├── ziti-controller
│   ├── ziti-router
│   └── ziti-tunnel
└── arm64
└── linux
├── ziti
├── ziti-controller
├── ziti-router
└── ziti-tunnel
```
### Initializing the Controller
Before you can run the controller you have to initialize it's database with an administrative user. Assuming you want to run with the edge enabled, this can be done using as follows:
+36 -16
View File
@@ -20,16 +20,24 @@ identity:
# the endpoint that routers will connect to the controller over.
ctrl:
listener: tls:127.0.0.1:6262
# options:
# (optional) settings
# set the maximum number of connect requests that are buffered and waiting to be acknowledged (1 to 5000, default 1000)
#maxQueuedConnects: 50
# the maximum number of connects that have begun hello synchronization (1 to 1000, default 16)
#maxOutstandingConnects: 100
# the number of milliseconds to wait before a hello synchronization fails and closes the connection (30ms to 60000ms, default: 1000ms)
#connectTimeoutMs: 3000
# Sets the control channel write timeout. A write timeout will close the control channel, so the router will reconnect
#writeTimeout: 15s
options:
# (optional) settings
# set the maximum number of connect requests that are buffered and waiting to be acknowledged (1 to 5000, default 1000)
#maxQueuedConnects: 50
# the maximum number of connects that have begun hello synchronization (1 to 1000, default 16)
#maxOutstandingConnects: 100
# the number of milliseconds to wait before a hello synchronization fails and closes the connection (30ms to 60000ms, default: 1000ms)
#connectTimeoutMs: 3000
# Sets the control channel write timeout. A write timeout will close the control channel, so the router will reconnect
#writeTimeout: 15s
# A listener address which will be sent to connecting routers in order to change their configured controller
# address. If defined, routers will update address configuration to immediately use the new address for future
# connections. The value of newListener must be resolvable both via DNS and validate via certificates
#newListener: tls:localhost:6262
# the endpoint that management tools connect to the controller over.
mgmt:
@@ -37,13 +45,13 @@ mgmt:
#options:
# (optional) settings
# set the maximum number of connect requests that are buffered and waiting to be acknowledged (1 to 5000, default 1000)
#maxQueuedConnects: 50
# the maximum number of connects that have begun hello synchronization (1 to 1000, default 16)
#maxOutstandingConnects: 100
# the number of milliseconds to wait before a hello synchronization fails and closes the connection (30ms to 60000ms, default: 1000ms)
#connectTimeoutMs: 3000
#maxQueuedConnects: 50
# the maximum number of connects that have begun hello synchronization (1 to 1000, default 16)
#maxOutstandingConnects: 100
# 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
@@ -153,10 +161,17 @@ web:
#interface - required
# A host:port string on which network interface to listen on. 0.0.0.0 will listen on all interfaces
- interface: 127.0.0.1:1280
# address - required
# The public address that external incoming requests will be able to resolve. Used in request processing and
# response content that requires full host:port/path addresses.
address: 127.0.0.1:1280
# newAddress - optional
# A host:port string which will be sent out as an HTTP header "ziti-new-address" if specified. If the header
# is present, clients should update location configuration to immediately use the new address for future
# connections. The value of newAddress must be resolvable both via DNS and validate via certificates
newAddress: localhost:1280
# identity - optional
# Allows the webListener to have a specific identity instead of defaulting to the root `identity` section.
# identity:
@@ -173,21 +188,26 @@ web:
# can cause resources on the host to be consumed as clients remain connected and idle. Lowering this value
# will cause clients to reconnect on subsequent HTTPs requests.
idleTimeout: 5000ms #http timeouts, new
# readTimeout - optional, default 5000ms
# The maximum amount of time in milliseconds http servers will wait to read the first incoming requests. A higher
# value risks consuming resources on the host with clients that are acting bad faith or suffering from high latency
# or packet loss. A lower value can risk losing connections to high latency/packet loss clients.
readTimeout: 5000ms
# writeTimeout - optional, default 10000ms
# The total maximum time in milliseconds that the http server will wait for a single requests to be received and
# responded too. A higher value can allow long running requests to consume resources on the host. A lower value
# can risk ending requests before the server has a chance to respond.
writeTimeout: 100000ms
# minTLSVersion - optional, default TSL1.2
# The minimum version of TSL to support
minTLSVersion: TLS1.2
# maxTLSVersion - optional, default TSL1.3
# The maximum version of TSL to support
maxTLSVersion: TLS1.3
# apis - required
# Allows one or more APIs to be bound to this webListener
+4 -1
View File
@@ -108,7 +108,10 @@ ctrl:
#connectTimeoutMs: 3000
# Sets the control channel write timeout. A write timeout will close the control channel, so the router will reconnect
#writeTimeout: 15s
# A listener address which will be sent to connecting routers in order to change their configured controller
# address. If defined, routers will update address configuration to immediately use the new address for future
# connections. The value of newListener must be resolvable both via DNS and validate via certificates
#newListener: tls:localhost:6262
# Management Channel Configuration
#
+15 -12
View File
@@ -25,18 +25,18 @@ require (
github.com/fatih/color v1.13.0
github.com/fullsailor/pkcs7 v0.0.0-20190404230743-d7302db945fa
github.com/go-acme/lego/v4 v4.2.0
github.com/go-openapi/runtime v0.21.0
github.com/go-openapi/runtime v0.21.1
github.com/go-openapi/strfmt v0.21.1
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
github.com/golang/protobuf v1.5.2
github.com/google/go-cmp v0.5.6
github.com/google/go-cmp v0.5.7
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.6.3
github.com/openziti/edge v0.21.50
github.com/openziti/fabric v0.17.19
github.com/openziti/foundation v0.16.14
github.com/openziti/sdk-golang v0.15.131
github.com/openziti/edge v0.21.70
github.com/openziti/fabric v0.17.34
github.com/openziti/foundation v0.17.0
github.com/openziti/sdk-golang v0.16.0
github.com/pborman/uuid v1.2.0
github.com/pkg/errors v0.9.1
github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0
@@ -57,6 +57,8 @@ require (
rsc.io/goversion v1.2.0
)
require github.com/openziti/channel v0.18.4
require (
github.com/AppsFlyer/go-sundheit v0.5.0 // indirect
github.com/BurntSushi/toml v0.4.1 // indirect
@@ -82,7 +84,7 @@ require (
github.com/fsnotify/fsnotify v1.5.1 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-openapi/analysis v0.20.1 // indirect
github.com/go-openapi/errors v0.20.1 // indirect
github.com/go-openapi/errors v0.20.2 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.19.6 // indirect
github.com/go-openapi/loads v0.21.0 // indirect
@@ -101,11 +103,12 @@ require (
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/jessevdk/go-flags v1.5.0 // indirect
github.com/jinzhu/copier v0.3.4 // indirect
github.com/jinzhu/copier v0.3.5 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/josharian/native v0.0.0-20200817173448-b6b71def0850 // indirect
github.com/kataras/go-events v0.0.3-0.20201007151548-c411dc70c0a6 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/kr/pty v1.1.8 // indirect
github.com/kyokomi/emoji/v2 v2.2.8 // indirect
github.com/lucas-clemente/quic-go v0.23.0 // indirect
github.com/lucasb-eyer/go-colorful v1.0.3 // indirect
@@ -132,7 +135,7 @@ require (
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/openziti/dilithium v0.3.3 // indirect
github.com/orcaman/concurrent-map v0.0.0-20210106121528-16402b402231 // indirect
github.com/parallaxsecond/parsec-client-go v0.0.0-20210416104105-e2d188152601 // indirect
github.com/parallaxsecond/parsec-client-go v0.0.0-20220111122524-cb78842db373 // indirect
github.com/pelletier/go-toml v1.9.4 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e // indirect
@@ -151,12 +154,12 @@ require (
github.com/yusufpapurcu/wmi v1.2.2 // indirect
go.mongodb.org/mongo-driver v1.7.5 // indirect
go.mozilla.org/pkcs7 v0.0.0-20200128120323-432b2356ecb1 // indirect
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect
golang.org/x/crypto v0.0.0-20220131195533-30dcbda58838 // indirect
golang.org/x/image v0.0.0-20191206065243-da761ea9ff43 // indirect
golang.org/x/mod v0.5.1 // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/sys v0.0.0-20211210111614-af8b64212486 // indirect
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 // indirect
golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27 // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/tools v0.1.7 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
+31 -18
View File
@@ -304,8 +304,9 @@ github.com/go-openapi/errors v0.19.6/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpX
github.com/go-openapi/errors v0.19.7/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M=
github.com/go-openapi/errors v0.19.8/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M=
github.com/go-openapi/errors v0.19.9/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M=
github.com/go-openapi/errors v0.20.1 h1:j23mMDtRxMwIobkpId7sWh7Ddcx4ivaoqUbfXx5P+a8=
github.com/go-openapi/errors v0.20.1/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M=
github.com/go-openapi/errors v0.20.2 h1:dxy7PGTqEh94zj2E3h1cUmQQWiM1+aeCROfAr02EmK8=
github.com/go-openapi/errors v0.20.2/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M=
github.com/go-openapi/jsonpointer v0.17.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M=
github.com/go-openapi/jsonpointer v0.18.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M=
github.com/go-openapi/jsonpointer v0.19.2/go.mod h1:3akKfEdA7DF1sugOqz1dVQHBcuDBPKZGEoHC/NkiQRg=
@@ -337,8 +338,9 @@ github.com/go-openapi/runtime v0.19.4/go.mod h1:X277bwSUBxVlCYR3r7xgZZGKVvBd/29g
github.com/go-openapi/runtime v0.19.15/go.mod h1:dhGWCTKRXlAfGnQG0ONViOZpjfg0m2gUt9nTQPQZuoo=
github.com/go-openapi/runtime v0.19.16/go.mod h1:5P9104EJgYcizotuXhEuUrzVc+j1RiSjahULvYmlv98=
github.com/go-openapi/runtime v0.19.24/go.mod h1:Lm9YGCeecBnUUkFTxPC4s1+lwrkJ0pthx8YvyjCfkgk=
github.com/go-openapi/runtime v0.21.0 h1:giZ8eT26R+/rx6RX2MkYjZPY8vPYVKDhP/mOazrQHzM=
github.com/go-openapi/runtime v0.21.0/go.mod h1:aQg+kaIQEn+A2CRSY1TxbM8+sT9g2V3aLc1FbIAnbbs=
github.com/go-openapi/runtime v0.21.1 h1:/KIG00BzA2x2HRStX2tnhbqbQdPcFlkgsYCiNY20FZs=
github.com/go-openapi/runtime v0.21.1/go.mod h1:aQg+kaIQEn+A2CRSY1TxbM8+sT9g2V3aLc1FbIAnbbs=
github.com/go-openapi/spec v0.17.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI=
github.com/go-openapi/spec v0.18.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI=
github.com/go-openapi/spec v0.19.2/go.mod h1:sCxk3jxKgioEJikev4fgkNmwS+3kuYdJtcsZsD5zxMY=
@@ -480,8 +482,9 @@ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o=
github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE=
github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ=
github.com/google/go-licenses v0.0.0-20201026145851-73411c8fa237/go.mod h1:g1VOUGKZYIqe8lDq2mL7plhAWXqrEaGUs7eIjthN1sk=
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
@@ -590,7 +593,7 @@ github.com/iij/doapi v0.0.0-20190504054126-0bbf12d6d7df/go.mod h1:QMZY7/J/KSQEhK
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/influxdata/influxdb-client-go/v2 v2.2.2/go.mod h1:fa/d1lAdUHxuc1jedx30ZfNG573oQTQmUni3N6pcW+0=
github.com/influxdata/influxdb-client-go/v2 v2.6.0/go.mod h1:Y/0W1+TZir7ypoQZYd2IrnVOKB3Tq6oegAQeSVN/+EU=
github.com/influxdata/influxdb-client-go/v2 v2.7.0/go.mod h1:Y/0W1+TZir7ypoQZYd2IrnVOKB3Tq6oegAQeSVN/+EU=
github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d h1:/WZQPMZNsjZ7IlCpsLGdQBINg5bxKQ1K1sh6awxLtkA=
github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo=
github.com/influxdata/line-protocol v0.0.0-20200327222509-2487e7298839/go.mod h1:xaLFMmpvUxqXtVkUJfg9QmT88cDaCJ3ZKgdZ78oO8Qo=
@@ -602,8 +605,8 @@ github.com/jellevandenhooff/dkim v0.0.0-20150330215556-f50fe3d243e1/go.mod h1:E0
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/jessevdk/go-flags v1.5.0 h1:1jKYvbxEjfUl0fmqTCOfonvskHHXMjBySTLW4y9LFvc=
github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4=
github.com/jinzhu/copier v0.3.4 h1:mfU6jI9PtCeUjkjQ322dlff9ELjGDu975C2p/nrubVI=
github.com/jinzhu/copier v0.3.4/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg=
github.com/jinzhu/copier v0.3.5 h1:GlvfUwHk62RokgqVNvYsku0TATCF7bAHVwEXoBh3iJg=
github.com/jinzhu/copier v0.3.5/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg=
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
github.com/jmespath/go-jmespath v0.3.0/go.mod h1:9QtRXoHjLGCJ5IBSaohpXITPlowMeeYCZ7fLUTSywik=
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
@@ -836,16 +839,21 @@ github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+
github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc=
github.com/openzipkin/zipkin-go v0.1.1/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTmOf0Erfk+hxe8=
github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw=
github.com/openziti/channel v0.18.3/go.mod h1:wmpGSNQranDE7jsiT+Cv31UzOO3z+m69JxE2tzYwkyY=
github.com/openziti/channel v0.18.4 h1:TXQcqJjT+cZYt6uk4Ri+4lGsKCNtkj5wpn6GbX0MIkY=
github.com/openziti/channel v0.18.4/go.mod h1:wmpGSNQranDE7jsiT+Cv31UzOO3z+m69JxE2tzYwkyY=
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.21.50 h1:LNvaM2m1+YOqM+Ugo6ONSXrbjSS+634BFFraw8AngNM=
github.com/openziti/edge v0.21.50/go.mod h1:V8LL5CwPFohqRfrnE7eig8856edn1L28tfBkduoi+M0=
github.com/openziti/fabric v0.17.19 h1:aynMWpxsPPNREuFPxYcxmrgpQlgeaBqEzdXU52NRm1Y=
github.com/openziti/fabric v0.17.19/go.mod h1:HIquY6ph5+yC9vL38EQh2n5qWSeu5y81Pgc1YPhtPVQ=
github.com/openziti/foundation v0.16.14 h1:fwiQK7bdhs+z9idFVpEfWHzk7p0DGIvbrFbYJ6UcU8c=
github.com/openziti/foundation v0.16.14/go.mod h1:SHG4x9kLP+M7sn0BJpoc/RbSIh1Hm1BxwBPHFmCf7qE=
github.com/openziti/sdk-golang v0.15.131 h1:6i3Z2T8xcLu75VHtFhuYSNuEV7lDUphGbapZHBEjeI8=
github.com/openziti/sdk-golang v0.15.131/go.mod h1:X9YCsI4POO58WjXyKf9a16ujteJyjYBsQQ956cj8O7k=
github.com/openziti/edge v0.21.70 h1:pzv1f6P0QSIHUwVNYlP4a11EZtRy6bMAT3wzkHOg7Q0=
github.com/openziti/edge v0.21.70/go.mod h1:Jh7/RTvgxS3gTETnKQV5eITom9qa0TQTHOf0SqFqARs=
github.com/openziti/fabric v0.17.34 h1:A2P2aeJg8UmsXY81SVAKcc2UFoVxkWjvYAOWNoDGFNo=
github.com/openziti/fabric v0.17.34/go.mod h1:ZOuDngcSa0VJCNHRdYw6xCD0Tr/peZrc+Uqi8Gqc25U=
github.com/openziti/foundation v0.16.17/go.mod h1:D8IchItaO2SvK/fc/JpX9yF0vNymmOw2gzeNqwHz4+g=
github.com/openziti/foundation v0.16.18/go.mod h1:D8IchItaO2SvK/fc/JpX9yF0vNymmOw2gzeNqwHz4+g=
github.com/openziti/foundation v0.17.0 h1:frhZqq9f6l+BBgYNYpnvo36T1CQsN/7DtKJPWDOQpHI=
github.com/openziti/foundation v0.17.0/go.mod h1:D8IchItaO2SvK/fc/JpX9yF0vNymmOw2gzeNqwHz4+g=
github.com/openziti/sdk-golang v0.16.0 h1:Wq4P17btCYeh6nJsFVQpMzC4xgXBTYcKHOJr7Qb484w=
github.com/openziti/sdk-golang v0.16.0/go.mod h1:Bxmfwgn89gIaIkdQ/3PENo7pLu5Yw1Eyiu2taP3Vqow=
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=
@@ -856,8 +864,9 @@ github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6
github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo=
github.com/otiai10/mint v1.3.1/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc=
github.com/ovh/go-ovh v1.1.0/go.mod h1:AxitLZ5HBRPyUd+Zl60Ajaag+rNTdVXWIkzfrVuTXWA=
github.com/parallaxsecond/parsec-client-go v0.0.0-20210416104105-e2d188152601 h1:1YdmkuR6lJ+mDvdkI8cBDKOljRWL4kdPFSu3qRAEf6g=
github.com/parallaxsecond/parsec-client-go v0.0.0-20210416104105-e2d188152601/go.mod h1:iFrEMRwLidGESW7mwIhRWDD7m5ktzKeCX2XNCyAFtNk=
github.com/parallaxsecond/parsec-client-go v0.0.0-20220111122524-cb78842db373 h1:CUvH4JL/8OVy023LMER3dB/MerNQ6OIz4QV3E/JQ3UY=
github.com/parallaxsecond/parsec-client-go v0.0.0-20220111122524-cb78842db373/go.mod h1:gLH27qo/dvMhLTVVyMELpe3Tut7sOfkiDg7ZpeqKwsw=
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ=
@@ -1141,8 +1150,9 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 h1:HWj/xjIHfjYU5nVXpTM0s39J9CbLn7Cc5a7IC5rwsMQ=
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20220131195533-30dcbda58838 h1:71vQrMauZZhcTVK6KdYM+rklehEEwb3E+ZhaE5jrPrE=
golang.org/x/crypto v0.0.0-20220131195533-30dcbda58838/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
@@ -1255,6 +1265,7 @@ golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qx
golang.org/x/net v0.0.0-20210928044308-7d9f5e0b762b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20211020060615-d418f374d309/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20211029224645-99673261e6eb/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20211209124913-491a49abca63 h1:iocB37TsdFuN6IBRZ+ry36wrkoV51/tl5vOWqkcPGvY=
golang.org/x/net v0.0.0-20211209124913-491a49abca63/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
@@ -1401,11 +1412,13 @@ golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211205182925-97ca703d548d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211210111614-af8b64212486 h1:5hpz5aRr+W1erYCL5JRhSUBJRph7l9XkNveoExlrKYk=
golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27 h1:XDXtA5hveEEV8JB2l7nhMTp3t3cHp9ZpwcdjqyEWLlo=
golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+64 -4
View File
@@ -2,11 +2,71 @@
#
# build the Linux artifacts for amd64, arm, arm64
#
# see instructions to run reproducible build with Docker in ./Dockerfile.linux-build
# runs one background job per desired architecture unless there are too few CPUs
#
#
set -o pipefail -e -u
# if no architectures supplied then default list of three
if (( ${#} )); then
typeset -a JOBS=(${@})
else
typeset -a JOBS=(amd64 arm arm64)
fi
# specify the Go template used by Gox to save the artifacts
GOX_OUTPUT="release/{{.Arch}}/{{.OS}}/{{.Dir}}"
CGO_ENABLED=true gox -os=linux -arch=amd64 -output=${GOX_OUTPUT} ./...
CC=arm-linux-gnueabihf-gcc CGO_ENABLED=true gox -cgo -os=linux -arch=arm -output=${GOX_OUTPUT} ./...
CC=aarch64-linux-gnu-gcc CGO_ENABLED=true gox -cgo -os=linux -arch=arm64 -output=$GOX_OUTPUT ./...
# count the number of available CPUs for time-efficient parallelism
PROC_COUNT=$(nproc --all)
# compute the number of processors available for each job, rounded down to integer
PROCS_PER_JOB=$((PROC_COUNT / ${#JOBS[@]}))
# if multiple jobs and at least one processor for each job then background, else foreground with all available CPUs-1 (gox default)
if (( ${#JOBS[@]} > 1 && ${PROCS_PER_JOB} )); then
BACKGROUND="&"
# initialize an associative array in which to map background PIDs to the ARCH being built
typeset -A BUILDS
else
BACKGROUND="" # run normally in foreground
PROCS_PER_JOB=0 # invokes gox default to use all CPUs-1
fi
for ARCH in ${JOBS[@]}; do
GOX_CMD="
gox \
-cgo \
-os=linux \
-arch=${ARCH} \
-output=${GOX_OUTPUT} \
-parallel=${PROCS_PER_JOB} \
./...
"
case ${ARCH} in
amd64) eval ${GOX_CMD} ${BACKGROUND}
(( ${PROCS_PER_JOB} )) && BUILDS[${!}]=${ARCH} # if greater than zero procs per job then map background pid->arch
;;
arm) eval CC=arm-linux-gnueabihf-gcc ${GOX_CMD} ${BACKGROUND}
(( ${PROCS_PER_JOB} )) && BUILDS[${!}]=${ARCH}
;;
arm64) eval CC=aarch64-linux-gnu-gcc ${GOX_CMD} ${BACKGROUND}
(( ${PROCS_PER_JOB} )) && BUILDS[${!}]=${ARCH}
;;
*) echo "ERROR: invalid architecture '${ARCH}', must be one of amd64, arm, arm64" >&2
exit 1
;;
esac
done
# if not background in parallel then exit now with well earned success
[[ -z "${BACKGROUND:-}" ]] || exit 0
# Wait for builds in the background and exit with an error if any fail
EXIT=0
while true; do
# "wait -p" requires BASH >=5.1 which is present in Ubuntu 20.10 and Debian Bullseye
wait -n -p JOB_PID; JOB_RESULT=$?
echo "Building for ${BUILDS[$JOB_PID]} finished with result ${JOB_RESULT}"
(( ${JOB_RESULT} )) && EXIT=1
done
exit ${EXIT}
+2 -1
View File
@@ -19,6 +19,8 @@
package main
import (
"math/rand"
"github.com/michaelquigley/pfxlog"
"github.com/openziti/foundation/transport"
"github.com/openziti/foundation/transport/quic"
@@ -33,7 +35,6 @@ import (
_ "github.com/openziti/ziti/ziti-fabric-test/subcmd/loop2"
_ "github.com/openziti/ziti/ziti-fabric-test/subcmd/loop3"
"github.com/sirupsen/logrus"
"math/rand"
)
func init() {
+1
View File
@@ -18,6 +18,7 @@ package main
import (
"fmt"
"github.com/michaelquigley/pfxlog"
"github.com/openziti/foundation/transport"
"github.com/openziti/foundation/transport/quic"
+8 -4
View File
@@ -17,7 +17,7 @@
package subcmd
import (
"github.com/openziti/foundation/channel2"
"github.com/openziti/channel"
"github.com/openziti/foundation/identity/dotziti"
"github.com/openziti/foundation/identity/identity"
"github.com/openziti/foundation/transport"
@@ -37,7 +37,11 @@ func NewMgmtClient(cmd *cobra.Command) *mgmtClient {
return client
}
func (c *mgmtClient) Connect() (channel2.Channel, error) {
func (c *mgmtClient) Connect() (channel.Channel, error) {
return c.ConnectAndBind(nil)
}
func (c *mgmtClient) ConnectAndBind(bindHandler channel.BindHandler) (channel.Channel, error) {
if endpoint, id, err := dotziti.LoadIdentity(c.idName); err == nil {
c.id = id
endpointStr := endpoint
@@ -45,8 +49,8 @@ func (c *mgmtClient) Connect() (channel2.Channel, error) {
endpointStr = c.mgmtEndpoint
}
if mgmtAddress, err := transport.ParseAddress(endpointStr); err == nil {
dialer := channel2.NewClassicDialer(c.id, mgmtAddress, nil)
if ch, err := channel2.NewChannel("mgmt", dialer, nil); err == nil {
dialer := channel.NewClassicDialer(c.id, mgmtAddress, nil)
if ch, err := channel.NewChannel("mgmt", dialer, bindHandler, nil); err == nil {
return ch, nil
} else {
return nil, err
+10 -16
View File
@@ -18,11 +18,10 @@ package subcmd
import (
"crypto/sha1"
"errors"
"fmt"
"github.com/golang/protobuf/proto"
"github.com/openziti/channel"
"github.com/openziti/fabric/pb/mgmt_pb"
"github.com/openziti/foundation/channel2"
"github.com/openziti/foundation/identity/certtools"
"github.com/spf13/cobra"
"time"
@@ -51,25 +50,20 @@ var createRouter = &cobra.Command{
},
}
if body, err := proto.Marshal(request); err == nil {
requestMsg := channel2.NewMessage(int32(mgmt_pb.ContentType_CreateRouterRequestType), body)
waitCh, err := ch.SendAndWait(requestMsg)
requestMsg := channel.NewMessage(int32(mgmt_pb.ContentType_CreateRouterRequestType), body)
responseMsg, err := requestMsg.WithTimeout(5 * time.Second).SendForReply(ch)
if err != nil {
panic(err)
}
select {
case responseMsg := <-waitCh:
if responseMsg.ContentType == channel2.ContentTypeResultType {
result := channel2.UnmarshalResult(responseMsg)
if result.Success {
fmt.Printf("\nsuccess\n\n")
} else {
fmt.Printf("\nfailure [%s]\n\n", result.Message)
}
if responseMsg.ContentType == channel.ContentTypeResultType {
result := channel.UnmarshalResult(responseMsg)
if result.Success {
fmt.Printf("\nsuccess\n\n")
} else {
panic(fmt.Errorf("unexpected response type %v", responseMsg.ContentType))
fmt.Printf("\nfailure [%s]\n\n", result.Message)
}
case <-time.After(5 * time.Second):
panic(errors.New("timeout"))
} else {
panic(fmt.Errorf("unexpected response type %v", responseMsg.ContentType))
}
} else {
panic(err)
+5 -5
View File
@@ -19,8 +19,8 @@ package subcmd
import (
"fmt"
"github.com/golang/protobuf/proto"
"github.com/openziti/channel"
"github.com/openziti/fabric/pb/mgmt_pb"
"github.com/openziti/foundation/channel2"
"github.com/spf13/cobra"
"time"
)
@@ -53,13 +53,13 @@ var createService = &cobra.Command{
if err != nil {
panic(err)
}
requestMsg := channel2.NewMessage(int32(mgmt_pb.ContentType_CreateServiceRequestType), body)
responseMsg, err := ch.SendAndWaitWithTimeout(requestMsg, 5*time.Second)
requestMsg := channel.NewMessage(int32(mgmt_pb.ContentType_CreateServiceRequestType), body)
responseMsg, err := requestMsg.WithTimeout(5 * time.Second).SendForReply(ch)
if err != nil {
panic(err)
}
if responseMsg.ContentType == channel2.ContentTypeResultType {
result := channel2.UnmarshalResult(responseMsg)
if responseMsg.ContentType == channel.ContentTypeResultType {
result := channel.UnmarshalResult(responseMsg)
if result.Success {
fmt.Printf("\nsuccess\n\n")
} else {
+5 -5
View File
@@ -19,8 +19,8 @@ package subcmd
import (
"fmt"
"github.com/golang/protobuf/proto"
"github.com/openziti/channel"
"github.com/openziti/fabric/pb/mgmt_pb"
"github.com/openziti/foundation/channel2"
"github.com/openziti/foundation/util/stringz"
"github.com/spf13/cobra"
"time"
@@ -81,13 +81,13 @@ var createTerminator = &cobra.Command{
if err != nil {
panic(err)
}
requestMsg := channel2.NewMessage(int32(mgmt_pb.ContentType_CreateTerminatorRequestType), body)
responseMsg, err := ch.SendAndWaitWithTimeout(requestMsg, 5*time.Second)
requestMsg := channel.NewMessage(int32(mgmt_pb.ContentType_CreateTerminatorRequestType), body)
responseMsg, err := requestMsg.WithTimeout(5 * time.Second).SendForReply(ch)
if err != nil {
panic(err)
}
if responseMsg.ContentType == channel2.ContentTypeResultType {
result := channel2.UnmarshalResult(responseMsg)
if responseMsg.ContentType == channel.ContentTypeResultType {
result := channel.UnmarshalResult(responseMsg)
if result.Success {
fmt.Printf("\nsuccess\n\n")
} else {
+5 -5
View File
@@ -19,8 +19,8 @@ package subcmd
import (
"fmt"
"github.com/golang/protobuf/proto"
"github.com/openziti/channel"
"github.com/openziti/fabric/pb/mgmt_pb"
"github.com/openziti/foundation/channel2"
"github.com/spf13/cobra"
"time"
)
@@ -43,8 +43,8 @@ var getService = &cobra.Command{
if err != nil {
panic(err)
}
requestMsg := channel2.NewMessage(int32(mgmt_pb.ContentType_GetServiceRequestType), body)
responseMsg, err := ch.SendAndWaitWithTimeout(requestMsg, 5*time.Second)
requestMsg := channel.NewMessage(int32(mgmt_pb.ContentType_GetServiceRequestType), body)
responseMsg, err := requestMsg.WithTimeout(5 * time.Second).SendForReply(ch)
if err != nil {
panic(err)
}
@@ -65,8 +65,8 @@ var getService = &cobra.Command{
} else {
fmt.Printf("Id not found\n")
}
} else if responseMsg.ContentType == channel2.ContentTypeResultType {
result := channel2.UnmarshalResult(responseMsg)
} else if responseMsg.ContentType == channel.ContentTypeResultType {
result := channel.UnmarshalResult(responseMsg)
if result.Success {
fmt.Printf("\nsuccess\n\n")
} else {
+5 -5
View File
@@ -19,8 +19,8 @@ package subcmd
import (
"fmt"
"github.com/golang/protobuf/proto"
"github.com/openziti/channel"
"github.com/openziti/fabric/pb/mgmt_pb"
"github.com/openziti/foundation/channel2"
"github.com/spf13/cobra"
"time"
)
@@ -43,8 +43,8 @@ var getTerminator = &cobra.Command{
if err != nil {
panic(err)
}
requestMsg := channel2.NewMessage(int32(mgmt_pb.ContentType_GetTerminatorRequestType), body)
responseMsg, err := ch.SendAndWaitWithTimeout(requestMsg, 5*time.Second)
requestMsg := channel.NewMessage(int32(mgmt_pb.ContentType_GetTerminatorRequestType), body)
responseMsg, err := requestMsg.WithTimeout(5 * time.Second).SendForReply(ch)
if err != nil {
panic(err)
}
@@ -59,8 +59,8 @@ var getTerminator = &cobra.Command{
} else {
fmt.Printf("Id not found\n")
}
} else if responseMsg.ContentType == channel2.ContentTypeResultType {
result := channel2.UnmarshalResult(responseMsg)
} else if responseMsg.ContentType == channel.ContentTypeResultType {
result := channel.UnmarshalResult(responseMsg)
if result.Success {
fmt.Printf("\nsuccess\n\n")
} else {
+21 -26
View File
@@ -17,11 +17,11 @@
package subcmd
import (
"github.com/openziti/foundation/channel2"
"github.com/openziti/fabric/pb/mgmt_pb"
"errors"
"fmt"
"github.com/golang/protobuf/proto"
"github.com/openziti/channel"
"github.com/openziti/fabric/pb/mgmt_pb"
"github.com/spf13/cobra"
"time"
)
@@ -49,36 +49,31 @@ func inspect(cmd *cobra.Command, args []string) {
if err != nil {
panic(err)
}
requestMsg := channel2.NewMessage(int32(mgmt_pb.ContentType_InspectRequestType), body)
waitCh, err := ch.SendAndWait(requestMsg)
requestMsg := channel.NewMessage(int32(mgmt_pb.ContentType_InspectRequestType), body)
responseMsg, err := requestMsg.WithTimeout(10 * time.Second).SendForReply(ch)
if err != nil {
panic(err)
}
select {
case responseMsg := <-waitCh:
if responseMsg.ContentType == int32(mgmt_pb.ContentType_InspectResponseType) {
response := &mgmt_pb.InspectResponse{}
err := proto.Unmarshal(responseMsg.Body, response)
if err != nil {
panic(err)
}
if response.Success {
fmt.Printf("\nResults: (%d)\n", len(response.Values))
for _, value := range response.Values {
fmt.Printf("%v.%v\n", value.AppId, value.Name)
fmt.Printf("%v\n\n", value.Value)
}
} else {
fmt.Printf("\nEncountered errors: (%d)\n", len(response.Errors))
for _, err := range response.Errors {
fmt.Printf("\t%v\n", err)
}
if responseMsg.ContentType == int32(mgmt_pb.ContentType_InspectResponseType) {
response := &mgmt_pb.InspectResponse{}
err := proto.Unmarshal(responseMsg.Body, response)
if err != nil {
panic(err)
}
if response.Success {
fmt.Printf("\nResults: (%d)\n", len(response.Values))
for _, value := range response.Values {
fmt.Printf("%v.%v\n", value.AppId, value.Name)
fmt.Printf("%v\n\n", value.Value)
}
} else {
panic(errors.New("unexpected response"))
fmt.Printf("\nEncountered errors: (%d)\n", len(response.Errors))
for _, err := range response.Errors {
fmt.Printf("\t%v\n", err)
}
}
case <-time.After(10 * time.Second):
panic(errors.New("timeout"))
} else {
panic(errors.New("unexpected response"))
}
} else {
panic(err)
+23 -29
View File
@@ -20,8 +20,8 @@ import (
"errors"
"fmt"
"github.com/golang/protobuf/proto"
"github.com/openziti/channel"
"github.com/openziti/fabric/pb/mgmt_pb"
"github.com/openziti/foundation/channel2"
"github.com/spf13/cobra"
"sort"
"time"
@@ -46,40 +46,34 @@ func listCircuits(cmd *cobra.Command, args []string) {
if err != nil {
panic(err)
}
requestMsg := channel2.NewMessage(int32(mgmt_pb.ContentType_ListCircuitsRequestType), body)
waitCh, err := ch.SendAndWait(requestMsg)
requestMsg := channel.NewMessage(int32(mgmt_pb.ContentType_ListCircuitsRequestType), body)
responseMsg, err := requestMsg.WithTimeout(5 * time.Second).SendForReply(ch)
if err != nil {
panic(err)
}
select {
case responseMsg := <-waitCh:
if responseMsg.ContentType == int32(mgmt_pb.ContentType_ListCircuitsResponseType) {
response := &mgmt_pb.ListCircuitsResponse{}
err := proto.Unmarshal(responseMsg.Body, response)
if err == nil {
out := fmt.Sprintf("\nCircuits: (%d)\n\n", len(response.Circuits))
out += fmt.Sprintf("%-12s | %-12s | %-12s | %s\n", "Id", "Client", "Service", "Path")
sort.Slice(response.Circuits, func(i, j int) bool {
if response.Circuits[i].ServiceId == response.Circuits[j].ServiceId {
return response.Circuits[i].Id < response.Circuits[j].Id
}
return response.Circuits[i].ServiceId < response.Circuits[j].ServiceId
})
for _, s := range response.Circuits {
out += fmt.Sprintf("%-12s | %-12s | %-12s | %s", s.Id, s.ClientId, s.ServiceId, s.Path.CalculateDisplayPath())
if responseMsg.ContentType == int32(mgmt_pb.ContentType_ListCircuitsResponseType) {
response := &mgmt_pb.ListCircuitsResponse{}
err := proto.Unmarshal(responseMsg.Body, response)
if err == nil {
out := fmt.Sprintf("\nCircuits: (%d)\n\n", len(response.Circuits))
out += fmt.Sprintf("%-12s | %-12s | %-12s | %s\n", "Id", "Client", "Service", "Path")
sort.Slice(response.Circuits, func(i, j int) bool {
if response.Circuits[i].ServiceId == response.Circuits[j].ServiceId {
return response.Circuits[i].Id < response.Circuits[j].Id
}
out += "\n"
fmt.Print(out)
} else {
panic(err)
return response.Circuits[i].ServiceId < response.Circuits[j].ServiceId
})
for _, s := range response.Circuits {
out += fmt.Sprintf("%-12s | %-12s | %-12s | %s", s.Id, s.ClientId, s.ServiceId, s.Path.CalculateDisplayPath())
}
} else {
panic(errors.New("unexpected response"))
}
out += "\n"
fmt.Print(out)
case <-time.After(5 * time.Second):
panic(errors.New("timeout"))
} else {
panic(err)
}
} else {
panic(errors.New("unexpected response"))
}
} else {
panic(err)
+32 -38
View File
@@ -20,8 +20,8 @@ import (
"errors"
"fmt"
"github.com/golang/protobuf/proto"
"github.com/openziti/channel"
"github.com/openziti/fabric/pb/mgmt_pb"
"github.com/openziti/foundation/channel2"
"github.com/spf13/cobra"
"sort"
"time"
@@ -46,49 +46,43 @@ func listLinks(cmd *cobra.Command, args []string) {
if err != nil {
panic(err)
}
requestMsg := channel2.NewMessage(int32(mgmt_pb.ContentType_ListLinksRequestType), body)
waitCh, err := ch.SendAndWait(requestMsg)
requestMsg := channel.NewMessage(int32(mgmt_pb.ContentType_ListLinksRequestType), body)
responseMsg, err := requestMsg.WithTimeout(5 * time.Second).SendForReply(ch)
if err != nil {
panic(err)
}
select {
case responseMsg := <-waitCh:
if responseMsg.ContentType == int32(mgmt_pb.ContentType_ListLinksResponseType) {
response := &mgmt_pb.ListLinksResponse{}
err := proto.Unmarshal(responseMsg.Body, response)
if err == nil {
out := fmt.Sprintf("\nLinks: (%d)\n\n", len(response.Links))
out += fmt.Sprintf("%-6s | %-24s -> %-24s | %-12s | %-4s | %-13s | %-12s | %-6s\n", "Id", "Src", "Dst", "State", "Cost", "Latency", "Full Cost", "Status")
sort.Slice(response.Links, func(i, j int) bool {
if response.Links[i].Src == response.Links[j].Src {
return response.Links[i].Dst < response.Links[j].Dst
}
return response.Links[i].Src < response.Links[j].Src
})
for _, l := range response.Links {
status := "up"
if l.Down {
status = "down"
}
// Convert nanoseconds to fractional seconds
srcLatency := float64(l.SrcLatency) / 1_000_000_000.0
dstLatency := float64(l.DstLatency) / 1_000_000_000.0
cost := (l.SrcLatency / 1_000_000) + (l.DstLatency / 1_000_000) + int64(l.Cost)
out += fmt.Sprintf("%-6s | %-24s -> %-24s | %-12s | %-4d | %-0.4f %-0.4f | %-12v | %-6v\n", l.Id, l.Src, l.Dst, l.State, l.Cost, srcLatency, dstLatency,
cost, status)
if responseMsg.ContentType == int32(mgmt_pb.ContentType_ListLinksResponseType) {
response := &mgmt_pb.ListLinksResponse{}
err := proto.Unmarshal(responseMsg.Body, response)
if err == nil {
out := fmt.Sprintf("\nLinks: (%d)\n\n", len(response.Links))
out += fmt.Sprintf("%-6s | %-24s -> %-24s | %-12s | %-4s | %-13s | %-12s | %-6s\n", "Id", "Src", "Dst", "State", "Cost", "Latency", "Full Cost", "Status")
sort.Slice(response.Links, func(i, j int) bool {
if response.Links[i].Src == response.Links[j].Src {
return response.Links[i].Dst < response.Links[j].Dst
}
out += "\n"
fmt.Print(out)
} else {
panic(err)
return response.Links[i].Src < response.Links[j].Src
})
for _, l := range response.Links {
status := "up"
if l.Down {
status = "down"
}
// Convert nanoseconds to fractional seconds
srcLatency := float64(l.SrcLatency) / 1_000_000_000.0
dstLatency := float64(l.DstLatency) / 1_000_000_000.0
cost := (l.SrcLatency / 1_000_000) + (l.DstLatency / 1_000_000) + int64(l.Cost)
out += fmt.Sprintf("%-6s | %-24s -> %-24s | %-12s | %-4d | %-0.4f %-0.4f | %-12v | %-6v\n", l.Id, l.Src, l.Dst, l.State, l.Cost, srcLatency, dstLatency,
cost, status)
}
} else {
panic(errors.New("unexpected response"))
}
out += "\n"
fmt.Print(out)
case <-time.After(5 * time.Second):
panic(errors.New("timeout"))
} else {
panic(err)
}
} else {
panic(errors.New("unexpected response"))
}
} else {
panic(err)
+25 -31
View File
@@ -20,8 +20,8 @@ import (
"errors"
"fmt"
"github.com/golang/protobuf/proto"
"github.com/openziti/channel"
"github.com/openziti/fabric/pb/mgmt_pb"
"github.com/openziti/foundation/channel2"
"github.com/spf13/cobra"
"time"
)
@@ -47,42 +47,36 @@ var listRouters = &cobra.Command{
if err != nil {
panic(err)
}
requestMsg := channel2.NewMessage(int32(mgmt_pb.ContentType_ListRoutersRequestType), body)
waitCh, err := ch.SendAndWait(requestMsg)
requestMsg := channel.NewMessage(int32(mgmt_pb.ContentType_ListRoutersRequestType), body)
responseMsg, err := requestMsg.WithTimeout(5 * time.Second).SendForReply(ch)
if err != nil {
panic(err)
}
select {
case responseMsg := <-waitCh:
if responseMsg.ContentType == int32(mgmt_pb.ContentType_ListRoutersResponseType) {
response := &mgmt_pb.ListRoutersResponse{}
err := proto.Unmarshal(responseMsg.Body, response)
if err == nil {
out := fmt.Sprintf("\nRouters: (%d)\n\n", len(response.Routers))
out += fmt.Sprintf("%-12s | %-30s | %-40s | %-9s | %s\n", "Id", "Name", "Fingerprint", "Status", "Version")
for _, r := range response.Routers {
status := ""
if r.Connected {
status += "Connected"
}
if r.ListenerAddress != "" {
status += " (" + r.ListenerAddress + ")"
}
out += fmt.Sprintf("%-12s | %-30s | %-40s | %-9s | %s\n", r.Id, r.Name, r.Fingerprint, status, r.Version)
if responseMsg.ContentType == int32(mgmt_pb.ContentType_ListRoutersResponseType) {
response := &mgmt_pb.ListRoutersResponse{}
err := proto.Unmarshal(responseMsg.Body, response)
if err == nil {
out := fmt.Sprintf("\nRouters: (%d)\n\n", len(response.Routers))
out += fmt.Sprintf("%-12s | %-30s | %-40s | %-9s | %s\n", "Id", "Name", "Fingerprint", "Status", "Version")
for _, r := range response.Routers {
status := ""
if r.Connected {
status += "Connected"
}
out += "\n"
fmt.Print(out)
} else {
panic(err)
if r.ListenerAddress != "" {
status += " (" + r.ListenerAddress + ")"
}
out += fmt.Sprintf("%-12s | %-30s | %-40s | %-9s | %s\n", r.Id, r.Name, r.Fingerprint, status, r.Version)
}
} else {
panic(errors.New("unexpected response"))
}
case <-time.After(5 * time.Second):
panic(errors.New("timeout"))
}
out += "\n"
fmt.Print(out)
} else {
panic(err)
}
} else {
panic(errors.New("unexpected response"))
}
} else {
panic(err)
}
+3 -3
View File
@@ -20,8 +20,8 @@ import (
"errors"
"fmt"
"github.com/golang/protobuf/proto"
"github.com/openziti/channel"
"github.com/openziti/fabric/pb/mgmt_pb"
"github.com/openziti/foundation/channel2"
"github.com/spf13/cobra"
"time"
)
@@ -47,8 +47,8 @@ var listServices = &cobra.Command{
if err != nil {
panic(err)
}
requestMsg := channel2.NewMessage(int32(mgmt_pb.ContentType_ListServicesRequestType), body)
responseMsg, err := ch.SendAndWaitWithTimeout(requestMsg, 5*time.Second)
requestMsg := channel.NewMessage(int32(mgmt_pb.ContentType_ListServicesRequestType), body)
responseMsg, err := requestMsg.WithTimeout(5 * time.Second).SendForReply(ch)
if err != nil {
panic(err)
}
+3 -3
View File
@@ -20,8 +20,8 @@ import (
"errors"
"fmt"
"github.com/golang/protobuf/proto"
"github.com/openziti/channel"
"github.com/openziti/fabric/pb/mgmt_pb"
"github.com/openziti/foundation/channel2"
"github.com/spf13/cobra"
"time"
)
@@ -47,8 +47,8 @@ var listTerminators = &cobra.Command{
if err != nil {
panic(err)
}
requestMsg := channel2.NewMessage(int32(mgmt_pb.ContentType_ListTerminatorsRequestType), body)
responseMsg, err := ch.SendAndWaitWithTimeout(requestMsg, 5*time.Second)
requestMsg := channel.NewMessage(int32(mgmt_pb.ContentType_ListTerminatorsRequestType), body)
responseMsg, err := requestMsg.WithTimeout(5 * time.Second).SendForReply(ch)
if err != nil {
panic(err)
}
+10 -17
View File
@@ -17,11 +17,10 @@
package subcmd
import (
"errors"
"fmt"
"github.com/golang/protobuf/proto"
"github.com/openziti/channel"
"github.com/openziti/fabric/pb/mgmt_pb"
"github.com/openziti/foundation/channel2"
"github.com/spf13/cobra"
"time"
)
@@ -52,26 +51,20 @@ func removeCircuit(cmd *cobra.Command, args []string) {
if err != nil {
panic(err)
}
requestMsg := channel2.NewMessage(int32(mgmt_pb.ContentType_RemoveCircuitRequestType), body)
waitCh, err := ch.SendAndWait(requestMsg)
requestMsg := channel.NewMessage(int32(mgmt_pb.ContentType_RemoveCircuitRequestType), body)
responseMsg, err := requestMsg.WithTimeout(5 * time.Second).SendForReply(ch)
if err != nil {
panic(err)
}
select {
case responseMsg := <-waitCh:
if responseMsg.ContentType == channel2.ContentTypeResultType {
result := channel2.UnmarshalResult(responseMsg)
if result.Success {
fmt.Printf("\nsuccess\n\n")
} else {
fmt.Printf("\nfailure [%s]\n\n", result.Message)
}
if responseMsg.ContentType == channel.ContentTypeResultType {
result := channel.UnmarshalResult(responseMsg)
if result.Success {
fmt.Printf("\nsuccess\n\n")
} else {
panic(fmt.Errorf("unexpected response type %v", responseMsg.ContentType))
fmt.Printf("\nfailure [%s]\n\n", result.Message)
}
case <-time.After(5 * time.Second):
panic(errors.New("timeout"))
} else {
panic(fmt.Errorf("unexpected response type %v", responseMsg.ContentType))
}
}
}
+11 -17
View File
@@ -17,11 +17,10 @@
package subcmd
import (
"github.com/openziti/foundation/channel2"
"github.com/openziti/fabric/pb/mgmt_pb"
"errors"
"fmt"
"github.com/golang/protobuf/proto"
"github.com/openziti/channel"
"github.com/openziti/fabric/pb/mgmt_pb"
"github.com/spf13/cobra"
"time"
)
@@ -41,25 +40,20 @@ var removeRouter = &cobra.Command{
RouterId: args[0],
}
if body, err := proto.Marshal(request); err == nil {
requestMsg := channel2.NewMessage(int32(mgmt_pb.ContentType_RemoveRouterRequestType), body)
waitCh, err := ch.SendAndWait(requestMsg)
requestMsg := channel.NewMessage(int32(mgmt_pb.ContentType_RemoveRouterRequestType), body)
responseMsg, err := requestMsg.WithTimeout(5 * time.Second).SendForReply(ch)
if err != nil {
panic(err)
}
select {
case responseMsg := <-waitCh:
if responseMsg.ContentType == channel2.ContentTypeResultType {
result := channel2.UnmarshalResult(responseMsg)
if result.Success {
fmt.Printf("\nsuccess\n\n")
} else {
fmt.Printf("\nfailure [%s]\n\n", result.Message)
}
if responseMsg.ContentType == channel.ContentTypeResultType {
result := channel.UnmarshalResult(responseMsg)
if result.Success {
fmt.Printf("\nsuccess\n\n")
} else {
panic(fmt.Errorf("unexpected response type %v", responseMsg.ContentType))
fmt.Printf("\nfailure [%s]\n\n", result.Message)
}
case <-time.After(5 * time.Second):
panic(errors.New("timeout"))
} else {
panic(fmt.Errorf("unexpected response type %v", responseMsg.ContentType))
}
} else {
panic(err)
+5 -5
View File
@@ -19,8 +19,8 @@ package subcmd
import (
"fmt"
"github.com/golang/protobuf/proto"
"github.com/openziti/channel"
"github.com/openziti/fabric/pb/mgmt_pb"
"github.com/openziti/foundation/channel2"
"github.com/spf13/cobra"
"time"
)
@@ -43,13 +43,13 @@ var removeService = &cobra.Command{
if err != nil {
panic(err)
}
requestMsg := channel2.NewMessage(int32(mgmt_pb.ContentType_RemoveServiceRequestType), body)
responseMsg, err := ch.SendAndWaitWithTimeout(requestMsg, 5*time.Second)
requestMsg := channel.NewMessage(int32(mgmt_pb.ContentType_RemoveServiceRequestType), body)
responseMsg, err := requestMsg.WithTimeout(5 * time.Second).SendForReply(ch)
if err != nil {
panic(err)
}
if responseMsg.ContentType == channel2.ContentTypeResultType {
result := channel2.UnmarshalResult(responseMsg)
if responseMsg.ContentType == channel.ContentTypeResultType {
result := channel.UnmarshalResult(responseMsg)
if result.Success {
fmt.Printf("\nsuccess\n\n")
} else {
+5 -5
View File
@@ -19,8 +19,8 @@ package subcmd
import (
"fmt"
"github.com/golang/protobuf/proto"
"github.com/openziti/channel"
"github.com/openziti/fabric/pb/mgmt_pb"
"github.com/openziti/foundation/channel2"
"github.com/spf13/cobra"
"time"
)
@@ -43,13 +43,13 @@ var removeTerminator = &cobra.Command{
if err != nil {
panic(err)
}
requestMsg := channel2.NewMessage(int32(mgmt_pb.ContentType_RemoveTerminatorRequestType), body)
responseMsg, err := ch.SendAndWaitWithTimeout(requestMsg, 5*time.Second)
requestMsg := channel.NewMessage(int32(mgmt_pb.ContentType_RemoveTerminatorRequestType), body)
responseMsg, err := requestMsg.WithTimeout(5 * time.Second).SendForReply(ch)
if err != nil {
panic(err)
}
if responseMsg.ContentType == channel2.ContentTypeResultType {
result := channel2.UnmarshalResult(responseMsg)
if responseMsg.ContentType == channel.ContentTypeResultType {
result := channel.UnmarshalResult(responseMsg)
if result.Success {
fmt.Printf("\nsuccess\n\n")
} else {
+13 -20
View File
@@ -17,11 +17,10 @@
package subcmd
import (
"github.com/openziti/foundation/channel2"
"github.com/openziti/fabric/pb/mgmt_pb"
"errors"
"fmt"
"github.com/golang/protobuf/proto"
"github.com/openziti/channel"
"github.com/openziti/fabric/pb/mgmt_pb"
"github.com/spf13/cobra"
"strconv"
"time"
@@ -44,30 +43,24 @@ func setLinkCost(cmd *cobra.Command, args []string) {
if ch, err := setLinkCostClient.Connect(); err == nil {
if cost, err := strconv.Atoi(args[1]); err == nil {
request := &mgmt_pb.SetLinkCostRequest{
LinkId: args[0],
Cost: int32(cost),
LinkId: args[0],
Cost: int32(cost),
}
if body, err := proto.Marshal(request); err == nil {
requestMsg := channel2.NewMessage(int32(mgmt_pb.ContentType_SetLinkCostRequestType), body)
waitCh, err := ch.SendAndWait(requestMsg)
requestMsg := channel.NewMessage(int32(mgmt_pb.ContentType_SetLinkCostRequestType), body)
responseMsg, err := requestMsg.WithTimeout(5 * time.Second).SendForReply(ch)
if err != nil {
panic(err)
}
select {
case responseMsg := <-waitCh:
if responseMsg.ContentType == channel2.ContentTypeResultType {
result := channel2.UnmarshalResult(responseMsg)
if result.Success {
fmt.Printf("\nsuccess\n\n")
} else {
fmt.Printf("\nfailure [%s]\n\n", result.Message)
}
if responseMsg.ContentType == channel.ContentTypeResultType {
result := channel.UnmarshalResult(responseMsg)
if result.Success {
fmt.Printf("\nsuccess\n\n")
} else {
panic(fmt.Errorf("unexpected response type %v", responseMsg.ContentType))
fmt.Printf("\nfailure [%s]\n\n", result.Message)
}
case <-time.After(5 * time.Second):
panic(errors.New("timeout"))
} else {
panic(fmt.Errorf("unexpected response type %v", responseMsg.ContentType))
}
} else {
panic(err)
+11 -18
View File
@@ -17,11 +17,10 @@
package subcmd
import (
"github.com/openziti/foundation/channel2"
"github.com/openziti/fabric/pb/mgmt_pb"
"errors"
"fmt"
"github.com/golang/protobuf/proto"
"github.com/openziti/channel"
"github.com/openziti/fabric/pb/mgmt_pb"
"github.com/spf13/cobra"
"strconv"
"time"
@@ -48,26 +47,20 @@ func setLinkDown(cmd *cobra.Command, args []string) {
Down: down,
}
if body, err := proto.Marshal(request); err == nil {
requestMsg := channel2.NewMessage(int32(mgmt_pb.ContentType_SetLinkDownRequestType), body)
waitCh, err := ch.SendAndWait(requestMsg)
requestMsg := channel.NewMessage(int32(mgmt_pb.ContentType_SetLinkDownRequestType), body)
responseMsg, err := requestMsg.WithTimeout(5 * time.Second).SendForReply(ch)
if err != nil {
panic(err)
}
select {
case responseMsg := <-waitCh:
if responseMsg.ContentType == channel2.ContentTypeResultType {
result := channel2.UnmarshalResult(responseMsg)
if result.Success {
fmt.Printf("\nsuccess\n\n")
} else {
fmt.Printf("\nfailure [%s]\n\n", result.Message)
}
if responseMsg.ContentType == channel.ContentTypeResultType {
result := channel.UnmarshalResult(responseMsg)
if result.Success {
fmt.Printf("\nsuccess\n\n")
} else {
panic(fmt.Errorf("unexpected response type %v", responseMsg.ContentType))
fmt.Printf("\nfailure [%s]\n\n", result.Message)
}
case <-time.After(5 * time.Second):
panic(errors.New("timeout"))
} else {
panic(fmt.Errorf("unexpected response type %v", responseMsg.ContentType))
}
}
} else {
+5 -5
View File
@@ -18,8 +18,8 @@ package subcmd
import (
"fmt"
"github.com/openziti/channel"
"github.com/openziti/fabric/pb/mgmt_pb"
"github.com/openziti/foundation/channel2"
"github.com/spf13/cobra"
"time"
)
@@ -42,13 +42,13 @@ func snapshotDb(cmd *cobra.Command, args []string) {
panic(err)
}
requestMsg := channel2.NewMessage(int32(mgmt_pb.ContentType_SnapshotDbRequestType), nil)
responseMsg, err := ch.SendAndWaitWithTimeout(requestMsg, 5*time.Second)
requestMsg := channel.NewMessage(int32(mgmt_pb.ContentType_SnapshotDbRequestType), nil)
responseMsg, err := requestMsg.WithTimeout(5 * time.Second).SendForReply(ch)
if err != nil {
panic(err)
}
if responseMsg.ContentType == channel2.ContentTypeResultType {
result := channel2.UnmarshalResult(responseMsg)
if responseMsg.ContentType == channel.ContentTypeResultType {
result := channel.UnmarshalResult(responseMsg)
if result.Success {
fmt.Printf("\nsuccess\n\n")
} else {
+15 -18
View File
@@ -17,11 +17,10 @@
package subcmd
import (
"errors"
"fmt"
"github.com/golang/protobuf/proto"
"github.com/openziti/channel"
"github.com/openziti/fabric/pb/mgmt_pb"
"github.com/openziti/foundation/channel2"
"github.com/spf13/cobra"
"time"
)
@@ -39,7 +38,16 @@ var streamCircuitsCmd = &cobra.Command{
var streamCircuitsClient *mgmtClient
func streamCircuits(*cobra.Command, []string) {
ch, err := streamCircuitsClient.Connect()
cw := newCloseWatcher()
bindHandler := func(binding channel.Binding) error {
binding.AddTypedReceiveHandler(&circuitsHandler{})
binding.AddCloseHandler(cw)
return nil
}
ch, err := streamCircuitsClient.ConnectAndBind(channel.BindHandlerF(bindHandler))
if err != nil {
panic(err)
}
@@ -50,23 +58,12 @@ func streamCircuits(*cobra.Command, []string) {
panic(err)
}
ch.AddReceiveHandler(&circuitsHandler{})
requestMsg := channel2.NewMessage(int32(mgmt_pb.ContentType_StreamCircuitsRequestType), body)
waitCh, err := ch.SendAndSync(requestMsg)
if err != nil {
requestMsg := channel.NewMessage(int32(mgmt_pb.ContentType_StreamCircuitsRequestType), body)
if err = requestMsg.WithTimeout(5 * time.Second).SendAndWaitForWire(ch); err != nil {
panic(err)
}
select {
case err := <-waitCh:
if err != nil {
panic(err)
}
case <-time.After(5 * time.Second):
panic(errors.New("timeout"))
}
waitForChannelClose(ch)
cw.waitForChannelClose()
}
type circuitsHandler struct{}
@@ -75,7 +72,7 @@ func (*circuitsHandler) ContentType() int32 {
return int32(mgmt_pb.ContentType_StreamCircuitsEventType)
}
func (*circuitsHandler) HandleReceive(msg *channel2.Message, _ channel2.Channel) {
func (*circuitsHandler) HandleReceive(msg *channel.Message, _ channel.Channel) {
event := &mgmt_pb.StreamCircuitsEvent{}
err := proto.Unmarshal(msg.Body, event)
if err != nil {
+11 -8
View File
@@ -17,25 +17,28 @@
package subcmd
import (
"github.com/openziti/foundation/channel2"
"github.com/michaelquigley/pfxlog"
"github.com/openziti/channel"
"sync"
)
func waitForChannelClose(ch channel2.Channel) {
func newCloseWatcher() *closeWatcher {
waitGroup := &sync.WaitGroup{}
waitGroup.Add(1)
ch.AddCloseHandler(&closeWatcher{waitGroup})
waitGroup.Wait()
return &closeWatcher{
waitGroup: waitGroup,
}
}
type closeWatcher struct {
waitGroup *sync.WaitGroup
}
func (watcher *closeWatcher) HandleClose(ch channel2.Channel) {
func (self *closeWatcher) HandleClose(ch channel.Channel) {
pfxlog.Logger().Info("Management channel to controller closed. Shutting down.")
watcher.waitGroup.Done()
self.waitGroup.Done()
}
func (self *closeWatcher) waitForChannelClose() {
self.waitGroup.Wait()
}
+15 -19
View File
@@ -17,13 +17,12 @@
package subcmd
import (
"github.com/openziti/foundation/channel2"
"github.com/openziti/fabric/pb/mgmt_pb"
"errors"
"fmt"
"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/ptypes"
"github.com/golang/protobuf/ptypes/timestamp"
"github.com/openziti/channel"
"github.com/openziti/fabric/pb/mgmt_pb"
"github.com/spf13/cobra"
"sort"
"time"
@@ -43,7 +42,15 @@ var streamMetricsCmd = &cobra.Command{
var streamMetricsClient *mgmtClient
func streamMetrics(cmd *cobra.Command, args []string) {
ch, err := streamMetricsClient.Connect()
cw := newCloseWatcher()
bindHandler := func(binding channel.Binding) error {
binding.AddTypedReceiveHandler(&metricsHandler{})
binding.AddCloseHandler(cw)
return nil
}
ch, err := streamCircuitsClient.ConnectAndBind(channel.BindHandlerF(bindHandler))
if err != nil {
panic(err)
}
@@ -64,23 +71,12 @@ func streamMetrics(cmd *cobra.Command, args []string) {
panic(err)
}
ch.AddReceiveHandler(&metricsHandler{})
requestMsg := channel2.NewMessage(int32(mgmt_pb.ContentType_StreamMetricsRequestType), body)
waitCh, err := ch.SendAndSync(requestMsg)
if err != nil {
requestMsg := channel.NewMessage(int32(mgmt_pb.ContentType_StreamMetricsRequestType), body)
if err = requestMsg.WithTimeout(5 * time.Second).SendAndWaitForWire(ch); err != nil {
panic(err)
}
select {
case err := <-waitCh:
if err != nil {
panic(err)
}
case <-time.After(5 * time.Second):
panic(errors.New("timeout"))
}
waitForChannelClose(ch)
cw.waitForChannelClose()
}
type metricsHandler struct{}
@@ -89,7 +85,7 @@ func (*metricsHandler) ContentType() int32 {
return int32(mgmt_pb.ContentType_StreamMetricsEventType)
}
func (*metricsHandler) HandleReceive(msg *channel2.Message, ch channel2.Channel) {
func (*metricsHandler) HandleReceive(msg *channel.Message, ch channel.Channel) {
response := &mgmt_pb.StreamMetricsEvent{}
err := proto.Unmarshal(msg.Body, response)
if err != nil {
+13 -19
View File
@@ -17,12 +17,11 @@
package subcmd
import (
"github.com/openziti/foundation/channel2"
"github.com/openziti/fabric/pb/mgmt_pb"
trace_pb "github.com/openziti/foundation/trace/pb"
"errors"
"fmt"
"github.com/golang/protobuf/proto"
"github.com/openziti/channel"
"github.com/openziti/fabric/pb/mgmt_pb"
trace_pb "github.com/openziti/foundation/trace/pb"
"github.com/spf13/cobra"
"time"
)
@@ -65,26 +64,21 @@ func togglePipeTraces(cmd *cobra.Command, args []string) {
}
if body, err := proto.Marshal(request); err == nil {
requestMsg := channel2.NewMessage(int32(mgmt_pb.ContentType_TogglePipeTracesRequestType), body)
waitCh, err := ch.SendAndWait(requestMsg)
requestMsg := channel.NewMessage(int32(mgmt_pb.ContentType_TogglePipeTracesRequestType), body)
responseMsg, err := requestMsg.WithTimeout(5 * time.Second).SendForReply(ch)
if err != nil {
panic(err)
}
select {
case responseMsg := <-waitCh:
if responseMsg.ContentType == channel2.ContentTypeResultType {
result := channel2.UnmarshalResult(responseMsg)
if result.Success {
fmt.Printf("\ntracing enabled successfully\n\n")
fmt.Println(result.Message)
} else {
fmt.Printf("\ntracing enable failured [%s]\n\n", result.Message)
}
if responseMsg.ContentType == channel.ContentTypeResultType {
result := channel.UnmarshalResult(responseMsg)
if result.Success {
fmt.Printf("\ntracing enabled successfully\n\n")
fmt.Println(result.Message)
} else {
panic(fmt.Errorf("unexpected response type %v", responseMsg.ContentType))
fmt.Printf("\ntracing enable failured [%s]\n\n", result.Message)
}
case <-time.After(5 * time.Second):
panic(errors.New("timeout"))
} else {
panic(fmt.Errorf("unexpected response type %v", responseMsg.ContentType))
}
} else {
panic(err)
+67 -18
View File
@@ -17,15 +17,16 @@
package subcmd
import (
"errors"
"encoding/json"
"fmt"
"github.com/golang/protobuf/proto"
"github.com/openziti/channel"
"github.com/openziti/fabric/pb/ctrl_pb"
"github.com/openziti/fabric/pb/mgmt_pb"
"github.com/openziti/fabric/router/xgress"
"github.com/openziti/foundation/channel2"
"github.com/openziti/foundation/trace/pb"
"github.com/spf13/cobra"
"reflect"
"sort"
"time"
)
@@ -72,7 +73,15 @@ func streamTraces(_ *cobra.Command, args []string) {
}
}
ch, err := streamTracesClient.Connect()
cw := newCloseWatcher()
bindHandler := func(binding channel.Binding) error {
binding.AddTypedReceiveHandler(&traceHandler{})
binding.AddCloseHandler(cw)
return nil
}
ch, err := streamCircuitsClient.ConnectAndBind(channel.BindHandlerF(bindHandler))
if err != nil {
panic(err)
}
@@ -82,22 +91,13 @@ func streamTraces(_ *cobra.Command, args []string) {
panic(err)
}
ch.AddReceiveHandler(&traceHandler{})
requestMsg := channel2.NewMessage(int32(mgmt_pb.ContentType_StreamTracesRequestType), body)
requestMsg := channel.NewMessage(int32(mgmt_pb.ContentType_StreamTracesRequestType), body)
waitCh, err := ch.SendAndSync(requestMsg)
if err != nil {
if err = requestMsg.WithTimeout(5 * time.Second).SendAndWaitForWire(ch); err != nil {
panic(err)
}
select {
case err := <-waitCh:
if err != nil {
panic(err)
}
case <-time.After(5 * time.Second):
panic(errors.New("timeout"))
}
waitForChannelClose(ch)
cw.waitForChannelClose()
}
func getContentType(name string) (int32, error) {
@@ -141,7 +141,7 @@ func (*traceHandler) ContentType() int32 {
return int32(mgmt_pb.ContentType_StreamTracesEventType)
}
func (*traceHandler) HandleReceive(msg *channel2.Message, ch channel2.Channel) {
func (*traceHandler) HandleReceive(msg *channel.Message, _ channel.Channel) {
event := &trace_pb.ChannelMessage{}
err := proto.Unmarshal(msg.Body, event)
if err != nil {
@@ -156,10 +156,59 @@ func (*traceHandler) HandleReceive(msg *channel2.Message, ch channel2.Channel) {
if event.ReplyFor != -1 {
replyFor = fmt.Sprintf(">%d", event.ReplyFor)
}
meta := channel2.DecodeTraceAndFormat(event.Decode)
meta := DecodeTraceAndFormat(event.Decode)
if meta == "" {
meta = fmt.Sprintf("missing decode, content-type=%v", event.ContentType)
}
fmt.Printf("%8d: %-16s %8s %s #%-5d %5s | %s\n",
event.Timestamp, event.Identity, event.Channel, flow, event.Sequence, replyFor, meta)
}
func DecodeTraceAndFormat(decode []byte) string {
if len(decode) > 0 {
meta := make(map[string]interface{})
err := json.Unmarshal(decode, &meta)
if err != nil {
panic(err)
}
out := fmt.Sprintf("%-24s", fmt.Sprintf("%-8s %s", meta[channel.DecoderFieldName], meta[channel.MessageFieldName]))
if len(meta) > 2 {
keys := make([]string, 0)
for k := range meta {
if k != channel.DecoderFieldName && k != channel.MessageFieldName {
keys = append(keys, k)
}
}
sort.Strings(keys)
out += " {"
for i := 0; i < len(keys); i++ {
k := keys[i]
if i > 0 {
out += " "
}
out += k
out += "=["
v := meta[k]
switch v.(type) {
case string:
out += v.(string)
case float64:
out += fmt.Sprintf("%0.0f", v.(float64))
case bool:
out += fmt.Sprintf("%t", v.(bool))
default:
out += fmt.Sprintf("<%s>", reflect.TypeOf(v))
}
out += "]"
}
out += "}"
}
return out
} else {
return ""
}
}
+9 -8
View File
@@ -17,12 +17,13 @@
package trace
import (
"github.com/openziti/foundation/channel2"
"github.com/openziti/foundation/trace"
"github.com/openziti/foundation/trace/pb"
"encoding/json"
"errors"
"fmt"
"github.com/openziti/channel"
"github.com/openziti/foundation/trace"
"github.com/openziti/foundation/trace/pb"
"github.com/openziti/ziti/ziti-fabric/subcmd"
"github.com/spf13/cobra"
)
@@ -80,7 +81,7 @@ func (h *dumpHandler) Handle(msg interface{}) error {
if t.ReplyFor != -1 {
replyFor = fmt.Sprintf(">%d", t.ReplyFor)
}
fmt.Printf("%8s: %-16s %8s %s #%-5d %5s | %s\n", h.formatTimestamp(t.Timestamp), t.Identity, t.Channel, flow, t.Sequence, replyFor, channel2.DecodeTraceAndFormat(t.Decode))
fmt.Printf("%8s: %-16s %8s %s #%-5d %5s | %s\n", h.formatTimestamp(t.Timestamp), t.Identity, t.Channel, flow, t.Sequence, replyFor, subcmd.DecodeTraceAndFormat(t.Decode))
} else {
h.formatTimestamp(t.Timestamp)
@@ -99,7 +100,7 @@ func (h *dumpHandler) formatTimestamp(timestamp int64) string {
h.lastTimestamp = timestamp
return "0"
}
out := fmt.Sprintf("%d", (timestamp - h.lastTimestamp) / 1000)
out := fmt.Sprintf("%d", (timestamp-h.lastTimestamp)/1000)
h.lastTimestamp = timestamp
return out
}
@@ -115,13 +116,13 @@ func filterMatch(trace *trace_pb.ChannelMessage) (bool, error) {
channelMatch := true
if dumpCmdDecoderFilter != "" {
channelMatch = dumpCmdDecoderFilter == meta[channel2.DecoderFieldName]
channelMatch = dumpCmdDecoderFilter == meta[channel.DecoderFieldName]
}
messageMatch := true
if dumpCmdMessageFilter != "" {
messageMatch = dumpCmdMessageFilter == meta[channel2.MessageFieldName]
messageMatch = dumpCmdMessageFilter == meta[channel.MessageFieldName]
}
return channelMatch && messageMatch, nil
}
}