diff --git a/CHANGELOG.md b/CHANGELOG.md index 17511ca22..f25e2d0b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,40 @@ +# Release 0.28.2 + +## What's New + +* IMPORTANT: If you update your OpenZiti binaries to this version or later (which can be done easily with the `getZiti()` function, you will need to migrate any existing network that has been developed using OpenZiti v0.27.5 or earlier binaries as the new binaries will expect the new environment variable names. A function `performMigration()` has been provided in the `ziti-cli-script.sh` for this purpose. Simply source the latest `ziti-cli-script.sh`, and your current network's .env file, then run `performMigration()` to update environment variable name references. If the migration process cannot find your existing environment file in the default location, you will need to provide the path to the migration function, ex: `performMigration ` +* If you were using the `ZITI_HOME` environment variable to configure where your ziti CLI profiles were stored, you should now use `ZITI_CONFIG_DIR` instead. + + +## Component Updates and Bug Fixes + +* github.com/openziti/channel/v2: [v2.0.80 -> v2.0.81](https://github.com/openziti/channel/compare/v2.0.80...v2.0.81) +* github.com/openziti/edge: [v0.24.326 -> v0.24.345](https://github.com/openziti/edge/compare/v0.24.326...v0.24.345) + * [Issue #1528](https://github.com/openziti/edge/issues/1528) - edge unbind returns incorect message if token is not suplied or invalid + * [Issue #1416](https://github.com/openziti/edge/issues/1416) - Allow MFA token name to be configured + +* github.com/openziti/edge-api: [v0.25.25 -> v0.25.29](https://github.com/openziti/edge-api/compare/v0.25.25...v0.25.29) +* github.com/openziti/fabric: [v0.23.35 -> v0.23.39](https://github.com/openziti/fabric/compare/v0.23.35...v0.23.39) + * [Issue #751](https://github.com/openziti/fabric/issues/751) - Use of Fprintf causing buffer pool corruption with amqp event output + +* github.com/openziti/foundation/v2: [v2.0.25 -> v2.0.26](https://github.com/openziti/foundation/compare/v2.0.25...v2.0.26) +* github.com/openziti/identity: [v1.0.56 -> v1.0.57](https://github.com/openziti/identity/compare/v1.0.56...v1.0.57) +* github.com/openziti/runzmd: [v1.0.25 -> v1.0.26](https://github.com/openziti/runzmd/compare/v1.0.25...v1.0.26) +* github.com/openziti/sdk-golang: [v0.20.58 -> v0.20.67](https://github.com/openziti/sdk-golang/compare/v0.20.58...v0.20.67) +* github.com/openziti/storage: [v0.2.7 -> v0.2.8](https://github.com/openziti/storage/compare/v0.2.7...v0.2.8) +* github.com/openziti/transport/v2: [v2.0.90 -> v2.0.91](https://github.com/openziti/transport/compare/v2.0.90...v2.0.91) +* github.com/openziti/metrics: [v1.2.26 -> v1.2.27](https://github.com/openziti/metrics/compare/v1.2.26...v1.2.27) +* github.com/openziti/secretstream: [v0.1.8 -> v0.1.9](https://github.com/openziti/secretstream/compare/v0.1.8...v0.1.9) +* github.com/openziti/ziti: [v0.28.1 -> v0.28.2](https://github.com/openziti/ziti/compare/v0.28.1...v0.28.2) + * [Issue #1144](https://github.com/openziti/ziti/issues/1144) - DB explore subcommand panic + * [Issue #986](https://github.com/openziti/ziti/issues/986) - Updated default ports in `.env` file to match documentation. + * [Issue #920](https://github.com/openziti/ziti/issues/920) - Fixed bug causing failure when re-running quickstart. + * [Issue #779](https://github.com/openziti/ziti/issues/779) - Add ability to upgrade ziti binaries using a quickstart function. + * [Issue #761](https://github.com/openziti/ziti/issues/761) - Remove Management Listener section from controller config. + * [Issue #650](https://github.com/openziti/ziti/issues/650) - Removed/Updated references to `ZITI_EDGE_CONTROLLER_API` + * Quickstart environment variable names have been cleaned up. + * [Issue #1030](https://github.com/openziti/ziti/issues/1030) - Provide an upgrade path for quickstart cleanup + # Release 0.28.1 ## What's New diff --git a/doc/003-local-deploy.md b/doc/003-local-deploy.md index 74106bdaf..a4d9fc2c0 100644 --- a/doc/003-local-deploy.md +++ b/doc/003-local-deploy.md @@ -36,12 +36,12 @@ ZITI_HOME=. \ ZITI_CTRL_LISTENER_ADDRESS=127.0.0.1 \ ZITI_CTRL_EDGE_LISTENER_HOST_PORT=127.0.0.1:1280 \ ZITI_EDGE_CTRL_ADVERTISED_HOST_PORT=127.0.0.1:1280 \ -ZITI_CTRL_IDENTITY_CERT=./etc/ca/intermediate/certs/ctrl-client.cert.pem \ -ZITI_CTRL_IDENTITY_SERVER_CERT=./etc/ca/intermediate/certs/ctrl-server.cert.pem \ -ZITI_CTRL_IDENTITY_KEY=./etc/ca/intermediate/private/ctrl.key.pem \ -ZITI_CTRL_IDENTITY_CA=./etc/ca/intermediate/certs/ca-chain.cert.pem \ -ZITI_SIGNING_CERT=./etc/ca/intermediate/certs/intermediate.cert.pem \ -ZITI_SIGNING_KEY=./etc/ca/intermediate/private/intermediate.key.decrypted.pem \ +ZITI_PKI_CTRL_CERT=./etc/ca/intermediate/certs/ctrl-client.cert.pem \ +ZITI_PKI_CTRL_SERVER_CERT=./etc/ca/intermediate/certs/ctrl-server.cert.pem \ +ZITI_PKI_CTRL_KEY=./etc/ca/intermediate/private/ctrl.key.pem \ +ZITI_PKI_CTRL_CA=./etc/ca/intermediate/certs/ca-chain.cert.pem \ +ZITI_PKI_SIGNER_CERT=./etc/ca/intermediate/certs/intermediate.cert.pem \ +ZITI_PKI_SIGNER_KEY=./etc/ca/intermediate/private/intermediate.key.decrypted.pem \ ziti create config controller \ --output ./db/ctrl-config.yml ``` @@ -82,8 +82,8 @@ Generate a configuration file for router01. ```bash ZITI_HOME=./db \ -ZITI_CTRL_ADVERTISED_ADDRESS=127.0.0.1 \ -ZITI_EDGE_ROUTER_RAWNAME=localhost \ +ZITI_CTRL_EDGE_ADVERTISED_ADDRESS=127.0.0.1 \ +ZITI_EDGE_ROUTER_NAME=localhost \ ziti create config router edge \ --routerName router01 \ --output ./db/router01-config.yml diff --git a/go.mod b/go.mod index 3ca4ba1e6..e05fc82b9 100644 --- a/go.mod +++ b/go.mod @@ -21,16 +21,16 @@ require ( github.com/jedib0t/go-pretty/v6 v6.4.0 github.com/michaelquigley/pfxlog v0.6.10 github.com/openziti/agent v1.0.14 - github.com/openziti/channel/v2 v2.0.80 - github.com/openziti/edge v0.24.326 - github.com/openziti/edge-api v0.25.25 - github.com/openziti/fabric v0.23.35 - github.com/openziti/foundation/v2 v2.0.25 - github.com/openziti/identity v1.0.56 - github.com/openziti/runzmd v1.0.25 - github.com/openziti/sdk-golang v0.20.58 - github.com/openziti/storage v0.2.7 - github.com/openziti/transport/v2 v2.0.90 + github.com/openziti/channel/v2 v2.0.81 + github.com/openziti/edge v0.24.345 + github.com/openziti/edge-api v0.25.29 + github.com/openziti/fabric v0.23.39 + github.com/openziti/foundation/v2 v2.0.26 + github.com/openziti/identity v1.0.57 + github.com/openziti/runzmd v1.0.26 + github.com/openziti/sdk-golang v0.20.67 + github.com/openziti/storage v0.2.8 + github.com/openziti/transport/v2 v2.0.91 github.com/openziti/xweb/v2 v2.0.2 github.com/openziti/ziti-db-explorer v1.1.1 github.com/pkg/errors v0.9.1 @@ -43,7 +43,7 @@ require ( github.com/spf13/viper v1.10.0 github.com/stretchr/testify v1.8.4 go.etcd.io/bbolt v1.3.7 - golang.org/x/net v0.10.0 + golang.org/x/net v0.11.0 google.golang.org/grpc v1.42.0 google.golang.org/protobuf v1.30.0 gopkg.in/AlecAivazis/survey.v1 v1.8.7 @@ -86,12 +86,12 @@ require ( github.com/go-logr/stdr v1.2.2 // indirect github.com/go-ole/go-ole v1.2.6 // indirect github.com/go-openapi/analysis v0.21.4 // indirect - github.com/go-openapi/errors v0.20.3 // indirect + github.com/go-openapi/errors v0.20.4 // indirect github.com/go-openapi/jsonpointer v0.19.6 // indirect github.com/go-openapi/jsonreference v0.20.2 // indirect github.com/go-openapi/loads v0.21.2 // indirect github.com/go-openapi/spec v0.20.9 // indirect - github.com/go-openapi/swag v0.22.3 // indirect + github.com/go-openapi/swag v0.22.4 // indirect github.com/go-openapi/validate v0.22.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang-jwt/jwt v3.2.2+incompatible // indirect @@ -114,7 +114,7 @@ require ( github.com/josharian/native v1.1.0 // indirect github.com/kataras/go-events v0.0.3 // indirect github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect - github.com/klauspost/compress v1.16.5 // indirect + github.com/klauspost/compress v1.16.6 // indirect github.com/kr/pty v1.1.8 // indirect github.com/kyokomi/emoji/v2 v2.2.12 // indirect github.com/lucasb-eyer/go-colorful v1.2.0 // indirect @@ -129,7 +129,7 @@ require ( github.com/mdlayher/netlink v1.7.2 // indirect github.com/mdlayher/socket v0.4.1 // indirect github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect - github.com/miekg/dns v1.1.54 // indirect + github.com/miekg/dns v1.1.55 // indirect github.com/miekg/pkcs11 v1.1.1 // indirect github.com/mitchellh/go-ps v1.0.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect @@ -142,8 +142,8 @@ require ( github.com/opentracing/opentracing-go v1.2.0 // indirect github.com/openziti/dilithium v0.3.3 // indirect github.com/openziti/jwks v1.0.3 // indirect - github.com/openziti/metrics v1.2.26 // indirect - github.com/openziti/secretstream v0.1.8 // indirect + github.com/openziti/metrics v1.2.27 // indirect + github.com/openziti/secretstream v0.1.9 // indirect github.com/openziti/x509-claims v1.0.3 // indirect github.com/orcaman/concurrent-map/v2 v2.0.1 // indirect github.com/parallaxsecond/parsec-client-go v0.0.0-20221025095442-f0a77d263cf9 // indirect @@ -175,14 +175,14 @@ require ( go.opentelemetry.io/otel v1.16.0 // indirect go.opentelemetry.io/otel/metric v1.16.0 // indirect go.opentelemetry.io/otel/trace v1.16.0 // indirect - golang.org/x/crypto v0.9.0 // indirect + golang.org/x/crypto v0.10.0 // indirect golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 // indirect - golang.org/x/image v0.7.0 // indirect + golang.org/x/image v0.8.0 // indirect golang.org/x/mod v0.8.0 // indirect - golang.org/x/sync v0.2.0 // indirect - golang.org/x/sys v0.8.0 // indirect - golang.org/x/term v0.8.0 // indirect - golang.org/x/text v0.9.0 // indirect + golang.org/x/sync v0.3.0 // indirect + golang.org/x/sys v0.9.0 // indirect + golang.org/x/term v0.9.0 // indirect + golang.org/x/text v0.10.0 // indirect golang.org/x/tools v0.6.0 // indirect google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa // indirect gopkg.in/ini.v1 v1.66.2 // indirect diff --git a/go.sum b/go.sum index ba86f9615..9fb62a3a0 100644 --- a/go.sum +++ b/go.sum @@ -273,8 +273,8 @@ github.com/go-openapi/analysis v0.21.4/go.mod h1:4zQ35W4neeZTqh3ol0rv/O8JBbka9Qy 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.2/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M= -github.com/go-openapi/errors v0.20.3 h1:rz6kiC84sqNQoqrtulzaL/VERgkoCyB6WdEkc2ujzUc= -github.com/go-openapi/errors v0.20.3/go.mod h1:Z3FlZ4I8jEGxjUK+bugx3on2mIAk4txuAOhlsB1FSgk= +github.com/go-openapi/errors v0.20.4 h1:unTcVm6PispJsMECE3zWgvG4xTiKda1LIR5rCRWLG6M= +github.com/go-openapi/errors v0.20.4/go.mod h1:Z3FlZ4I8jEGxjUK+bugx3on2mIAk4txuAOhlsB1FSgk= github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE= @@ -300,8 +300,9 @@ github.com/go-openapi/strfmt v0.21.7/go.mod h1:adeGTkxE44sPyLk0JV235VQAO/ZXUr8KA github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= github.com/go-openapi/swag v0.19.15/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= github.com/go-openapi/swag v0.21.1/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= -github.com/go-openapi/swag v0.22.3 h1:yMBqmnQ0gyZvEb/+KzuWZOXgllrXT4SADYbvDaXHv/g= github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= +github.com/go-openapi/swag v0.22.4 h1:QLMzNJnMGPRNDCbySlcj1x01tzU8/9LTTL9hZZZogBU= +github.com/go-openapi/swag v0.22.4/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= github.com/go-openapi/validate v0.22.1 h1:G+c2ub6q47kfX1sOBLwIQwzBVt8qmOAARyo/9Fqs9NU= github.com/go-openapi/validate v0.22.1/go.mod h1:rjnrwK57VJ7A8xqfpAOEKRH8yQSGUriMu5/zuPSQ1hg= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= @@ -550,8 +551,8 @@ github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= -github.com/klauspost/compress v1.16.5 h1:IFV2oUNUzZaz+XyusxpLzpzS8Pt5rh0Z16For/djlyI= -github.com/klauspost/compress v1.16.5/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= +github.com/klauspost/compress v1.16.6 h1:91SKEy4K37vkp255cJ8QesJhjyRO0hn9i9G0GoUwLsk= +github.com/klauspost/compress v1.16.6/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/kolo/xmlrpc v0.0.0-20200310150728-e0350524596b/go.mod h1:o03bZfuBwAXHetKXuInt4S7omeXUu62/A845kiycsSQ= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= @@ -652,8 +653,8 @@ github.com/michaelquigley/pfxlog v0.6.10/go.mod h1:gEiNTfKEX6cJHSwRpOuqBpc8oYrlh github.com/microcosm-cc/bluemonday v1.0.1/go.mod h1:hsXNsILzKxV+sX77C5b8FSuKF00vh2OMYv+xgHpAMF4= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/miekg/dns v1.1.31/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM= -github.com/miekg/dns v1.1.54 h1:5jon9mWcb0sFJGpnI99tOMhCPyJ+RPVz5b63MQG0VWI= -github.com/miekg/dns v1.1.54/go.mod h1:uInx36IzPl7FYnDcMeVWxj9byh7DutNykX4G9Sj60FY= +github.com/miekg/dns v1.1.55 h1:GoQ4hpsj0nFLYe+bWiCToyrBEJXkQfOOIvFGFy0lEgo= +github.com/miekg/dns v1.1.55/go.mod h1:uInx36IzPl7FYnDcMeVWxj9byh7DutNykX4G9Sj60FY= github.com/miekg/pkcs11 v1.1.1 h1:Ugu9pdy6vAYku5DEpVWVFPYnzV+bxB+iRdbuFSu7TvU= github.com/miekg/pkcs11 v1.1.1/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs= github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= @@ -721,34 +722,34 @@ github.com/openzipkin/zipkin-go v0.1.1/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTm github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw= github.com/openziti/agent v1.0.14 h1:OTYhj2HeIlFwaFNcVT5BlYf7s4xa0TNmhnjmBpN8Afg= github.com/openziti/agent v1.0.14/go.mod h1:zfm53+PVWoGFzjGGgQdKby5749G6VRYHe+eQJmoVKy4= -github.com/openziti/channel/v2 v2.0.80 h1:1gDikwcVvhRKs+CO8OyUHMSJWVJarCm5+OmffZ4gPCU= -github.com/openziti/channel/v2 v2.0.80/go.mod h1:U1KSHZXWlg8VelsZ55+ZGiARYWh+XbJbD7AfN0NXUdQ= +github.com/openziti/channel/v2 v2.0.81 h1:YtFMJz4pMhhOH92zZbOKAvx/l5zaRz5TQff0lTa5G6w= +github.com/openziti/channel/v2 v2.0.81/go.mod h1:d+2+i51uXi8J6M8OsazLJg1OzSPmL+sOyzdiRUmra3I= 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.24.326 h1:Y5Z3DGac2ghXivh04S/3HgTymp1UliTaSlLn5fo3qdg= -github.com/openziti/edge v0.24.326/go.mod h1:vI2HZMZa+PdiIjf25xpg19lR32X+ouLbY3idOIw+Dac= -github.com/openziti/edge-api v0.25.25 h1:1S7L9JsvXuzd8nULZEPNgafPfhnHQY4Hhqj8B00CKTw= -github.com/openziti/edge-api v0.25.25/go.mod h1:aDUHHxOGtxFXnoDaTXpNF6gq+tbDkWCURP5yaEJbdm0= -github.com/openziti/fabric v0.23.35 h1:SxdMC88E5PCm7SoE8q0q8yOaO2fC1RiJES/sOYymVe4= -github.com/openziti/fabric v0.23.35/go.mod h1:eFG042f6bv/vZSOmp48pVAqEntCfkkMJCVAbNG9GHno= -github.com/openziti/foundation/v2 v2.0.25 h1:tGb9wdu6KCpO49RJ3HX2ClOVHf8gdntplIh/7CEVaM4= -github.com/openziti/foundation/v2 v2.0.25/go.mod h1:EOqea8Q1wXd4hS9MxFYM6ngDgenKGxz8c+CJ8Svr7BI= -github.com/openziti/identity v1.0.56 h1:h8SzatjWa3TCpIG6/holKUTHSKtNAJ1MuK5CCY31ZOw= -github.com/openziti/identity v1.0.56/go.mod h1:5h08wngbQjENt6sWPp+GyWpqNkeSPwMdDFPFONf6EBE= +github.com/openziti/edge v0.24.345 h1:7anwwljort9FsriHoBAiz6DOOkPJV2XCzZJLmn/TxFo= +github.com/openziti/edge v0.24.345/go.mod h1:pjU6bCSfaAVQLajeKB/ypGYoeZnIuHw7Y75kX37WHTw= +github.com/openziti/edge-api v0.25.29 h1:DbZ0GKpch9ik+XnC0qoP1dOg1AmgUEeWH4VIyOIehrQ= +github.com/openziti/edge-api v0.25.29/go.mod h1:mqYquh1RYvHjV/M9MGO4Ng0Xq9ixAH8o8cT5kw5XCWY= +github.com/openziti/fabric v0.23.39 h1:t6npkfBsPr+8GvF9X/rTLHxGsce5FTa4NoA80MInxYc= +github.com/openziti/fabric v0.23.39/go.mod h1:px2zUzQrgObmv6sdXgGJ028Wr45aGcgpFvfIP/qgDFo= +github.com/openziti/foundation/v2 v2.0.26 h1:RISGM97aIFnnEkxrcVsO6fnGg9W4ByydSnqWAVkJAqY= +github.com/openziti/foundation/v2 v2.0.26/go.mod h1:ngdQq0KLGIDfzkQQzu1BQSMLNrsBUXdziGvsJns4cFM= +github.com/openziti/identity v1.0.57 h1:tVFYGMVFINKWi4RV75yEz7hbDuRPqRnG+AiFAEtvXHQ= +github.com/openziti/identity v1.0.57/go.mod h1:cwkBpiIy1C4S6r+dD0jPKq9mS4aj7NuABt1WJwxHon8= github.com/openziti/jwks v1.0.3 h1:hf8wkb+Cg4nH/HM0KROFd7u+C3DkRVcFZJ7tDV+4icc= github.com/openziti/jwks v1.0.3/go.mod h1:t4xxq8vlXGsPn29kiQVnZBBDDnEoOFqtJoHibkJunQQ= -github.com/openziti/metrics v1.2.26 h1:8q93bK1MYAdR9ODr0qNAJ1/BQpFtHYdxZiH0Fc9LLo8= -github.com/openziti/metrics v1.2.26/go.mod h1:Z1c9pNHQr+yZODDsOeim93rYg5Hw1kPsuHi3zdy70dA= -github.com/openziti/runzmd v1.0.25 h1:/6LVurAnU8Hl4Tcm0FcncNicTIo3gwu2eMCiViPqzNQ= -github.com/openziti/runzmd v1.0.25/go.mod h1:pYnqjgH8/geMdzU8OIxamU8RlRdRaOh00mWBxDoXPDo= -github.com/openziti/sdk-golang v0.20.58 h1:cHyzEQiZSsaeJbN/lYqAY0i5fDlt9wlFH7LtG+0qFwE= -github.com/openziti/sdk-golang v0.20.58/go.mod h1:L6mGhnsxwDuVBE7ByCVLf2kPymf5l9l6WRUMA3SfZeo= -github.com/openziti/secretstream v0.1.8 h1:AgPHLDuXTiM1apHQmBvwvSW1vbQqAm7wUJDHqkQ/6Nk= -github.com/openziti/secretstream v0.1.8/go.mod h1:qcF8EmSX5SAT8k2pzsDI4bWugopv9AA+ltgWDrcAAEw= -github.com/openziti/storage v0.2.7 h1:rQVVclnkCZyr4XXKMypIJf46HFGJX5KEYWEycUhWvtg= -github.com/openziti/storage v0.2.7/go.mod h1:bGhUs/0XDsEJnTtNTpFAIh1X4lfdKvHu0m+8Z1TFVyM= -github.com/openziti/transport/v2 v2.0.90 h1:QoddlajGdyOZZDTxhgapkd3wucosTVGJn8z5Pt3ltOM= -github.com/openziti/transport/v2 v2.0.90/go.mod h1:q8zNDI7lYqA4flQVJwJZQg8HJVNcG7kIFLnH9qfeHDc= +github.com/openziti/metrics v1.2.27 h1:Dw/FSC+QvyqkDmLeSsxzCRD0aFPwgivwQyQsxzlAgoQ= +github.com/openziti/metrics v1.2.27/go.mod h1:mhP2c8MTGL0C5H8yAsNwBq88SW1C3Mx1ICVO6heMbJQ= +github.com/openziti/runzmd v1.0.26 h1:bWJhTD0jwkRi01e/fY72UbJ+x4iNEzE2Lx5chNp1sCU= +github.com/openziti/runzmd v1.0.26/go.mod h1:Lj1MpR8DXhVKxw6MdaSU0bD6Wh8CwzNpEw5Qm/NSWfM= +github.com/openziti/sdk-golang v0.20.67 h1:atesqk/yUAM1sBe5zaMwKrRBYLzeEtUz7BQn72hFyR8= +github.com/openziti/sdk-golang v0.20.67/go.mod h1:zieqsVAB/kawb/Ske7zkArUG2TGUIOdcHyVh79NcnBA= +github.com/openziti/secretstream v0.1.9 h1:mNCMr9oYQ4JAfdU4iU79i3si4vqVVsErzrhXuKC7R3M= +github.com/openziti/secretstream v0.1.9/go.mod h1:tq0XVUwFAT0TwfBpILp4KaeEnasduNTUixOIrmUZUGA= +github.com/openziti/storage v0.2.8 h1:Rbnj6LKfcdR644kXrS4bF0ot+z17zDGCiUifd1eOvZ0= +github.com/openziti/storage v0.2.8/go.mod h1:Cd1YuhqSLbVI0vaujTQl/cHgPCECapLGh/s4bMgKczM= +github.com/openziti/transport/v2 v2.0.91 h1:eEWRSoy9+tDf6K+jJcl5TSHm6GX7IKiBQg8XxmDyELQ= +github.com/openziti/transport/v2 v2.0.91/go.mod h1:FDGkg110LTdmz4Kp1zucomvc++ld7UKXFfNWBTwQIlQ= github.com/openziti/x509-claims v1.0.3 h1:HNdQ8Nf1agB3lBs1gahcO6zfkeS4S5xoQ2/PkY4HRX0= github.com/openziti/x509-claims v1.0.3/go.mod h1:Z0WIpBm6c4ecrpRKrou6Gk2wrLWxJO/+tuUwKh8VewE= github.com/openziti/xweb/v2 v2.0.2 h1:XYlVFriTq/U1wcUrc+XPnWJGhXh9NJPhtQ7+r3aC0cU= @@ -1054,8 +1055,8 @@ golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= -golang.org/x/crypto v0.9.0 h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g= -golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0= +golang.org/x/crypto v0.10.0 h1:LKqV2xt9+kDzSTfOhx4FrkEBcMrAgHSYgzywV9zcGmM= +golang.org/x/crypto v0.10.0/go.mod h1:o4eNf7Ede1fv+hwOwZsTHl9EsPFO6q6ZvYR8vYfY45I= 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= @@ -1072,8 +1073,8 @@ golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMx golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/image v0.0.0-20191206065243-da761ea9ff43/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/image v0.7.0 h1:gzS29xtG1J5ybQlv0PuyfE3nmc6R4qB73m6LUUmvFuw= -golang.org/x/image v0.7.0/go.mod h1:nd/q4ef1AKKYl/4kft7g+6UyGbdiqWqTP1ZAbRoV7Rg= +golang.org/x/image v0.8.0 h1:agUcRXV/+w6L9ryntYYsF2x9fQTMd4T8fiiYXAVW6Jg= +golang.org/x/image v0.8.0/go.mod h1:PwLxp3opCYg4WR2WO9P0L6ESnsD6bLTWcw8zanLMVFM= golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= @@ -1157,8 +1158,8 @@ golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qx golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= -golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= +golang.org/x/net v0.11.0 h1:Gi2tvZIJyBtO9SDr1q9h5hEQCp/4L2RQ+ar0qjx2oNU= +golang.org/x/net v0.11.0/go.mod h1:2L/ixqYpgIVXmeoSA/4Lu7BzTG4KIyPIryS4IsOd1oQ= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -1188,8 +1189,8 @@ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI= -golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= +golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sys v0.0.0-20180606202747-9527bec2660b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180622082034-63fc586f45fe/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1278,14 +1279,15 @@ golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s= +golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/term v0.8.0 h1:n5xxQn2i3PC0yLAbjTpNT85q/Kgzcr2gIoX9OrJUols= -golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= +golang.org/x/term v0.9.0 h1:GRRCnKYhdQrD8kfRAdQ6Zcw1P0OcELxGLKJvtjVMZ28= +golang.org/x/term v0.9.0/go.mod h1:M6DEAAIenWoTxdKrOltXcmDY3rSplQUkrvaDU5FcQyo= 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= @@ -1297,8 +1299,8 @@ golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= -golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.10.0 h1:UpjohKhiEgNc0CSauXmwYftY1+LlaC75SJwh0SgCX58= +golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= diff --git a/quickstart/README.md b/quickstart/README.md index 7e16850b3..087d58253 100644 --- a/quickstart/README.md +++ b/quickstart/README.md @@ -103,7 +103,7 @@ Ziti Controller: Ziti Edge Router: - routerName=edge-router; docker run -d --name "${zitinw}-${routerName}" --rm -e ZITI_EDGE_ROUTER_RAWNAME="${routerName}" --volume "${zitinw_shared}":/openziti/shared -it --network="${zitinw}" --hostname "${routerName}" --network-alias="${routerName}" --rm openziti/quickstart /openziti/scripts/run-router.sh edge + routerName=edge-router; docker run -d --name "${zitinw}-${routerName}" --rm -e ZITI_EDGE_ROUTER_NAME="${routerName}" --volume "${zitinw_shared}":/openziti/shared -it --network="${zitinw}" --hostname "${routerName}" --network-alias="${routerName}" --rm openziti/quickstart /openziti/scripts/run-router.sh edge diff --git a/quickstart/docker/.env b/quickstart/docker/.env index 577d31807..676e2c942 100644 --- a/quickstart/docker/.env +++ b/quickstart/docker/.env @@ -7,20 +7,17 @@ ZITI_VERSION=latest ZITI_EDGE_IDENTITY_ENROLLMENT_DURATION=10080 ZITI_EDGE_ROUTER_ENROLLMENT_DURATION=10080 -# controller address/port information -ZITI_CONTROLLER_RAWNAME=ziti-controller -#ZITI_CONTROLLER_HOSTNAME=advertised.address -#ZITI_CTRL_PORT=8440 +# controller name, address/port information +ZITI_CTRL_NAME=ziti-controller +ZITI_CTRL_EDGE_ADVERTISED_ADDRESS=ziti-edge-controller +#ZITI_CTRL_EDGE_ADVERTISED_PORT=1280 # Leave password blank to have a unique value generated or set the password explicitly ZITI_PWD= -ZITI_EDGE_CONTROLLER_RAWNAME=ziti-edge-controller -#ZITI_EDGE_CONTROLLER_HOSTNAME=advertised.address -#ZITI_EDGE_CONTROLLER_PORT=8441 #ZITI_EDGE_CONTROLLER_IP_OVERRIDE=172.17.0.1 # router address/port information -#ZITI_EDGE_ROUTER_RAWNAME=advertised.address -#ZITI_EDGE_ROUTER_PORT=8442 +#ZITI_EDGE_ROUTER_ADVERTISED_HOST=advertised.address +#ZITI_EDGE_ROUTER_PORT=3022 #ZITI_EDGE_ROUTER_IP_OVERRIDE=172.17.0.1 diff --git a/quickstart/docker/docker-compose.yml b/quickstart/docker/docker-compose.yml index cdd600793..9c1eef4eb 100644 --- a/quickstart/docker/docker-compose.yml +++ b/quickstart/docker/docker-compose.yml @@ -5,8 +5,8 @@ services: env_file: - ./.env ports: - - ${ZITI_EDGE_CONTROLLER_PORT:-1280}:${ZITI_EDGE_CONTROLLER_PORT:-1280} - - ${ZITI_CTRL_PORT:-6262}:${ZITI_CTRL_PORT:-6262} + - ${ZITI_CTRL_EDGE_ADVERTISED_PORT:-1280}:${ZITI_CTRL_EDGE_ADVERTISED_PORT:-1280} + - ${ZITI_CTRL_LISTENER_PORT:-6262}:${ZITI_CTRL_LISTENER_PORT:-6262} environment: - ZITI_EDGE_IDENTITY_ENROLLMENT_DURATION=${ZITI_EDGE_IDENTITY_ENROLLMENT_DURATION} - ZITI_EDGE_ROUTER_ENROLLMENT_DURATION=${ZITI_EDGE_ROUTER_ENROLLMENT_DURATION} @@ -28,8 +28,7 @@ services: depends_on: - ziti-controller environment: - - ZITI_CONTROLLER_RAWNAME="${ZITI_CONTROLLER_RAWNAME}" - - ZITI_EDGE_CONTROLLER_RAWNAME="${ZITI_EDGE_CONTROLLER_RAWNAME}" + - ZITI_CTRL_EDGE_ADVERTISED_ADDRESS="${ZITI_CTRL_EDGE_ADVERTISED_ADDRESS}" env_file: - ./.env networks: @@ -51,10 +50,10 @@ services: depends_on: - ziti-controller environment: - - ZITI_CONTROLLER_RAWNAME="${ZITI_CONTROLLER_RAWNAME}" - - ZITI_EDGE_CONTROLLER_RAWNAME="${ZITI_EDGE_CONTROLLER_RAWNAME}" - - ZITI_EDGE_ROUTER_RAWNAME=${ZITI_EDGE_ROUTER_RAWNAME:-ziti-edge-router} + - ZITI_CTRL_EDGE_ADVERTISED_ADDRESS="${ZITI_CTRL_EDGE_ADVERTISED_ADDRESS}" + - ZITI_EDGE_ROUTER_NAME=${ZITI_EDGE_ROUTER_NAME:-ziti-edge-router} - ZITI_EDGE_ROUTER_ROLES=public + - ZITI_EDGE_ROUTER_ADVERTISED_HOST=${ZITI_EDGE_ROUTER_ADVERTISED_HOST:-ziti-edge-router} ports: - ${ZITI_EDGE_ROUTER_PORT:-3022}:${ZITI_EDGE_ROUTER_PORT:-3022} networks: @@ -70,11 +69,11 @@ services: depends_on: - ziti-controller environment: - - ZITI_CONTROLLER_RAWNAME="${ZITI_CONTROLLER_RAWNAME}" - - ZITI_EDGE_CONTROLLER_RAWNAME="${ZITI_EDGE_CONTROLLER_RAWNAME}" - - ZITI_EDGE_ROUTER_RAWNAME=ziti-edge-router-wss + - ZITI_CTRL_EDGE_ADVERTISED_ADDRESS="${ZITI_CTRL_EDGE_ADVERTISED_ADDRESS}" + - ZITI_EDGE_ROUTER_NAME=ziti-edge-router-wss - ZITI_EDGE_ROUTER_PORT=3023 - ZITI_EDGE_ROUTER_ROLES=public + - ZITI_EDGE_ROUTER_ADVERTISED_HOST=ziti-edge-router-wss ports: - 3023:3023 networks: @@ -90,9 +89,9 @@ services: depends_on: - ziti-controller environment: - - ZITI_CONTROLLER_RAWNAME="${ZITI_CONTROLLER_RAWNAME}" - - ZITI_EDGE_CONTROLLER_RAWNAME="${ZITI_EDGE_CONTROLLER_RAWNAME}" - - ZITI_EDGE_ROUTER_RAWNAME=ziti-fabric-router-br + - ZITI_CTRL_EDGE_ADVERTISED_ADDRESS="${ZITI_CTRL_EDGE_ADVERTISED_ADDRESS}" + - ZITI_EDGE_ROUTER_NAME=ziti-fabric-router-br + - ZITI_EDGE_ROUTER_ADVERTISED_HOST=ziti-fabric-router-br #ports: # - 3024:3024 networks: @@ -108,9 +107,9 @@ services: depends_on: - ziti-controller environment: - - ZITI_CONTROLLER_RAWNAME="${ZITI_CONTROLLER_RAWNAME}" - - ZITI_EDGE_CONTROLLER_RAWNAME="${ZITI_EDGE_CONTROLLER_RAWNAME}" - - ZITI_EDGE_ROUTER_RAWNAME=ziti-private-red + - ZITI_CTRL_EDGE_ADVERTISED_ADDRESS="${ZITI_CTRL_EDGE_ADVERTISED_ADDRESS}" + - ZITI_EDGE_ROUTER_NAME=ziti-private-red + - ZITI_EDGE_ROUTER_ADVERTISED_HOST=ziti-private-red #ports: # - 3025:3025 networks: @@ -125,9 +124,9 @@ services: depends_on: - ziti-controller environment: - - ZITI_CONTROLLER_RAWNAME="${ZITI_CONTROLLER_RAWNAME}" - - ZITI_EDGE_CONTROLLER_RAWNAME="${ZITI_EDGE_CONTROLLER_RAWNAME}" - - ZITI_EDGE_ROUTER_RAWNAME=ziti-private-blue + - ZITI_CTRL_EDGE_ADVERTISED_ADDRESS="${ZITI_CTRL_EDGE_ADVERTISED_ADDRESS}" + - ZITI_EDGE_ROUTER_NAME=ziti-private-blue + - ZITI_EDGE_ROUTER_ADVERTISED_HOST=ziti-private-blue #ports: # - 3026:3026 networks: @@ -151,8 +150,8 @@ services: ziti-console: image: openziti/zac environment: - - ZAC_SERVER_CERT_CHAIN=/persistent/pki/${ZITI_EDGE_CONTROLLER_HOSTNAME:-ziti-controller}-intermediate/certs/${ZITI_EDGE_CONTROLLER_HOSTNAME:-ziti-controller}-server.cert - - ZAC_SERVER_KEY=/persistent/pki/${ZITI_EDGE_CONTROLLER_HOSTNAME:-ziti-controller}-intermediate/keys/${ZITI_EDGE_CONTROLLER_HOSTNAME:-ziti-controller}-server.key + - ZAC_SERVER_CERT_CHAIN=/persistent/pki/${ZITI_CTRL_EDGE_ADVERTISED_ADDRESS:-ziti-controller}-intermediate/certs/${ZITI_CTRL_EDGE_ADVERTISED_ADDRESS:-ziti-controller}-server.cert + - ZAC_SERVER_KEY=/persistent/pki/${ZITI_CTRL_EDGE_ADVERTISED_ADDRESS:-ziti-controller}-intermediate/keys/${ZITI_CTRL_EDGE_ADVERTISED_ADDRESS:-ziti-controller}-server.key - PORTTLS=8443 ports: - 1408:1408 diff --git a/quickstart/docker/image/Dockerfile b/quickstart/docker/image/Dockerfile index a7e4bac4c..11fcb9d70 100644 --- a/quickstart/docker/image/Dockerfile +++ b/quickstart/docker/image/Dockerfile @@ -32,7 +32,7 @@ ENV ZITI_BIN_ROOT="${ZITI_BIN_DIR}" ENV ZITI_SCRIPTS=/var/openziti/scripts # copy the ziti binaries to a directory already on the path -COPY --chown=ziti --from=fetch-ziti-bins /ziti-bin "${ZITI_BIN_DIR}" +COPY --chown=ziti ziti.ignore "${ZITI_BIN_DIR}" COPY --chown=ziti ziti-cli-functions.sh "${ZITI_SCRIPTS}/" COPY --chown=ziti run-controller.sh "${ZITI_SCRIPTS}/" COPY --chown=ziti run-router.sh "${ZITI_SCRIPTS}/" @@ -40,4 +40,4 @@ COPY --chown=ziti run-with-ziti-cli.sh "${ZITI_SCRIPTS}/" COPY --chown=ziti access-control.sh "${ZITI_SCRIPTS}/" COPY --chown=ziti run-router-external.sh "${ZITI_SCRIPTS}/" -RUN /bin/bash -c "source ${ZITI_SCRIPTS}/ziti-cli-functions.sh; ziti_createEnvFile; echo source ${ZITI_HOME}/ziti.env >> ~/.bashrc" +RUN /bin/bash -c "source ${ZITI_SCRIPTS}/ziti-cli-functions.sh; echo source ${ZITI_HOME}/ziti.env >> ~/.bashrc" diff --git a/quickstart/docker/image/run-controller.sh b/quickstart/docker/image/run-controller.sh index 93ec7bd60..df3a61680 100755 --- a/quickstart/docker/image/run-controller.sh +++ b/quickstart/docker/image/run-controller.sh @@ -1,21 +1,19 @@ #!/bin/bash - ziti_controller_cfg="${ZITI_HOME}/ziti-edge-controller.yaml" -export ZITI_CONTROLLER_RAWNAME=ziti-controller -export ZITI_EDGE_CONTROLLER_RAWNAME=ziti-edge-controller +export ZITI_CTRL_EDGE_ADVERTISED_ADDRESS=ziti-edge-controller . "${ZITI_SCRIPTS}/ziti-cli-functions.sh" -# access-control.init is created by ziti-controller-init-container after initial controller startup +echo "ZITI_CTRL_EDGE_ADVERTISED_ADDRESS is ${ZITI_CTRL_EDGE_ADVERTISED_ADDRESS}" if [ ! -f "${ZITI_HOME}/access-control.init" ]; then - generateEnvFile + setupEnvironment + persistEnvironmentValues fi -. "${ZITI_HOME}/ziti.env" +. ${ZITI_HOME}/ziti.env # create pki createPki - if [ ! -f "${ziti_controller_cfg}" ]; then echo " " echo "${ziti_controller_cfg} doesn't exist. Generating config file" @@ -29,9 +27,9 @@ else fi # initialize the database with the admin user: -"${ZITI_BIN_DIR}/ziti-controller" edge init "${ZITI_HOME}/ziti-edge-controller.yaml" -u "${ZITI_USER}" -p "${ZITI_PWD}" +"${ZITI_BIN_DIR}/ziti" controller edge init "${ZITI_HOME}/${ZITI_CTRL_NAME}.yaml" -u "${ZITI_USER}" -p "${ZITI_PWD}" # create a place for the internal db mkdir -p $ZITI_HOME/db -"${ZITI_BIN_DIR}/ziti-controller" run "${ZITI_HOME}/ziti-edge-controller.yaml" +"${ZITI_BIN_DIR}/ziti" controller run "${ZITI_HOME}/${ZITI_CTRL_NAME}.yaml" diff --git a/quickstart/docker/image/run-router-external.sh b/quickstart/docker/image/run-router-external.sh index 25f5814ea..208dc0699 100755 --- a/quickstart/docker/image/run-router-external.sh +++ b/quickstart/docker/image/run-router-external.sh @@ -7,81 +7,81 @@ sleep 5 . "${ZITI_SCRIPTS}/ziti-cli-functions.sh" # If we have not defined these, then no point going further - so dont -if [[ "${ZITI_EDGE_ROUTER_HOSTNAME}" == "" ]]; then echo "ERROR: Missing ZITI_EDGE_ROUTER_HOSTNAME definition" >&2; exit; fi -export ZITI_EDGE_ROUTER_RAWNAME=${ZITI_EDGE_ROUTER_RAWNAME_OVERRIDE} +if [[ "${ZITI_ROUTER_ADVERTISED_ADDRESS}" == "" ]]; then echo "ERROR: Missing ZITI_ROUTER_ADVERTISED_ADDRESS definition" >&2; exit; fi +export ZITI_EDGE_ROUTER_NAME=${ZITI_EDGE_ROUTER_NAME_OVERRIDE} -echo "ZITI_EDGE_ROUTER_HOSTNAME = ${ZITI_EDGE_ROUTER_HOSTNAME}" +echo "ZITI_ROUTER_ADVERTISED_ADDRESS = ${ZITI_ROUTER_ADVERTISED_ADDRESS}" # If we dont have a key file, then we assume we haven't enrolled, so lets do that -if [ ! -f ${ZITI_EDGE_ROUTER_HOSTNAME}.jwt ]; then +if [ ! -f ${ZITI_ROUTER_ADVERTISED_ADDRESS}.jwt ]; then # May have been a bad attempt before, so lets clean up - rm -f ${ZITI_HOME}/${ZITI_EDGE_ROUTER_HOSTNAME}* + rm -f ${ZITI_HOME}/${ZITI_ROUTER_ADVERTISED_ADDRESS}* # If we have override variables then override the base variable # This is required as the .bashrc loads the env file which clobbers passed in varibles if [[ "${ZITI_EDGE_ROUTER_RAWNAME_OVERRIDE}" == "" ]]; then echo "ERROR: Missing ZITI_EDGE_ROUTER_RAWNAME_OVERRIDE definition" >&2; exit; fi # May have been a bad attempt before, so lets clean up - rm -f ${ZITI_HOME}/${ZITI_EDGE_ROUTER_RAWNAME}* + rm -f ${ZITI_HOME}/${ZITI_EDGE_ROUTER_NAME}* - if [[ ${ZITI_CTRL_ADVERTISED_ADDRESS_OVERRIDE} != "" ]]; then export ZITI_CTRL_ADVERTISED_ADDRESS=${ZITI_CTRL_ADVERTISED_ADDRESS_OVERRIDE}; fi + if [[ ${ZITI_CTRL_EDGE_ADVERTISED_ADDRESS} != "" ]]; then export ZITI_CTRL_EDGE_ADVERTISED_ADDRESS=${ZITI_CTRL_EDGE_ADVERTISED_ADDRESS}; fi if [[ ${ZITI_USER_OVERRIDE} != "" ]]; then export ZITI_USER=${ZITI_USER_OVERRIDE}; fi if [[ ${ZITI_PWD_OVERRIDE} != "" ]]; then export ZITI_PWD=${ZITI_PWD_OVERRIDE}; fi - if [[ ${ZITI_EDGE_CONTROLLER_PORT_OVERRIDE} != "" ]]; then export ZITI_EDGE_CONTROLLER_PORT=${ZITI_EDGE_CONTROLLER_PORT_OVERRIDE}; fi - if [[ ${ZITI_EDGE_ROUTER_HOSTNAME} == "" ]]; then export ZITI_EDGE_ROUTER_HOSTNAME=${ZITI_EDGE_ROUTER_RAWNAME}; fi + if [[ ${ZITI_EDGE_CONTROLLER_PORT_OVERRIDE} != "" ]]; then export ZITI_CTRL_EDGE_ADVERTISED_PORT=${ZITI_EDGE_CONTROLLER_PORT_OVERRIDE}; fi + if [[ ${ZITI_ROUTER_ADVERTISED_ADDRESS} == "" ]]; then export ZITI_ROUTER_ADVERTISED_ADDRESS=${ZITI_EDGE_ROUTER_NAME}; fi # First off - lets make sure we have what we need if [[ ${ZITI_USER} == "" ]] || [[ ${ZITI_PWD} == "" ]]; then echo "ERROR: Need ZITI_USER and ZITI_PWD defined" >&2; exit; fi if [[ "$1" == "" ]]; then echo "ERROR: Have not defined router type. It should be one of edge,wss,fabric or private." >&2; exit; fi - if [[ "${ZITI_CTRL_ADVERTISED_ADDRESS}" == "" ]]; then echo "ERROR: Missing ZITI_CTRL_ADVERTISED_ADDRESS_OVERRIDE definition" >&2; exit; fi + if [[ "${ZITI_CTRL_EDGE_ADVERTISED_ADDRESS}" == "" ]]; then echo "ERROR: Missing ZITI_CTRL_EDGE_ADVERTISED_ADDRESS definition" >&2; exit; fi if [[ "${ZITI_EDGE_ROUTER_PORT-}" == "" ]]; then export ZITI_EDGE_ROUTER_PORT="3022"; fi - if [[ "${ZITI_EDGE_ROUTER_ROLES}" == "" ]]; then export ZITI_EDGE_ROUTER_ROLES="${ZITI_EDGE_ROUTER_HOSTNAME}"; fi + if [[ "${ZITI_EDGE_ROUTER_ROLES}" == "" ]]; then export ZITI_EDGE_ROUTER_ROLES="${ZITI_ROUTER_ADVERTISED_ADDRESS}"; fi - echo "ZITI_EDGE_ROUTER_RAWNAME = ${ZITI_EDGE_ROUTER_RAWNAME}" + echo "ZITI_EDGE_ROUTER_NAME = ${ZITI_EDGE_ROUTER_NAME}" echo "ZITI_EDGE_ROUTER_ROLES = ${ZITI_EDGE_ROUTER_ROLES}" echo "ZITI_EDGE_ROUTER_PORT = ${ZITI_EDGE_ROUTER_PORT}" - echo "ZITI_CTRL_ADVERTISED_ADDRESS = ${ZITI_CTRL_ADVERTISED_ADDRESS}" - echo "ZITI_CTRL_PORT = ${ZITI_CTRL_PORT}" + echo "ZITI_CTRL_EDGE_ADVERTISED_ADDRESS = ${ZITI_CTRL_EDGE_ADVERTISED_ADDRESS}" + echo "ZITI_CTRL_LISTENER_PORT = ${ZITI_CTRL_LISTENER_PORT}" echo "ZITI_USER = ${ZITI_USER}" if [[ ! "${ZITI_PWD}" == "" ]]; then echo "ZITI_PWD = (obscured)"; fi # Login to the cloud controller - "${ZITI_BIN_DIR}/ziti" edge login -y ${ZITI_CTRL_ADVERTISED_ADDRESS}:${ZITI_EDGE_CONTROLLER_PORT} -u ${ZITI_USER} -p ${ZITI_PWD} + "${ZITI_BIN_DIR}/ziti" edge login -y ${ZITI_CTRL_EDGE_ADVERTISED_ADDRESS}:${ZITI_CTRL_EDGE_ADVERTISED_PORT} -u ${ZITI_USER} -p ${ZITI_PWD} if [[ "$1" == "edge" ]]; then echo "CREATING EDGE ROUTER CONFIG" - createEdgeRouterConfig "${ZITI_EDGE_ROUTER_RAWNAME}" + createEdgeRouterConfig "${ZITI_EDGE_ROUTER_NAME}" fi if [[ "$1" == "wss" ]]; then echo "CREATING EDGE ROUTER WSS CONFIG" - createEdgeRouterWssConfig "${ZITI_EDGE_ROUTER_RAWNAME}" + createEdgeRouterWssConfig "${ZITI_EDGE_ROUTER_NAME}" fi if [[ "$1" == "fabric" ]]; then echo "CREATING FABRIC ROUTER CONFIG" - createFabricRouterConfig "${ZITI_EDGE_ROUTER_RAWNAME}" + createFabricRouterConfig "${ZITI_EDGE_ROUTER_NAME}" fi if [[ "$1" == "private" ]]; then echo "CREATING PRIVATE ROUTER CONFIG" - createPrivateRouterConfig "${ZITI_EDGE_ROUTER_RAWNAME}" + createPrivateRouterConfig "${ZITI_EDGE_ROUTER_NAME}" fi - mv ${ZITI_HOME}/${ZITI_EDGE_ROUTER_RAWNAME}.yaml ${ZITI_HOME}/${ZITI_EDGE_ROUTER_HOSTNAME}.yaml + mv ${ZITI_HOME}/${ZITI_EDGE_ROUTER_NAME}.yaml ${ZITI_HOME}/${ZITI_ROUTER_ADVERTISED_ADDRESS}.yaml - echo "---------- Creating edge-router ${ZITI_EDGE_ROUTER_RAWNAME}...." - found=$(${ZITI_BIN_DIR}/ziti edge list edge-routers 'name = "'"${ZITI_EDGE_ROUTER_HOSTNAME}"'"' | grep -c "${ZITI_EDGE_ROUTER_HOSTNAME}") + echo "---------- Creating edge-router ${ZITI_EDGE_ROUTER_NAME}...." + found=$(${ZITI_BIN_DIR}/ziti edge list edge-routers 'name = "'"${ZITI_ROUTER_ADVERTISED_ADDRESS}"'"' | grep -c "${ZITI_ROUTER_ADVERTISED_ADDRESS}") if [[ found -gt 0 ]]; then - echo "---------- Found existing edge-router ${ZITI_EDGE_ROUTER_HOSTNAME}...." + echo "---------- Found existing edge-router ${ZITI_ROUTER_ADVERTISED_ADDRESS}...." else - "${ZITI_BIN_DIR}/ziti" edge create edge-router "${ZITI_EDGE_ROUTER_HOSTNAME}" -o "${ZITI_HOME}/${ZITI_EDGE_ROUTER_HOSTNAME}.jwt" -t -a "${ZITI_EDGE_ROUTER_ROLES}" + "${ZITI_BIN_DIR}/ziti" edge create edge-router "${ZITI_ROUTER_ADVERTISED_ADDRESS}" -o "${ZITI_HOME}/${ZITI_ROUTER_ADVERTISED_ADDRESS}.jwt" -t -a "${ZITI_EDGE_ROUTER_ROLES}" sleep 1 - echo "---------- Enrolling edge-router ${ZITI_EDGE_ROUTER_HOSTNAME}...." - "${ZITI_BIN_DIR}/ziti-router" enroll "${ZITI_HOME}/${ZITI_EDGE_ROUTER_HOSTNAME}.yaml" --jwt "${ZITI_HOME}/${ZITI_EDGE_ROUTER_HOSTNAME}.jwt" + echo "---------- Enrolling edge-router ${ZITI_ROUTER_ADVERTISED_ADDRESS}...." + "${ZITI_BIN_DIR}/ziti-router" enroll "${ZITI_HOME}/${ZITI_ROUTER_ADVERTISED_ADDRESS}.yaml" --jwt "${ZITI_HOME}/${ZITI_ROUTER_ADVERTISED_ADDRESS}.jwt" echo "" fi fi # Run the router -"${ZITI_BIN_DIR}/ziti-router" run "${ZITI_HOME}/${ZITI_EDGE_ROUTER_HOSTNAME}.yaml" > "${ZITI_HOME}/ziti-${ZITI_EDGE_ROUTER_HOSTNAME}.log" +"${ZITI_BIN_DIR}/ziti-router" run "${ZITI_HOME}/${ZITI_ROUTER_ADVERTISED_ADDRESS}.yaml" > "${ZITI_HOME}/ziti-${ZITI_ROUTER_ADVERTISED_ADDRESS}.log" diff --git a/quickstart/docker/image/run-router.sh b/quickstart/docker/image/run-router.sh index 5ffe384c9..0cb23b18b 100755 --- a/quickstart/docker/image/run-router.sh +++ b/quickstart/docker/image/run-router.sh @@ -5,60 +5,53 @@ sleep 5 . "${ZITI_SCRIPTS}/ziti-cli-functions.sh" -if [[ "${ZITI_CONTROLLER_RAWNAME-}" == "" ]]; then export ZITI_CONTROLLER_RAWNAME="ziti-controller"; fi -if [[ "${ZITI_EDGE_CONTROLLER_RAWNAME-}" == "" ]]; then export ZITI_EDGE_CONTROLLER_RAWNAME="ziti-edge-controller"; fi -if [[ "${ZITI_EDGE_ROUTER_RAWNAME-}" == "" ]]; then - export ZITI_EDGE_ROUTER_DESIRED_RAWNAME="${ZITI_NETWORK-}-edge-router" +if [[ "${ZITI_CTRL_EDGE_ADVERTISED_ADDRESS-}" == "" ]]; then export ZITI_CTRL_EDGE_ADVERTISED_ADDRESS="ziti-edge-controller"; fi +if [[ "${ZITI_EDGE_ROUTER_NAME-}" == "" ]]; then + ZITI_EDGE_ROUTER_DESIRED_NAME="${ZITI_NETWORK-}-edge-router" else - ZITI_EDGE_ROUTER_DESIRED_RAWNAME="${ZITI_EDGE_ROUTER_RAWNAME}" + ZITI_EDGE_ROUTER_DESIRED_NAME="${ZITI_EDGE_ROUTER_NAME}" fi if [[ "${ZITI_EDGE_ROUTER_PORT-}" == "" ]]; then export ZITI_EDGE_ROUTER_PORT="3022"; fi -if [[ "${ZITI_EDGE_ROUTER_HOSTNAME}" == "" ]]; then export ZITI_EDGE_ROUTER_HOSTNAME="${ZITI_EDGE_ROUTER_RAWNAME}${ZITI_DOMAIN_SUFFIX}"; fi -if [[ "${ZITI_EDGE_ROUTER_ROLES}" == "" ]]; then export ZITI_EDGE_ROUTER_ROLES="${ZITI_EDGE_ROUTER_RAWNAME}"; fi +if [[ "${ZITI_ROUTER_ADVERTISED_ADDRESS}" == "" ]]; then export ZITI_ROUTER_ADVERTISED_ADDRESS="${ZITI_EDGE_ROUTER_NAME}${ZITI_DOMAIN_SUFFIX}"; fi +if [[ "${ZITI_EDGE_ROUTER_ROLES}" == "" ]]; then export ZITI_EDGE_ROUTER_ROLES="${ZITI_EDGE_ROUTER_NAME}"; fi . ${ZITI_HOME}/ziti.env # This is a unique situation due to the env file being shared among all routers so we need to explicitly set the router -export ZITI_EDGE_ROUTER_RAWNAME="${ZITI_EDGE_ROUTER_DESIRED_RAWNAME}" +export ZITI_EDGE_ROUTER_NAME="${ZITI_EDGE_ROUTER_DESIRED_NAME}" -# shellcheck disable=SC2091 -until $(curl -s -o /dev/null --fail -k "https://${ZITI_EDGE_CTRL_ADVERTISED_HOST_PORT}"); do - echo "waiting for https://${ZITI_EDGE_CTRL_ADVERTISED_HOST_PORT}" - sleep 2 -done - -createRouterPki "${ZITI_EDGE_ROUTER_RAWNAME}" +_wait_for_controller zitiLogin if [[ "$1" == "edge" ]]; then echo "CREATING EDGE ROUTER CONFIG" - createEdgeRouterConfig "${ZITI_EDGE_ROUTER_RAWNAME}" + createEdgeRouterConfig "${ZITI_EDGE_ROUTER_NAME}" fi if [[ "$1" == "wss" ]]; then echo "CREATING EDGE ROUTER WSS CONFIG" - createEdgeRouterWssConfig "${ZITI_EDGE_ROUTER_RAWNAME}" + createEdgeRouterWssConfig "${ZITI_EDGE_ROUTER_NAME}" fi if [[ "$1" == "fabric" ]]; then echo "CREATING FABRIC ROUTER CONFIG" - createFabricRouterConfig "${ZITI_EDGE_ROUTER_RAWNAME}" + createFabricRouterConfig "${ZITI_EDGE_ROUTER_NAME}" fi if [[ "$1" == "private" ]]; then echo "CREATING PRIVATE ROUTER CONFIG" - createPrivateRouterConfig "${ZITI_EDGE_ROUTER_RAWNAME}" + createPrivateRouterConfig "${ZITI_EDGE_ROUTER_NAME}" fi -echo "---------- Creating edge-router ${ZITI_EDGE_ROUTER_HOSTNAME}...." -found=$(ziti edge list edge-routers 'name = "'"${ZITI_EDGE_ROUTER_HOSTNAME}"'"' | grep -c "${ZITI_EDGE_ROUTER_HOSTNAME}") +echo "---------- Creating edge-router ${ZITI_ROUTER_ADVERTISED_ADDRESS}...." +found=$(ziti edge list edge-routers 'name = "'"${ZITI_ROUTER_ADVERTISED_ADDRESS}"'"' | grep -c "${ZITI_ROUTER_ADVERTISED_ADDRESS}") if [[ found -gt 0 ]]; then - echo "---------- Found existing edge-router ${ZITI_EDGE_ROUTER_HOSTNAME}...." + echo "---------- Found existing edge-router ${ZITI_ROUTER_ADVERTISED_ADDRESS}...." else - "${ZITI_BIN_DIR}/ziti" edge create edge-router "${ZITI_EDGE_ROUTER_HOSTNAME}" -o "${ZITI_HOME}/${ZITI_EDGE_ROUTER_HOSTNAME}.jwt" -t -a "${ZITI_EDGE_ROUTER_ROLES}" + "${ZITI_BIN_DIR}/ziti" edge create edge-router "${ZITI_ROUTER_ADVERTISED_ADDRESS}" -o "${ZITI_HOME}/${ZITI_ROUTER_ADVERTISED_ADDRESS}.jwt" -t -a "${ZITI_EDGE_ROUTER_ROLES}" sleep 1 - echo "---------- Enrolling edge-router ${ZITI_EDGE_ROUTER_HOSTNAME}...." - "${ZITI_BIN_DIR}/ziti-router" enroll "${ZITI_HOME}/${ZITI_EDGE_ROUTER_HOSTNAME}.yaml" --jwt "${ZITI_HOME}/${ZITI_EDGE_ROUTER_HOSTNAME}.jwt" + echo "---------- Enrolling edge-router ${ZITI_ROUTER_ADVERTISED_ADDRESS}...." + "${ZITI_BIN_DIR}/ziti-router" enroll "${ZITI_HOME}/${ZITI_ROUTER_ADVERTISED_ADDRESS}.yaml" --jwt "${ZITI_HOME}/${ZITI_ROUTER_ADVERTISED_ADDRESS}.jwt" echo "" fi -"${ZITI_BIN_DIR}/ziti-router" run "${ZITI_HOME}/${ZITI_EDGE_ROUTER_RAWNAME}.yaml" > "${ZITI_HOME}/ziti-${ZITI_EDGE_ROUTER_HOSTNAME}.log" +"${ZITI_BIN_DIR}/ziti" router run "${ZITI_HOME}/${ZITI_ROUTER_ADVERTISED_ADDRESS}.yaml" > "${ZITI_HOME}/ziti-${ZITI_ROUTER_ADVERTISED_ADDRESS}.log" diff --git a/quickstart/docker/image/run-with-ziti-cli.sh b/quickstart/docker/image/run-with-ziti-cli.sh index 34cf0f0e1..6c10213a2 100755 --- a/quickstart/docker/image/run-with-ziti-cli.sh +++ b/quickstart/docker/image/run-with-ziti-cli.sh @@ -36,21 +36,16 @@ sleep 1 . "${ZITI_SCRIPTS}/ziti-cli-functions.sh" -if [[ "${ZITI_CONTROLLER_RAWNAME-}" == "" ]]; then export export ZITI_CONTROLLER_RAWNAME="ziti-controller"; fi -if [[ "${ZITI_EDGE_CONTROLLER_RAWNAME-}" == "" ]]; then export export ZITI_EDGE_CONTROLLER_RAWNAME="ziti-edge-controller"; fi -if [[ "${ZITI_EDGE_ROUTER_RAWNAME-}" == "" ]]; then export export ZITI_EDGE_ROUTER_RAWNAME="${ZITI_NETWORK-}-edge-router"; fi +if [[ "${ZITI_CTRL_EDGE_ADVERTISED_ADDRESS-}" == "" ]]; then export ZITI_CTRL_EDGE_ADVERTISED_ADDRESS="ziti-edge-controller"; fi +if [[ "${ZITI_EDGE_ROUTER_NAME-}" == "" ]]; then export ZITI_EDGE_ROUTER_NAME="${ZITI_NETWORK-}-edge-router"; fi if [[ "${ZITI_EDGE_ROUTER_PORT-}" == "" ]]; then export ZITI_EDGE_ROUTER_PORT="3022"; fi -if [[ "${ZITI_EDGE_ROUTER_HOSTNAME}" == "" ]]; then export ZITI_EDGE_ROUTER_HOSTNAME="${ZITI_EDGE_ROUTER_RAWNAME}${ZITI_DOMAIN_SUFFIX}"; fi -if [[ "${ZITI_EDGE_ROUTER_ROLES}" == "" ]]; then export ZITI_EDGE_ROUTER_ROLES="${ZITI_EDGE_ROUTER_RAWNAME}"; fi +if [[ "${ZITI_ROUTER_ADVERTISED_ADDRESS}" == "" ]]; then export ZITI_ROUTER_ADVERTISED_ADDRESS="${ZITI_EDGE_ROUTER_NAME}${ZITI_DOMAIN_SUFFIX}"; fi +if [[ "${ZITI_EDGE_ROUTER_ROLES}" == "" ]]; then export ZITI_EDGE_ROUTER_ROLES="${ZITI_EDGE_ROUTER_NAME}"; fi . "${ZITI_HOME}"/ziti.env # Wait for the controller -# shellcheck disable=SC2091 -until $(curl -s -o /dev/null --fail -k "https://${ZITI_EDGE_CTRL_ADVERTISED_HOST_PORT}"); do - echo "waiting for https://${ZITI_EDGE_CTRL_ADVERTISED_HOST_PORT}" - sleep 2 -done +_wait_for_controller echo " " echo "*****************************************************" diff --git a/quickstart/docker/image/ziti-cli-functions.sh b/quickstart/docker/image/ziti-cli-functions.sh old mode 100755 new mode 100644 index f408c7f48..1e072bae0 --- a/quickstart/docker/image/ziti-cli-functions.sh +++ b/quickstart/docker/image/ziti-cli-functions.sh @@ -83,22 +83,22 @@ function cleanZitiController { } function initializeController { log_file="${ZITI_HOME-}/${ZITI_EDGE_CONTROLLER_RAWNAME}-init.log" - "${ZITI_BIN_DIR-}/ziti-controller" edge init "${ZITI_HOME_OS_SPECIFIC}/${ZITI_EDGE_CONTROLLER_RAWNAME}.yaml" -u "${ZITI_USER-}" -p "${ZITI_PWD}" &> "${log_file}" - echo -e "ziti-controller initialized. see $(BLUE "${log_file}") for details" + "${ZITI_BIN_DIR-}/ziti" controller edge init "${ZITI_HOME_OS_SPECIFIC}/${ZITI_EDGE_CONTROLLER_RAWNAME}.yaml" -u "${ZITI_USER-}" -p "${ZITI_PWD}" &> "${log_file}" + echo -e "ziti controller initialized. see $(BLUE "${log_file}") for details" } function startController { log_file="${ZITI_HOME-}/${ZITI_EDGE_CONTROLLER_RAWNAME}.log" # shellcheck disable=SC2034 - "${ZITI_BIN_DIR-}/ziti-controller" run "${ZITI_HOME_OS_SPECIFIC}/${ZITI_EDGE_CONTROLLER_RAWNAME}.yaml" &> "${log_file}" & + "${ZITI_BIN_DIR-}/ziti" controller run "${ZITI_HOME_OS_SPECIFIC}/${ZITI_EDGE_CONTROLLER_RAWNAME}.yaml" &> "${log_file}" & ZITI_EXPRESS_CONTROLLER_PID=$! - echo -e "ziti-controller started as process id: $ZITI_EXPRESS_CONTROLLER_PID. log located at: $(BLUE "${log_file}")" + echo -e "ziti controller started as process id: $ZITI_EXPRESS_CONTROLLER_PID. log located at: $(BLUE "${log_file}")" } function stopController { if [[ -n ${ZITI_EXPRESS_CONTROLLER_PID:-} ]]; then kill "$ZITI_EXPRESS_CONTROLLER_PID" # shellcheck disable=SC2181 - if [[ $? == 0 ]]; then + if [[ $? == 0 ]]; then echo "Controller stopped." return 0 fi @@ -110,10 +110,10 @@ function stopController { function startRouter { log_file="${ZITI_HOME_OS_SPECIFIC}/${ZITI_EDGE_ROUTER_RAWNAME}.log" - "${ZITI_BIN_DIR}/ziti-router" run "${ZITI_HOME_OS_SPECIFIC}/${ZITI_EDGE_ROUTER_RAWNAME}.yaml" > "${log_file}" 2>&1 & + "${ZITI_BIN_DIR}/ziti" router run "${ZITI_HOME_OS_SPECIFIC}/${ZITI_EDGE_ROUTER_RAWNAME}.yaml" > "${log_file}" 2>&1 & ZITI_EXPRESS_EDGE_ROUTER_PID=$! echo -e "Express Edge Router started as process id: $ZITI_EXPRESS_EDGE_ROUTER_PID. log located at: $(BLUE "${log_file}")" - + } function stopRouter { @@ -582,7 +582,7 @@ function ziti_expressConfiguration { sleep 1 echo "---------- Enrolling edge-router ${ZITI_EDGE_ROUTER_RAWNAME}...." - "${ZITI_BIN_DIR-}/ziti-router" enroll "${ZITI_HOME_OS_SPECIFIC}/${ZITI_EDGE_ROUTER_RAWNAME}.yaml" --jwt "${ZITI_HOME_OS_SPECIFIC}/${ZITI_EDGE_ROUTER_RAWNAME}.jwt" &> "${ZITI_HOME_OS_SPECIFIC}/${ZITI_EDGE_ROUTER_RAWNAME}.enrollment.log" + "${ZITI_BIN_DIR-}/ziti" router enroll "${ZITI_HOME_OS_SPECIFIC}/${ZITI_EDGE_ROUTER_RAWNAME}.yaml" --jwt "${ZITI_HOME_OS_SPECIFIC}/${ZITI_EDGE_ROUTER_RAWNAME}.jwt" &> "${ZITI_HOME_OS_SPECIFIC}/${ZITI_EDGE_ROUTER_RAWNAME}.enrollment.log" echo "" stopController @@ -1075,7 +1075,7 @@ function ziti_createEnvFile { echo "ZITI_NETWORK set to: ${ZITI_NETWORK}" if [[ "${ZITI_USER-}" == "" ]]; then export ZITI_USER="admin"; fi - if [[ "${ZITI_PWD-}" == "" ]]; then + if [[ "${ZITI_PWD-}" == "" ]]; then ZITI_PWD="$(LC_ALL=C tr -dc _A-Z-a-z-0-9 < /dev/urandom | head -c32)" echo -en "Do you want to keep the generated admin password '$ZITI_PWD'? (Y/n) " # shellcheck disable=SC2162 @@ -1216,13 +1216,13 @@ function createControllerSystemdFile { cat > "${output_file}" < "${output_file}" < "${output_file}" < Label - ziti-controller-${controller_name} + ziti controller-${controller_name} ProgramArguments - $ZITI_BIN_DIR/ziti-controller + $ZITI_BIN_DIR/ziti + controller run $ZITI_HOME/${controller_name}.yaml @@ -1407,7 +1408,8 @@ cat > "${output_file}" <$router_name ProgramArguments - $ZITI_BIN_DIR/ziti-router + $ZITI_BIN_DIR/ziti + router run $ZITI_HOME/ctrl.with.edge.yml diff --git a/quickstart/docker/simplified-docker-compose.yml b/quickstart/docker/simplified-docker-compose.yml index bc9d20e13..c9f86096b 100644 --- a/quickstart/docker/simplified-docker-compose.yml +++ b/quickstart/docker/simplified-docker-compose.yml @@ -5,8 +5,8 @@ services: env_file: - ./.env ports: - - ${ZITI_EDGE_CONTROLLER_PORT:-1280}:${ZITI_EDGE_CONTROLLER_PORT:-1280} - - ${ZITI_CTRL_PORT:-6262}:${ZITI_CTRL_PORT:-6262} + - ${ZITI_CTRL_EDGE_ADVERTISED_PORT:-1280}:${ZITI_CTRL_EDGE_ADVERTISED_PORT:-1280} + - ${ZITI_CTRL_LISTENER_PORT:-6262}:${ZITI_CTRL_LISTENER_PORT:-6262} environment: - ZITI_EDGE_IDENTITY_ENROLLMENT_DURATION=${ZITI_EDGE_IDENTITY_ENROLLMENT_DURATION} - ZITI_EDGE_ROUTER_ENROLLMENT_DURATION=${ZITI_EDGE_ROUTER_ENROLLMENT_DURATION} @@ -28,8 +28,8 @@ services: depends_on: - ziti-controller environment: - - ZITI_CONTROLLER_RAWNAME="${ZITI_CONTROLLER_RAWNAME}" - - ZITI_EDGE_CONTROLLER_RAWNAME="${ZITI_EDGE_CONTROLLER_RAWNAME}" + - ZITI_CTRL_EDGE_ADVERTISED_ADDRESS="${ZITI_CTRL_EDGE_ADVERTISED_ADDRESS}" + - ZITI_CTRL_EDGE_ADVERTISED_PORT="${ZITI_CTRL_EDGE_ADVERTISED_PORT}" env_file: - ./.env networks: @@ -51,9 +51,8 @@ services: depends_on: - ziti-controller environment: - - ZITI_CONTROLLER_RAWNAME="${ZITI_CONTROLLER_RAWNAME}" - - ZITI_EDGE_CONTROLLER_RAWNAME="${ZITI_EDGE_CONTROLLER_RAWNAME}" - - ZITI_EDGE_ROUTER_RAWNAME=${ZITI_EDGE_ROUTER_RAWNAME:-ziti-edge-router} + - ZITI_CTRL_EDGE_ADVERTISED_ADDRESS="${ZITI_CTRL_EDGE_ADVERTISED_ADDRESS}" + - ZITI_EDGE_ROUTER_NAME=${ZITI_EDGE_ROUTER_NAME:-ziti-edge-router} - ZITI_EDGE_ROUTER_ROLES=public ports: - ${ZITI_EDGE_ROUTER_PORT:-3022}:${ZITI_EDGE_ROUTER_PORT:-3022} @@ -69,8 +68,8 @@ services: image: openziti/zac working_dir: /usr/src/app environment: - - ZAC_SERVER_CERT_CHAIN=/persistent/pki/${ZITI_EDGE_CONTROLLER_HOSTNAME:-ziti-controller}-intermediate/certs/${ZITI_EDGE_CONTROLLER_HOSTNAME:-ziti-controller}-server.cert - - ZAC_SERVER_KEY=/persistent/pki/${ZITI_EDGE_CONTROLLER_HOSTNAME:-ziti-controller}-intermediate/keys/${ZITI_EDGE_CONTROLLER_HOSTNAME:-ziti-controller}-server.key + - ZAC_SERVER_CERT_CHAIN=/persistent/pki/${ZITI_CTRL_EDGE_ADVERTISED_ADDRESS:-ziti-controller}-intermediate/certs/${ZITI_CTRL_EDGE_ADVERTISED_ADDRESS:-ziti-controller}-server.cert + - ZAC_SERVER_KEY=/persistent/pki/${ZITI_CTRL_EDGE_ADVERTISED_ADDRESS:-ziti-controller}-intermediate/keys/${ZITI_CTRL_EDGE_ADVERTISED_ADDRESS:-ziti-controller}-server.key - PORTTLS=8443 depends_on: - ziti-controller diff --git a/quickstart/local/add-zcat.sh b/quickstart/local/add-zcat.sh index 0a159558a..211a924e1 100644 --- a/quickstart/local/add-zcat.sh +++ b/quickstart/local/add-zcat.sh @@ -1,10 +1,10 @@ -ziti edge login "${ZITI_EDGE_CONTROLLER_API}" -u "${ZITI_USER}" -p "${ZITI_PWD}" -y +ziti edge login "${ZITI_CTRL_EDGE_ADVERTISED_ADDRESS}" -u "${ZITI_USER}" -p "${ZITI_PWD}" -y ziti edge delete service zcatsvc ziti edge delete config zcatconfig ziti edge create config zcatconfig ziti-tunneler-client.v1 '{ "hostname" : "zcat.ziti", "port" : 7256 }' ziti edge create service zcatsvc --configs zcatconfig -ziti edge create terminator zcatsvc "${ZITI_EDGE_ROUTER_HOSTNAME}" tcp:localhost:7256 +ziti edge create terminator zcatsvc "${ZITI_ROUTER_ADVERTISED_ADDRESS}" tcp:localhost:7256 diff --git a/quickstart/local/newid.sh b/quickstart/local/newid.sh index 52f318a9d..adbea0c17 100755 --- a/quickstart/local/newid.sh +++ b/quickstart/local/newid.sh @@ -1,7 +1,7 @@ suffix=$(date +"%b-%d-%H%M") idname="User${suffix}" -ziti edge login "${ZITI_EDGE_CONTROLLER_API}" -u "${ZITI_USER}" -p "${ZITI_PWD}" -y +ziti edge login "${ZITI_CTRL_EDGE_ADVERTISED_ADDRESS}" -u "${ZITI_USER}" -p "${ZITI_PWD}" -y ziti edge delete identity "${idname}" ziti edge create identity device "${idname}" -o "${ZITI_HOME}/test_identity".jwt diff --git a/quickstart/local/restart-ziti.sh b/quickstart/local/restart-ziti.sh index 21dfb963e..fcf521d86 100755 --- a/quickstart/local/restart-ziti.sh +++ b/quickstart/local/restart-ziti.sh @@ -22,6 +22,6 @@ DIRNAME=$(dirname $0) sleep 1 ziti-router -v run "${ZITI_HOME}/${ZITI_ROUTER_RED_NAME}.yaml" > "${ZITI_HOME}/ziti-${ZITI_ROUTER_RED_NAME}.log" 2>&1 & # sleep 1 -# ziti-router run "${ZITI_HOME}/${ZITI_EDGE_ROUTER_HOSTNAME}.yaml" > "${ZITI_HOME}/ziti-${ZITI_EDGE_ROUTER_HOSTNAME}.log" 2>&1 & +# ziti-router run "${ZITI_HOME}/${ZITI_ROUTER_ADVERTISED_ADDRESS}.yaml" > "${ZITI_HOME}/ziti-${ZITI_ROUTER_ADVERTISED_ADDRESS}.log" 2>&1 & sleep 1 ziti-router -v run "${ZITI_HOME}/${ZITI_EDGE_WSS_ROUTER_HOSTNAME}.yaml" > "${ZITI_HOME}/ziti-${ZITI_EDGE_WSS_ROUTER_HOSTNAME}.log" 2>&1 & diff --git a/quickstart/local/run-dns.sh b/quickstart/local/run-dns.sh deleted file mode 100755 index 4bd51e110..000000000 --- a/quickstart/local/run-dns.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/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_CONTROLLER_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/quickstart/local/test-ziti.sh b/quickstart/local/test-ziti.sh index 44f6b7935..e946c1a3c 100755 --- a/quickstart/local/test-ziti.sh +++ b/quickstart/local/test-ziti.sh @@ -1,4 +1,4 @@ -ziti edge controller login "${ZITI_EDGE_CONTROLLER_API}" -u "${ZITI_USER}" -p "${ZITI_PWD}" -y +ziti edge controller login "${ZITI_CTRL_EDGE_ADVERTISED_ADDRESS}" -u "${ZITI_USER}" -p "${ZITI_PWD}" -y ziti edge delete service netcatsvc ziti edge delete service zcatsvc @@ -12,19 +12,19 @@ ziti edge controller delete config iperfsvcconfig ziti edge controller create config httpbinsvcconfig ziti-tunneler-client.v1 '{ "hostname" : "httpbin.ziti", "port" : 8000 }' ziti edge controller create service httpbinsvc --configs httpbinsvcconfig -ziti edge controller create terminator httpbinsvc "${ZITI_EDGE_ROUTER_HOSTNAME}" tcp:localhost:80 +ziti edge controller create terminator httpbinsvc "${ZITI_ROUTER_ADVERTISED_ADDRESS}" tcp:localhost:80 ziti edge controller create config netcatconfig ziti-tunneler-client.v1 '{ "hostname" : "localhost", "port" : 7256 }' ziti edge controller create service netcatsvc --configs netcatconfig -ziti edge controller create terminator netcatsvc "${ZITI_EDGE_ROUTER_HOSTNAME}" tcp:localhost:7256 +ziti edge controller create terminator netcatsvc "${ZITI_ROUTER_ADVERTISED_ADDRESS}" tcp:localhost:7256 ziti edge controller create config zcatconfig ziti-tunneler-client.v1 '{ "hostname" : "zcat.ziti", "port" : 7256 }' ziti edge controller create service zcatsvc --configs zcatconfig -ziti edge controller create terminator zcatsvc "${ZITI_EDGE_ROUTER_HOSTNAME}" tcp:localhost:7256 +ziti edge controller create terminator zcatsvc "${ZITI_ROUTER_ADVERTISED_ADDRESS}" tcp:localhost:7256 ziti edge controller create config iperfsvcconfig ziti-tunneler-client.v1 '{ "hostname" : "iperf3.ziti", "port" : 15000 }' ziti edge controller create service iperfsvc --configs iperfsvcconfig -ziti edge controller create terminator iperfsvc "${ZITI_EDGE_ROUTER_HOSTNAME}" tcp:localhost:5201 +ziti edge controller create terminator iperfsvc "${ZITI_ROUTER_ADVERTISED_ADDRESS}" tcp:localhost:5201 ziti edge controller delete identity "test_identity" ziti edge controller create identity device "test_identity" -o "${ZITI_HOME}/test_identity".jwt diff --git a/quickstart/test/quickstart_test.go b/quickstart/test/quickstart_test.go index 12379cb2f..bd919fab5 100644 --- a/quickstart/test/quickstart_test.go +++ b/quickstart/test/quickstart_test.go @@ -220,17 +220,15 @@ quickstart script is run. */ func TestQuickStartEnvFile(t *testing.T) { expectedValues := []string{ - "export ZITI_EDGE_ROUTER_RAWNAME=\"localhost-edge-router\"", - "export ZITI_EDGE_CONTROLLER_RAWNAME=\"localhost\"", - "export ZITI_HOME_OS_SPECIFIC=\"/persistent\"", + "export ZITI_EDGE_ROUTER_NAME=\"localhost-edge-router\"", + "export ZITI_CTRL_EDGE_ADVERTISED_PORT=\"localhost\"", "export ZITI_HOME=\"/persistent\"", "export ZITI_BIN_DIR=\"/var/openziti/ziti-bin\"", - "export ZITI_EDGE_CTRL_ADVERTISED=\"localhost:1280\"", "export ZITI_USER=\"admin\"", "export ZITI_PWD=\"admin\"", - "export ZITI_PKI_OS_SPECIFIC=\"/persistent/pki\"", - "export ZITI_EDGE_CONTROLLER_ROOTCA_NAME=\"localhost-root-ca\"", - "export ZITI_EDGE_CONTROLLER_INTERMEDIATE_NAME=\"localhost-intermediate\"", + "export ZITI_PKI=\"/persistent/pki\"", + "export ZITI_PKI_CTRL_EDGE_ROOTCA_NAME=\"localhost-root-ca\"", + "export ZITI_PKI_CTRL_EDGE_INTERMEDIATE_NAME=\"localhost-intermediate\"", } // Build the image diff --git a/quickstart/ziti-cli-functions.sh b/quickstart/ziti-cli-functions.sh deleted file mode 120000 index 50707f689..000000000 --- a/quickstart/ziti-cli-functions.sh +++ /dev/null @@ -1 +0,0 @@ -docker/image/ziti-cli-functions.sh \ No newline at end of file diff --git a/ziti/cmd/config_templates/controller.yml b/ziti/cmd/config_templates/controller.yml index 06ebe8210..edd148269 100644 --- a/ziti/cmd/config_templates/controller.yml +++ b/ziti/cmd/config_templates/controller.yml @@ -1,7 +1,7 @@ v: 3 #trace: -# path: "{{ .Controller.Name }}.trace" +# path: "{{ .Controller.Web.BindPoints.AddressAddress }}.trace" #profile: # memory: @@ -10,10 +10,10 @@ v: 3 db: "{{ .ZitiHome }}/db/ctrl.db" identity: - cert: "{{ .Controller.IdentityCert }}" - server_cert: "{{ .Controller.IdentityServerCert }}" - key: "{{ .Controller.IdentityKey }}" - ca: "{{ .Controller.IdentityCA }}" + cert: "{{ .Controller.Identity.Cert }}" + server_cert: "{{ .Controller.Identity.ServerCert }}" + key: "{{ .Controller.Identity.Key }}" + ca: "{{ .Controller.Identity.Ca }}" # Network Configuration # @@ -69,25 +69,13 @@ identity: ctrl: #options: # (optional) settings - # set the maximum number of connect requests that are buffered and waiting to be acknowledged ({{ .Controller.MinQueuedConnects }} to {{ .Controller.MaxQueuedConnects }}, default {{ .Controller.DefaultQueuedConnects }}) - #maxQueuedConnects: {{ .Controller.DefaultQueuedConnects }} - # the maximum number of connects that have begun hello synchronization ({{ .Controller.MinOutstandingConnects }} to {{ .Controller.MaxOutstandingConnects }}, default {{ .Controller.DefaultOutstandingConnects }}) - #maxOutstandingConnects: {{ .Controller.DefaultOutstandingConnects }} - # the number of milliseconds to wait before a hello synchronization fails and closes the connection ({{ .Controller.MinConnectTimeout.Milliseconds }}ms to {{ .Controller.MaxConnectTimeout.Milliseconds }}ms, default: {{ .Controller.DefaultConnectTimeout.Milliseconds }}ms) - #connectTimeoutMs: {{ .Controller.DefaultConnectTimeout.Milliseconds }} - listener: tls:{{ .Controller.ListenerAddress }}:{{ .Controller.Port }} - -# the endpoint that management tools connect to the controller over. -mgmt: - #options: - # (optional) settings - # set the maximum number of connect requests that are buffered and waiting to be acknowledged ({{ .Controller.MinQueuedConnects }} to {{ .Controller.MaxQueuedConnects }}, default {{ .Controller.DefaultQueuedConnects }}) - #maxQueuedConnects: {{ .Controller.DefaultQueuedConnects }} - # the maximum number of connects that have begun hello synchronization ({{ .Controller.MinOutstandingConnects }} to {{ .Controller.MaxOutstandingConnects }}, default {{ .Controller.DefaultOutstandingConnects }}) - #maxOutstandingConnects: {{ .Controller.DefaultOutstandingConnects }} - # the number of milliseconds to wait before a hello synchronization fails and closes the connection ({{ .Controller.MinConnectTimeout.Milliseconds }}ms to {{ .Controller.MaxConnectTimeout.Milliseconds }}ms, default: {{ .Controller.DefaultConnectTimeout.Milliseconds }}ms) - #connectTimeoutMs: {{ .Controller.DefaultConnectTimeout.Milliseconds }} - listener: tls:{{ .Controller.ListenerAddress }}:10000 + # set the maximum number of connect requests that are buffered and waiting to be acknowledged ({{ .Controller.Ctrl.MinQueuedConnects }} to {{ .Controller.Ctrl.MaxQueuedConnects }}, default {{ .Controller.Ctrl.DefaultQueuedConnects }}) + #maxQueuedConnects: {{ .Controller.Ctrl.DefaultQueuedConnects }} + # the maximum number of connects that have begun hello synchronization ({{ .Controller.Ctrl.MinOutstandingConnects }} to {{ .Controller.Ctrl.MaxOutstandingConnects }}, default {{ .Controller.Ctrl.DefaultOutstandingConnects }}) + #maxOutstandingConnects: {{ .Controller.Ctrl.DefaultOutstandingConnects }} + # the number of milliseconds to wait before a hello synchronization fails and closes the connection ({{ .Controller.Ctrl.MinConnectTimeout.Milliseconds }}ms to {{ .Controller.Ctrl.MaxConnectTimeout.Milliseconds }}ms, default: {{ .Controller.Ctrl.DefaultConnectTimeout.Milliseconds }}ms) + #connectTimeoutMs: {{ .Controller.Ctrl.DefaultConnectTimeout.Milliseconds }} + listener: tls:{{ .Controller.Ctrl.ListenerAddress }}:{{ .Controller.Ctrl.ListenerPort }} #metrics: # influxdb: @@ -102,30 +90,30 @@ mgmt: healthChecks: boltCheck: - # How often to try entering a bolt read tx. Defaults to {{ .Controller.HealthCheck.Interval.Seconds }} seconds - interval: {{ .Controller.HealthCheck.Interval.Seconds }}s - # When to time out the check. Defaults to {{ .Controller.HealthCheck.Timeout.Seconds }} seconds - timeout: {{ .Controller.HealthCheck.Timeout.Seconds }}s - # How long to wait before starting the check. Defaults to {{ .Controller.HealthCheck.InitialDelay.Seconds }} seconds - initialDelay: {{ .Controller.HealthCheck.InitialDelay.Seconds }}s + # How often to try entering a bolt read tx. Defaults to {{ .Controller.HealthChecks.Interval.Seconds }} seconds + interval: {{ .Controller.HealthChecks.Interval.Seconds }}s + # When to time out the check. Defaults to {{ .Controller.HealthChecks.Timeout.Seconds }} seconds + timeout: {{ .Controller.HealthChecks.Timeout.Seconds }}s + # How long to wait before starting the check. Defaults to {{ .Controller.HealthChecks.InitialDelay.Seconds }} seconds + initialDelay: {{ .Controller.HealthChecks.InitialDelay.Seconds }}s # By having an 'edge' section defined, the ziti-controller will attempt to parse the edge configuration. Removing this # section, commenting out, or altering the name of the section will cause the edge to not run. edge: # This section represents the configuration of the Edge API that is served over HTTPS api: - #(optional, default {{ .Controller.Edge.APIActivityUpdateInterval.Seconds }}s) Alters how frequently heartbeat and last activity values are persisted - # activityUpdateInterval: {{ .Controller.Edge.APIActivityUpdateInterval.Seconds }}s - #(optional, default {{ .Controller.Edge.APIActivityUpdateBatchSize }}) The number of API Sessions updated for last activity per transaction - # activityUpdateBatchSize: {{ .Controller.Edge.APIActivityUpdateBatchSize }} - # sessionTimeout - optional, default {{ .Controller.Edge.APISessionTimeout.Minutes }}m + #(optional, default {{ .Controller.EdgeApi.APIActivityUpdateInterval.Seconds }}s) Alters how frequently heartbeat and last activity values are persisted + # activityUpdateInterval: {{ .Controller.EdgeApi.APIActivityUpdateInterval.Seconds }}s + #(optional, default {{ .Controller.EdgeApi.APIActivityUpdateBatchSize }}) The number of API Sessions updated for last activity per transaction + # activityUpdateBatchSize: {{ .Controller.EdgeApi.APIActivityUpdateBatchSize }} + # sessionTimeout - optional, default {{ .Controller.EdgeApi.SessionTimeout.Minutes }}m # The number of minutes before an Edge API session will time out. Timeouts are reset by # API requests and connections that are maintained to Edge Routers - sessionTimeout: {{ .Controller.Edge.APISessionTimeout.Minutes }}m + sessionTimeout: {{ .Controller.EdgeApi.SessionTimeout.Minutes }}m # address - required # The default address (host:port) to use for enrollment for the Client API. This value must match one of the addresses # defined in this Controller.WebListener.'s bindPoints. - address: {{ .Controller.Edge.AdvertisedHostPort }} + address: {{ .Controller.EdgeApi.Address }}:{{ .Controller.EdgeApi.Port }} # This section is used to define option that are used during enrollment of Edge Routers, Ziti Edge Identities. enrollment: # signingCert - required @@ -133,22 +121,22 @@ edge: # a signing certificate from the PKI that the Ziti environment is using to sign certificates. The signingCert.cert # will be added to the /.well-known CA store that is used to bootstrap trust with the Ziti Controller. signingCert: - cert: {{ .Controller.Edge.ZitiSigningCert }} - key: {{ .Controller.Edge.ZitiSigningKey }} + cert: {{ .Controller.EdgeEnrollment.SigningCert }} + key: {{ .Controller.EdgeEnrollment.SigningCertKey }} # edgeIdentity - optional # A section for identity enrollment specific settings edgeIdentity: - # duration - optional, default {{ .Controller.DefaultEdgeIdentityDuration.Minutes }}m + # duration - optional, default {{ .Controller.EdgeEnrollment.DefaultEdgeIdentityDuration.Minutes }}m # The length of time that a Ziti Edge Identity enrollment should remain valid. After # this duration, the enrollment will expire and no longer be usable. - duration: {{ .Controller.EdgeIdentityDuration.Minutes }}m + duration: {{ .Controller.EdgeEnrollment.EdgeIdentityDuration.Minutes }}m # edgeRouter - Optional # A section for edge router enrollment specific settings. edgeRouter: - # duration - optional, default {{ .Controller.DefaultEdgeRouterDuration.Minutes }}m + # duration - optional, default {{ .Controller.EdgeEnrollment.DefaultEdgeRouterDuration.Minutes }}m # The length of time that a Ziti Edge Router enrollment should remain valid. After # this duration, the enrollment will expire and no longer be usable. - duration: {{ .Controller.EdgeRouterDuration.Minutes }}m + duration: {{ .Controller.EdgeEnrollment.EdgeRouterDuration.Minutes }}m # web # Defines webListeners that will be hosted by the controller. Each webListener can host many APIs and be bound to many @@ -165,43 +153,43 @@ web: bindPoints: #interface - required # A host:port string on which network interface to listen on. 0.0.0.0 will listen on all interfaces - - interface: {{ .Controller.Edge.ListenerHostPort }} + - interface: {{ .Controller.Web.BindPoints.InterfaceAddress }}:{{ .Controller.Web.BindPoints.InterfacePort }} # 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: {{ .Controller.Edge.AdvertisedHostPort }} + address: {{ .Controller.Web.BindPoints.AddressAddress }}:{{ .Controller.Web.BindPoints.AddressPort }} # identity - optional # Allows the webListener to have a specific identity instead of defaulting to the root 'identity' section. identity: - ca: "{{ .Controller.Edge.IdentityCA }}" - key: "{{ .Controller.Edge.IdentityKey }}" - server_cert: "{{ .Controller.Edge.IdentityServerCert }}" - cert: "{{ .Controller.Edge.IdentityCert }}" + ca: "{{ .Controller.Web.Identity.Ca }}" + key: "{{ .Controller.Web.Identity.Key }}" + server_cert: "{{ .Controller.Web.Identity.ServerCert }}" + cert: "{{ .Controller.Web.Identity.Cert }}" # options - optional # Allows the specification of webListener level options - mainly dealing with HTTP/TLS settings. These options are # used for all http servers started by the current webListener. options: - # idleTimeoutMs - optional, default {{ .Controller.WebListener.IdleTimeout.Milliseconds }}ms + # idleTimeoutMs - optional, default {{ .Controller.Web.Options.IdleTimeout.Milliseconds }}ms # The maximum amount of idle time in milliseconds allowed for pipelined HTTP requests. Setting this too high # 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: {{ .Controller.WebListener.IdleTimeout.Milliseconds }}ms #http timeouts, new - # readTimeoutMs - optional, default {{ .Controller.WebListener.ReadTimeout.Milliseconds }}ms + idleTimeout: {{ .Controller.Web.Options.IdleTimeout.Milliseconds }}ms #http timeouts, new + # readTimeoutMs - optional, default {{ .Controller.Web.Options.ReadTimeout.Milliseconds }}ms # 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: {{ .Controller.WebListener.ReadTimeout.Milliseconds }}ms - # writeTimeoutMs - optional, default {{ .Controller.WebListener.WriteTimeout.Milliseconds }}ms + readTimeout: {{ .Controller.Web.Options.ReadTimeout.Milliseconds }}ms + # writeTimeoutMs - optional, default {{ .Controller.Web.Options.WriteTimeout.Milliseconds }}ms # 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: {{ .Controller.WebListener.WriteTimeout.Milliseconds }}ms - # minTLSVersion - optional, default {{ .Controller.WebListener.MinTLSVersion }} + writeTimeout: {{ .Controller.Web.Options.WriteTimeout.Milliseconds }}ms + # minTLSVersion - optional, default {{ .Controller.Web.Options.MinTLSVersion }} # The minimum version of TSL to support - minTLSVersion: {{ .Controller.WebListener.MinTLSVersion }} - # maxTLSVersion - optional, default {{ .Controller.WebListener.MaxTLSVersion }} + minTLSVersion: {{ .Controller.Web.Options.MinTLSVersion }} + # maxTLSVersion - optional, default {{ .Controller.Web.Options.MaxTLSVersion }} # The maximum version of TSL to support - maxTLSVersion: {{ .Controller.WebListener.MaxTLSVersion }} + maxTLSVersion: {{ .Controller.Web.Options.MaxTLSVersion }} # apis - required # Allows one or more APIs to be bound to this webListener apis: diff --git a/ziti/cmd/config_templates/router.yml b/ziti/cmd/config_templates/router.yml index 149218422..de0c01867 100644 --- a/ziti/cmd/config_templates/router.yml +++ b/ziti/cmd/config_templates/router.yml @@ -13,7 +13,7 @@ identity: ca: "{{ .Router.IdentityCA }}" ctrl: - endpoint: tls:{{ .Controller.AdvertisedAddress }}:{{ .Controller.Port }} + endpoint: tls:{{ .Controller.Web.BindPoints.AddressAddress }}:{{ .Controller.Ctrl.ListenerPort }} link: dialers: @@ -47,7 +47,7 @@ csr: organizationalUnit: Ziti sans: dns: - - {{ .Router.Edge.Hostname }} + - {{ .Router.Edge.AdvertisedHost }} - localhost ip: - "127.0.0.1" @@ -62,7 +62,7 @@ edge: organizationalUnit: Ziti sans: dns: - - {{ .Router.Edge.Hostname }} + - {{ .Router.Edge.AdvertisedHost }} - localhost ip: - "127.0.0.1" diff --git a/ziti/cmd/create_config.go b/ziti/cmd/create_config.go index 2dd5635fd..3ec18ae1f 100644 --- a/ziti/cmd/create_config.go +++ b/ziti/cmd/create_config.go @@ -58,50 +58,64 @@ type ConfigTemplateValues struct { Router RouterTemplateValues } -type ControllerTemplateValues struct { - Name string - Port string - AdvertisedAddress string - ListenerAddress string - IdentityCert string - IdentityServerCert string - IdentityKey string - IdentityCA string - MinQueuedConnects int - MaxQueuedConnects int - DefaultQueuedConnects int - MinOutstandingConnects int - MaxOutstandingConnects int - DefaultOutstandingConnects int - MinConnectTimeout time.Duration - MaxConnectTimeout time.Duration - DefaultConnectTimeout time.Duration +type CtrlValues struct { + MinQueuedConnects int + MaxQueuedConnects int + DefaultQueuedConnects int + MinOutstandingConnects int + MaxOutstandingConnects int + DefaultOutstandingConnects int + MinConnectTimeout time.Duration + MaxConnectTimeout time.Duration + DefaultConnectTimeout time.Duration + ListenerAddress string + ListenerPort string +} + +type HealthChecksValues struct { + Interval time.Duration + Timeout time.Duration + InitialDelay time.Duration +} + +type EdgeApiValues struct { + APIActivityUpdateBatchSize int + APIActivityUpdateInterval time.Duration + SessionTimeout time.Duration + Address string + Port string +} + +type EdgeEnrollmentValues struct { + SigningCert string + SigningCertKey string EdgeIdentityDuration time.Duration EdgeRouterDuration time.Duration DefaultEdgeIdentityDuration time.Duration DefaultEdgeRouterDuration time.Duration - Edge EdgeControllerValues - WebListener ControllerWebListenerValues - HealthCheck ControllerHealthCheckValues } -type EdgeControllerValues struct { - AdvertisedPort string - ZitiSigningCert string - ZitiSigningKey string - - APIActivityUpdateBatchSize int - APIActivityUpdateInterval time.Duration - APISessionTimeout time.Duration - ListenerHostPort string - AdvertisedHostPort string - IdentityCert string - IdentityServerCert string - IdentityKey string - IdentityCA string +type WebValues struct { + BindPoints BindPointsValues + Identity IdentityValues + Options WebOptionsValues } -type ControllerWebListenerValues struct { +type BindPointsValues struct { + InterfaceAddress string + InterfacePort string + AddressAddress string + AddressPort string +} + +type IdentityValues struct { + Ca string + Key string + ServerCert string + Cert string +} + +type WebOptionsValues struct { IdleTimeout time.Duration ReadTimeout time.Duration WriteTimeout time.Duration @@ -109,10 +123,13 @@ type ControllerWebListenerValues struct { MaxTLSVersion string } -type ControllerHealthCheckValues struct { - Interval time.Duration - Timeout time.Duration - InitialDelay time.Duration +type ControllerTemplateValues struct { + Identity IdentityValues + Ctrl CtrlValues + HealthChecks HealthChecksValues + EdgeApi EdgeApiValues + EdgeEnrollment EdgeEnrollmentValues + Web WebValues } type RouterTemplateValues struct { @@ -132,7 +149,6 @@ type RouterTemplateValues struct { } type EdgeRouterTemplateValues struct { - Hostname string Port string IPOverride string AdvertisedHost string @@ -170,16 +186,7 @@ var workingDir string var data = &ConfigTemplateValues{} func init() { - zh := os.Getenv("ZITI_HOME") - if zh == "" { - wd, err := os.Getwd() - if wd == "" || err != nil { - //on error just use "." - workingDir = "." - } - } - - workingDir = cmdHelper.NormalizePath(zh) + workingDir, _ = cmdHelper.GetZitiHome() } // NewCmdCreateConfig creates a command object for the "config" command @@ -206,7 +213,7 @@ func (options *CreateConfigOptions) addCreateFlags(cmd *cobra.Command) { cmd.PersistentFlags().StringVarP(&options.Output, optionOutput, "o", defaultOutput, outputDescription) } -func (data *ConfigTemplateValues) populateEnvVars() { +func (data *ConfigTemplateValues) populateConfigValues() { // Get and add hostname to the params hostname, err := os.Hostname() @@ -216,89 +223,92 @@ func (data *ConfigTemplateValues) populateEnvVars() { zitiHome, err := cmdHelper.GetZitiHome() handleVariableError(err, constants.ZitiHomeVarName) - // Get Ziti Controller Name - zitiCtrlHostname, err := cmdHelper.GetZitiCtrlName() - handleVariableError(err, constants.ZitiCtrlNameVarName) + // Get Ziti Controller ctrl:listener address and port + ctrlListenerAddress, err := cmdHelper.GetCtrlListenerAddress() + handleVariableError(err, constants.CtrlListenerAddressVarName) + ctrlListenerPort, err := cmdHelper.GetCtrlListenerPort() + handleVariableError(err, constants.CtrlListenerPortVarName) + + // Get Ziti Controller edge:api address and port + ctrlEdgeApiAddress, err := cmdHelper.GetCtrlEdgeApiAddress() + handleVariableError(err, constants.CtrlEdgeApiAddressVarName) + ctrlEdgeApiPort, err := cmdHelper.GetCtrlEdgeApiPort() + handleVariableError(err, constants.CtrlEdgeApiPortVarName) + + // Get Ziti Controller Identity edge:enrollment duration + ctrlEdgeIdentityEnrollmentDuration, err := cmdHelper.GetCtrlEdgeIdentityEnrollmentDuration() + handleVariableError(err, constants.CtrlEdgeIdentityEnrollmentDurationVarName) + + // Get Ziti Controller Router edge:enrollment enrollment duration + ctrlEdgeRouterEnrollmentDuration, err := cmdHelper.GetCtrlEdgeRouterEnrollmentDuration() + handleVariableError(err, constants.CtrlEdgeRouterEnrollmentDurationVarName) + + // Get Ziti Controller web:bindPoints interface address and port + ctrlEdgeInterfaceAddress, err := cmdHelper.GetCtrlEdgeInterfaceAddress() + handleVariableError(err, constants.CtrlEdgeInterfaceAddressVarName) + ctrlEdgeInterfacePort, err := cmdHelper.GetCtrlEdgeInterfacePort() + handleVariableError(err, constants.CtrlEdgeInterfacePortVarName) + + // Get Ziti Controller web:bindPoints address address and port + ctrlEdgeAdvertisedAddress, err := cmdHelper.GetCtrlEdgeAdvertisedAddress() + handleVariableError(err, constants.CtrlEdgeAdvertisedAddressVarName) + ctrlEdgeAdvertisedPort, err := cmdHelper.GetCtrlEdgeAdvertisedPort() + handleVariableError(err, constants.CtrlEdgeAdvertisedPortVarName) // Get Ziti Edge Router Port zitiEdgeRouterPort, err := cmdHelper.GetZitiEdgeRouterPort() handleVariableError(err, constants.ZitiEdgeRouterPortVarName) - // Get Ziti Controller Listener Address - zitiCtrlListenerAddress, err := cmdHelper.GetZitiCtrlListenerAddress() - handleVariableError(err, constants.ZitiCtrlListenerAddressVarName) - - // Get Ziti Controller Advertised Address - zitiCtrlAdvertisedAddress, err := cmdHelper.GetZitiCtrlAdvertisedAddress() - handleVariableError(err, constants.ZitiCtrlAdvertisedAddressVarName) - - // Get Ziti Controller Port - zitiCtrlPort, err := cmdHelper.GetZitiCtrlPort() - handleVariableError(err, constants.ZitiCtrlPortVarName) - - // Get Ziti Edge Controller Listener Host and Port - zitiEdgeCtrlListenerHostPort, err := cmdHelper.GetZitiEdgeCtrlListenerHostPort() - handleVariableError(err, constants.ZitiEdgeCtrlListenerHostPortVarName) - - // Get Ziti Edge Controller Advertised Host and Port - zitiEdgeCtrlAdvertisedHostPort, err := cmdHelper.GetZitiEdgeCtrlAdvertisedHostPort() - handleVariableError(err, constants.ZitiEdgeCtrlAdvertisedHostPortVarName) - - // Get Ziti Edge Controller Advertised Port - zitiEdgeCtrlAdvertisedPort, err := cmdHelper.GetZitiEdgeCtrlAdvertisedPort() - handleVariableError(err, constants.ZitiEdgeCtrlAdvertisedPortVarName) - - // Get Ziti edge Identity enrollment duration - zitiEdgeIdentityEnrollmentDuration, err := cmdHelper.GetZitiEdgeIdentityEnrollmentDuration() - handleVariableError(err, constants.ZitiEdgeIdentityEnrollmentDurationVarName) - - // Get Ziti edge Router enrollment duration - zitiEdgeRouterEnrollmentDuration, err := cmdHelper.GetZitiEdgeRouterEnrollmentDuration() - handleVariableError(err, constants.ZitiEdgeRouterEnrollmentDurationVarName) - zitiEdgeRouterListenerBindPort, err := cmdHelper.GetZitiEdgeRouterListenerBindPort() handleVariableError(err, constants.ZitiEdgeRouterListenerBindPortVarName) data.ZitiHome = zitiHome data.Hostname = hostname - data.Controller.Name = zitiCtrlHostname - data.Controller.ListenerAddress = zitiCtrlListenerAddress - data.Controller.AdvertisedAddress = zitiCtrlAdvertisedAddress - data.Controller.Port = zitiCtrlPort - data.Controller.Edge.ListenerHostPort = zitiEdgeCtrlListenerHostPort - data.Controller.Edge.AdvertisedHostPort = zitiEdgeCtrlAdvertisedHostPort + // ************* Controller Values ************ + // Identities are handled in create_config_controller + // ctrl: + data.Controller.Ctrl.MinQueuedConnects = channel.MinQueuedConnects + data.Controller.Ctrl.MaxQueuedConnects = channel.MaxQueuedConnects + data.Controller.Ctrl.DefaultQueuedConnects = channel.DefaultQueuedConnects + data.Controller.Ctrl.MinOutstandingConnects = channel.MinOutstandingConnects + data.Controller.Ctrl.MaxOutstandingConnects = channel.MaxOutstandingConnects + data.Controller.Ctrl.DefaultOutstandingConnects = channel.DefaultOutstandingConnects + data.Controller.Ctrl.MinConnectTimeout = channel.MinConnectTimeout + data.Controller.Ctrl.MaxConnectTimeout = channel.MaxConnectTimeout + data.Controller.Ctrl.DefaultConnectTimeout = channel.DefaultConnectTimeout + data.Controller.Ctrl.ListenerAddress = ctrlListenerAddress + data.Controller.Ctrl.ListenerPort = ctrlListenerPort + // healthChecks: + data.Controller.HealthChecks.Interval = fabCtrl.DefaultHealthChecksBoltCheckInterval + data.Controller.HealthChecks.Timeout = fabCtrl.DefaultHealthChecksBoltCheckTimeout + data.Controller.HealthChecks.InitialDelay = fabCtrl.DefaultHealthChecksBoltCheckInitialDelay + // edge: + data.Controller.EdgeApi.APIActivityUpdateBatchSize = edge.DefaultEdgeApiActivityUpdateBatchSize + data.Controller.EdgeApi.APIActivityUpdateInterval = edge.DefaultEdgeAPIActivityUpdateInterval + data.Controller.EdgeApi.SessionTimeout = edge.DefaultEdgeSessionTimeout + data.Controller.EdgeApi.Address = ctrlEdgeApiAddress + data.Controller.EdgeApi.Port = ctrlEdgeApiPort + data.Controller.EdgeEnrollment.EdgeIdentityDuration = ctrlEdgeIdentityEnrollmentDuration + data.Controller.EdgeEnrollment.EdgeRouterDuration = ctrlEdgeRouterEnrollmentDuration + data.Controller.EdgeEnrollment.DefaultEdgeIdentityDuration = edge.DefaultEdgeEnrollmentDuration + data.Controller.EdgeEnrollment.DefaultEdgeRouterDuration = edge.DefaultEdgeEnrollmentDuration + // web: + data.Controller.Web.BindPoints.InterfaceAddress = ctrlEdgeInterfaceAddress + data.Controller.Web.BindPoints.InterfacePort = ctrlEdgeInterfacePort + data.Controller.Web.BindPoints.AddressAddress = ctrlEdgeAdvertisedAddress + data.Controller.Web.BindPoints.AddressPort = ctrlEdgeAdvertisedPort + // Web Identities are handled in create_config_controller + data.Controller.Web.Options.IdleTimeout = edge.DefaultHttpIdleTimeout + data.Controller.Web.Options.ReadTimeout = edge.DefaultHttpReadTimeout + data.Controller.Web.Options.WriteTimeout = edge.DefaultHttpWriteTimeout + data.Controller.Web.Options.MinTLSVersion = fabXweb.ReverseTlsVersionMap[fabXweb.MinTLSVersion] + data.Controller.Web.Options.MaxTLSVersion = fabXweb.ReverseTlsVersionMap[fabXweb.MaxTLSVersion] + + // ************* Router Values ************ data.Router.Edge.Port = zitiEdgeRouterPort data.Router.Edge.ListenerBindPort = zitiEdgeRouterListenerBindPort - data.Controller.Edge.AdvertisedPort = zitiEdgeCtrlAdvertisedPort - data.Controller.EdgeIdentityDuration = zitiEdgeIdentityEnrollmentDuration - data.Controller.EdgeRouterDuration = zitiEdgeRouterEnrollmentDuration - data.Controller.DefaultEdgeIdentityDuration = edge.DefaultEdgeEnrollmentDuration - data.Controller.DefaultEdgeRouterDuration = edge.DefaultEdgeEnrollmentDuration -} - -func (data *ConfigTemplateValues) populateDefaults() { data.Router.Listener.GetSessionTimeout = constants.DefaultGetSessionTimeout - data.Controller.MinQueuedConnects = channel.MinQueuedConnects - data.Controller.MaxQueuedConnects = channel.MaxQueuedConnects - data.Controller.DefaultQueuedConnects = channel.DefaultQueuedConnects - data.Controller.MinOutstandingConnects = channel.MinOutstandingConnects - data.Controller.MaxOutstandingConnects = channel.MaxOutstandingConnects - data.Controller.DefaultOutstandingConnects = channel.DefaultOutstandingConnects - data.Controller.MinConnectTimeout = channel.MinConnectTimeout - data.Controller.MaxConnectTimeout = channel.MaxConnectTimeout - data.Controller.DefaultConnectTimeout = channel.DefaultConnectTimeout - data.Controller.HealthCheck.Timeout = fabCtrl.DefaultHealthChecksBoltCheckTimeout - data.Controller.HealthCheck.Interval = fabCtrl.DefaultHealthChecksBoltCheckInterval - data.Controller.HealthCheck.InitialDelay = fabCtrl.DefaultHealthChecksBoltCheckInitialDelay - data.Controller.Edge.APIActivityUpdateBatchSize = edge.DefaultEdgeApiActivityUpdateBatchSize - data.Controller.Edge.APIActivityUpdateInterval = edge.DefaultEdgeAPIActivityUpdateInterval - data.Controller.Edge.APISessionTimeout = edge.DefaultEdgeSessionTimeout - data.Controller.WebListener.IdleTimeout = edge.DefaultHttpIdleTimeout - data.Controller.WebListener.ReadTimeout = edge.DefaultHttpReadTimeout - data.Controller.WebListener.WriteTimeout = edge.DefaultHttpWriteTimeout - data.Controller.WebListener.MinTLSVersion = fabXweb.ReverseTlsVersionMap[fabXweb.MinTLSVersion] - data.Controller.WebListener.MaxTLSVersion = fabXweb.ReverseTlsVersionMap[fabXweb.MaxTLSVersion] data.Router.Wss.WriteTimeout = foundation.DefaultWsWriteTimeout data.Router.Wss.ReadTimeout = foundation.DefaultWsReadTimeout data.Router.Wss.IdleTimeout = foundation.DefaultWsIdleTimeout diff --git a/ziti/cmd/create_config_controller.go b/ziti/cmd/create_config_controller.go index da4c7619f..04fb44b21 100644 --- a/ziti/cmd/create_config_controller.go +++ b/ziti/cmd/create_config_controller.go @@ -72,7 +72,6 @@ type CreateConfigControllerOptions struct { CreateConfigOptions CtrlPort string - MgmtListener string EdgeIdentityEnrollmentDuration time.Duration EdgeRouterEnrollmentDuration time.Duration } @@ -101,19 +100,18 @@ func NewCmdCreateConfigController() *cobra.Command { logrus.SetOutput(logOut) } - data.populateEnvVars() - data.populateDefaults() + data.populateConfigValues() // Update controller specific values with configOptions passed in if the argument was provided or the value is currently blank - if data.Controller.Port == "" || controllerOptions.CtrlPort != constants.DefaultZitiControllerPort { - data.Controller.Port = controllerOptions.CtrlPort + if data.Controller.Ctrl.ListenerPort == "" || controllerOptions.CtrlPort != constants.DefaultCtrlListenerPort { + data.Controller.Ctrl.ListenerPort = controllerOptions.CtrlPort } // Update with the passed in arg if it's not the default (CLI flag should override other methods of modifying these values) if controllerOptions.EdgeIdentityEnrollmentDuration != edge.DefaultEdgeEnrollmentDuration { - data.Controller.EdgeIdentityDuration = controllerOptions.EdgeIdentityEnrollmentDuration + data.Controller.EdgeEnrollment.EdgeIdentityDuration = controllerOptions.EdgeIdentityEnrollmentDuration } if controllerOptions.EdgeRouterEnrollmentDuration != edge.DefaultEdgeEnrollmentDuration { - data.Controller.EdgeRouterDuration = controllerOptions.EdgeRouterEnrollmentDuration + data.Controller.EdgeEnrollment.EdgeRouterDuration = controllerOptions.EdgeRouterEnrollmentDuration } // process identity information @@ -140,7 +138,7 @@ func NewCmdCreateConfigController() *cobra.Command { } func (options *CreateConfigControllerOptions) addFlags(cmd *cobra.Command) { - cmd.Flags().StringVar(&options.CtrlPort, optionCtrlPort, constants.DefaultZitiControllerPort, "port used for the router to controller communication") + cmd.Flags().StringVar(&options.CtrlPort, optionCtrlPort, constants.DefaultCtrlListenerPort, "port used for the router to controller communication") cmd.Flags().StringVar(&options.DatabaseFile, optionDatabaseFile, "ctrl.db", "location of the database file") cmd.Flags().DurationVar(&options.EdgeIdentityEnrollmentDuration, optionEdgeIdentityEnrollmentDuration, edge.DefaultEdgeEnrollmentDuration, "the edge identity enrollment duration, use 0h0m0s format") cmd.Flags().DurationVar(&options.EdgeRouterEnrollmentDuration, optionEdgeRouterEnrollmentDuration, edge.DefaultEdgeEnrollmentDuration, "the edge router enrollment duration, use 0h0m0s format") @@ -181,18 +179,6 @@ func (options *CreateConfigControllerOptions) run(data *ConfigTemplateValues) er return nil } -func hostnameOrNetworkName() string { - val := os.Getenv("ZITI_NETWORK_NAME") - if val == "" { - h, err := os.Hostname() - if err != nil { - return "localhost" - } - return h - } - return val -} - func SetControllerIdentity(data *ControllerTemplateValues) { SetControllerIdentityCert(data) SetControllerIdentityServerCert(data) @@ -200,32 +186,32 @@ func SetControllerIdentity(data *ControllerTemplateValues) { SetControllerIdentityCA(data) } func SetControllerIdentityCert(c *ControllerTemplateValues) { - val := os.Getenv(constants.ZitiCtrlIdentityCertVarName) + val := os.Getenv(constants.PkiCtrlCertVarName) if val == "" { - val = workingDir + "/" + hostnameOrNetworkName() + ".cert" // default + val = workingDir + "/" + helpers2.HostnameOrNetworkName() + ".cert" // default } - c.IdentityCert = helpers2.NormalizePath(val) + c.Identity.Cert = helpers2.NormalizePath(val) } func SetControllerIdentityServerCert(c *ControllerTemplateValues) { - val := os.Getenv(constants.ZitiCtrlIdentityServerCertVarName) + val := os.Getenv(constants.PkiCtrlServerCertVarName) if val == "" { - val = workingDir + "/" + hostnameOrNetworkName() + ".server.chain.cert" // default + val = workingDir + "/" + helpers2.HostnameOrNetworkName() + ".server.chain.cert" // default } - c.IdentityServerCert = helpers2.NormalizePath(val) + c.Identity.ServerCert = helpers2.NormalizePath(val) } func SetControllerIdentityKey(c *ControllerTemplateValues) { - val := os.Getenv(constants.ZitiCtrlIdentityKeyVarName) + val := os.Getenv(constants.PkiCtrlKeyVarName) if val == "" { - val = workingDir + "/" + hostnameOrNetworkName() + ".key" // default + val = workingDir + "/" + helpers2.HostnameOrNetworkName() + ".key" // default } - c.IdentityKey = helpers2.NormalizePath(val) + c.Identity.Key = helpers2.NormalizePath(val) } func SetControllerIdentityCA(c *ControllerTemplateValues) { - val := os.Getenv(constants.ZitiCtrlIdentityCAVarName) + val := os.Getenv(constants.PkiCtrlCAVarName) if val == "" { - val = workingDir + "/" + hostnameOrNetworkName() + ".ca" // default + val = workingDir + "/" + helpers2.HostnameOrNetworkName() + ".ca" // default } - c.IdentityCA = helpers2.NormalizePath(val) + c.Identity.Ca = helpers2.NormalizePath(val) } func SetEdgeConfig(data *ControllerTemplateValues) { @@ -233,18 +219,19 @@ func SetEdgeConfig(data *ControllerTemplateValues) { SetEdgeSigningKey(data) } func SetEdgeSigningCert(c *ControllerTemplateValues) { - val := os.Getenv(constants.ZitiSigningCertVarName) + val := os.Getenv(constants.PkiSignerCertVarName) if val == "" { - val = workingDir + "/" + hostnameOrNetworkName() + ".signing.cert" // default + val = workingDir + "/" + helpers2.HostnameOrNetworkName() + ".signing.cert" // default } - c.Edge.ZitiSigningCert = helpers2.NormalizePath(val) + c.EdgeEnrollment.SigningCert = helpers2.NormalizePath(val) + } func SetEdgeSigningKey(c *ControllerTemplateValues) { - val := os.Getenv(constants.ZitiSigningKeyVarName) + val := os.Getenv(constants.PkiSignerKeyVarName) if val == "" { - val = workingDir + "/" + hostnameOrNetworkName() + ".signing.key" // default + val = workingDir + "/" + helpers2.HostnameOrNetworkName() + ".signing.key" // default } - c.Edge.ZitiSigningKey = helpers2.NormalizePath(val) + c.EdgeEnrollment.SigningCertKey = helpers2.NormalizePath(val) } func SetWebConfig(data *ControllerTemplateValues) { @@ -254,30 +241,30 @@ func SetWebConfig(data *ControllerTemplateValues) { SetWebIdentityCA(data) } func SetWebIdentityCert(c *ControllerTemplateValues) { - val := os.Getenv(constants.ZitiEdgeCtrlIdentityCertVarName) + val := os.Getenv(constants.CtrlPkiEdgeCertVarName) if val == "" { - val = c.IdentityCert //default + val = c.Identity.Cert //default } - c.Edge.IdentityCert = helpers2.NormalizePath(val) + c.Web.Identity.Cert = helpers2.NormalizePath(val) } func SetWebIdentityServerCert(c *ControllerTemplateValues) { - val := os.Getenv(constants.ZitiEdgeCtrlIdentityServerCertVarName) + val := os.Getenv(constants.CtrlPkiEdgeServerCertVarName) if val == "" { - val = c.IdentityServerCert //default + val = c.Identity.ServerCert //default } - c.Edge.IdentityServerCert = helpers2.NormalizePath(val) + c.Web.Identity.ServerCert = helpers2.NormalizePath(val) } func SetWebIdentityKey(c *ControllerTemplateValues) { - val := os.Getenv(constants.ZitiEdgeCtrlIdentityKeyVarName) + val := os.Getenv(constants.CtrlPkiEdgeKeyVarName) if val == "" { - val = c.IdentityKey //default + val = c.Identity.Key //default } - c.Edge.IdentityKey = helpers2.NormalizePath(val) + c.Web.Identity.Key = helpers2.NormalizePath(val) } func SetWebIdentityCA(c *ControllerTemplateValues) { - val := os.Getenv(constants.ZitiEdgeCtrlIdentityCAVarName) + val := os.Getenv(constants.CtrlPkiEdgeCAVarName) if val == "" { - val = c.IdentityCA //default + val = c.Identity.Ca //default } - c.Edge.IdentityCA = helpers2.NormalizePath(val) + c.Web.Identity.Ca = helpers2.NormalizePath(val) } diff --git a/ziti/cmd/create_config_controller_test.go b/ziti/cmd/create_config_controller_test.go index 491100b4c..b42b9b13d 100644 --- a/ziti/cmd/create_config_controller_test.go +++ b/ziti/cmd/create_config_controller_test.go @@ -2,9 +2,11 @@ package cmd import ( "fmt" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "github.com/stretchr/testify/assert" "gopkg.in/yaml.v3" "os" + "strings" "testing" "time" ) @@ -16,27 +18,22 @@ type ControllerConfig struct { Db string `yaml:"db"` Identity Identity `yaml:"identity"` Ctrl Ctrl `yaml:"ctrl"` - Mgmt Mgmt `yaml:"mgmt"` HealthChecks HealthChecks `yaml:"healthChecks"` Edge Edge `yaml:"edge"` Web []Web `yaml:"web"` } type Identity struct { - Cert string `yaml:"cert"` - Server_cert string `yaml:"server_cert"` - Key string `yaml:"key"` - Ca string `yaml:"ca"` + Cert string `yaml:"cert"` + ServerCert string `yaml:"server_cert"` + Key string `yaml:"key"` + Ca string `yaml:"ca"` } type Ctrl struct { Listener string `yaml:"listener"` } -type Mgmt struct { - Listener string `yaml:"listener"` -} - type HealthChecks struct { BoltCheck BoltCheck `yaml:"boltCheck"` } @@ -108,6 +105,8 @@ type ApiOptions struct { /* END Controller config template structure */ +var controllerOptions = CreateConfigControllerOptions{} + func TestControllerOutputPathDoesNotExist(t *testing.T) { expectedErrorMsg := "stat /IDoNotExist: no such file or directory" @@ -121,16 +120,109 @@ func TestControllerOutputPathDoesNotExist(t *testing.T) { } func TestCreateConfigControllerTemplateValues(t *testing.T) { - expectedNonEmptyStringFields := []string{".Controller.Name", ".ZitiHome", ".Controller.IdentityCert", ".Controller.IdentityServerCert", ".Controller.IdentityKey", ".Controller.IdentityCA", ".Controller.ListenerAddress", ".Controller.Port", ".Controller.Edge.AdvertisedHostPort", ".Controller.Edge.ZitiSigningCert", ".Controller.Edge.ZitiSigningKey", ".Controller.Edge.ListenerHostPort", ".Controller.Edge.IdentityCA", ".Controller.Edge.IdentityKey", ".Controller.Edge.IdentityServerCert", ".Controller.Edge.IdentityCert", ".Controller.WebListener.MinTLSVersion", ".Controller.WebListener.MaxTLSVersion"} - expectedNonEmptyStringValues := []*string{&data.Controller.Name, &data.ZitiHome, &data.Controller.IdentityCert, &data.Controller.IdentityServerCert, &data.Controller.IdentityKey, &data.Controller.IdentityCA, &data.Controller.ListenerAddress, &data.Controller.Port, &data.Controller.Edge.AdvertisedHostPort, &data.Controller.Edge.ZitiSigningCert, &data.Controller.Edge.ZitiSigningKey, &data.Controller.Edge.ListenerHostPort, &data.Controller.Edge.IdentityCA, &data.Controller.Edge.IdentityKey, &data.Controller.Edge.IdentityServerCert, &data.Controller.Edge.IdentityCert, &data.Controller.WebListener.MinTLSVersion, &data.Controller.WebListener.MaxTLSVersion} - expectedNonEmptyTimeFields := []string{".Controller.HealthCheck.Interval", ".Controller.HealthCheck.Timeout", ".Controller.HealthCheck.InitialDelay", ".Controller.Edge.APISessionTimeout", ".Controller.EdgeIdentityDuration", ".Controller.EdgeRouterDuration", ".Controller.WebListener.IdleTimeout", ".Controller.WebListener.ReadTimeout", ".Controller.WebListener.WriteTimeout"} - expectedNonEmptyTimeValues := []*time.Duration{&data.Controller.HealthCheck.Interval, &data.Controller.HealthCheck.Timeout, &data.Controller.HealthCheck.InitialDelay, &data.Controller.Edge.APISessionTimeout, &data.Controller.EdgeIdentityDuration, &data.Controller.EdgeRouterDuration, &data.Controller.WebListener.IdleTimeout, &data.Controller.WebListener.ReadTimeout, &data.Controller.WebListener.WriteTimeout} // Create and run the CLI command (capture output, otherwise config prints to stdout instead of test results) - cmd := NewCmdCreateConfigController() - _ = captureOutput(func() { - _ = cmd.Execute() - }) + // This must run first, otherwise the addresses used later won't be correct; this command re-allocates the `data` struct + _ = execCreateConfigControllerCommand(nil, nil) + + expectedNonEmptyStringFields := []string{ + ".ZitiHome", + ".Controller.Identity.Cert", + ".Controller.Identity.ServerCert", + ".Controller.Identity.Key", + ".Controller.Identity.Ca", + ".Controller.Ctrl.ListenerAddress", + ".Controller.Ctrl.ListenerPort", + ".Controller.EdgeApi.Address", + ".Controller.EdgeApi.Port", + ".Controller.EdgeEnrollment.SigningCert", + ".Controller.EdgeEnrollment.SigningCertKey", + ".Controller.Web.BindPoints.InterfaceAddress", + ".Controller.Web.BindPoints.InterfacePort", + ".Controller.Web.BindPoints.AddressAddress", + ".Controller.Web.BindPoints.AddressPort", + ".Controller.Web.Identity.Ca", + ".Controller.Web.Identity.Key", + ".Controller.Web.Identity.ServerCert", + ".Controller.Web.Identity.Cert", + ".Controller.Web.Options.MinTLSVersion", + ".Controller.Web.Options.MaxTLSVersion", + } + expectedNonEmptyStringValues := []*string{ + &data.ZitiHome, + &data.Controller.Identity.Cert, + &data.Controller.Identity.ServerCert, + &data.Controller.Identity.Key, + &data.Controller.Identity.Ca, + &data.Controller.Ctrl.ListenerAddress, + &data.Controller.Ctrl.ListenerPort, + &data.Controller.EdgeApi.Address, + &data.Controller.EdgeApi.Port, + &data.Controller.EdgeEnrollment.SigningCert, + &data.Controller.EdgeEnrollment.SigningCertKey, + &data.Controller.Web.BindPoints.InterfaceAddress, + &data.Controller.Web.BindPoints.InterfacePort, + &data.Controller.Web.BindPoints.AddressAddress, + &data.Controller.Web.BindPoints.AddressPort, + &data.Controller.Web.Identity.Ca, + &data.Controller.Web.Identity.Key, + &data.Controller.Web.Identity.ServerCert, + &data.Controller.Web.Identity.Cert, + &data.Controller.Web.Options.MinTLSVersion, + &data.Controller.Web.Options.MaxTLSVersion, + } + + expectedNonZeroTimeFields := []string{ + ".Controller.Ctrl.MinConnectTimeout", + ".Controller.Ctrl.MaxConnectTimeout", + ".Controller.Ctrl.DefaultConnectTimeout", + ".Controller.HealthChecks.Interval", + ".Controller.HealthChecks.Timeout", + ".Controller.HealthChecks.InitialDelay", + ".Controller.EdgeApi.APIActivityUpdateInterval", + ".Controller.EdgeApi.SessionTimeout", + ".Controller.EdgeEnrollment.DefaultEdgeIdentityDuration", + ".Controller.EdgeEnrollment.EdgeIdentityDuration", + ".Controller.EdgeEnrollment.DefaultEdgeRouterDuration", + ".Controller.EdgeEnrollment.EdgeRouterDuration", + ".Controller.Web.Options.IdleTimeout", + ".Controller.Web.Options.ReadTimeout", + ".Controller.Web.Options.WriteTimeout", + } + + expectedNonZeroTimeValues := []*time.Duration{ + &data.Controller.Ctrl.MinConnectTimeout, + &data.Controller.Ctrl.MaxConnectTimeout, + &data.Controller.Ctrl.DefaultConnectTimeout, + &data.Controller.HealthChecks.Interval, + &data.Controller.HealthChecks.Timeout, + &data.Controller.HealthChecks.InitialDelay, + &data.Controller.EdgeApi.APIActivityUpdateInterval, + &data.Controller.EdgeApi.SessionTimeout, + &data.Controller.EdgeEnrollment.DefaultEdgeIdentityDuration, + &data.Controller.EdgeEnrollment.EdgeIdentityDuration, + &data.Controller.EdgeEnrollment.DefaultEdgeRouterDuration, + &data.Controller.EdgeEnrollment.EdgeRouterDuration, + &data.Controller.Web.Options.IdleTimeout, + &data.Controller.Web.Options.ReadTimeout, + &data.Controller.Web.Options.WriteTimeout, + } + + expectedNonZeroIntFields := []string{ + ".Controller.Ctrl.DefaultQueuedConnects", + ".Controller.Ctrl.MinOutstandingConnects", + ".Controller.Ctrl.MaxOutstandingConnects", + ".Controller.Ctrl.DefaultOutstandingConnects", + ".Controller.EdgeApi.APIActivityUpdateBatchSize", + } + + expectedNonZeroIntValues := []*int{ + &data.Controller.Ctrl.DefaultQueuedConnects, + &data.Controller.Ctrl.MinOutstandingConnects, + &data.Controller.Ctrl.MaxOutstandingConnects, + &data.Controller.Ctrl.DefaultOutstandingConnects, + &data.Controller.EdgeApi.APIActivityUpdateBatchSize, + } // Check that the expected string template values are not blank for field, value := range expectedNonEmptyStringValues { @@ -138,292 +230,595 @@ func TestCreateConfigControllerTemplateValues(t *testing.T) { } // Check that the expected time.Duration template values are not zero - for field, value := range expectedNonEmptyTimeValues { - assert.NotZero(t, *value, expectedNonEmptyTimeFields[field]+" should be a non-zero value") + for field, value := range expectedNonZeroTimeValues { + assert.NotZero(t, *value, expectedNonZeroTimeFields[field]+" should be a non-zero value") + } + + // Check that the expected integer template values are not zero + for field, value := range expectedNonZeroIntValues { + assert.NotZero(t, *value, expectedNonZeroIntFields[field]+" should be a non-zero value") } } -// Edge Ctrl Listener address and port should use default values if env vars are not set -func TestDefaultListenerAddress(t *testing.T) { - expectedListenerAddress := "0.0.0.0:1280" +func TestCtrlConfigDefaultsWhenUnset(t *testing.T) { + // Clears template data and unsets all env vars + clearControllerOptionsAndTemplateData() - // Make sure the related env vars are unset - _ = os.Unsetenv("ZITI_EDGE_CONTROLLER_PORT") - _ = os.Unsetenv("ZITI_CTRL_EDGE_LISTENER_HOST_PORT") + ctrlConfig := execCreateConfigControllerCommand(nil, nil) - // Create and run the CLI command (capture output, otherwise config prints to stdout instead of test results) - cmd := NewCmdCreateConfigController() - _ = captureOutput(func() { - _ = cmd.Execute() + // identity: + t.Run("TestPKICert", func(t *testing.T) { + expectedValue := workingDir + "/" + cmdhelper.HostnameOrNetworkName() + ".cert" + + assert.Equal(t, expectedValue, data.Controller.Identity.Cert) + assert.Equal(t, expectedValue, ctrlConfig.Identity.Cert) + }) + t.Run("TestPKIServerCert", func(t *testing.T) { + expectedValue := workingDir + "/" + cmdhelper.HostnameOrNetworkName() + ".server.chain.cert" + + assert.Equal(t, expectedValue, data.Controller.Identity.ServerCert) + assert.Equal(t, expectedValue, ctrlConfig.Identity.ServerCert) + }) + t.Run("TestPKIKey", func(t *testing.T) { + expectedValue := workingDir + "/" + cmdhelper.HostnameOrNetworkName() + ".key" + + assert.Equal(t, expectedValue, data.Controller.Identity.Key) + assert.Equal(t, expectedValue, ctrlConfig.Identity.Key) + }) + t.Run("TestPKICA", func(t *testing.T) { + expectedValue := workingDir + "/" + cmdhelper.HostnameOrNetworkName() + ".ca" + + assert.Equal(t, expectedValue, data.Controller.Identity.Ca) + assert.Equal(t, expectedValue, ctrlConfig.Identity.Ca) }) - assert.Equal(t, expectedListenerAddress, data.Controller.Edge.ListenerHostPort) + // ctrl: + t.Run("TestListenerAddress", func(t *testing.T) { + expectedValue := testDefaultCtrlListenerAddress + + assert.Equal(t, expectedValue, data.Controller.Ctrl.ListenerAddress) + assert.Equal(t, expectedValue, strings.Split(ctrlConfig.Ctrl.Listener, ":")[1]) + }) + t.Run("TestListenerPort", func(t *testing.T) { + expectedValue := testDefaultCtrlListenerPort + + assert.Equal(t, expectedValue, data.Controller.Ctrl.ListenerPort) + assert.Equal(t, expectedValue, strings.Split(ctrlConfig.Ctrl.Listener, ":")[2]) + }) + + // healthChecks: + t.Run("TestBoltCheckInterval", func(t *testing.T) { + expectedValue := testDefaultBoltCheckInterval + + assert.Equal(t, expectedValue, fmt.Sprint(data.Controller.HealthChecks.Interval.Seconds(), "s")) + assert.Equal(t, expectedValue, ctrlConfig.HealthChecks.BoltCheck.Interval) + }) + t.Run("TestBoltCheckTimeout", func(t *testing.T) { + expectedValue := testDefaultBoltCheckTimeout + + assert.Equal(t, expectedValue, fmt.Sprint(data.Controller.HealthChecks.Timeout.Seconds(), "s")) + assert.Equal(t, expectedValue, ctrlConfig.HealthChecks.BoltCheck.Timeout) + }) + t.Run("TestBoltCheckInitialDelay", func(t *testing.T) { + expectedValue := testDefaultBoltCheckInitialDelay + + assert.Equal(t, expectedValue, fmt.Sprint(data.Controller.HealthChecks.InitialDelay.Seconds(), "s")) + assert.Equal(t, expectedValue, ctrlConfig.HealthChecks.BoltCheck.InitialDelay) + }) + + // edge + t.Run("TestEdgeAPIAddress", func(t *testing.T) { + // Should default to the value of Ctrl Edge Advertised Address + expectedValue := data.Controller.Web.BindPoints.AddressAddress + + assert.Equal(t, expectedValue, data.Controller.EdgeApi.Address) + assert.Equal(t, expectedValue, strings.Split(ctrlConfig.Edge.Api.Address, ":")[0]) + }) + t.Run("TestEdgeAPIPort", func(t *testing.T) { + // Should default to the value of Ctrl Edge Advertised Port + expectedValue := data.Controller.Web.BindPoints.AddressPort + + assert.Equal(t, expectedValue, data.Controller.EdgeApi.Port) + assert.Equal(t, expectedValue, strings.Split(ctrlConfig.Edge.Api.Address, ":")[1]) + }) + t.Run("TestEdgeEnrollmentSigningCert", func(t *testing.T) { + // Should default to the value of Ctrl Edge Advertised Port + expectedValue := workingDir + "/" + cmdhelper.HostnameOrNetworkName() + ".signing.cert" + + assert.Equal(t, expectedValue, data.Controller.EdgeEnrollment.SigningCert) + assert.Equal(t, expectedValue, ctrlConfig.Edge.Enrollment.SigningCert.Cert) + }) + t.Run("TestEdgeEnrollmentSigningKey", func(t *testing.T) { + // Should default to the value of Ctrl Edge Advertised Port + expectedValue := workingDir + "/" + cmdhelper.HostnameOrNetworkName() + ".signing.key" + + assert.Equal(t, expectedValue, data.Controller.EdgeEnrollment.SigningCertKey) + assert.Equal(t, expectedValue, ctrlConfig.Edge.Enrollment.SigningCert.Key) + }) + + // web:bindPoints + t.Run("TestEdgeBindpointInterfaceAddress", func(t *testing.T) { + // Should default to the value of Ctrl Listener Address + expectedValue := data.Controller.Ctrl.ListenerAddress + + assert.Equal(t, expectedValue, data.Controller.Web.BindPoints.InterfaceAddress) + assert.Equal(t, expectedValue, strings.Split(ctrlConfig.Web[0].BindPoints[0].BpInterface, ":")[0]) + }) + t.Run("TestEdgeBindpointInterfacePort", func(t *testing.T) { + // Should default to the value of Ctrl Edge Advertised Port + expectedValue := data.Controller.Web.BindPoints.AddressPort + + assert.Equal(t, expectedValue, data.Controller.Web.BindPoints.InterfacePort) + assert.Equal(t, expectedValue, strings.Split(ctrlConfig.Web[0].BindPoints[0].BpInterface, ":")[1]) + }) + t.Run("TestEdgeAdvertisedAddress", func(t *testing.T) { + // Should default to hostname + expectedValue, _ := os.Hostname() + + assert.Equal(t, expectedValue, data.Controller.Web.BindPoints.AddressAddress) + assert.Equal(t, expectedValue, strings.Split(ctrlConfig.Web[0].BindPoints[0].Address, ":")[0]) + }) + t.Run("TestEdgeAdvertisedPort", func(t *testing.T) { + // Should default to the Const value + expectedValue := testDefaultCtrlEdgeAdvertisedPort + + assert.Equal(t, expectedValue, data.Controller.Web.BindPoints.AddressPort) + assert.Equal(t, expectedValue, strings.Split(ctrlConfig.Web[0].BindPoints[0].Address, ":")[1]) + }) + t.Run("TestEdgeIdentityEnrollmentDuration", func(t *testing.T) { + assert.Equal(t, testDefaultEdgeIdentityEnrollmentDuration, data.Controller.EdgeEnrollment.EdgeIdentityDuration) + assert.Equal(t, testDefaultEdgeIdentityEnrollmentStr, ctrlConfig.Edge.Enrollment.EdgeIdentity.Duration) + }) + t.Run("TestEdgeRouterEnrollmentDuration", func(t *testing.T) { + assert.Equal(t, testDefaultEdgeRouterEnrollmentDuration, data.Controller.EdgeEnrollment.EdgeRouterDuration) + assert.Equal(t, testDefaultEdgeRouterEnrollmentStr, ctrlConfig.Edge.Enrollment.EdgeRouter.Duration) + }) + + // web:identity + t.Run("TestEdgePKICert", func(t *testing.T) { + // Defaults to the Controller identity ca + expectedValue := data.Controller.Identity.Ca + + assert.Equal(t, expectedValue, data.Controller.Web.Identity.Ca) + assert.Equal(t, expectedValue, ctrlConfig.Web[0].Identity.Ca) + }) + t.Run("TestEdgePKIServerCert", func(t *testing.T) { + // Defaults to the Controller identity key + expectedValue := data.Controller.Identity.Key + + assert.Equal(t, expectedValue, data.Controller.Web.Identity.Key) + assert.Equal(t, expectedValue, ctrlConfig.Web[0].Identity.Key) + }) + t.Run("TestEdgePKIKey", func(t *testing.T) { + // Defaults to the Controller identity server cert + expectedValue := data.Controller.Identity.ServerCert + + assert.Equal(t, expectedValue, data.Controller.Web.Identity.ServerCert) + assert.Equal(t, expectedValue, ctrlConfig.Web[0].Identity.ServerCert) + }) + t.Run("TestEdgePKICA", func(t *testing.T) { + // Defaults to the Controller identity cert + expectedValue := data.Controller.Identity.Cert + + assert.Equal(t, expectedValue, data.Controller.Web.Identity.Cert) + assert.Equal(t, expectedValue, ctrlConfig.Web[0].Identity.Cert) + }) + + // web:options + t.Run("TestEdgeOptionsIdleTimeout", func(t *testing.T) { + expectedValue := testDefaultEdgeOptionsIdleTimeout + + assert.Equal(t, expectedValue, fmt.Sprint(data.Controller.Web.Options.IdleTimeout.Milliseconds(), "ms")) + assert.Equal(t, expectedValue, ctrlConfig.Web[0].Options.IdleTimeout) + }) + t.Run("TestEdgeOptionsReadTimeout", func(t *testing.T) { + expectedValue := testDefaultEdgeOptionsReadTimeout + + assert.Equal(t, expectedValue, fmt.Sprint(data.Controller.Web.Options.ReadTimeout.Milliseconds(), "ms")) + assert.Equal(t, expectedValue, ctrlConfig.Web[0].Options.ReadTimeout) + }) + t.Run("TestEdgeOptionsWriteTimeout", func(t *testing.T) { + expectedValue := testDefaultEdgeOptionsWriteTimeout + + assert.Equal(t, expectedValue, fmt.Sprint(data.Controller.Web.Options.WriteTimeout.Milliseconds(), "ms")) + assert.Equal(t, expectedValue, ctrlConfig.Web[0].Options.WriteTimeout) + }) + t.Run("TestEdgeOptionsMinTLS", func(t *testing.T) { + expectedValue := testDefaultEdgeOptionsMinTLSVersion + + assert.Equal(t, expectedValue, data.Controller.Web.Options.MinTLSVersion) + assert.Equal(t, expectedValue, ctrlConfig.Web[0].Options.MinTLSVersion) + }) + t.Run("TestEdgeOptionsMaxTLS", func(t *testing.T) { + expectedValue := testDefaultEdgeOptionsMaxTLSVersion + + assert.Equal(t, expectedValue, data.Controller.Web.Options.MaxTLSVersion) + assert.Equal(t, expectedValue, ctrlConfig.Web[0].Options.MaxTLSVersion) + }) } -// Edge Ctrl Listener port should use ZITI_EDGE_CONTROLLER_PORT if it is set -func TestListenerAddressWhenEdgeCtrlPortAndListenerHostPortNotSet(t *testing.T) { - myPort := "1234" - expectedListenerAddress := "0.0.0.0:" + myPort +func TestCtrlConfigDefaultsWhenBlank(t *testing.T) { + keys := map[string]string{ + "ZITI_PKI_CTRL_CERT": "", + "ZITI_CTRL_EDGE_ADVERTISED_ADDRESS": "", + "ZITI_HOME": "", + } + // run the config + ctrlConfig := execCreateConfigControllerCommand(nil, keys) - // Make sure the related env vars are unset - _ = os.Unsetenv("ZITI_CTRL_EDGE_LISTENER_HOST_PORT") + // identity: + t.Run("TestPKICert", func(t *testing.T) { + expectedValue := workingDir + "/" + cmdhelper.HostnameOrNetworkName() + ".cert" - // Set the edge controller port - _ = os.Setenv("ZITI_EDGE_CONTROLLER_PORT", myPort) + assert.Equal(t, expectedValue, data.Controller.Identity.Cert) + assert.Equal(t, expectedValue, ctrlConfig.Identity.Cert) + }) + t.Run("TestPKIServerCert", func(t *testing.T) { + expectedValue := workingDir + "/" + cmdhelper.HostnameOrNetworkName() + ".server.chain.cert" - // Create and run the CLI command (capture output, otherwise config prints to stdout instead of test results) - cmd := NewCmdCreateConfigController() - _ = captureOutput(func() { - _ = cmd.Execute() + assert.Equal(t, expectedValue, data.Controller.Identity.ServerCert) + assert.Equal(t, expectedValue, ctrlConfig.Identity.ServerCert) + }) + t.Run("TestPKIKey", func(t *testing.T) { + expectedValue := workingDir + "/" + cmdhelper.HostnameOrNetworkName() + ".key" + + assert.Equal(t, expectedValue, data.Controller.Identity.Key) + assert.Equal(t, expectedValue, ctrlConfig.Identity.Key) + }) + t.Run("TestPKICA", func(t *testing.T) { + expectedValue := workingDir + "/" + cmdhelper.HostnameOrNetworkName() + ".ca" + + assert.Equal(t, expectedValue, data.Controller.Identity.Ca) + assert.Equal(t, expectedValue, ctrlConfig.Identity.Ca) }) - assert.Equal(t, expectedListenerAddress, data.Controller.Edge.ListenerHostPort) + // ctrl: + t.Run("TestListenerAddress", func(t *testing.T) { + expectedValue := testDefaultCtrlListenerAddress + + assert.Equal(t, expectedValue, data.Controller.Ctrl.ListenerAddress) + assert.Equal(t, expectedValue, strings.Split(ctrlConfig.Ctrl.Listener, ":")[1]) + }) + t.Run("TestListenerPort", func(t *testing.T) { + expectedValue := testDefaultCtrlListenerPort + + assert.Equal(t, expectedValue, data.Controller.Ctrl.ListenerPort) + assert.Equal(t, expectedValue, strings.Split(ctrlConfig.Ctrl.Listener, ":")[2]) + }) + + // healthChecks: + t.Run("TestBoltCheckInterval", func(t *testing.T) { + expectedValue := testDefaultBoltCheckInterval + + assert.Equal(t, expectedValue, fmt.Sprint(data.Controller.HealthChecks.Interval.Seconds(), "s")) + assert.Equal(t, expectedValue, ctrlConfig.HealthChecks.BoltCheck.Interval) + }) + t.Run("TestBoltCheckTimeout", func(t *testing.T) { + expectedValue := testDefaultBoltCheckTimeout + + assert.Equal(t, expectedValue, fmt.Sprint(data.Controller.HealthChecks.Timeout.Seconds(), "s")) + assert.Equal(t, expectedValue, ctrlConfig.HealthChecks.BoltCheck.Timeout) + }) + t.Run("TestBoltCheckInitialDelay", func(t *testing.T) { + expectedValue := testDefaultBoltCheckInitialDelay + + assert.Equal(t, expectedValue, fmt.Sprint(data.Controller.HealthChecks.InitialDelay.Seconds(), "s")) + assert.Equal(t, expectedValue, ctrlConfig.HealthChecks.BoltCheck.InitialDelay) + }) + + // edge + t.Run("TestEdgeAPIAddress", func(t *testing.T) { + // Should default to the value of Ctrl Edge Advertised Address + expectedValue := data.Controller.Web.BindPoints.AddressAddress + + assert.Equal(t, expectedValue, data.Controller.EdgeApi.Address) + assert.Equal(t, expectedValue, strings.Split(ctrlConfig.Edge.Api.Address, ":")[0]) + }) + t.Run("TestEdgeAPIPort", func(t *testing.T) { + // Should default to the value of Ctrl Edge Advertised Port + expectedValue := data.Controller.Web.BindPoints.AddressPort + + assert.Equal(t, expectedValue, data.Controller.EdgeApi.Port) + assert.Equal(t, expectedValue, strings.Split(ctrlConfig.Edge.Api.Address, ":")[1]) + }) + t.Run("TestEdgeEnrollmentSigningCert", func(t *testing.T) { + // Should default to the value of Ctrl Edge Advertised Port + expectedValue := workingDir + "/" + cmdhelper.HostnameOrNetworkName() + ".signing.cert" + + assert.Equal(t, expectedValue, data.Controller.EdgeEnrollment.SigningCert) + assert.Equal(t, expectedValue, ctrlConfig.Edge.Enrollment.SigningCert.Cert) + }) + t.Run("TestEdgeEnrollmentSigningKey", func(t *testing.T) { + // Should default to the value of Ctrl Edge Advertised Port + expectedValue := workingDir + "/" + cmdhelper.HostnameOrNetworkName() + ".signing.key" + + assert.Equal(t, expectedValue, data.Controller.EdgeEnrollment.SigningCertKey) + assert.Equal(t, expectedValue, ctrlConfig.Edge.Enrollment.SigningCert.Key) + }) + t.Run("TestEdgeIdentityEnrollmentDuration", func(t *testing.T) { + assert.Equal(t, testDefaultEdgeIdentityEnrollmentDuration, data.Controller.EdgeEnrollment.EdgeIdentityDuration) + assert.Equal(t, testDefaultEdgeIdentityEnrollmentStr, ctrlConfig.Edge.Enrollment.EdgeIdentity.Duration) + }) + t.Run("TestEdgeRouterEnrollmentDuration", func(t *testing.T) { + assert.Equal(t, testDefaultEdgeRouterEnrollmentDuration, data.Controller.EdgeEnrollment.EdgeRouterDuration) + assert.Equal(t, testDefaultEdgeRouterEnrollmentStr, ctrlConfig.Edge.Enrollment.EdgeRouter.Duration) + }) + + // web:bindPoints + t.Run("TestEdgeBindpointInterfaceAddress", func(t *testing.T) { + // Should default to the value of Ctrl Listener Address + expectedValue := data.Controller.Ctrl.ListenerAddress + + assert.Equal(t, expectedValue, data.Controller.Web.BindPoints.InterfaceAddress) + assert.Equal(t, expectedValue, strings.Split(ctrlConfig.Web[0].BindPoints[0].BpInterface, ":")[0]) + }) + t.Run("TestEdgeBindpointInterfacePort", func(t *testing.T) { + // Should default to the value of Ctrl Edge Advertised Port + expectedValue := data.Controller.Web.BindPoints.AddressPort + + assert.Equal(t, expectedValue, data.Controller.Web.BindPoints.InterfacePort) + assert.Equal(t, expectedValue, strings.Split(ctrlConfig.Web[0].BindPoints[0].BpInterface, ":")[1]) + }) + t.Run("TestEdgeAdvertisedAddress", func(t *testing.T) { + // Should default to hostname + expectedValue, _ := os.Hostname() + + assert.Equal(t, expectedValue, data.Controller.Web.BindPoints.AddressAddress) + assert.Equal(t, expectedValue, strings.Split(ctrlConfig.Web[0].BindPoints[0].Address, ":")[0]) + }) + t.Run("TestEdgeAdvertisedPort", func(t *testing.T) { + // Should default to the Const value + expectedValue := testDefaultCtrlEdgeAdvertisedPort + + assert.Equal(t, expectedValue, data.Controller.Web.BindPoints.AddressPort) + assert.Equal(t, expectedValue, strings.Split(ctrlConfig.Web[0].BindPoints[0].Address, ":")[1]) + }) + + // web:identity + t.Run("TestEdgePKICert", func(t *testing.T) { + // Defaults to the Controller identity ca + expectedValue := data.Controller.Identity.Ca + + assert.Equal(t, expectedValue, data.Controller.Web.Identity.Ca) + assert.Equal(t, expectedValue, ctrlConfig.Web[0].Identity.Ca) + }) + t.Run("TestEdgePKIServerCert", func(t *testing.T) { + // Defaults to the Controller identity key + expectedValue := data.Controller.Identity.Key + + assert.Equal(t, expectedValue, data.Controller.Web.Identity.Key) + assert.Equal(t, expectedValue, ctrlConfig.Web[0].Identity.Key) + }) + t.Run("TestEdgePKIKey", func(t *testing.T) { + // Defaults to the Controller identity server cert + expectedValue := data.Controller.Identity.ServerCert + + assert.Equal(t, expectedValue, data.Controller.Web.Identity.ServerCert) + assert.Equal(t, expectedValue, ctrlConfig.Web[0].Identity.ServerCert) + }) + t.Run("TestEdgePKICA", func(t *testing.T) { + // Defaults to the Controller identity cert + expectedValue := data.Controller.Identity.Cert + + assert.Equal(t, expectedValue, data.Controller.Web.Identity.Cert) + assert.Equal(t, expectedValue, ctrlConfig.Web[0].Identity.Cert) + }) + + // web:options + t.Run("TestEdgeOptionsIdleTimeout", func(t *testing.T) { + expectedValue := testDefaultEdgeOptionsIdleTimeout + + assert.Equal(t, expectedValue, fmt.Sprint(data.Controller.Web.Options.IdleTimeout.Milliseconds(), "ms")) + assert.Equal(t, expectedValue, ctrlConfig.Web[0].Options.IdleTimeout) + }) + t.Run("TestEdgeOptionsReadTimeout", func(t *testing.T) { + expectedValue := testDefaultEdgeOptionsReadTimeout + + assert.Equal(t, expectedValue, fmt.Sprint(data.Controller.Web.Options.ReadTimeout.Milliseconds(), "ms")) + assert.Equal(t, expectedValue, ctrlConfig.Web[0].Options.ReadTimeout) + }) + t.Run("TestEdgeOptionsWriteTimeout", func(t *testing.T) { + expectedValue := testDefaultEdgeOptionsWriteTimeout + + assert.Equal(t, expectedValue, fmt.Sprint(data.Controller.Web.Options.WriteTimeout.Milliseconds(), "ms")) + assert.Equal(t, expectedValue, ctrlConfig.Web[0].Options.WriteTimeout) + }) + t.Run("TestEdgeOptionsMinTLS", func(t *testing.T) { + expectedValue := testDefaultEdgeOptionsMinTLSVersion + + assert.Equal(t, expectedValue, data.Controller.Web.Options.MinTLSVersion) + assert.Equal(t, expectedValue, ctrlConfig.Web[0].Options.MinTLSVersion) + }) + t.Run("TestEdgeOptionsMaxTLS", func(t *testing.T) { + expectedValue := testDefaultEdgeOptionsMaxTLSVersion + + assert.Equal(t, expectedValue, data.Controller.Web.Options.MaxTLSVersion) + assert.Equal(t, expectedValue, ctrlConfig.Web[0].Options.MaxTLSVersion) + }) } -// Edge Ctrl Listener address and port should always use ZITI_EDGE_CTRL_LISTENER_HOST_PORT value if it is set -func TestListenerAddressWhenEdgeCtrlPortAndListenerHostPortSet(t *testing.T) { - myPort := "1234" - expectedListenerAddress := "0.0.0.0:4321" // Expecting a different port even when edge ctrl port is set +func TestZitiCtrlIdentitySection(t *testing.T) { + certPath := "/var/test/custom/path/file.cert" + serverCertPath := "/var/test/custom/path/file.chain.pem" + keyPath := "/var/test/custom/path/file.key" + caPath := "/var/test/custom/path/file.pem" + keys := map[string]string{ + "ZITI_PKI_CTRL_CERT": certPath, + "ZITI_PKI_CTRL_SERVER_CERT": serverCertPath, + "ZITI_PKI_CTRL_KEY": keyPath, + "ZITI_PKI_CTRL_CA": caPath, + } - // Set a custom value for the host and port - _ = os.Setenv("ZITI_CTRL_EDGE_LISTENER_HOST_PORT", expectedListenerAddress) + ctrlConfig := execCreateConfigControllerCommand(nil, keys) - // Set the edge controller port (this should not show up in the end resulting listener address) - _ = os.Setenv("ZITI_EDGE_CONTROLLER_PORT", myPort) - - // Create and run the CLI command (capture output, otherwise config prints to stdout instead of test results) - cmd := NewCmdCreateConfigController() - _ = captureOutput(func() { - _ = cmd.Execute() - }) - - assert.Equal(t, expectedListenerAddress, data.Controller.Edge.ListenerHostPort) + assert.Equal(t, certPath, data.Controller.Identity.Cert) + assert.Equal(t, certPath, ctrlConfig.Identity.Cert) + assert.Equal(t, serverCertPath, data.Controller.Identity.ServerCert) + assert.Equal(t, serverCertPath, ctrlConfig.Identity.ServerCert) + assert.Equal(t, keyPath, data.Controller.Identity.Key) + assert.Equal(t, keyPath, ctrlConfig.Identity.Key) + assert.Equal(t, caPath, data.Controller.Identity.Ca) + assert.Equal(t, caPath, ctrlConfig.Identity.Ca) } -// Edge Ctrl Advertised Port should update the edge ctrl port to the default when ZITI_EDGE_CONTROLLER_PORT is not set -func TestDefaultEdgeCtrlAdvertisedPort(t *testing.T) { - expectedPort := "1280" // Expecting the default port of 1280 +func TestCtrlListenerAddress(t *testing.T) { + customValue := "123.456.7.8" + keys := map[string]string{ + "ZITI_CTRL_LISTENER_ADDRESS": customValue, + } - // Set a custom value for the host and port - _ = os.Unsetenv("ZITI_EDGE_CONTROLLER_PORT") + ctrlConfig := execCreateConfigControllerCommand(nil, keys) - // Create and run the CLI command (capture output, otherwise config prints to stdout instead of test results) - cmd := NewCmdCreateConfigController() - _ = captureOutput(func() { - _ = cmd.Execute() - }) - - assert.Equal(t, expectedPort, data.Controller.Edge.AdvertisedPort) + assert.Equal(t, customValue, data.Controller.Ctrl.ListenerAddress) + assert.Equal(t, customValue, strings.Split(ctrlConfig.Ctrl.Listener, ":")[1]) } -// Edge Ctrl Advertised Port should update the edge ctrl port to the custom value when ZITI_EDGE_CONTROLLER_PORT is set -func TestEdgeCtrlAdvertisedPortValueWhenSet(t *testing.T) { - expectedPort := "1234" // Setting a custom port which is not the default value +func TestCtrlListenerPort(t *testing.T) { + customValue := "9999" + keys := map[string]string{ + "ZITI_CTRL_LISTENER_PORT": customValue, + } - // Set a custom value for the host and port - _ = os.Setenv("ZITI_EDGE_CONTROLLER_PORT", expectedPort) + ctrlConfig := execCreateConfigControllerCommand(nil, keys) - // Create and run the CLI command (capture output, otherwise config prints to stdout instead of test results) - cmd := NewCmdCreateConfigController() - _ = captureOutput(func() { - _ = cmd.Execute() - }) - - assert.Equal(t, expectedPort, data.Controller.Edge.AdvertisedPort) + assert.Equal(t, customValue, data.Controller.Ctrl.ListenerPort) + assert.Equal(t, customValue, strings.Split(ctrlConfig.Ctrl.Listener, ":")[2]) } -func TestDefaultEdgeIdentityEnrollmentDuration(t *testing.T) { - // Expect the default (3 hours) - expectedDuration := time.Duration(180) * time.Minute - expectedConfigValue := "180m" +func TestCtrlEdgeAPIAddress(t *testing.T) { + customValue := "123.456.7.8" + keys := map[string]string{ + "ZITI_CTRL_EDGE_API_ADDRESS": customValue, + } - // Unset the env var so the default is used - _ = os.Unsetenv("ZITI_EDGE_IDENTITY_ENROLLMENT_DURATION") + ctrlConfig := execCreateConfigControllerCommand(nil, keys) - // Create and run the CLI command (capture output, otherwise config prints to stdout instead of test results) - cmd := NewCmdCreateConfigController() - configOutput := captureOutput(func() { - _ = cmd.Execute() - }) - - assert.Equal(t, expectedDuration, data.Controller.EdgeIdentityDuration) - - // Expect that the config value is represented correctly - configStruct := configToStruct(configOutput) - assert.Equal(t, expectedConfigValue, configStruct.Edge.Enrollment.EdgeIdentity.Duration) + assert.Equal(t, customValue, data.Controller.EdgeApi.Address) + assert.Equal(t, customValue, strings.Split(ctrlConfig.Edge.Api.Address, ":")[0]) } -func TestEdgeIdentityEnrollmentDurationWhenEnvVarSet(t *testing.T) { - expectedDuration := 5 * time.Minute // Setting a custom duration which is not the default value - expectedConfigValue := "5m" +func TestCtrlEdgeAPIPort(t *testing.T) { + customValue := "9999" + keys := map[string]string{ + "ZITI_CTRL_EDGE_API_PORT": customValue, + } - // Set a custom value for the enrollment duration - _ = os.Setenv("ZITI_EDGE_IDENTITY_ENROLLMENT_DURATION", fmt.Sprintf("%.0f", expectedDuration.Minutes())) + ctrlConfig := execCreateConfigControllerCommand(nil, keys) - // Create and run the CLI command (capture output, otherwise config prints to stdout instead of test results) - cmd := NewCmdCreateConfigController() - configOutput := captureOutput(func() { - _ = cmd.Execute() - }) - - assert.Equal(t, expectedDuration, data.Controller.EdgeIdentityDuration) - - // Expect that the config value is represented correctly - configStruct := configToStruct(configOutput) - assert.Equal(t, expectedConfigValue, configStruct.Edge.Enrollment.EdgeIdentity.Duration) + assert.Equal(t, customValue, data.Controller.EdgeApi.Port) + assert.Equal(t, customValue, strings.Split(ctrlConfig.Edge.Api.Address, ":")[1]) } -func TestEdgeIdentityEnrollmentDurationWhenEnvVarSetToBlank(t *testing.T) { - // Expect the default (3 hours) - expectedDuration := time.Duration(180) * time.Minute - expectedConfigValue := "180m" +func TestCtrlEdgeAPIEnrollmentSignerCert(t *testing.T) { + certPath := "/var/test/custom/path/file.cert" + keyPath := "/var/test/custom/path/file.key" + keys := map[string]string{ + "ZITI_PKI_SIGNER_CERT": certPath, + "ZITI_PKI_SIGNER_KEY": keyPath, + } - // Set a custom value for the enrollment duration - _ = os.Setenv("ZITI_EDGE_IDENTITY_ENROLLMENT_DURATION", "") + ctrlConfig := execCreateConfigControllerCommand(nil, keys) - // Create and run the CLI command (capture output, otherwise config prints to stdout instead of test results) - cmd := NewCmdCreateConfigController() - configOutput := captureOutput(func() { - _ = cmd.Execute() - }) + assert.Equal(t, certPath, data.Controller.EdgeEnrollment.SigningCert) + assert.Equal(t, certPath, ctrlConfig.Edge.Enrollment.SigningCert.Cert) + assert.Equal(t, keyPath, data.Controller.EdgeEnrollment.SigningCertKey) + assert.Equal(t, keyPath, ctrlConfig.Edge.Enrollment.SigningCert.Key) +} - assert.Equal(t, expectedDuration, data.Controller.EdgeIdentityDuration) +func TestEdgeIdentityEnrollmentDurationEnvVar(t *testing.T) { + customDuration := time.Duration(5) * time.Minute + customValue := "5" + expectedValue := customValue + "m" // Env Var int is converted to minutes format + keys := map[string]string{ + "ZITI_EDGE_IDENTITY_ENROLLMENT_DURATION": customValue, + } - // Expect that the config value is represented correctly - configStruct := configToStruct(configOutput) - assert.Equal(t, expectedConfigValue, configStruct.Edge.Enrollment.EdgeIdentity.Duration) + ctrlConfig := execCreateConfigControllerCommand(nil, keys) + + assert.Equal(t, customDuration, data.Controller.EdgeEnrollment.EdgeIdentityDuration) + assert.Equal(t, expectedValue, ctrlConfig.Edge.Enrollment.EdgeIdentity.Duration) } func TestEdgeIdentityEnrollmentDurationCLITakesPriority(t *testing.T) { - envVarValue := 5 * time.Minute // Setting a custom duration which is not the default value - cliValue := "10m" // Setting a CLI custom duration which is also not the default value - expectedConfigValue := "10m" + envVarValue := "5" // Setting a custom duration which is not the default value + cliValue := "10m" // Setting a CLI custom duration which is also not the default value + expectedConfigValue := cliValue + keys := map[string]string{ + "ZITI_EDGE_IDENTITY_ENROLLMENT_DURATION": envVarValue, + } + args := []string{"--identityEnrollmentDuration", cliValue} - // Set a custom value for the enrollment duration - _ = os.Setenv("ZITI_EDGE_IDENTITY_ENROLLMENT_DURATION", fmt.Sprintf("%.0f", envVarValue.Minutes())) - - // Create and run the CLI command (capture output, otherwise config prints to stdout instead of test results) - cmd := NewCmdCreateConfigController() - cmd.SetArgs([]string{"--identityEnrollmentDuration", cliValue}) - configOutput := captureOutput(func() { - _ = cmd.Execute() - }) + ctrlConfig := execCreateConfigControllerCommand(args, keys) // Expect that the CLI value was used over the environment variable expectedValue, _ := time.ParseDuration(cliValue) - assert.Equal(t, expectedValue, data.Controller.EdgeIdentityDuration) + assert.Equal(t, expectedValue, data.Controller.EdgeEnrollment.EdgeIdentityDuration) // Expect that the config value is represented correctly - configStruct := configToStruct(configOutput) - assert.Equal(t, expectedConfigValue, configStruct.Edge.Enrollment.EdgeIdentity.Duration) + assert.Equal(t, expectedConfigValue, ctrlConfig.Edge.Enrollment.EdgeIdentity.Duration) } -func TestDefaultEdgeRouterEnrollmentDuration(t *testing.T) { - expectedDuration := time.Duration(180) * time.Minute - expectedConfigValue := "180m" +func TestEdgeIdentityEnrollmentDurationCLIConvertsToMin(t *testing.T) { + cliValue := "1h" // Setting a CLI custom duration which is also not the default value + expectedConfigValue := "60m" // Config value representation should be in minutes - // Unset the env var so the default is used - _ = os.Unsetenv("ZITI_EDGE_ROUTER_ENROLLMENT_DURATION") + args := []string{"--identityEnrollmentDuration", cliValue} + ctrlConfig := execCreateConfigControllerCommand(args, nil) - // Create and run the CLI command (capture output, otherwise config prints to stdout instead of test results) - cmd := NewCmdCreateConfigController() - configOutput := captureOutput(func() { - _ = cmd.Execute() - }) - - assert.Equal(t, expectedDuration, data.Controller.EdgeRouterDuration) + // Expect that the CLI value was used over the environment variable + expectedValue, _ := time.ParseDuration(cliValue) + assert.Equal(t, expectedValue, data.Controller.EdgeEnrollment.EdgeIdentityDuration) // Expect that the config value is represented correctly - configStruct := configToStruct(configOutput) - assert.Equal(t, expectedConfigValue, configStruct.Edge.Enrollment.EdgeRouter.Duration) + assert.Equal(t, expectedConfigValue, ctrlConfig.Edge.Enrollment.EdgeIdentity.Duration) } -func TestEdgeRouterEnrollmentDurationWhenEnvVarSet(t *testing.T) { - expectedDuration := 5 * time.Minute // Setting a custom duration which is not the default value - expectedConfigValue := "5m" +func TestEdgeRouterEnrollmentDurationEnvVar(t *testing.T) { + customDuration := time.Duration(5) * time.Minute + customValue := "5" + expectedValue := customValue + "m" // Env Var int is converted to minutes format + keys := map[string]string{ + "ZITI_EDGE_ROUTER_ENROLLMENT_DURATION": customValue, + } - // Set a custom value for the enrollment duration - _ = os.Setenv("ZITI_EDGE_ROUTER_ENROLLMENT_DURATION", fmt.Sprintf("%.0f", expectedDuration.Minutes())) + ctrlConfig := execCreateConfigControllerCommand(nil, keys) - // Create and run the CLI command (capture output, otherwise config prints to stdout instead of test results) - cmd := NewCmdCreateConfigController() - configOutput := captureOutput(func() { - _ = cmd.Execute() - }) - - assert.Equal(t, expectedDuration, data.Controller.EdgeRouterDuration) - - // Expect that the config value is represented correctly - configStruct := configToStruct(configOutput) - assert.Equal(t, expectedConfigValue, configStruct.Edge.Enrollment.EdgeRouter.Duration) -} - -func TestEdgeRouterEnrollmentDurationWhenEnvVarSetToBlank(t *testing.T) { - // Expect the default (3 hours) - expectedDuration := time.Duration(180) * time.Minute - expectedConfigValue := "180m" - - // Set a custom value for the enrollment duration - _ = os.Setenv("ZITI_EDGE_ROUTER_ENROLLMENT_DURATION", "") - - // Create and run the CLI command - cmd := NewCmdCreateConfigController() - configOutput := captureOutput(func() { - _ = cmd.Execute() - }) - - assert.Equal(t, expectedDuration, data.Controller.EdgeRouterDuration) - - // Expect that the config value is represented correctly - configStruct := configToStruct(configOutput) - assert.Equal(t, expectedConfigValue, configStruct.Edge.Enrollment.EdgeRouter.Duration) + assert.Equal(t, customDuration, data.Controller.EdgeEnrollment.EdgeRouterDuration) + assert.Equal(t, expectedValue, ctrlConfig.Edge.Enrollment.EdgeRouter.Duration) } func TestEdgeRouterEnrollmentDurationCLITakesPriority(t *testing.T) { - envVarValue := 5 * time.Minute // Setting a custom duration which is not the default value - cliValue := "10m" // Setting a CLI custom duration which is also not the default value - expectedConfigValue := "10m" // Config value representation should be in minutes + envVarValue := "5" // Setting a custom duration which is not the default value + cliValue := "10m" // Setting a CLI custom duration which is also not the default value + expectedConfigValue := cliValue + keys := map[string]string{ + "ZITI_EDGE_ROUTER_ENROLLMENT_DURATION": envVarValue, + } + args := []string{"--routerEnrollmentDuration", cliValue} - // Set a custom value for the enrollment duration - _ = os.Setenv("ZITI_EDGE_ROUTER_ENROLLMENT_DURATION", fmt.Sprintf("%.0f", envVarValue.Minutes())) - - // Create and run the CLI command (capture output, otherwise config prints to stdout instead of test results) - cmd := NewCmdCreateConfigController() - cmd.SetArgs([]string{"--routerEnrollmentDuration", cliValue}) - configOutput := captureOutput(func() { - _ = cmd.Execute() - }) + ctrlConfig := execCreateConfigControllerCommand(args, keys) // Expect that the CLI value was used over the environment variable expectedValue, _ := time.ParseDuration(cliValue) - assert.Equal(t, expectedValue, data.Controller.EdgeRouterDuration) + assert.Equal(t, expectedValue, data.Controller.EdgeEnrollment.EdgeRouterDuration) // Expect that the config value is represented correctly - configStruct := configToStruct(configOutput) - assert.Equal(t, expectedConfigValue, configStruct.Edge.Enrollment.EdgeRouter.Duration) + assert.Equal(t, expectedConfigValue, ctrlConfig.Edge.Enrollment.EdgeRouter.Duration) } func TestEdgeRouterEnrollmentDurationCLIConvertsToMin(t *testing.T) { cliValue := "1h" // Setting a CLI custom duration which is also not the default value expectedConfigValue := "60m" // Config value representation should be in minutes - // Make sure the env var is not set - _ = os.Unsetenv("ZITI_EDGE_ROUTER_ENROLLMENT_DURATION") - - // Create and run the CLI command - cmd := NewCmdCreateConfigController() - cmd.SetArgs([]string{"--routerEnrollmentDuration", cliValue}) - configOutput := captureOutput(func() { - _ = cmd.Execute() - }) + args := []string{"--routerEnrollmentDuration", cliValue} + ctrlConfig := execCreateConfigControllerCommand(args, nil) // Expect that the CLI value was used over the environment variable expectedValue, _ := time.ParseDuration(cliValue) - assert.Equal(t, expectedValue, data.Controller.EdgeRouterDuration) + assert.Equal(t, expectedValue, data.Controller.EdgeEnrollment.EdgeRouterDuration) // Expect that the config value is represented correctly - configStruct := configToStruct(configOutput) - assert.Equal(t, expectedConfigValue, configStruct.Edge.Enrollment.EdgeRouter.Duration) + assert.Equal(t, expectedConfigValue, ctrlConfig.Edge.Enrollment.EdgeRouter.Duration) } func TestEdgeRouterAndIdentityEnrollmentDurationTogetherCLI(t *testing.T) { @@ -432,19 +827,11 @@ func TestEdgeRouterAndIdentityEnrollmentDurationTogetherCLI(t *testing.T) { expectedIdentityConfigValue := "60m" expectedRouterConfigValue := "30m" - // Make sure the env vars are not set - _ = os.Unsetenv("ZITI_EDGE_IDENTITY_ENROLLMENT_DURATION") - _ = os.Unsetenv("ZITI_EDGE_ROUTER_ENROLLMENT_DURATION") - // Create and run the CLI command - cmd := NewCmdCreateConfigController() - cmd.SetArgs([]string{"--routerEnrollmentDuration", cliRouterDurationValue, "--identityEnrollmentDuration", cliIdentityDurationValue}) - configOutput := captureOutput(func() { - _ = cmd.Execute() - }) + args := []string{"--routerEnrollmentDuration", cliRouterDurationValue, "--identityEnrollmentDuration", cliIdentityDurationValue} + configStruct := execCreateConfigControllerCommand(args, nil) // Expect that the config values are represented correctly - configStruct := configToStruct(configOutput) assert.Equal(t, expectedIdentityConfigValue, configStruct.Edge.Enrollment.EdgeIdentity.Duration) assert.Equal(t, expectedRouterConfigValue, configStruct.Edge.Enrollment.EdgeRouter.Duration) } @@ -452,25 +839,100 @@ func TestEdgeRouterAndIdentityEnrollmentDurationTogetherCLI(t *testing.T) { func TestEdgeRouterAndIdentityEnrollmentDurationTogetherEnvVar(t *testing.T) { envVarIdentityDurationValue := "120" envVarRouterDurationValue := "60" - expectedIdentityConfigValue := "120m" - expectedRouterConfigValue := "60m" - - // Set the env vars - _ = os.Setenv("ZITI_EDGE_IDENTITY_ENROLLMENT_DURATION", envVarIdentityDurationValue) - _ = os.Setenv("ZITI_EDGE_ROUTER_ENROLLMENT_DURATION", envVarRouterDurationValue) + expectedIdentityConfigValue := envVarIdentityDurationValue + "m" + expectedRouterConfigValue := envVarRouterDurationValue + "m" // Create and run the CLI command - cmd := NewCmdCreateConfigController() - configOutput := captureOutput(func() { - _ = cmd.Execute() - }) + keys := map[string]string{ + "ZITI_EDGE_IDENTITY_ENROLLMENT_DURATION": envVarIdentityDurationValue, + "ZITI_EDGE_ROUTER_ENROLLMENT_DURATION": envVarRouterDurationValue, + } + configStruct := execCreateConfigControllerCommand(nil, keys) // Expect that the config values are represented correctly - configStruct := configToStruct(configOutput) assert.Equal(t, expectedIdentityConfigValue, configStruct.Edge.Enrollment.EdgeIdentity.Duration) assert.Equal(t, expectedRouterConfigValue, configStruct.Edge.Enrollment.EdgeRouter.Duration) } +func TestCtrlEdgeInterfaceAddress(t *testing.T) { + customValue := "123.456.7.8" + keys := map[string]string{ + "ZITI_CTRL_EDGE_INTERFACE_ADDRESS": customValue, + } + + ctrlConfig := execCreateConfigControllerCommand(nil, keys) + + assert.Equal(t, customValue, data.Controller.Web.BindPoints.InterfaceAddress) + assert.Equal(t, customValue, strings.Split(ctrlConfig.Web[0].BindPoints[0].BpInterface, ":")[0]) +} + +func TestCtrlEdgeInterfacePort(t *testing.T) { + customValue := "9999" + keys := map[string]string{ + "ZITI_CTRL_EDGE_INTERFACE_PORT": customValue, + } + + ctrlConfig := execCreateConfigControllerCommand(nil, keys) + + assert.Equal(t, customValue, data.Controller.Web.BindPoints.InterfacePort) + assert.Equal(t, customValue, strings.Split(ctrlConfig.Web[0].BindPoints[0].BpInterface, ":")[1]) +} + +func TestCtrlEdgeAdvertisedAddress(t *testing.T) { + customValue := "123.456.7.8" + keys := map[string]string{ + "ZITI_CTRL_EDGE_ADVERTISED_ADDRESS": customValue, + } + + ctrlConfig := execCreateConfigControllerCommand(nil, keys) + + assert.Equal(t, customValue, data.Controller.Web.BindPoints.AddressAddress) + assert.Equal(t, customValue, strings.Split(ctrlConfig.Web[0].BindPoints[0].Address, ":")[0]) +} + +func TestCtrlEdgeAdvertisedPort(t *testing.T) { + customValue := "9999" + keys := map[string]string{ + "ZITI_CTRL_EDGE_ADVERTISED_PORT": customValue, + } + + ctrlConfig := execCreateConfigControllerCommand(nil, keys) + + assert.Equal(t, customValue, data.Controller.Web.BindPoints.AddressPort) + assert.Equal(t, customValue, strings.Split(ctrlConfig.Web[0].BindPoints[0].Address, ":")[1]) +} + +func TestCtrlEdgeIdentitySection(t *testing.T) { + caPath := "/var/test/custom/path/file.pem" + keyPath := "/var/test/custom/path/file.key" + serverCertPath := "/var/test/custom/path/file.chain.pem" + certPath := "/var/test/custom/path/file.cert" + keys := map[string]string{ + "ZITI_PKI_CTRL_CA": caPath, + "ZITI_PKI_CTRL_KEY": keyPath, + "ZITI_PKI_CTRL_SERVER_CERT": serverCertPath, + "ZITI_PKI_CTRL_CERT": certPath, + } + + ctrlConfig := execCreateConfigControllerCommand(nil, keys) + + assert.Equal(t, certPath, data.Controller.Web.Identity.Cert) + assert.Equal(t, certPath, ctrlConfig.Web[0].Identity.Cert) + assert.Equal(t, serverCertPath, data.Controller.Web.Identity.ServerCert) + assert.Equal(t, serverCertPath, ctrlConfig.Web[0].Identity.ServerCert) + assert.Equal(t, keyPath, data.Controller.Web.Identity.Key) + assert.Equal(t, keyPath, ctrlConfig.Web[0].Identity.Key) + assert.Equal(t, caPath, data.Controller.Web.Identity.Ca) + assert.Equal(t, caPath, ctrlConfig.Web[0].Identity.Ca) +} + +func clearControllerOptionsAndTemplateData() { + controllerOptions = CreateConfigControllerOptions{} + data = &ConfigTemplateValues{} + + unsetZitiEnv() +} + func configToStruct(config string) ControllerConfig { configStruct := ControllerConfig{} err2 := yaml.Unmarshal([]byte(config), &configStruct) @@ -479,3 +941,19 @@ func configToStruct(config string) ControllerConfig { } return configStruct } + +func execCreateConfigControllerCommand(args []string, keys map[string]string) ControllerConfig { + // Setup + clearControllerOptionsAndTemplateData() + controllerOptions.Output = defaultOutput + + setEnvByMap(keys) + // Create and run the CLI command (capture output to convert to a template struct) + cmd := NewCmdCreateConfigController() + cmd.SetArgs(args) + configOutput := captureOutput(func() { + _ = cmd.Execute() + }) + + return configToStruct(configOutput) +} diff --git a/ziti/cmd/create_config_environment.go b/ziti/cmd/create_config_environment.go index 9c25baef6..44933dcc1 100644 --- a/ziti/cmd/create_config_environment.go +++ b/ziti/cmd/create_config_environment.go @@ -25,6 +25,7 @@ import ( "os" "path/filepath" "runtime" + "strconv" "strings" "text/template" @@ -83,8 +84,7 @@ func NewCmdCreateConfigEnvironment() *cobra.Command { Long: createConfigEnvironmentLong, Example: createConfigEnvironmentExample, PreRun: func(cmd *cobra.Command, args []string) { - data.populateEnvVars() - data.populateDefaults() + data.populateConfigValues() // Set router identities SetZitiRouterIdentity(&data.Router, validateRouterName("")) // Set up other identity info @@ -94,34 +94,35 @@ func NewCmdCreateConfigEnvironment() *cobra.Command { environmentOptions.EnvVars = []EnvVar{ {constants.ZitiHomeVarName, constants.ZitiHomeVarDescription, data.ZitiHome}, - {constants.ZitiCtrlNameVarName, constants.ZitiCtrlNameVarDescription, data.Controller.Name}, - {constants.ZitiCtrlPortVarName, constants.ZitiCtrlPortVarDescription, data.Controller.Port}, - {constants.ZitiEdgeRouterRawNameVarName, constants.ZitiEdgeRouterRawNameVarDescription, data.Router.Edge.Hostname}, + {constants.PkiCtrlCertVarName, constants.PkiCtrlCertVarDescription, data.Controller.Identity.Cert}, + {constants.PkiCtrlServerCertVarName, constants.PkiCtrlServerCertVarDescription, data.Controller.Identity.ServerCert}, + {constants.PkiCtrlKeyVarName, constants.PkiCtrlKeyVarDescription, data.Controller.Identity.Key}, + {constants.PkiCtrlCAVarName, constants.PkiCtrlCAVarDescription, data.Controller.Identity.Ca}, + {constants.CtrlListenerAddressVarName, constants.CtrlListenerAddressVarDescription, data.Controller.Ctrl.ListenerAddress}, + {constants.CtrlListenerPortVarName, constants.CtrlListenerPortVarDescription, data.Controller.Ctrl.ListenerPort}, + {constants.CtrlEdgeApiAddressVarName, constants.CtrlEdgeApiAddressVarDescription, data.Controller.EdgeApi.Address}, + {constants.CtrlEdgeApiPortVarName, constants.CtrlEdgeApiPortVarDescription, data.Controller.EdgeApi.Port}, + {constants.PkiSignerCertVarName, constants.PkiSignerCertVarDescription, data.Controller.EdgeEnrollment.SigningCert}, + {constants.PkiSignerKeyVarName, constants.PkiSignerKeyVarDescription, data.Controller.EdgeEnrollment.SigningCertKey}, + {constants.CtrlEdgeIdentityEnrollmentDurationVarName, constants.CtrlEdgeIdentityEnrollmentDurationVarDescription, strconv.FormatInt(int64(data.Controller.EdgeEnrollment.EdgeIdentityDuration), 10)}, + {constants.CtrlEdgeRouterEnrollmentDurationVarName, constants.CtrlEdgeRouterEnrollmentDurationVarDescription, strconv.FormatInt(int64(data.Controller.EdgeEnrollment.EdgeRouterDuration), 10)}, + {constants.CtrlEdgeInterfaceAddressVarName, constants.CtrlEdgeInterfaceAddressVarDescription, data.Controller.Web.BindPoints.InterfaceAddress}, + {constants.CtrlEdgeInterfacePortVarName, constants.CtrlEdgeInterfacePortVarDescription, data.Controller.Web.BindPoints.InterfacePort}, + {constants.CtrlEdgeAdvertisedAddressVarName, constants.CtrlEdgeAdvertisedAddressVarDescription, data.Controller.Web.BindPoints.AddressAddress}, + {constants.CtrlEdgeAdvertisedPortVarName, constants.CtrlEdgeAdvertisedPortVarDescription, data.Controller.Web.BindPoints.AddressPort}, + {constants.CtrlPkiEdgeCertVarName, constants.CtrlPkiEdgeCertVarDescription, data.Controller.Web.Identity.Cert}, + {constants.CtrlPkiEdgeServerCertVarName, constants.CtrlPkiEdgeServerCertVarDescription, data.Controller.Web.Identity.ServerCert}, + {constants.CtrlPkiEdgeKeyVarName, constants.CtrlPkiEdgeKeyVarDescription, data.Controller.Web.Identity.Key}, + {constants.CtrlPkiEdgeCAVarName, constants.CtrlPkiEdgeCAVarDescription, data.Controller.Web.Identity.Ca}, + {constants.ZitiEdgeRouterNameVarName, constants.ZitiEdgeRouterNameVarDescription, data.Router.Name}, {constants.ZitiEdgeRouterPortVarName, constants.ZitiEdgeRouterPortVarDescription, data.Router.Edge.Port}, {constants.ZitiEdgeRouterListenerBindPortVarName, constants.ZitiEdgeRouterListenerBindPortVarDescription, data.Router.Edge.ListenerBindPort}, - {constants.ZitiEdgeCtrlIdentityCertVarName, constants.ZitiEdgeCtrlIdentityCertVarDescription, data.Controller.Edge.IdentityCert}, - {constants.ZitiEdgeCtrlIdentityServerCertVarName, constants.ZitiEdgeCtrlIdentityServerCertVarDescription, data.Controller.Edge.IdentityServerCert}, - {constants.ZitiEdgeCtrlIdentityKeyVarName, constants.ZitiEdgeCtrlIdentityKeyVarDescription, data.Controller.Edge.IdentityKey}, - {constants.ZitiEdgeCtrlIdentityCAVarName, constants.ZitiEdgeCtrlIdentityCAVarDescription, data.Controller.Edge.IdentityCA}, - {constants.ZitiCtrlIdentityCertVarName, constants.ZitiCtrlIdentityCertVarDescription, data.Controller.IdentityCert}, - {constants.ZitiCtrlIdentityServerCertVarName, constants.ZitiCtrlIdentityServerCertVarDescription, data.Controller.IdentityServerCert}, - {constants.ZitiCtrlIdentityKeyVarName, constants.ZitiCtrlIdentityKeyVarDescription, data.Controller.IdentityKey}, - {constants.ZitiCtrlIdentityCAVarName, constants.ZitiCtrlIdentityCAVarDescription, data.Controller.IdentityCA}, - {constants.ZitiSigningCertVarName, constants.ZitiSigningCertVarDescription, data.Controller.Edge.ZitiSigningCert}, - {constants.ZitiSigningKeyVarName, constants.ZitiSigningKeyVarDescription, data.Controller.Edge.ZitiSigningKey}, {constants.ZitiRouterIdentityCertVarName, constants.ZitiRouterIdentityCertVarDescription, data.Router.IdentityCert}, {constants.ZitiRouterIdentityServerCertVarName, constants.ZitiRouterIdentityServerCertVarDescription, data.Router.IdentityServerCert}, {constants.ZitiRouterIdentityKeyVarName, constants.ZitiRouterIdentityKeyVarDescription, data.Router.IdentityKey}, {constants.ZitiRouterIdentityCAVarName, constants.ZitiRouterIdentityCAVarDescription, data.Router.IdentityCA}, {constants.ZitiEdgeRouterIPOverrideVarName, constants.ZitiEdgeRouterIPOverrideVarDescription, data.Router.Edge.IPOverride}, {constants.ZitiEdgeRouterAdvertisedHostVarName, constants.ZitiEdgeRouterAdvertisedHostVarDescription, data.Router.Edge.AdvertisedHost}, - {constants.ZitiCtrlListenerAddressVarName, constants.ZitiCtrlListenerAddressVarDescription, data.Controller.ListenerAddress}, - {constants.ZitiCtrlAdvertisedAddressVarName, constants.ZitiCtrlAdvertisedAddressVarDescription, data.Controller.AdvertisedAddress}, - {constants.ZitiEdgeCtrlListenerHostPortVarName, constants.ZitiEdgeCtrlListenerHostPortVarDescription, data.Controller.Edge.ListenerHostPort}, - {constants.ZitiEdgeCtrlAdvertisedHostPortVarName, constants.ZitiEdgeCtrlAdvertisedHostPortVarDescription, data.Controller.Edge.AdvertisedHostPort}, - {constants.ZitiEdgeCtrlAdvertisedPortVarName, constants.ZitiEdgeCtrlAdvertisedPortVarDescription, data.Controller.Edge.AdvertisedPort}, - {constants.ZitiEdgeIdentityEnrollmentDurationVarName, constants.ZitiEdgeIdentityEnrollmentDurationVarDescription, data.Controller.EdgeIdentityDuration.String()}, - {constants.ZitiEdgeRouterEnrollmentDurationVarName, constants.ZitiEdgeRouterEnrollmentDurationVarDescription, data.Controller.EdgeRouterDuration.String()}, } // Setup logging @@ -187,16 +188,32 @@ func NewCmdCreateConfigEnvironment() *cobra.Command { "%-40s %-50s %s\n"+ "%-40s %-50s %s\n"+ "%-40s %-50s %s\n"+ + "%-40s %-50s %s\n"+ + "%-40s %-50s %s\n"+ + "%-40s %-50s %s\n"+ "%-40s %-50s %s", constants.ZitiHomeVarName, constants.ZitiHomeVarDescription, data.ZitiHome, - constants.ZitiCtrlPortVarName, constants.ZitiCtrlPortVarDescription, data.Controller.Port, - constants.ZitiCtrlNameVarName, constants.ZitiCtrlNameVarDescription, data.Controller.Name, - constants.ZitiCtrlAdvertisedAddressVarName, constants.ZitiCtrlAdvertisedAddressVarDescription, data.Controller.AdvertisedAddress, - constants.ZitiCtrlListenerAddressVarName, constants.ZitiCtrlListenerAddressVarDescription, data.Controller.ListenerAddress, - constants.ZitiEdgeCtrlListenerHostPortVarName, constants.ZitiEdgeCtrlListenerHostPortVarDescription, data.Controller.Edge.ListenerHostPort, - constants.ZitiEdgeCtrlAdvertisedHostPortVarName, constants.ZitiEdgeCtrlAdvertisedHostPortVarDescription, data.Controller.Edge.AdvertisedHostPort, - constants.ZitiEdgeCtrlAdvertisedPortVarName, constants.ZitiEdgeCtrlAdvertisedPortVarDescription, data.Controller.Edge.AdvertisedPort, - constants.ZitiEdgeRouterRawNameVarName, constants.ZitiEdgeRouterRawNameVarDescription, data.Router.Edge.Hostname, + constants.PkiCtrlCertVarName, constants.PkiCtrlCertVarDescription, data.Controller.Identity.Cert, + constants.PkiCtrlServerCertVarName, constants.PkiCtrlServerCertVarDescription, data.Controller.Identity.ServerCert, + constants.PkiCtrlKeyVarName, constants.PkiCtrlKeyVarDescription, data.Controller.Identity.Key, + constants.PkiCtrlCAVarName, constants.PkiCtrlCAVarDescription, data.Controller.Identity.Ca, + constants.CtrlListenerAddressVarName, constants.CtrlListenerAddressVarDescription, data.Controller.Ctrl.ListenerAddress, + constants.CtrlListenerPortVarName, constants.CtrlListenerPortVarDescription, data.Controller.Ctrl.ListenerPort, + constants.CtrlEdgeApiAddressVarName, constants.CtrlEdgeApiAddressVarDescription, data.Controller.EdgeApi.Address, + constants.CtrlEdgeApiPortVarName, constants.CtrlEdgeApiPortVarDescription, data.Controller.EdgeApi.Port, + constants.PkiSignerCertVarName, constants.PkiSignerCertVarDescription, data.Controller.EdgeEnrollment.SigningCert, + constants.PkiSignerKeyVarName, constants.PkiSignerKeyVarDescription, data.Controller.EdgeEnrollment.SigningCertKey, + constants.CtrlEdgeIdentityEnrollmentDurationVarName, constants.CtrlEdgeIdentityEnrollmentDurationVarDescription, strconv.FormatInt(int64(data.Controller.EdgeEnrollment.EdgeIdentityDuration), 10), + constants.CtrlEdgeRouterEnrollmentDurationVarName, constants.CtrlEdgeRouterEnrollmentDurationVarDescription, strconv.FormatInt(int64(data.Controller.EdgeEnrollment.EdgeRouterDuration), 10), + constants.CtrlEdgeInterfaceAddressVarName, constants.CtrlEdgeInterfaceAddressVarDescription, data.Controller.Web.BindPoints.InterfaceAddress, + constants.CtrlEdgeInterfacePortVarName, constants.CtrlEdgeInterfacePortVarDescription, data.Controller.Web.BindPoints.InterfacePort, + constants.CtrlEdgeAdvertisedAddressVarName, constants.CtrlEdgeAdvertisedAddressVarDescription, data.Controller.Web.BindPoints.AddressAddress, + constants.CtrlEdgeAdvertisedPortVarName, constants.CtrlEdgeAdvertisedPortVarDescription, data.Controller.Web.BindPoints.AddressPort, + constants.CtrlPkiEdgeCertVarName, constants.CtrlPkiEdgeCertVarDescription, data.Controller.Web.Identity.Cert, + constants.CtrlPkiEdgeServerCertVarName, constants.CtrlPkiEdgeServerCertVarDescription, data.Controller.Web.Identity.ServerCert, + constants.CtrlPkiEdgeKeyVarName, constants.CtrlPkiEdgeKeyVarDescription, data.Controller.Web.Identity.Key, + constants.CtrlPkiEdgeCAVarName, constants.CtrlPkiEdgeCAVarDescription, data.Controller.Web.Identity.Ca, + constants.ZitiEdgeRouterNameVarName, constants.ZitiEdgeRouterNameVarDescription, data.Router.Name, constants.ZitiEdgeRouterPortVarName, constants.ZitiEdgeRouterPortVarDescription, data.Router.Edge.Port, constants.ZitiEdgeRouterListenerBindPortVarName, constants.ZitiEdgeRouterListenerBindPortVarDescription, data.Router.Edge.ListenerBindPort, constants.ZitiRouterIdentityCertVarName, constants.ZitiRouterIdentityCertVarDescription, data.Router.IdentityCert, @@ -205,18 +222,8 @@ func NewCmdCreateConfigEnvironment() *cobra.Command { constants.ZitiRouterIdentityCAVarName, constants.ZitiRouterIdentityCAVarDescription, data.Router.IdentityCA, constants.ZitiEdgeRouterIPOverrideVarName, constants.ZitiEdgeRouterIPOverrideVarDescription, data.Router.Edge.IPOverride, constants.ZitiEdgeRouterAdvertisedHostVarName, constants.ZitiEdgeRouterAdvertisedHostVarDescription, data.Router.Edge.AdvertisedHost, - constants.ZitiCtrlIdentityCertVarName, constants.ZitiCtrlIdentityCertVarDescription, data.Controller.IdentityCert, - constants.ZitiCtrlIdentityServerCertVarName, constants.ZitiCtrlIdentityServerCertVarDescription, data.Controller.IdentityServerCert, - constants.ZitiCtrlIdentityKeyVarName, constants.ZitiCtrlIdentityKeyVarDescription, data.Controller.IdentityKey, - constants.ZitiCtrlIdentityCAVarName, constants.ZitiCtrlIdentityCAVarDescription, data.Controller.IdentityCA, - constants.ZitiEdgeCtrlIdentityCertVarName, constants.ZitiEdgeCtrlIdentityCertVarDescription, data.Controller.Edge.IdentityCert, - constants.ZitiEdgeCtrlIdentityServerCertVarName, constants.ZitiEdgeCtrlIdentityServerCertVarDescription, data.Controller.Edge.IdentityServerCert, - constants.ZitiEdgeCtrlIdentityKeyVarName, constants.ZitiEdgeCtrlIdentityKeyVarDescription, data.Controller.Edge.IdentityKey, - constants.ZitiEdgeCtrlIdentityCAVarName, constants.ZitiEdgeCtrlIdentityCAVarDescription, data.Controller.Edge.IdentityCA, - constants.ZitiSigningCertVarName, constants.ZitiSigningCertVarDescription, data.Controller.Edge.ZitiSigningCert, - constants.ZitiSigningKeyVarName, constants.ZitiSigningKeyVarDescription, data.Controller.Edge.ZitiSigningKey, - constants.ZitiEdgeIdentityEnrollmentDurationVarName, constants.ZitiEdgeIdentityEnrollmentDurationVarDescription, fmt.Sprintf("%.0f", data.Controller.EdgeIdentityDuration.Minutes()), - constants.ZitiEdgeRouterEnrollmentDurationVarName, constants.ZitiEdgeRouterEnrollmentDurationVarDescription, fmt.Sprintf("%.0f", data.Controller.EdgeRouterDuration.Minutes())) + constants.CtrlEdgeIdentityEnrollmentDurationVarName, constants.CtrlEdgeIdentityEnrollmentDurationVarDescription, fmt.Sprintf("%.0f", data.Controller.EdgeEnrollment.EdgeIdentityDuration.Minutes()), + constants.CtrlEdgeRouterEnrollmentDurationVarName, constants.CtrlEdgeRouterEnrollmentDurationVarDescription, fmt.Sprintf("%.0f", data.Controller.EdgeEnrollment.EdgeRouterDuration.Minutes())) cmd.Long = createConfigLong diff --git a/ziti/cmd/create_config_router.go b/ziti/cmd/create_config_router.go index 10ed476a3..249d2dc51 100644 --- a/ziti/cmd/create_config_router.go +++ b/ziti/cmd/create_config_router.go @@ -64,8 +64,7 @@ func NewCmdCreateConfigRouter() *cobra.Command { logrus.SetOutput(logOut) } - data.populateEnvVars() - data.populateDefaults() + data.populateConfigValues() // Update router data with options passed in data.Router.Name = validateRouterName(routerOptions.RouterName) diff --git a/ziti/cmd/create_config_router_common.go b/ziti/cmd/create_config_router_common.go index 378faeee1..2a2e5daca 100644 --- a/ziti/cmd/create_config_router_common.go +++ b/ziti/cmd/create_config_router_common.go @@ -20,7 +20,6 @@ import ( _ "embed" cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "github.com/openziti/ziti/ziti/constants" - "log" "os" ) @@ -30,38 +29,26 @@ func SetZitiRouterIdentity(r *RouterTemplateValues, routerName string) { SetZitiRouterIdentityKey(r, routerName) SetZitiRouterIdentityCA(r, routerName) + // Set the router name + r.Name = routerName + // Edge router IP override edgeRouterIPOverride := os.Getenv(constants.ZitiEdgeRouterIPOverrideVarName) if edgeRouterIPOverride != "" { r.Edge.IPOverride = edgeRouterIPOverride } - externalDNS := os.Getenv(constants.ExternalDNSVarName) - edgeRouterRawName := os.Getenv(constants.ZitiEdgeRouterRawNameVarName) - if externalDNS != "" { - r.Edge.Hostname = externalDNS - r.Edge.AdvertisedHost = r.Edge.Hostname //not redundant set AdvertisedHost - } else if edgeRouterRawName != "" { - r.Edge.Hostname = edgeRouterRawName - r.Edge.AdvertisedHost = r.Edge.Hostname //not redundant set AdvertisedHost - } else { - r.Edge.Hostname, _ = os.Hostname() - r.Edge.AdvertisedHost = r.Edge.Hostname //not redundant set AdvertisedHost - } - + // Set advertised host advertisedHost := os.Getenv(constants.ZitiEdgeRouterAdvertisedHostVarName) + resolvedHostname, _ := os.Hostname() if advertisedHost != "" { - if advertisedHost != edgeRouterIPOverride && advertisedHost != r.Edge.AdvertisedHost { - log.Panicf("if %s[%s] is supplied, it *MUST* match the %s[%s] or resolved hostname[%s]", constants.ZitiEdgeRouterAdvertisedHostVarName, advertisedHost, constants.ZitiEdgeRouterIPOverrideVarName, edgeRouterIPOverride, r.Edge.Hostname) - } - r.Edge.AdvertisedHost = advertisedHost //finally override AdvertisedHost if provided + r.Edge.AdvertisedHost = advertisedHost } else { - if externalDNS != "" || edgeRouterRawName != "" { - r.Edge.AdvertisedHost = r.Edge.Hostname - } else if edgeRouterIPOverride != "" { + // If advertised host is not provided, set to IP override, or default to resolved hostname + if edgeRouterIPOverride != "" { r.Edge.AdvertisedHost = edgeRouterIPOverride } else { - r.Edge.AdvertisedHost = r.Edge.Hostname //not redundant set AdvertisedHost + r.Edge.AdvertisedHost = resolvedHostname } } } diff --git a/ziti/cmd/create_config_router_edge_test.go b/ziti/cmd/create_config_router_edge_test.go index 61e55f3cc..4e061a53e 100644 --- a/ziti/cmd/create_config_router_edge_test.go +++ b/ziti/cmd/create_config_router_edge_test.go @@ -3,7 +3,9 @@ package cmd import ( "github.com/openziti/ziti/ziti/constants" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "os" + "strconv" "strings" "testing" "time" @@ -12,65 +14,33 @@ import ( var defaultArgs = []string{"edge", "--routerName", "test-router"} var testHostname, _ = os.Hostname() -func setEnvByMap[K string, V string](m map[K]V) { - for k, v := range m { - os.Setenv(string(k), string(v)) - } -} - -func execCreateConfigCommand(args []string, keys map[string]string) { - // Setup options - clearOptionsAndTemplateData() - routerOptions.Output = defaultOutput - - setEnvByMap(keys) - // Create and run the CLI command (capture output, otherwise config prints to stdout instead of test results) - cmd := NewCmdCreateConfigRouter() - cmd.SetArgs(args) - _ = captureOutput(func() { - _ = cmd.Execute() - }) -} - -func TestEdgeRouterAdvertised(t *testing.T) { - clearOptionsAndTemplateData() +func TestEdgeRouterAdvertisedAddress(t *testing.T) { + clearRouterOptionsAndTemplateData() routerAdvHostIp := "192.168.10.10" routerAdvHostDns := "controller01.zitinetwork.example.org" keys := map[string]string{ - "ZITI_CTRL_PORT": "80", - "ZITI_EDGE_ROUTER_PORT": "443", + "ZITI_CTRL_LISTENER_PORT": "80", + "ZITI_EDGE_ROUTER_PORT": "443", } + // Defaults to hostname if nothing is set execCreateConfigCommand(defaultArgs, keys) - assert.Equal(t, testHostname, data.Router.Edge.AdvertisedHost, nil) + require.Equal(t, testHostname, data.Router.Edge.AdvertisedHost, nil) - keys["ZITI_EDGE_ROUTER_RAWNAME"] = routerAdvHostDns - execCreateConfigCommand(defaultArgs, keys) - assert.Equal(t, routerAdvHostDns, data.Router.Edge.AdvertisedHost, nil) - - keys["ZITI_EDGE_ROUTER_RAWNAME"] = "" + // If IP override set, uses that value over hostname keys["ZITI_EDGE_ROUTER_IP_OVERRIDE"] = routerAdvHostIp execCreateConfigCommand(defaultArgs, keys) - assert.Equal(t, routerAdvHostIp, data.Router.Edge.AdvertisedHost, nil) - - keys["ZITI_EDGE_ROUTER_IP_OVERRIDE"] = "" - keys["EXTERNAL_DNS"] = routerAdvHostDns - execCreateConfigCommand(defaultArgs, keys) - assert.Equal(t, routerAdvHostDns, data.Router.Edge.AdvertisedHost, nil) - - keys["ZITI_EDGE_ROUTER_ADVERTISED_HOST"] = routerAdvHostIp - keys["ZITI_EDGE_ROUTER_IP_OVERRIDE"] = routerAdvHostIp - execCreateConfigCommand(defaultArgs, keys) - assert.Equal(t, routerAdvHostIp, data.Router.Edge.AdvertisedHost, nil) + require.Equal(t, routerAdvHostIp, data.Router.Edge.AdvertisedHost, nil) + // If advertised address set, uses that over IP override or hostname keys["ZITI_EDGE_ROUTER_ADVERTISED_HOST"] = routerAdvHostDns - keys["EXTERNAL_DNS"] = routerAdvHostDns + keys["ZITI_EDGE_ROUTER_IP_OVERRIDE"] = routerAdvHostIp execCreateConfigCommand(defaultArgs, keys) - assert.Equal(t, routerAdvHostDns, data.Router.Edge.AdvertisedHost, nil) + require.Equal(t, routerAdvHostDns, data.Router.Edge.AdvertisedHost, nil) } func TestTunnelerEnabledByDefault(t *testing.T) { // Setup options - clearOptionsAndTemplateData() + clearRouterOptionsAndTemplateData() routerOptions.Output = defaultOutput // Create and run the CLI command without the tunnel flag @@ -88,7 +58,7 @@ func TestTunnelerEnabledByDefault(t *testing.T) { func TestTunnelerNoneMode(t *testing.T) { // Setup options - clearOptionsAndTemplateData() + clearRouterOptionsAndTemplateData() routerOptions.Output = defaultOutput // Create and run the CLI command with the disable tunnel flag @@ -109,7 +79,7 @@ func TestTunnelerNoneMode(t *testing.T) { func TestTunnelerHostModeIsDefault(t *testing.T) { // Setup options - clearOptionsAndTemplateData() + clearRouterOptionsAndTemplateData() routerOptions.Output = defaultOutput // Create and run the CLI command without the tunnel flag @@ -128,7 +98,7 @@ func TestTunnelerHostModeIsDefault(t *testing.T) { func TestTunnelerTproxyMode(t *testing.T) { // Setup options - clearOptionsAndTemplateData() + clearRouterOptionsAndTemplateData() routerOptions.Output = defaultOutput // Create and run the CLI command without the tunnel flag @@ -151,7 +121,7 @@ func TestTunnelerInvalidMode(t *testing.T) { expectedErrorMsg := "Unknown tunneler mode [" + invalidMode + "] provided, should be \"" + noneTunMode + "\", \"" + hostTunMode + "\", or \"" + tproxyTunMode + "\"" // Create the options with both flags set to true - clearOptionsAndTemplateData() + clearRouterOptionsAndTemplateData() routerOptions.Output = defaultOutput routerOptions.TunnelerMode = invalidMode @@ -161,7 +131,7 @@ func TestTunnelerInvalidMode(t *testing.T) { } func TestPrivateEdgeRouterNotAdvertising(t *testing.T) { - clearOptionsAndTemplateData() + clearRouterOptionsAndTemplateData() // Create and run the CLI command config := createRouterConfig([]string{"edge", "--routerName", "myRouter", "--private"}) @@ -175,7 +145,7 @@ func TestBlankEdgeRouterNameBecomesHostname(t *testing.T) { blank := "" // Setup options with blank router name - clearOptionsAndTemplateData() + clearRouterOptionsAndTemplateData() routerOptions.Output = defaultOutput routerOptions.RouterName = blank @@ -191,7 +161,7 @@ func TestBlankEdgeRouterNameBecomesHostname(t *testing.T) { } func TestDefaultZitiEdgeRouterListenerBindPort(t *testing.T) { - expectedDefaultPort := TEST_ROUTER_LISTENER_PORT + expectedDefaultPortStr := strconv.Itoa(testDefaultRouterListenerPort) // Make sure the related env vars are unset _ = os.Unsetenv("ZITI_EDGE_ROUTER_LISTENER_BIND_PORT") @@ -200,14 +170,14 @@ func TestDefaultZitiEdgeRouterListenerBindPort(t *testing.T) { config := createRouterConfig([]string{"edge", "--routerName", "testRouter"}) // Check that the template data has been updated as expected - assert.Equal(t, expectedDefaultPort, data.Router.Edge.ListenerBindPort) + assert.Equal(t, expectedDefaultPortStr, data.Router.Edge.ListenerBindPort) // Check that the actual config output has the correct port for i := 1; i < len(config.Link.Listeners); i++ { if config.Link.Listeners[i].Binding == "transport" { // Assert Bind and Advertise use Bind port value - assert.Equal(t, expectedDefaultPort, strings.Split(config.Link.Listeners[i].Bind, ":")[1]) - assert.Equal(t, expectedDefaultPort, strings.Split(config.Link.Listeners[i].Address, ":")[1]) + require.Equal(t, expectedDefaultPortStr, strings.Split(config.Link.Listeners[i].Bind, ":")[1]) + require.Equal(t, expectedDefaultPortStr, strings.Split(config.Link.Listeners[i].Address, ":")[1]) break } } @@ -239,7 +209,7 @@ func TestEdgeRouterCannotBeWSSAndPrivate(t *testing.T) { expectedErrorMsg := "Flags for private and wss configs are mutually exclusive. You must choose private or wss, not both" // Create the options with both flags set to true - clearOptionsAndTemplateData() + clearRouterOptionsAndTemplateData() routerOptions.Output = defaultOutput routerOptions.IsPrivate = true routerOptions.WssEnabled = true @@ -253,7 +223,7 @@ func TestEdgeRouterOutputPathDoesNotExist(t *testing.T) { expectedErrorMsg := "stat /IDoNotExist: no such file or directory" // Set the router options - clearOptionsAndTemplateData() + clearRouterOptionsAndTemplateData() routerOptions.TunnelerMode = defaultTunnelerMode routerOptions.RouterName = "MyEdgeRouter" routerOptions.Output = "/IDoNotExist/MyEdgeRouter.yaml" @@ -265,8 +235,8 @@ func TestEdgeRouterOutputPathDoesNotExist(t *testing.T) { func TestExecuteCreateConfigRouterEdgeHasNonBlankTemplateValues(t *testing.T) { routerName := "MyEdgeRouter" - expectedNonEmptyStringFields := []string{".Router.Edge.ListenerBindPort", ".ZitiHome", ".Hostname", ".Router.Name", ".Router.IdentityCert", ".Router.IdentityServerCert", ".Router.IdentityKey", ".Router.IdentityCA", ".Router.Edge.Hostname", ".Router.Edge.Port"} - expectedNonEmptyStringValues := []*string{&data.Router.Edge.ListenerBindPort, &data.ZitiHome, &data.Hostname, &data.Router.Name, &data.Router.IdentityCert, &data.Router.IdentityServerCert, &data.Router.IdentityKey, &data.Router.IdentityCA, &data.Router.Edge.Hostname, &data.Router.Edge.Port} + expectedNonEmptyStringFields := []string{".Router.Edge.ListenerBindPort", ".ZitiHome", ".Hostname", ".Router.Name", ".Router.IdentityCert", ".Router.IdentityServerCert", ".Router.IdentityKey", ".Router.IdentityCA", ".Router.Edge.Port"} + expectedNonEmptyStringValues := []*string{&data.Router.Edge.ListenerBindPort, &data.ZitiHome, &data.Hostname, &data.Router.Name, &data.Router.IdentityCert, &data.Router.IdentityServerCert, &data.Router.IdentityKey, &data.Router.IdentityCA, &data.Router.Edge.Port} expectedNonEmptyIntFields := []string{".Router.Listener.OutQueueSize", ".Router.Wss.ReadBufferSize", ".Router.Wss.WriteBufferSize", ".Router.Forwarder.XgressDialQueueLength", ".Router.Forwarder.XgressDialWorkerCount", ".Router.Forwarder.LinkDialQueueLength", ".Router.Forwarder.LinkDialWorkerCount"} expectedNonEmptyIntValues := []*int{&data.Router.Listener.OutQueueSize, &data.Router.Wss.ReadBufferSize, &data.Router.Wss.WriteBufferSize, &data.Router.Forwarder.XgressDialQueueLength, &data.Router.Forwarder.XgressDialWorkerCount, &data.Router.Forwarder.LinkDialQueueLength, &data.Router.Forwarder.LinkDialWorkerCount} expectedNonEmptyTimeFields := []string{".Router.Listener.ConnectTimeout", "Router.Listener.GetSessionTimeout", ".Router.Wss.WriteTimeout", ".Router.Wss.ReadTimeout", ".Router.Wss.IdleTimeout", ".Router.Wss.PongTimeout", ".Router.Wss.PingInterval", ".Router.Wss.HandshakeTimeout", ".Router.Forwarder.LatencyProbeInterval"} @@ -297,7 +267,7 @@ func TestEdgeRouterIPOverrideIsConsumed(t *testing.T) { externalIP := "123.456.78.9" // Setup options - clearOptionsAndTemplateData() + clearRouterOptionsAndTemplateData() routerOptions.Output = defaultOutput // Set the env variable to non-empty value diff --git a/ziti/cmd/create_config_router_fabric_test.go b/ziti/cmd/create_config_router_fabric_test.go index 935852989..7c4a005bb 100644 --- a/ziti/cmd/create_config_router_fabric_test.go +++ b/ziti/cmd/create_config_router_fabric_test.go @@ -4,17 +4,16 @@ import ( "github.com/openziti/ziti/ziti/constants" "github.com/stretchr/testify/assert" "os" + "strconv" "strings" "testing" "time" ) -var TEST_ROUTER_LISTENER_PORT = 10080 - func TestExecuteCreateConfigRouterFabricHasNonBlankTemplateValues(t *testing.T) { routerName := "MyFabricRouter" - expectedNonEmptyStringFields := []string{".Router.Listener.BindPort", ".ZitiHome", ".Hostname", ".Router.Name", ".Router.IdentityCert", ".Router.IdentityServerCert", ".Router.IdentityKey", ".Router.IdentityCA", ".Router.Edge.Hostname", ".Router.Edge.Port"} - expectedNonEmptyStringValues := []*string{&data.Router.Edge.ListenerBindPort, &data.ZitiHome, &data.Hostname, &data.Router.Name, &data.Router.IdentityCert, &data.Router.IdentityServerCert, &data.Router.IdentityKey, &data.Router.IdentityCA, &data.Router.Edge.Hostname, &data.Router.Edge.Port} + expectedNonEmptyStringFields := []string{".Router.Listener.BindPort", ".ZitiHome", ".Hostname", ".Router.Name", ".Router.IdentityCert", ".Router.IdentityServerCert", ".Router.IdentityKey", ".Router.IdentityCA", ".Router.Edge.Port"} + expectedNonEmptyStringValues := []*string{&data.Router.Edge.ListenerBindPort, &data.ZitiHome, &data.Hostname, &data.Router.Name, &data.Router.IdentityCert, &data.Router.IdentityServerCert, &data.Router.IdentityKey, &data.Router.IdentityCA, &data.Router.Edge.Port} expectedNonEmptyIntFields := []string{".Router.Listener.OutQueueSize", ".Router.Wss.ReadBufferSize", ".Router.Wss.WriteBufferSize", ".Router.Forwarder.XgressDialQueueLength", ".Router.Forwarder.XgressDialWorkerCount", ".Router.Forwarder.LinkDialQueueLength", ".Router.Forwarder.LinkDialWorkerCount"} expectedNonEmptyIntValues := []*int{&data.Router.Listener.OutQueueSize, &data.Router.Wss.ReadBufferSize, &data.Router.Wss.WriteBufferSize, &data.Router.Forwarder.XgressDialQueueLength, &data.Router.Forwarder.XgressDialWorkerCount, &data.Router.Forwarder.LinkDialQueueLength, &data.Router.Forwarder.LinkDialWorkerCount} expectedNonEmptyTimeFields := []string{".Router.Listener.ConnectTimeout", "Router.Listener.GetSessionTimeout", ".Router.Wss.WriteTimeout", ".Router.Wss.ReadTimeout", ".Router.Wss.IdleTimeout", ".Router.Wss.PongTimeout", ".Router.Wss.PingInterval", ".Router.Wss.HandshakeTimeout", ".Router.Forwarder.LatencyProbeInterval"} @@ -45,7 +44,7 @@ func TestFabricRouterIPOverrideIsConsumed(t *testing.T) { externalIP := "123.456.78.9" // Setup options - clearOptionsAndTemplateData() + clearRouterOptionsAndTemplateData() routerOptions.Output = defaultOutput // Set the env variable to non-empty value @@ -71,7 +70,7 @@ func TestFabricRouterIPOverrideIsConsumed(t *testing.T) { } func TestFabricRouterHasNoListeners(t *testing.T) { - clearOptionsAndTemplateData() + clearRouterOptionsAndTemplateData() // Create and run the CLI command config := createRouterConfig([]string{"fabric", "--routerName", "myRouter"}) @@ -85,7 +84,7 @@ func TestBlankFabricRouterNameBecomesHostname(t *testing.T) { blank := "" // Create the options with empty router name - clearOptionsAndTemplateData() + clearRouterOptionsAndTemplateData() routerOptions.Output = defaultOutput routerOptions.RouterName = blank @@ -104,7 +103,7 @@ func TestFabricRouterOutputPathDoesNotExist(t *testing.T) { expectedErrorMsg := "stat /IDoNotExist: no such file or directory" // Set the router options - clearOptionsAndTemplateData() + clearRouterOptionsAndTemplateData() routerOptions.RouterName = "MyFabricRouter" routerOptions.Output = "/IDoNotExist/MyFabricRouter.yaml" @@ -114,7 +113,7 @@ func TestFabricRouterOutputPathDoesNotExist(t *testing.T) { } func TestDefaultZitiFabricRouterListenerBindPort(t *testing.T) { - expectedDefaultPort := TEST_ROUTER_LISTENER_PORT + expectedDefaultPortStr := strconv.Itoa(testDefaultRouterListenerPort) // Make sure the related env vars are unset _ = os.Unsetenv("ZITI_EDGE_ROUTER_LISTENER_BIND_PORT") @@ -123,14 +122,14 @@ func TestDefaultZitiFabricRouterListenerBindPort(t *testing.T) { config := createRouterConfig([]string{"fabric", "--routerName", "testRouter"}) // Check that the template data has been updated as expected - assert.Equal(t, expectedDefaultPort, data.Router.Edge.ListenerBindPort) + assert.Equal(t, expectedDefaultPortStr, data.Router.Edge.ListenerBindPort) // Check that the actual config output has the correct port for i := 1; i < len(config.Link.Listeners); i++ { if config.Link.Listeners[i].Binding == "transport" { // Assert Bind and Advertise use Bind port value - assert.Equal(t, expectedDefaultPort, strings.Split(config.Link.Listeners[i].Bind, ":")[1]) - assert.Equal(t, expectedDefaultPort, strings.Split(config.Link.Listeners[i].Address, ":")[1]) + assert.Equal(t, expectedDefaultPortStr, strings.Split(config.Link.Listeners[i].Bind, ":")[1]) + assert.Equal(t, expectedDefaultPortStr, strings.Split(config.Link.Listeners[i].Address, ":")[1]) break } } diff --git a/ziti/cmd/create_config_router_test.go b/ziti/cmd/create_config_router_test.go index 7d0a18545..4ca5be906 100644 --- a/ziti/cmd/create_config_router_test.go +++ b/ziti/cmd/create_config_router_test.go @@ -9,6 +9,9 @@ import ( "testing" ) +// TEST constants +var testDefaultRouterListenerPort = 10080 + /* BEGIN Controller config template structure */ type RouterConfig struct { @@ -120,16 +123,25 @@ func createRouterConfig(args []string) RouterConfig { return configStruct } -func clearOptionsAndTemplateData() { +func execCreateConfigCommand(args []string, keys map[string]string) { + // Setup options + clearRouterOptionsAndTemplateData() + routerOptions.Output = defaultOutput + + setEnvByMap(keys) + // Create and run the CLI command (capture output, otherwise config prints to stdout instead of test results) + cmd := NewCmdCreateConfigRouter() + cmd.SetArgs(args) + _ = captureOutput(func() { + _ = cmd.Execute() + }) +} + +func clearRouterOptionsAndTemplateData() { routerOptions = CreateConfigRouterOptions{} data = &ConfigTemplateValues{} - // Unset environment variables - envVars := getZitiEnvironmentVariables() - for i := 0; i < len(envVars); i++ { - _ = os.Unsetenv(envVars[i]) - } - _ = os.Unsetenv(constants.ExternalDNSVarName) + unsetZitiEnv() } func TestSetZitiRouterIdentityCertDefault(t *testing.T) { @@ -232,54 +244,54 @@ func TestSetZitiRouterIdentityCACustom(t *testing.T) { assert.Equal(t, expectedCustom, rtv.IdentityCA) } -func TestSetZitiRouterIdentitySetsAllIdentitiesAndEdgeRouterRawName(t *testing.T) { +func TestSetZitiRouterIdentitySetsAllIdentitiesAndRouterName(t *testing.T) { // Setup - clearOptionsAndTemplateData() - expectedRawName := "MyEdgeRouterRawName" + clearRouterOptionsAndTemplateData() + expectedName := "MyRouterName" blank := "" rtv := &RouterTemplateValues{} // Check that they're all currently blank - assert.Equal(t, blank, rtv.Edge.Hostname) + assert.Equal(t, blank, rtv.Name) assert.Equal(t, blank, rtv.IdentityCert) assert.Equal(t, blank, rtv.IdentityServerCert) assert.Equal(t, blank, rtv.IdentityKey) assert.Equal(t, blank, rtv.IdentityCA) // Set the env variable - _ = os.Setenv(constants.ZitiEdgeRouterRawNameVarName, expectedRawName) + _ = os.Setenv(constants.ZitiEdgeRouterNameVarName, expectedName) - SetZitiRouterIdentity(rtv, expectedRawName) + SetZitiRouterIdentity(rtv, expectedName) // Check that the value matches - assert.Equal(t, expectedRawName, rtv.Edge.Hostname) + assert.Equal(t, expectedName, rtv.Name) assert.NotEqualf(t, blank, rtv.IdentityCert, "Router.IdentityCert expected to have a value, instead it was blank") assert.NotEqualf(t, blank, rtv.IdentityServerCert, "Router.IdentityCert expected to have a value, instead it was blank") assert.NotEqualf(t, blank, rtv.IdentityKey, "Router.IdentityCert expected to have a value, instead it was blank") assert.NotEqualf(t, blank, rtv.IdentityCA, "Router.IdentityCert expected to have a value, instead it was blank") } -func TestSetZitiRouterIdentitySetsAllIdentitiesAndEdgeRouterRawNameToHostWhenBlank(t *testing.T) { +func TestSetZitiRouterIdentitySetsAllIdentitiesAndRouterNameToHostWhenBlank(t *testing.T) { // Setup - clearOptionsAndTemplateData() - expectedRawName, _ := os.Hostname() + clearRouterOptionsAndTemplateData() + expectedName, _ := os.Hostname() blank := "" rtv := &RouterTemplateValues{} // Check that they're all currently blank - assert.Equal(t, blank, rtv.Edge.Hostname) + assert.Equal(t, blank, rtv.Name) assert.Equal(t, blank, rtv.IdentityCert) assert.Equal(t, blank, rtv.IdentityServerCert) assert.Equal(t, blank, rtv.IdentityKey) assert.Equal(t, blank, rtv.IdentityCA) // Set the env variable to an empty value - _ = os.Setenv(constants.ZitiEdgeRouterRawNameVarName, "") + _ = os.Setenv(constants.ZitiEdgeRouterNameVarName, "") - SetZitiRouterIdentity(rtv, expectedRawName) + SetZitiRouterIdentity(rtv, expectedName) // Check that the value matches - assert.Equal(t, expectedRawName, rtv.Edge.Hostname) + assert.Equal(t, expectedName, rtv.Name) assert.NotEqualf(t, blank, rtv.IdentityCert, "Router.IdentityCert expected to have a value, instead it was blank") assert.NotEqualf(t, blank, rtv.IdentityServerCert, "Router.IdentityCert expected to have a value, instead it was blank") assert.NotEqualf(t, blank, rtv.IdentityKey, "Router.IdentityCert expected to have a value, instead it was blank") diff --git a/ziti/cmd/create_config_test.go b/ziti/cmd/create_config_test.go index 51ed0e9ed..09dc5a4f3 100644 --- a/ziti/cmd/create_config_test.go +++ b/ziti/cmd/create_config_test.go @@ -8,35 +8,58 @@ import ( "os" "strings" "testing" + "time" +) + +// These constants are hard-coded so that they may serve as a notifier. When the constants change in the source from +// which they came, we may need to update any related documentation. If the constant is changed, the tests should fail +// as they are expecting these hard-coded values. In which case, we update the hard-coded values and check any docs. +const ( + testDefaultCtrlEdgeAdvertisedPort = "1280" + testDefaultCtrlListenerAddress = "0.0.0.0" + testDefaultCtrlListenerPort = "6262" + testDefaultBoltCheckInterval = "30s" + testDefaultBoltCheckTimeout = "20s" + testDefaultBoltCheckInitialDelay = "30s" + testDefaultEdgeOptionsIdleTimeout = "5000ms" + testDefaultEdgeOptionsReadTimeout = "5000ms" + testDefaultEdgeOptionsWriteTimeout = "100000ms" + testDefaultEdgeOptionsMinTLSVersion = "TLS1.2" + testDefaultEdgeOptionsMaxTLSVersion = "TLS1.3" + testDefaultEdgeIdentityEnrollmentDuration = time.Duration(180) * time.Minute + testDefaultEdgeIdentityEnrollmentStr = "180m" + testDefaultEdgeRouterEnrollmentDuration = time.Duration(180) * time.Minute + testDefaultEdgeRouterEnrollmentStr = "180m" ) func getZitiEnvironmentVariables() []string { return []string{ "ZITI_HOME", - "ZITI_CONTROLLER_NAME", - "ZITI_CTRL_PORT", - "ZITI_EDGE_ROUTER_RAWNAME", + "ZITI_EDGE_ROUTER_NAME", "ZITI_EDGE_ROUTER_PORT", - "ZITI_EDGE_CTRL_IDENTITY_CERT", - "ZITI_EDGE_CTRL_IDENTITY_SERVER_CERT", - "ZITI_EDGE_CTRL_IDENTITY_KEY", - "ZITI_EDGE_CTRL_IDENTITY_CA", - "ZITI_EDGE_CONTROLLER_PORT", - "ZITI_CTRL_IDENTITY_CERT", - "ZITI_CTRL_IDENTITY_SERVER_CERT", - "ZITI_CTRL_IDENTITY_KEY", - "ZITI_CTRL_IDENTITY_CA", - "ZITI_SIGNING_CERT", - "ZITI_SIGNING_KEY", + "ZITI_PKI_CTRL_CERT", + "ZITI_PKI_CTRL_SERVER_CERT", + "ZITI_PKI_CTRL_KEY", + "ZITI_PKI_CTRL_CA", + "ZITI_CTRL_LISTENER_ADDRESS", + "ZITI_CTRL_LISTENER_PORT", + "ZITI_CTRL_EDGE_API_ADDRESS", + "ZITI_CTRL_EDGE_API_PORT", + "ZITI_PKI_SIGNER_CERT", + "ZITI_PKI_SIGNER_KEY", + "ZITI_CTRL_EDGE_INTERFACE_ADDRESS", + "ZITI_CTRL_EDGE_INTERFACE_PORT", + "ZITI_CTRL_EDGE_ADVERTISED_ADDRESS", + "ZITI_CTRL_EDGE_ADVERTISED_PORT", + "ZITI_PKI_EDGE_CA", + "ZITI_PKI_EDGE_KEY", + "ZITI_PKI_EDGE_SERVER_CERT", + "ZITI_PKI_EDGE_CERT", "ZITI_ROUTER_IDENTITY_CERT", "ZITI_ROUTER_IDENTITY_SERVER_CERT", "ZITI_ROUTER_IDENTITY_KEY", "ZITI_ROUTER_IDENTITY_CA", "ZITI_EDGE_ROUTER_IP_OVERRIDE", - "ZITI_CTRL_LISTENER_ADDRESS", - "ZITI_CTRL_ADVERTISED_ADDRESS", - "ZITI_CTRL_EDGE_LISTENER_HOST_PORT", - "ZITI_EDGE_CTRL_ADVERTISED_HOST_PORT", "ZITI_EDGE_IDENTITY_ENROLLMENT_DURATION", "ZITI_EDGE_ROUTER_ENROLLMENT_DURATION", "ZITI_EDGE_ROUTER_ADVERTISED_HOST", @@ -44,6 +67,14 @@ func getZitiEnvironmentVariables() []string { } } +func unsetZitiEnv() { + // Unset environment variables + envVars := getZitiEnvironmentVariables() + for i := 0; i < len(envVars); i++ { + _ = os.Unsetenv(envVars[i]) + } +} + // Test that all ZITI_* variables are included in the values for output func TestNoUnknownOutputEnvVariablesExist(t *testing.T) { // Get the list of ZITI_* environment variables @@ -234,3 +265,9 @@ func captureOutput(function func()) string { _, _ = io.Copy(&buffer, r) return buffer.String() } + +func setEnvByMap[K string, V string](m map[K]V) { + for k, v := range m { + os.Setenv(string(k), string(v)) + } +} diff --git a/ziti/cmd/database/cmd.go b/ziti/cmd/database/cmd.go index 41d23c9f4..f26bfe68d 100644 --- a/ziti/cmd/database/cmd.go +++ b/ziti/cmd/database/cmd.go @@ -14,6 +14,7 @@ func NewCmdDb(out io.Writer, errOut io.Writer) *cobra.Command { exploreCmd := &cobra.Command{ Use: "explore |help|version", Short: "Interactive CLI to explore Ziti database files", + Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { if err := zdecli.Run("ziti db explore", args[0]); err != nil { _, _ = errOut.Write([]byte(fmt.Sprintf("Error: %s", err))) diff --git a/ziti/cmd/helpers/env_helpers.go b/ziti/cmd/helpers/env_helpers.go index 27c5c497e..193d4ed39 100644 --- a/ziti/cmd/helpers/env_helpers.go +++ b/ziti/cmd/helpers/env_helpers.go @@ -47,7 +47,6 @@ func WorkingDir() (string, error) { } func GetZitiHome() (string, error) { - // Get path from env variable retVal := os.Getenv(constants.ZitiHomeVarName) @@ -55,7 +54,8 @@ func GetZitiHome() (string, error) { // If not set, create a default path of the current working directory workingDir, err := WorkingDir() if err != nil { - return "", err + // If there is an error just use . + workingDir = "." } err = os.Setenv(constants.ZitiHomeVarName, workingDir) @@ -69,15 +69,81 @@ func GetZitiHome() (string, error) { return NormalizePath(retVal), nil } -func GetZitiCtrlAdvertisedAddress() (string, error) { +func HostnameOrNetworkName() string { + val := os.Getenv("ZITI_NETWORK_NAME") + if val == "" { + h, err := os.Hostname() + if err != nil { + return "localhost" + } + return h + } + return val +} - // Use External DNS if set - extDNS := os.Getenv(constants.ExternalDNSVarName) - if extDNS != "" { - return extDNS, nil +func GetCtrlListenerAddress() (string, error) { + return getValueOrSetAndGetDefault(constants.CtrlListenerAddressVarName, constants.DefaultCtrlListenerAddress) +} + +func GetCtrlListenerPort() (string, error) { + return getValueOrSetAndGetDefault(constants.CtrlListenerPortVarName, constants.DefaultCtrlListenerPort) +} + +func GetCtrlEdgeApiAddress() (string, error) { + // Get the controller's edge advertised hostname to use as the default + defaultAddress, err := GetCtrlEdgeAdvertisedAddress() + if err != nil { + err := errors.Wrap(err, "Unable to get "+constants.CtrlEdgeAdvertisedAddressVarName) + if err != nil { + return "", err + } } - // Use hostname if external DNS and advertised address not set + return getValueOrSetAndGetDefault(constants.CtrlEdgeApiAddressVarName, defaultAddress) +} + +func GetCtrlEdgeApiPort() (string, error) { + // Get the controller's edge advertised port to use as the default + defaultPort, err := GetCtrlEdgeAdvertisedPort() + if err != nil { + err := errors.Wrap(err, "Unable to get "+constants.CtrlEdgeAdvertisedPortVarName) + if err != nil { + return "", err + } + } + + return getValueOrSetAndGetDefault(constants.CtrlEdgeApiPortVarName, defaultPort) +} + +func GetCtrlEdgeInterfaceAddress() (string, error) { + // Get the controller's listener hostname to use as the default + defaultHostname, err := GetCtrlListenerAddress() + if err != nil { + err := errors.Wrap(err, "Unable to get "+constants.CtrlListenerAddressVarName) + if err != nil { + return "", err + } + } + + return getValueOrSetAndGetDefault(constants.CtrlEdgeInterfaceAddressVarName, defaultHostname) +} + +func GetCtrlEdgeInterfacePort() (string, error) { + // Get the controller's edge advertised port to use as the default + defaultPort, err := GetCtrlEdgeAdvertisedPort() + if err != nil { + err := errors.Wrap(err, "Unable to get "+constants.CtrlEdgeAdvertisedPortVarName) + if err != nil { + return "", err + } + } + + return getValueOrSetAndGetDefault(constants.CtrlEdgeInterfacePortVarName, defaultPort) +} + +func GetCtrlEdgeAdvertisedAddress() (string, error) { + + // Use hostname if edge advertised address not set hostname, err := os.Hostname() if err != nil { err := errors.Wrap(err, "Unable to get hostname") @@ -86,19 +152,11 @@ func GetZitiCtrlAdvertisedAddress() (string, error) { } } - return getValueOrSetAndGetDefault(constants.ZitiCtrlAdvertisedAddressVarName, hostname) + return getValueOrSetAndGetDefault(constants.CtrlEdgeAdvertisedAddressVarName, hostname) } -func GetZitiCtrlPort() (string, error) { - return getValueOrSetAndGetDefault(constants.ZitiCtrlPortVarName, constants.DefaultZitiControllerPort) -} - -func GetZitiCtrlListenerAddress() (string, error) { - return getValueOrSetAndGetDefault(constants.ZitiCtrlListenerAddressVarName, constants.DefaultZitiControllerListenerAddress) -} - -func GetZitiCtrlName() (string, error) { - return getValueOrSetAndGetDefault(constants.ZitiCtrlNameVarName, constants.DefaultZitiControllerName) +func GetCtrlEdgeAdvertisedPort() (string, error) { + return getValueOrSetAndGetDefault(constants.CtrlEdgeAdvertisedPortVarName, constants.DefaultCtrlEdgeAdvertisedPort) } func GetZitiEdgeRouterPort() (string, error) { @@ -109,62 +167,17 @@ func GetZitiEdgeRouterListenerBindPort() (string, error) { return getValueOrSetAndGetDefault(constants.ZitiEdgeRouterListenerBindPortVarName, constants.DefaultZitiEdgeRouterListenerBindPort) } -func GetZitiEdgeCtrlListenerHostPort() (string, error) { - // Get the edge controller port to use as the default - edgeCtrlPort, err := GetZitiEdgeCtrlAdvertisedPort() +func GetCtrlEdgeIdentityEnrollmentDuration() (time.Duration, error) { + retVal, err := getValueOrSetAndGetDefault(constants.CtrlEdgeIdentityEnrollmentDurationVarName, strconv.FormatInt(int64(edge.DefaultEdgeEnrollmentDuration.Minutes()), 10)) if err != nil { - err := errors.Wrap(err, "Unable to get "+constants.ZitiEdgeCtrlAdvertisedPortVarName) - if err != nil { - return "", err - } - } - - return getValueOrSetAndGetDefault(constants.ZitiEdgeCtrlListenerHostPortVarName, constants.DefaultZitiEdgeListenerHost+":"+edgeCtrlPort) -} - -func GetZitiEdgeCtrlAdvertisedHostPort() (string, error) { - - port, err := GetZitiEdgeCtrlAdvertisedPort() - if err != nil { - err := errors.Wrap(err, "Unable to get "+constants.ZitiEdgeCtrlAdvertisedPortVarName) - if err != nil { - return "", err - } - } - - // Use External DNS if set - extDNS := os.Getenv(constants.ExternalDNSVarName) - if extDNS != "" { - return extDNS + ":" + port, nil - } - - // Use hostname and advertised port if advertised host port env var not set - hostname, err := os.Hostname() - if err != nil { - err := errors.Wrap(err, "Unable to get hostname") - if err != nil { - return "", err - } - } - - return getValueOrSetAndGetDefault(constants.ZitiEdgeCtrlAdvertisedHostPortVarName, hostname+":"+port) -} - -func GetZitiEdgeCtrlAdvertisedPort() (string, error) { - return getValueOrSetAndGetDefault(constants.ZitiEdgeCtrlAdvertisedPortVarName, constants.DefaultZitiEdgeAPIPort) -} - -func GetZitiEdgeIdentityEnrollmentDuration() (time.Duration, error) { - retVal, err := getValueOrSetAndGetDefault(constants.ZitiEdgeIdentityEnrollmentDurationVarName, strconv.FormatInt(int64(edge.DefaultEdgeEnrollmentDuration.Minutes()), 10)) - if err != nil { - err := errors.Wrap(err, "Unable to get "+constants.ZitiEdgeIdentityEnrollmentDurationVarDescription) + err := errors.Wrap(err, "Unable to get "+constants.CtrlEdgeIdentityEnrollmentDurationVarDescription) if err != nil { return edge.DefaultEdgeEnrollmentDuration, err } } retValInt, err := strconv.Atoi(retVal) if err != nil { - err := errors.Wrap(err, "Unable to get "+constants.ZitiEdgeIdentityEnrollmentDurationVarDescription) + err := errors.Wrap(err, "Unable to get "+constants.CtrlEdgeIdentityEnrollmentDurationVarDescription) if err != nil { return edge.DefaultEdgeEnrollmentDuration, err } @@ -173,17 +186,17 @@ func GetZitiEdgeIdentityEnrollmentDuration() (time.Duration, error) { return time.Duration(retValInt) * time.Minute, nil } -func GetZitiEdgeRouterEnrollmentDuration() (time.Duration, error) { - retVal, err := getValueOrSetAndGetDefault(constants.ZitiEdgeRouterEnrollmentDurationVarName, strconv.FormatInt(int64(edge.DefaultEdgeEnrollmentDuration.Minutes()), 10)) +func GetCtrlEdgeRouterEnrollmentDuration() (time.Duration, error) { + retVal, err := getValueOrSetAndGetDefault(constants.CtrlEdgeRouterEnrollmentDurationVarName, strconv.FormatInt(int64(edge.DefaultEdgeEnrollmentDuration.Minutes()), 10)) if err != nil { - err := errors.Wrap(err, "Unable to get "+constants.ZitiEdgeRouterEnrollmentDurationVarDescription) + err := errors.Wrap(err, "Unable to get "+constants.CtrlEdgeRouterEnrollmentDurationVarDescription) if err != nil { return edge.DefaultEdgeEnrollmentDuration, err } } retValInt, err := strconv.Atoi(retVal) if err != nil { - err := errors.Wrap(err, "Unable to get "+constants.ZitiEdgeRouterEnrollmentDurationVarDescription) + err := errors.Wrap(err, "Unable to get "+constants.CtrlEdgeRouterEnrollmentDurationVarDescription) if err != nil { return edge.DefaultEdgeEnrollmentDuration, err } diff --git a/ziti/cmd/helpers/helpers_test.go b/ziti/cmd/helpers/helpers_test.go index 29690e80a..6c24a85a0 100644 --- a/ziti/cmd/helpers/helpers_test.go +++ b/ziti/cmd/helpers/helpers_test.go @@ -10,16 +10,12 @@ import ( ) func TestHomeDirHasNoWindowsSlashes(t *testing.T) { - value := HomeDir() - assert.Zero(t, strings.Count(value, "\\")) - } func TestWorkingDirHasNoWindowsSlashes(t *testing.T) { value, _ := WorkingDir() - assert.Zero(t, strings.Count(value, "\\")) } @@ -54,7 +50,7 @@ func TestGetZitiHomeWhenSet(t *testing.T) { assert.Equal(t, expectedValue, actualValue) } -func TestGetZitiHomeWhenSetWithWindowsSlashes(t *testing.T) { +func TestGetHomeWhenSetWithWindowsSlashes(t *testing.T) { // Setup varName := "ZITI_HOME" expectedValue := "/path/to/ziti/home" @@ -67,16 +63,16 @@ func TestGetZitiHomeWhenSetWithWindowsSlashes(t *testing.T) { assert.Equal(t, expectedValue, actualValue) } -func TestGetZitiCtrlAdvertisedAddressWhenUnset(t *testing.T) { +func TestGetCtrlEdgeAdvertisedAddressWhenUnset(t *testing.T) { // Setup - varName := "ZITI_CTRL_ADVERTISED_ADDRESS" + varName := "ZITI_CTRL_EDGE_ADVERTISED_ADDRESS" // Ensure the variable is unset _ = os.Unsetenv(varName) expectedValue, _ := os.Hostname() // Check that the value matches - actualValue, _ := GetZitiCtrlAdvertisedAddress() + actualValue, _ := GetCtrlEdgeAdvertisedAddress() assert.Equal(t, expectedValue, actualValue) // The env variable should be populated with the expected value @@ -84,46 +80,29 @@ func TestGetZitiCtrlAdvertisedAddressWhenUnset(t *testing.T) { assert.Equal(t, expectedValue, envValue) } -func TestGetZitiCtrlAdvertisedAddressWhenSet(t *testing.T) { +func TestGetCtrlEdgeAdvertisedAddressWhenSet(t *testing.T) { // Setup - varName := "ZITI_CTRL_ADVERTISED_ADDRESS" + varName := "ZITI_CTRL_EDGE_ADVERTISED_ADDRESS" expectedValue := "localhost" // Set the env variable _ = os.Setenv(varName, expectedValue) // Check that the value matches - actualValue, _ := GetZitiCtrlAdvertisedAddress() + actualValue, _ := GetCtrlEdgeAdvertisedAddress() assert.Equal(t, expectedValue, actualValue) } -// Confirm that EXTERNAL_DNS is used over ZITI_CTRL_ADVERTISED_ADDRESS -func TestGetZitiCtrlAdvertisedAddressWhenExtDNSSet(t *testing.T) { +func TestGetCtrlPortWhenUnset(t *testing.T) { // Setup - ctrlAdvAddressVarName := "ZITI_CTRL_ADVERTISED_ADDRESS" - ctrlAdvAddressValue := "advertisedAddress" - extDNSVarName := "EXTERNAL_DNS" - externalDNSValue := "myexternaldns" - - // Set the env variable - _ = os.Setenv(ctrlAdvAddressVarName, ctrlAdvAddressValue) - _ = os.Setenv(extDNSVarName, externalDNSValue) - - // Check that the value matches - actualValue, _ := GetZitiCtrlAdvertisedAddress() - assert.Equal(t, externalDNSValue, actualValue) -} - -func TestGetZitiCtrlPortWhenUnset(t *testing.T) { - // Setup - varName := "ZITI_CTRL_PORT" + varName := "ZITI_CTRL_LISTENER_PORT" // Ensure the variable is unset _ = os.Unsetenv(varName) expectedValue := "6262" // Check that the value matches - actualValue, _ := GetZitiCtrlPort() + actualValue, _ := GetCtrlListenerPort() assert.Equal(t, expectedValue, actualValue) // The env variable should be populated with the expected value @@ -131,20 +110,20 @@ func TestGetZitiCtrlPortWhenUnset(t *testing.T) { assert.Equal(t, expectedValue, envValue) } -func TestGetZitiCtrlPortWhenSet(t *testing.T) { +func TestGetCtrlPortWhenSet(t *testing.T) { // Setup - varName := "ZITI_CTRL_PORT" + varName := "ZITI_CTRL_LISTENER_PORT" expectedValue := "1234" // Set the env variable _ = os.Setenv(varName, expectedValue) // Check that the value matches - actualValue, _ := GetZitiCtrlPort() + actualValue, _ := GetCtrlListenerPort() assert.Equal(t, expectedValue, actualValue) } -func TestGetZitiCtrlListenerAddressWhenUnset(t *testing.T) { +func TestGetCtrlListenerAddressWhenUnset(t *testing.T) { // Setup varName := "ZITI_CTRL_LISTENER_ADDRESS" @@ -153,7 +132,7 @@ func TestGetZitiCtrlListenerAddressWhenUnset(t *testing.T) { expectedValue := "0.0.0.0" // Check that the value matches - actualValue, _ := GetZitiCtrlListenerAddress() + actualValue, _ := GetCtrlListenerAddress() assert.Equal(t, expectedValue, actualValue) // The env variable should be populated with the expected value @@ -161,7 +140,7 @@ func TestGetZitiCtrlListenerAddressWhenUnset(t *testing.T) { assert.Equal(t, expectedValue, envValue) } -func TestGetZitiCtrlListenerAddressWhenSet(t *testing.T) { +func TestGetCtrlListenerAddressWhenSet(t *testing.T) { // Setup varName := "ZITI_CTRL_LISTENER_ADDRESS" expectedValue := "localhost" @@ -170,41 +149,11 @@ func TestGetZitiCtrlListenerAddressWhenSet(t *testing.T) { _ = os.Setenv(varName, expectedValue) // Check that the value matches - actualValue, _ := GetZitiCtrlListenerAddress() + actualValue, _ := GetCtrlListenerAddress() assert.Equal(t, expectedValue, actualValue) } -func TestGetZitiCtrlNameWhenUnset(t *testing.T) { - // Setup - varName := "ZITI_CONTROLLER_NAME" - - // Ensure the variable is unset - _ = os.Unsetenv(varName) - expectedValue := "controller" - - // Check that the value matches - actualValue, _ := GetZitiCtrlName() - assert.Equal(t, expectedValue, actualValue) - - // The env variable should be populated with the expected value - envValue := os.Getenv(varName) - assert.Equal(t, expectedValue, envValue) -} - -func TestGetZitiCtrlNameWhenSet(t *testing.T) { - // Setup - varName := "ZITI_CONTROLLER_NAME" - expectedValue := "MyController" - - // Set the env variable - _ = os.Setenv(varName, expectedValue) - - // Check that the value matches - actualValue, _ := GetZitiCtrlName() - assert.Equal(t, expectedValue, actualValue) -} - -func TestGetZitiEdgeRouterPortWhenUnset(t *testing.T) { +func TestGetEdgeRouterPortWhenUnset(t *testing.T) { // Setup varName := "ZITI_EDGE_ROUTER_PORT" @@ -221,7 +170,7 @@ func TestGetZitiEdgeRouterPortWhenUnset(t *testing.T) { assert.Equal(t, expectedValue, envValue) } -func TestGetZitiEdgeRouterPortWhenSet(t *testing.T) { +func TestGetEdgeRouterPortWhenSet(t *testing.T) { // Setup varName := "ZITI_EDGE_ROUTER_PORT" expectedValue := "4321" @@ -234,213 +183,112 @@ func TestGetZitiEdgeRouterPortWhenSet(t *testing.T) { assert.Equal(t, expectedValue, actualValue) } -func TestGetZitiEdgeCtrlListenerHostPortWhenUnset(t *testing.T) { +func TestGetCtrlEdgeAdvertisedPortWhenNotSet(t *testing.T) { // Setup - varName := "ZITI_CTRL_EDGE_LISTENER_HOST_PORT" - - // Ensure the variable is unset - _ = os.Unsetenv(varName) - expectedValue := "0.0.0.0:1280" - - // Check that the value matches - actualValue, _ := GetZitiEdgeCtrlListenerHostPort() - assert.Equal(t, expectedValue, actualValue) - - // The env variable should be populated with the expected value - envValue := os.Getenv(varName) - assert.Equal(t, expectedValue, envValue) -} - -func TestGetZitiEdgeCtrlListenerHostPortWhenSet(t *testing.T) { - // Setup - varName := "ZITI_CTRL_EDGE_LISTENER_HOST_PORT" - expectedValue := "localhost:1234" - - // Set the env variable - _ = os.Setenv(varName, expectedValue) - - // Check that the value matches - actualValue, _ := GetZitiEdgeCtrlListenerHostPort() - assert.Equal(t, expectedValue, actualValue) -} - -func TestGetZitiEdgeCtrlAdvertisedHostPortWhenUnset(t *testing.T) { - // Setup - edgeCtrlAdvHostPortVarName := "ZITI_EDGE_CTRL_ADVERTISED_HOST_PORT" - extDNSVarName := "EXTERNAL_DNS" - - // Set up env variables - _ = os.Unsetenv(extDNSVarName) - _ = os.Unsetenv(edgeCtrlAdvHostPortVarName) - hostname, _ := os.Hostname() - expectedValue := hostname + ":1280" - - // Check that the value matches - actualValue, _ := GetZitiEdgeCtrlAdvertisedHostPort() - assert.Equal(t, expectedValue, actualValue) - - // The env variable should be populated with the expected value - envValue := os.Getenv(edgeCtrlAdvHostPortVarName) - assert.Equal(t, expectedValue, envValue) -} - -func TestGetZitiEdgeCtrlAdvertisedHostPortWhenSet(t *testing.T) { - // Setup - edgeCtrlAdvHostPortVarName := "ZITI_EDGE_CTRL_ADVERTISED_HOST_PORT" - extDNSVarName := "EXTERNAL_DNS" - expectedValue := "localhost:4321" - - // Set the env variable - _ = os.Unsetenv(extDNSVarName) - _ = os.Setenv(edgeCtrlAdvHostPortVarName, expectedValue) - - // Check that the value matches - actualValue, _ := GetZitiEdgeCtrlAdvertisedHostPort() - assert.Equal(t, expectedValue, actualValue) -} - -// Confirm that EXTERNAL_DNS and ZITI_EDGE_CONTROLLER_PORT get used over ZITI_EDGE_CTRL_ADVERTISED_HOST_PORT -func TestGetZitiEdgeCtrlAdvertisedHostPortWhenExtDNSAndHostPortSet(t *testing.T) { - // Setup - extDNSVarName := "EXTERNAL_DNS" - zitiEdgeCtrlAdvHostPortVarName := "ZITI_EDGE_CTRL_ADVERTISED_HOST_PORT" - advHostPortValue := "localhost:1234" - externalDNSValue := "myexternaldns" - - expectedValue := externalDNSValue + ":1280" - - // Setup the env variables - _ = os.Setenv(zitiEdgeCtrlAdvHostPortVarName, advHostPortValue) - _ = os.Setenv(extDNSVarName, externalDNSValue) - - // Check that the value matches - actualValue, _ := GetZitiEdgeCtrlAdvertisedHostPort() - assert.Equal(t, expectedValue, actualValue) -} - -func TestGetZitiEdgeCtrlAdvertisedHostPortWhenExternalDNSAndPortSet(t *testing.T) { - // Setup - extDNSVarName := "EXTERNAL_DNS" - ctrlPortVarName := "ZITI_EDGE_CONTROLLER_PORT" - externalDNSValue := "myexternaldns" - ctrlPortValue := "1234" - expectedValue := externalDNSValue + ":" + ctrlPortValue - - // Setup the env variables - _ = os.Setenv(ctrlPortVarName, ctrlPortValue) - _ = os.Setenv(extDNSVarName, externalDNSValue) - - // Check that the value matches - actualValue, _ := GetZitiEdgeCtrlAdvertisedHostPort() - assert.Equal(t, expectedValue, actualValue) -} - -func TestGetZitiEdgeCtrlPortWhenNotSet(t *testing.T) { - // Setup - varName := "ZITI_EDGE_CONTROLLER_PORT" + varName := "ZITI_CTRL_EDGE_ADVERTISED_PORT" expectedValue := "1280" // Be sure the var is unset _ = os.Unsetenv(varName) // Check that the value matches - actualValue, _ := GetZitiEdgeCtrlAdvertisedPort() + actualValue, _ := GetCtrlEdgeAdvertisedPort() assert.Equal(t, expectedValue, actualValue) } -func TestGetZitiEdgeIdentityEnrollmentDurationWhenSet(t *testing.T) { +func TestGetCtrlEdgeAdvertisedPortWhenSet(t *testing.T) { // Setup - varName := "ZITI_EDGE_IDENTITY_ENROLLMENT_DURATION" - expectedValue := 5 * time.Minute - - // Set the env variable - _ = os.Setenv(varName, fmt.Sprintf("%.0f", expectedValue.Minutes())) - - // Check that the value matches - actualValue, _ := GetZitiEdgeIdentityEnrollmentDuration() - assert.Equal(t, expectedValue, actualValue) -} - -/* Ensure that the default value is returned even if the environment variable is set but is blank. */ -func TestGetZitiEdgeIdentityEnrollmentDurationWhenSetToBlank(t *testing.T) { - // Setup - varName := "ZITI_EDGE_IDENTITY_ENROLLMENT_DURATION" - // Expect the default, hard coding the value to act as an alert if default is changed in edge project - expectedValue := 180 * time.Minute - - // Set the env variable - _ = os.Setenv(varName, "") - - // Check that the value matches - actualValue, _ := GetZitiEdgeIdentityEnrollmentDuration() - assert.Equal(t, expectedValue, actualValue) -} - -func TestGetZitiEdgeIdentityEnrollmentDurationWhenNotSet(t *testing.T) { - // Setup - varName := "ZITI_EDGE_IDENTITY_ENROLLMENT_DURATION" - // Expect the default, hard coding the value to act as an alert if default is changed in edge project - expectedValue := 180 * time.Minute - - // Set the env variable - _ = os.Setenv(varName, fmt.Sprintf("%.0f", expectedValue.Minutes())) - - // Check that the value matches - actualValue, _ := GetZitiEdgeIdentityEnrollmentDuration() - assert.Equal(t, expectedValue, actualValue) -} - -func TestGetZitiEdgeRouterEnrollmentDurationWhenSet(t *testing.T) { - // Setup - varName := "ZITI_EDGE_ROUTER_ENROLLMENT_DURATION" - expectedValue := 5 * time.Minute - - // Set the env variable - _ = os.Setenv(varName, fmt.Sprintf("%.0f", expectedValue.Minutes())) - - // Check that the value matches - actualValue, _ := GetZitiEdgeRouterEnrollmentDuration() - assert.Equal(t, expectedValue, actualValue) -} - -/* Ensure that the default value is returned even if the environment variable is set but is blank. */ -func TestGetZitiEdgeRouterEnrollmentDurationWhenSetToBlank(t *testing.T) { - // Setup - varName := "ZITI_EDGE_ROUTER_ENROLLMENT_DURATION" - // Expect the default, hard coding the value to act as an alert if default is changed in edge project - expectedValue := 180 * time.Minute - - // Set the env variable - _ = os.Setenv(varName, "") - - // Check that the value matches - actualValue, _ := GetZitiEdgeRouterEnrollmentDuration() - assert.Equal(t, expectedValue, actualValue) -} - -func TestGetZitiEdgeRouterEnrollmentDurationWhenNotSet(t *testing.T) { - // Setup - varName := "ZITI_EDGE_ROUTER_ENROLLMENT_DURATION" - // Expect the default, hard coding the value to act as an alert if default is changed in edge project - expectedValue := 180 * time.Minute - - // Set the env variable - _ = os.Setenv(varName, fmt.Sprintf("%.0f", expectedValue.Minutes())) - - // Check that the value matches - actualValue, _ := GetZitiEdgeRouterEnrollmentDuration() - assert.Equal(t, expectedValue, actualValue) -} - -func TestGetZitiEdgeCtrlPortWhenSet(t *testing.T) { - // Setup - varName := "ZITI_EDGE_CONTROLLER_PORT" + varName := "ZITI_CTRL_EDGE_ADVERTISED_PORT" expectedValue := "1234" // Set the env variable _ = os.Setenv(varName, expectedValue) // Check that the value matches - actualValue, _ := GetZitiEdgeCtrlAdvertisedPort() + actualValue, _ := GetCtrlEdgeAdvertisedPort() + assert.Equal(t, expectedValue, actualValue) +} + +func TestGetEdgeIdentityEnrollmentDurationWhenSet(t *testing.T) { + // Setup + varName := "ZITI_EDGE_IDENTITY_ENROLLMENT_DURATION" + expectedValue := 5 * time.Minute + + // Set the env variable + _ = os.Setenv(varName, fmt.Sprintf("%.0f", expectedValue.Minutes())) + + // Check that the value matches + actualValue, _ := GetCtrlEdgeIdentityEnrollmentDuration() + assert.Equal(t, expectedValue, actualValue) +} + +/* Ensure that the default value is returned even if the environment variable is set but is blank. */ +func TestGetEdgeIdentityEnrollmentDurationWhenSetToBlank(t *testing.T) { + // Setup + varName := "ZITI_EDGE_IDENTITY_ENROLLMENT_DURATION" + // Expect the default, hard coding the value to act as an alert if default is changed in edge project + expectedValue := 180 * time.Minute + + // Set the env variable + _ = os.Setenv(varName, "") + + // Check that the value matches + actualValue, _ := GetCtrlEdgeIdentityEnrollmentDuration() + assert.Equal(t, expectedValue, actualValue) +} + +func TestGetEdgeIdentityEnrollmentDurationWhenNotSet(t *testing.T) { + // Setup + varName := "ZITI_EDGE_IDENTITY_ENROLLMENT_DURATION" + // Expect the default, hard coding the value to act as an alert if default is changed in edge project + expectedValue := 180 * time.Minute + + // Set the env variable + _ = os.Setenv(varName, fmt.Sprintf("%.0f", expectedValue.Minutes())) + + // Check that the value matches + actualValue, _ := GetCtrlEdgeIdentityEnrollmentDuration() + assert.Equal(t, expectedValue, actualValue) +} + +func TestGetEdgeRouterEnrollmentDurationWhenSet(t *testing.T) { + // Setup + varName := "ZITI_EDGE_ROUTER_ENROLLMENT_DURATION" + expectedValue := 5 * time.Minute + + // Set the env variable + _ = os.Setenv(varName, fmt.Sprintf("%.0f", expectedValue.Minutes())) + + // Check that the value matches + actualValue, _ := GetCtrlEdgeRouterEnrollmentDuration() + assert.Equal(t, expectedValue, actualValue) +} + +/* Ensure that the default value is returned even if the environment variable is set but is blank. */ +func TestGetEdgeRouterEnrollmentDurationWhenSetToBlank(t *testing.T) { + // Setup + varName := "ZITI_EDGE_ROUTER_ENROLLMENT_DURATION" + // Expect the default, hard coding the value to act as an alert if default is changed in edge project + expectedValue := 180 * time.Minute + + // Set the env variable + _ = os.Setenv(varName, "") + + // Check that the value matches + actualValue, _ := GetCtrlEdgeRouterEnrollmentDuration() + assert.Equal(t, expectedValue, actualValue) +} + +func TestGetEdgeRouterEnrollmentDurationWhenNotSet(t *testing.T) { + // Setup + varName := "ZITI_EDGE_ROUTER_ENROLLMENT_DURATION" + // Expect the default, hard coding the value to act as an alert if default is changed in edge project + expectedValue := 180 * time.Minute + + // Set the env variable + _ = os.Setenv(varName, fmt.Sprintf("%.0f", expectedValue.Minutes())) + + // Check that the value matches + actualValue, _ := GetCtrlEdgeRouterEnrollmentDuration() assert.Equal(t, expectedValue, actualValue) } diff --git a/ziti/constants/constants.go b/ziti/constants/constants.go index 3aacff84d..ce746b9fe 100644 --- a/ziti/constants/constants.go +++ b/ziti/constants/constants.go @@ -39,74 +39,74 @@ const ( DefaultZitiEdgeRouterListenerBindPort = "10080" DefaultGetSessionTimeout = 60 * time.Second - DefaultZitiEdgeRouterPort = "3022" - - DefaultZitiControllerName = "controller" - DefaultZitiEdgeAPIPort = "1280" - DefaultZitiEdgeListenerHost = "0.0.0.0" - DefaultZitiControllerListenerAddress = "0.0.0.0" - DefaultZitiControllerPort = "6262" + DefaultZitiEdgeRouterPort = "3022" + DefaultCtrlEdgeAdvertisedPort = "1280" + DefaultCtrlListenerAddress = "0.0.0.0" + DefaultCtrlListenerPort = "6262" ) // Env Var Constants const ( - ZitiHomeVarName = "ZITI_HOME" - ZitiHomeVarDescription = "Root home directory for Ziti related files" - ZitiCtrlNameVarName = "ZITI_CONTROLLER_NAME" - ZitiCtrlNameVarDescription = "The name of the Ziti Controller" - ZitiCtrlPortVarName = "ZITI_CTRL_PORT" - ZitiCtrlPortVarDescription = "The port of the Ziti Controller" - ZitiEdgeRouterRawNameVarName = "ZITI_EDGE_ROUTER_RAWNAME" - ZitiEdgeRouterRawNameVarDescription = "The Edge Router Raw Name" - ZitiEdgeRouterPortVarName = "ZITI_EDGE_ROUTER_PORT" - ZitiEdgeRouterPortVarDescription = "Port of the Ziti Edge Router" - ZitiEdgeCtrlIdentityCertVarName = "ZITI_EDGE_CTRL_IDENTITY_CERT" - ZitiEdgeCtrlIdentityCertVarDescription = "Path to Identity Cert for Ziti Edge Controller" - ZitiEdgeCtrlIdentityServerCertVarName = "ZITI_EDGE_CTRL_IDENTITY_SERVER_CERT" - ZitiEdgeCtrlIdentityServerCertVarDescription = "Path to Identity Server Cert for Ziti Edge Controller" - ZitiEdgeCtrlIdentityKeyVarName = "ZITI_EDGE_CTRL_IDENTITY_KEY" - ZitiEdgeCtrlIdentityKeyVarDescription = "Path to Identity Key for Ziti Edge Controller" - ZitiEdgeCtrlIdentityCAVarName = "ZITI_EDGE_CTRL_IDENTITY_CA" - ZitiEdgeCtrlIdentityCAVarDescription = "Path to Identity CA for Ziti Edge Controller" - ZitiCtrlIdentityCertVarName = "ZITI_CTRL_IDENTITY_CERT" - ZitiCtrlIdentityCertVarDescription = "Path to Identity Cert for Ziti Controller" - ZitiCtrlIdentityServerCertVarName = "ZITI_CTRL_IDENTITY_SERVER_CERT" - ZitiCtrlIdentityServerCertVarDescription = "Path to Identity Server Cert for Ziti Controller" - ZitiCtrlIdentityKeyVarName = "ZITI_CTRL_IDENTITY_KEY" - ZitiCtrlIdentityKeyVarDescription = "Path to Identity Key for Ziti Controller" - ZitiCtrlIdentityCAVarName = "ZITI_CTRL_IDENTITY_CA" - ZitiCtrlIdentityCAVarDescription = "Path to Identity CA for Ziti Controller" - ZitiSigningCertVarName = "ZITI_SIGNING_CERT" - ZitiSigningCertVarDescription = "Path to the Ziti Signing Cert" - ZitiSigningKeyVarName = "ZITI_SIGNING_KEY" - ZitiSigningKeyVarDescription = "Path to the Ziti Signing Key" - ZitiRouterIdentityCertVarName = "ZITI_ROUTER_IDENTITY_CERT" - ZitiRouterIdentityCertVarDescription = "Path to Identity Cert for Ziti Router" - ZitiRouterIdentityServerCertVarName = "ZITI_ROUTER_IDENTITY_SERVER_CERT" - ZitiRouterIdentityServerCertVarDescription = "Path to Identity Server Cert for Ziti Router" - ZitiRouterIdentityKeyVarName = "ZITI_ROUTER_IDENTITY_KEY" - ZitiRouterIdentityKeyVarDescription = "Path to Identity Key for Ziti Router" - ZitiRouterIdentityCAVarName = "ZITI_ROUTER_IDENTITY_CA" - ZitiRouterIdentityCAVarDescription = "Path to Identity CA for Ziti Router" - ZitiCtrlListenerAddressVarName = "ZITI_CTRL_LISTENER_ADDRESS" - ZitiCtrlListenerAddressVarDescription = "The Ziti Controller Listener Address" - ZitiCtrlAdvertisedAddressVarName = "ZITI_CTRL_ADVERTISED_ADDRESS" - ZitiCtrlAdvertisedAddressVarDescription = "The Ziti Controller Advertised Address" - ZitiEdgeCtrlListenerHostPortVarName = "ZITI_CTRL_EDGE_LISTENER_HOST_PORT" - ZitiEdgeCtrlListenerHostPortVarDescription = "Host and port of the Ziti Edge Controller Listener" - ZitiEdgeCtrlAdvertisedHostPortVarName = "ZITI_EDGE_CTRL_ADVERTISED_HOST_PORT" - ZitiEdgeCtrlAdvertisedHostPortVarDescription = "Host and port of the Ziti Edge Controller API" - ZitiEdgeCtrlAdvertisedPortVarName = "ZITI_EDGE_CONTROLLER_PORT" - ZitiEdgeCtrlAdvertisedPortVarDescription = "The advertised port of the edge controller" - ZitiEdgeIdentityEnrollmentDurationVarName = "ZITI_EDGE_IDENTITY_ENROLLMENT_DURATION" - ZitiEdgeIdentityEnrollmentDurationVarDescription = "The identity enrollment duration in minutes" - ZitiEdgeRouterEnrollmentDurationVarName = "ZITI_EDGE_ROUTER_ENROLLMENT_DURATION" - ZitiEdgeRouterEnrollmentDurationVarDescription = "The router enrollment duration in minutes" - ExternalDNSVarName = "EXTERNAL_DNS" - ZitiEdgeRouterIPOverrideVarName = "ZITI_EDGE_ROUTER_IP_OVERRIDE" - ZitiEdgeRouterIPOverrideVarDescription = "Override the default edge router IP with a custom IP, this IP will also be added to the PKI" - ZitiEdgeRouterAdvertisedHostVarName = "ZITI_EDGE_ROUTER_ADVERTISED_HOST" - ZitiEdgeRouterAdvertisedHostVarDescription = "The advertised host of the router" - ZitiEdgeRouterListenerBindPortVarName = "ZITI_EDGE_ROUTER_LISTENER_BIND_PORT" - ZitiEdgeRouterListenerBindPortVarDescription = "The port a public router will advertise on" + ZitiHomeVarName = "ZITI_HOME" + ZitiHomeVarDescription = "Root home directory for Ziti related files" + + PkiCtrlCertVarName = "ZITI_PKI_CTRL_CERT" + PkiCtrlCertVarDescription = "Path to Identity Cert for Ziti Controller" + PkiCtrlServerCertVarName = "ZITI_PKI_CTRL_SERVER_CERT" + PkiCtrlServerCertVarDescription = "Path to Identity Server Cert for Ziti Controller" + PkiCtrlKeyVarName = "ZITI_PKI_CTRL_KEY" + PkiCtrlKeyVarDescription = "Path to Identity Key for Ziti Controller" + PkiCtrlCAVarName = "ZITI_PKI_CTRL_CA" + PkiCtrlCAVarDescription = "Path to Identity CA for Ziti Controller" + CtrlListenerAddressVarName = "ZITI_CTRL_LISTENER_ADDRESS" + CtrlListenerAddressVarDescription = "The address routers will use to connect to the Ziti Controller" + CtrlListenerPortVarName = "ZITI_CTRL_LISTENER_PORT" + CtrlListenerPortVarDescription = "The port routers will use to connect to the Ziti Controller" + CtrlEdgeApiAddressVarName = "ZITI_CTRL_EDGE_API_ADDRESS" + CtrlEdgeApiAddressVarDescription = "The address for the controller's API plane" + CtrlEdgeApiPortVarName = "ZITI_CTRL_EDGE_API_PORT" + CtrlEdgeApiPortVarDescription = "The port for the controller's API plane" + PkiSignerCertVarName = "ZITI_PKI_SIGNER_CERT" + PkiSignerCertVarDescription = "Path to the Ziti Signing Cert" + PkiSignerKeyVarName = "ZITI_PKI_SIGNER_KEY" + PkiSignerKeyVarDescription = "Path to the Ziti Signing Key" + CtrlEdgeIdentityEnrollmentDurationVarName = "ZITI_EDGE_IDENTITY_ENROLLMENT_DURATION" + CtrlEdgeIdentityEnrollmentDurationVarDescription = "The identity enrollment duration in minutes" + CtrlEdgeRouterEnrollmentDurationVarName = "ZITI_EDGE_ROUTER_ENROLLMENT_DURATION" + CtrlEdgeRouterEnrollmentDurationVarDescription = "The router enrollment duration in minutes" + CtrlEdgeInterfaceAddressVarName = "ZITI_CTRL_EDGE_INTERFACE_ADDRESS" + CtrlEdgeInterfaceAddressVarDescription = "The interface address to bind the controller's edge listener to" + CtrlEdgeInterfacePortVarName = "ZITI_CTRL_EDGE_INTERFACE_PORT" + CtrlEdgeInterfacePortVarDescription = "The interface port to bind the controller's edge listener to" + CtrlEdgeAdvertisedAddressVarName = "ZITI_CTRL_EDGE_ADVERTISED_ADDRESS" + CtrlEdgeAdvertisedAddressVarDescription = "The publicly addressable controller address value" + CtrlEdgeAdvertisedPortVarName = "ZITI_CTRL_EDGE_ADVERTISED_PORT" + CtrlEdgeAdvertisedPortVarDescription = "The publicly addressable controller port value" + CtrlPkiEdgeCertVarName = "ZITI_PKI_EDGE_CERT" + CtrlPkiEdgeCertVarDescription = "Path to Identity Cert for Ziti Edge Controller" + CtrlPkiEdgeServerCertVarName = "ZITI_PKI_EDGE_SERVER_CERT" + CtrlPkiEdgeServerCertVarDescription = "Path to Identity Server Cert for Ziti Edge Controller" + CtrlPkiEdgeKeyVarName = "ZITI_PKI_EDGE_KEY" + CtrlPkiEdgeKeyVarDescription = "Path to Identity Key for Ziti Edge Controller" + CtrlPkiEdgeCAVarName = "ZITI_PKI_EDGE_CA" + CtrlPkiEdgeCAVarDescription = "Path to Identity CA for Ziti Edge Controller" + + ZitiEdgeRouterNameVarName = "ZITI_EDGE_ROUTER_NAME" + ZitiEdgeRouterNameVarDescription = "The Edge Router Name" + ZitiEdgeRouterPortVarName = "ZITI_EDGE_ROUTER_PORT" + ZitiEdgeRouterPortVarDescription = "Port of the Ziti Edge Router" + ZitiRouterIdentityCertVarName = "ZITI_ROUTER_IDENTITY_CERT" + ZitiRouterIdentityCertVarDescription = "Path to Identity Cert for Ziti Router" + ZitiRouterIdentityServerCertVarName = "ZITI_ROUTER_IDENTITY_SERVER_CERT" + ZitiRouterIdentityServerCertVarDescription = "Path to Identity Server Cert for Ziti Router" + ZitiRouterIdentityKeyVarName = "ZITI_ROUTER_IDENTITY_KEY" + ZitiRouterIdentityKeyVarDescription = "Path to Identity Key for Ziti Router" + ZitiRouterIdentityCAVarName = "ZITI_ROUTER_IDENTITY_CA" + ZitiRouterIdentityCAVarDescription = "Path to Identity CA for Ziti Router" + ZitiEdgeRouterIPOverrideVarName = "ZITI_EDGE_ROUTER_IP_OVERRIDE" + ZitiEdgeRouterIPOverrideVarDescription = "Override the default edge router IP with a custom IP, this IP will also be added to the PKI" + ZitiEdgeRouterAdvertisedHostVarName = "ZITI_EDGE_ROUTER_ADVERTISED_HOST" + ZitiEdgeRouterAdvertisedHostVarDescription = "The advertised host of the router" + ZitiEdgeRouterListenerBindPortVarName = "ZITI_EDGE_ROUTER_LISTENER_BIND_PORT" + ZitiEdgeRouterListenerBindPortVarDescription = "The port a public router will advertise on" ) diff --git a/ziti/util/dirs.go b/ziti/util/dirs.go index 597ca5e3f..9c28744ce 100644 --- a/ziti/util/dirs.go +++ b/ziti/util/dirs.go @@ -37,7 +37,7 @@ func HomeDir() string { } func ConfigDir() (string, error) { - path := os.Getenv("ZITI_HOME") + path := os.Getenv("ZITI_CONFIG_DIR") if path != "" { return path, nil } @@ -55,19 +55,6 @@ func ConfigDir() (string, error) { return path, nil } -func FabricConfigDir() (string, error) { - h, err := ConfigDir() - if err != nil { - return "", err - } - path := filepath.Join(h, "fabric") - err = os.MkdirAll(path, DefaultWritePermissions) - if err != nil { - return "", err - } - return path, nil -} - func ZitiAppConfigDir(zitiApp string) (string, error) { h, err := ConfigDir() if err != nil { diff --git a/ziti/util/rest.go b/ziti/util/rest.go index 9d2416f7b..d638a18bb 100644 --- a/ziti/util/rest.go +++ b/ziti/util/rest.go @@ -377,6 +377,10 @@ func UnTargz(tarball, target string, onlyFiles []string) error { return err } continue + } else { + if err = os.Remove(path); err != nil { + fmt.Printf("error removing [%s] (%v)", path, err) + } } file, err := os.OpenFile(path, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, info.Mode()) @@ -862,10 +866,16 @@ func EdgeControllerGetManagementApiBasePath(host string, cert string) string { client.SetRootCertificate(cert) } - resp, err := client.R().Get("/version") + // check v1 path first + resp, err := client.R().Get("/edge/client/v1/version") if err != nil || resp.StatusCode() != http.StatusOK { - return host + // if v1 path fails, fall back to removed /version path + resp, err = client.R().Get("/version") + + if err != nil || resp.StatusCode() != http.StatusOK { + return host + } } data, err := gabs.ParseJSON(resp.Body()) diff --git a/zititest/go.mod b/zititest/go.mod index a814a754e..f7d8669d0 100644 --- a/zititest/go.mod +++ b/zititest/go.mod @@ -8,22 +8,22 @@ require ( github.com/Jeffail/gabs v1.4.0 github.com/Jeffail/gabs/v2 v2.7.0 github.com/michaelquigley/pfxlog v0.6.10 - github.com/openziti/channel/v2 v2.0.80 - github.com/openziti/edge v0.24.326 + github.com/openziti/channel/v2 v2.0.81 + github.com/openziti/edge v0.24.345 github.com/openziti/fablab v0.4.52 - github.com/openziti/fabric v0.23.35 - github.com/openziti/foundation/v2 v2.0.25 - github.com/openziti/identity v1.0.56 - github.com/openziti/sdk-golang v0.20.58 - github.com/openziti/storage v0.2.7 - github.com/openziti/transport/v2 v2.0.90 + github.com/openziti/fabric v0.23.39 + github.com/openziti/foundation/v2 v2.0.26 + github.com/openziti/identity v1.0.57 + github.com/openziti/sdk-golang v0.20.67 + github.com/openziti/storage v0.2.8 + github.com/openziti/transport/v2 v2.0.91 github.com/openziti/ziti v0.28.0 github.com/pkg/errors v0.9.1 github.com/sirupsen/logrus v1.9.3 github.com/spf13/cobra v1.7.0 github.com/stretchr/testify v1.8.4 go.etcd.io/bbolt v1.3.7 - golang.org/x/net v0.10.0 + golang.org/x/net v0.11.0 google.golang.org/protobuf v1.30.0 gopkg.in/yaml.v3 v3.0.1 ) @@ -63,14 +63,14 @@ require ( github.com/go-logr/stdr v1.2.2 // indirect github.com/go-ole/go-ole v1.2.6 // indirect github.com/go-openapi/analysis v0.21.4 // indirect - github.com/go-openapi/errors v0.20.3 // indirect + github.com/go-openapi/errors v0.20.4 // indirect github.com/go-openapi/jsonpointer v0.19.6 // indirect github.com/go-openapi/jsonreference v0.20.2 // indirect github.com/go-openapi/loads v0.21.2 // indirect github.com/go-openapi/runtime v0.26.0 // indirect github.com/go-openapi/spec v0.20.9 // indirect github.com/go-openapi/strfmt v0.21.7 // indirect - github.com/go-openapi/swag v0.22.3 // indirect + github.com/go-openapi/swag v0.22.4 // indirect github.com/go-openapi/validate v0.22.1 // indirect github.com/go-resty/resty/v2 v2.7.0 // indirect github.com/golang-jwt/jwt v3.2.2+incompatible // indirect @@ -100,7 +100,7 @@ require ( github.com/josharian/native v1.1.0 // indirect github.com/kataras/go-events v0.0.3 // indirect github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect - github.com/klauspost/compress v1.16.5 // indirect + github.com/klauspost/compress v1.16.6 // indirect github.com/kr/fs v0.1.0 // indirect github.com/kyokomi/emoji/v2 v2.2.12 // indirect github.com/lucasb-eyer/go-colorful v1.2.0 // indirect @@ -116,7 +116,7 @@ require ( github.com/mdlayher/socket v0.4.1 // indirect github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect github.com/michaelquigley/figlet v0.0.0-20191015203154-054d06db54b4 // indirect - github.com/miekg/dns v1.1.54 // indirect + github.com/miekg/dns v1.1.55 // indirect github.com/miekg/pkcs11 v1.1.1 // indirect github.com/mitchellh/go-ps v1.0.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect @@ -126,11 +126,11 @@ require ( github.com/oliveagle/jsonpath v0.0.0-20180606110733-2e52cf6e6852 // indirect github.com/opentracing/opentracing-go v1.2.0 // indirect github.com/openziti/agent v1.0.14 // indirect - github.com/openziti/edge-api v0.25.25 // indirect + github.com/openziti/edge-api v0.25.29 // indirect github.com/openziti/jwks v1.0.3 // indirect - github.com/openziti/metrics v1.2.26 // indirect - github.com/openziti/runzmd v1.0.25 // indirect - github.com/openziti/secretstream v0.1.8 // indirect + github.com/openziti/metrics v1.2.27 // indirect + github.com/openziti/runzmd v1.0.26 // indirect + github.com/openziti/secretstream v0.1.9 // indirect github.com/openziti/x509-claims v1.0.3 // indirect github.com/openziti/xweb/v2 v2.0.2 // indirect github.com/openziti/ziti-db-explorer v1.1.1 // indirect @@ -170,14 +170,14 @@ require ( go.opentelemetry.io/otel v1.16.0 // indirect go.opentelemetry.io/otel/metric v1.16.0 // indirect go.opentelemetry.io/otel/trace v1.16.0 // indirect - golang.org/x/crypto v0.9.0 // indirect + golang.org/x/crypto v0.10.0 // indirect golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 // indirect - golang.org/x/image v0.7.0 // indirect + golang.org/x/image v0.8.0 // indirect golang.org/x/mod v0.8.0 // indirect - golang.org/x/sync v0.2.0 // indirect - golang.org/x/sys v0.8.0 // indirect - golang.org/x/term v0.8.0 // indirect - golang.org/x/text v0.9.0 // indirect + golang.org/x/sync v0.3.0 // indirect + golang.org/x/sys v0.9.0 // indirect + golang.org/x/term v0.9.0 // indirect + golang.org/x/text v0.10.0 // indirect golang.org/x/tools v0.6.0 // indirect gopkg.in/AlecAivazis/survey.v1 v1.8.7 // indirect gopkg.in/ini.v1 v1.66.2 // indirect diff --git a/zititest/go.sum b/zititest/go.sum index a5ff3437f..c90ccf65b 100644 --- a/zititest/go.sum +++ b/zititest/go.sum @@ -228,8 +228,8 @@ github.com/go-openapi/analysis v0.21.4/go.mod h1:4zQ35W4neeZTqh3ol0rv/O8JBbka9Qy 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.2/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M= -github.com/go-openapi/errors v0.20.3 h1:rz6kiC84sqNQoqrtulzaL/VERgkoCyB6WdEkc2ujzUc= -github.com/go-openapi/errors v0.20.3/go.mod h1:Z3FlZ4I8jEGxjUK+bugx3on2mIAk4txuAOhlsB1FSgk= +github.com/go-openapi/errors v0.20.4 h1:unTcVm6PispJsMECE3zWgvG4xTiKda1LIR5rCRWLG6M= +github.com/go-openapi/errors v0.20.4/go.mod h1:Z3FlZ4I8jEGxjUK+bugx3on2mIAk4txuAOhlsB1FSgk= github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE= @@ -255,8 +255,9 @@ github.com/go-openapi/strfmt v0.21.7/go.mod h1:adeGTkxE44sPyLk0JV235VQAO/ZXUr8KA github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= github.com/go-openapi/swag v0.19.15/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= github.com/go-openapi/swag v0.21.1/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= -github.com/go-openapi/swag v0.22.3 h1:yMBqmnQ0gyZvEb/+KzuWZOXgllrXT4SADYbvDaXHv/g= github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= +github.com/go-openapi/swag v0.22.4 h1:QLMzNJnMGPRNDCbySlcj1x01tzU8/9LTTL9hZZZogBU= +github.com/go-openapi/swag v0.22.4/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= github.com/go-openapi/validate v0.22.1 h1:G+c2ub6q47kfX1sOBLwIQwzBVt8qmOAARyo/9Fqs9NU= github.com/go-openapi/validate v0.22.1/go.mod h1:rjnrwK57VJ7A8xqfpAOEKRH8yQSGUriMu5/zuPSQ1hg= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= @@ -491,8 +492,8 @@ github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= -github.com/klauspost/compress v1.16.5 h1:IFV2oUNUzZaz+XyusxpLzpzS8Pt5rh0Z16For/djlyI= -github.com/klauspost/compress v1.16.5/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= +github.com/klauspost/compress v1.16.6 h1:91SKEy4K37vkp255cJ8QesJhjyRO0hn9i9G0GoUwLsk= +github.com/klauspost/compress v1.16.6/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/kolo/xmlrpc v0.0.0-20200310150728-e0350524596b/go.mod h1:o03bZfuBwAXHetKXuInt4S7omeXUu62/A845kiycsSQ= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= @@ -579,8 +580,8 @@ github.com/michaelquigley/pfxlog v0.6.10 h1:IbC/H3MmSDcPlQHF1UZPQU13Dkrs0+ycWRyQ github.com/michaelquigley/pfxlog v0.6.10/go.mod h1:gEiNTfKEX6cJHSwRpOuqBpc8oYrlhMiDK/xMk/gV7D0= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/miekg/dns v1.1.31/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM= -github.com/miekg/dns v1.1.54 h1:5jon9mWcb0sFJGpnI99tOMhCPyJ+RPVz5b63MQG0VWI= -github.com/miekg/dns v1.1.54/go.mod h1:uInx36IzPl7FYnDcMeVWxj9byh7DutNykX4G9Sj60FY= +github.com/miekg/dns v1.1.55 h1:GoQ4hpsj0nFLYe+bWiCToyrBEJXkQfOOIvFGFy0lEgo= +github.com/miekg/dns v1.1.55/go.mod h1:uInx36IzPl7FYnDcMeVWxj9byh7DutNykX4G9Sj60FY= github.com/miekg/pkcs11 v1.1.1 h1:Ugu9pdy6vAYku5DEpVWVFPYnzV+bxB+iRdbuFSu7TvU= github.com/miekg/pkcs11 v1.1.1/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs= github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= @@ -640,34 +641,34 @@ github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYr github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw= github.com/openziti/agent v1.0.14 h1:OTYhj2HeIlFwaFNcVT5BlYf7s4xa0TNmhnjmBpN8Afg= github.com/openziti/agent v1.0.14/go.mod h1:zfm53+PVWoGFzjGGgQdKby5749G6VRYHe+eQJmoVKy4= -github.com/openziti/channel/v2 v2.0.80 h1:1gDikwcVvhRKs+CO8OyUHMSJWVJarCm5+OmffZ4gPCU= -github.com/openziti/channel/v2 v2.0.80/go.mod h1:U1KSHZXWlg8VelsZ55+ZGiARYWh+XbJbD7AfN0NXUdQ= -github.com/openziti/edge v0.24.326 h1:Y5Z3DGac2ghXivh04S/3HgTymp1UliTaSlLn5fo3qdg= -github.com/openziti/edge v0.24.326/go.mod h1:vI2HZMZa+PdiIjf25xpg19lR32X+ouLbY3idOIw+Dac= -github.com/openziti/edge-api v0.25.25 h1:1S7L9JsvXuzd8nULZEPNgafPfhnHQY4Hhqj8B00CKTw= -github.com/openziti/edge-api v0.25.25/go.mod h1:aDUHHxOGtxFXnoDaTXpNF6gq+tbDkWCURP5yaEJbdm0= +github.com/openziti/channel/v2 v2.0.81 h1:YtFMJz4pMhhOH92zZbOKAvx/l5zaRz5TQff0lTa5G6w= +github.com/openziti/channel/v2 v2.0.81/go.mod h1:d+2+i51uXi8J6M8OsazLJg1OzSPmL+sOyzdiRUmra3I= +github.com/openziti/edge v0.24.345 h1:7anwwljort9FsriHoBAiz6DOOkPJV2XCzZJLmn/TxFo= +github.com/openziti/edge v0.24.345/go.mod h1:pjU6bCSfaAVQLajeKB/ypGYoeZnIuHw7Y75kX37WHTw= +github.com/openziti/edge-api v0.25.29 h1:DbZ0GKpch9ik+XnC0qoP1dOg1AmgUEeWH4VIyOIehrQ= +github.com/openziti/edge-api v0.25.29/go.mod h1:mqYquh1RYvHjV/M9MGO4Ng0Xq9ixAH8o8cT5kw5XCWY= github.com/openziti/fablab v0.4.52 h1:X5+NaRnfPxbzhxUh9b4IQmVNVgYWFf8/Ck2sKNz77ho= github.com/openziti/fablab v0.4.52/go.mod h1:aF8Fu3C8hnnaOJyAZz3AXGY4cMxQyBLhoIlSRJ/VVpc= -github.com/openziti/fabric v0.23.35 h1:SxdMC88E5PCm7SoE8q0q8yOaO2fC1RiJES/sOYymVe4= -github.com/openziti/fabric v0.23.35/go.mod h1:eFG042f6bv/vZSOmp48pVAqEntCfkkMJCVAbNG9GHno= -github.com/openziti/foundation/v2 v2.0.25 h1:tGb9wdu6KCpO49RJ3HX2ClOVHf8gdntplIh/7CEVaM4= -github.com/openziti/foundation/v2 v2.0.25/go.mod h1:EOqea8Q1wXd4hS9MxFYM6ngDgenKGxz8c+CJ8Svr7BI= -github.com/openziti/identity v1.0.56 h1:h8SzatjWa3TCpIG6/holKUTHSKtNAJ1MuK5CCY31ZOw= -github.com/openziti/identity v1.0.56/go.mod h1:5h08wngbQjENt6sWPp+GyWpqNkeSPwMdDFPFONf6EBE= +github.com/openziti/fabric v0.23.39 h1:t6npkfBsPr+8GvF9X/rTLHxGsce5FTa4NoA80MInxYc= +github.com/openziti/fabric v0.23.39/go.mod h1:px2zUzQrgObmv6sdXgGJ028Wr45aGcgpFvfIP/qgDFo= +github.com/openziti/foundation/v2 v2.0.26 h1:RISGM97aIFnnEkxrcVsO6fnGg9W4ByydSnqWAVkJAqY= +github.com/openziti/foundation/v2 v2.0.26/go.mod h1:ngdQq0KLGIDfzkQQzu1BQSMLNrsBUXdziGvsJns4cFM= +github.com/openziti/identity v1.0.57 h1:tVFYGMVFINKWi4RV75yEz7hbDuRPqRnG+AiFAEtvXHQ= +github.com/openziti/identity v1.0.57/go.mod h1:cwkBpiIy1C4S6r+dD0jPKq9mS4aj7NuABt1WJwxHon8= github.com/openziti/jwks v1.0.3 h1:hf8wkb+Cg4nH/HM0KROFd7u+C3DkRVcFZJ7tDV+4icc= github.com/openziti/jwks v1.0.3/go.mod h1:t4xxq8vlXGsPn29kiQVnZBBDDnEoOFqtJoHibkJunQQ= -github.com/openziti/metrics v1.2.26 h1:8q93bK1MYAdR9ODr0qNAJ1/BQpFtHYdxZiH0Fc9LLo8= -github.com/openziti/metrics v1.2.26/go.mod h1:Z1c9pNHQr+yZODDsOeim93rYg5Hw1kPsuHi3zdy70dA= -github.com/openziti/runzmd v1.0.25 h1:/6LVurAnU8Hl4Tcm0FcncNicTIo3gwu2eMCiViPqzNQ= -github.com/openziti/runzmd v1.0.25/go.mod h1:pYnqjgH8/geMdzU8OIxamU8RlRdRaOh00mWBxDoXPDo= -github.com/openziti/sdk-golang v0.20.58 h1:cHyzEQiZSsaeJbN/lYqAY0i5fDlt9wlFH7LtG+0qFwE= -github.com/openziti/sdk-golang v0.20.58/go.mod h1:L6mGhnsxwDuVBE7ByCVLf2kPymf5l9l6WRUMA3SfZeo= -github.com/openziti/secretstream v0.1.8 h1:AgPHLDuXTiM1apHQmBvwvSW1vbQqAm7wUJDHqkQ/6Nk= -github.com/openziti/secretstream v0.1.8/go.mod h1:qcF8EmSX5SAT8k2pzsDI4bWugopv9AA+ltgWDrcAAEw= -github.com/openziti/storage v0.2.7 h1:rQVVclnkCZyr4XXKMypIJf46HFGJX5KEYWEycUhWvtg= -github.com/openziti/storage v0.2.7/go.mod h1:bGhUs/0XDsEJnTtNTpFAIh1X4lfdKvHu0m+8Z1TFVyM= -github.com/openziti/transport/v2 v2.0.90 h1:QoddlajGdyOZZDTxhgapkd3wucosTVGJn8z5Pt3ltOM= -github.com/openziti/transport/v2 v2.0.90/go.mod h1:q8zNDI7lYqA4flQVJwJZQg8HJVNcG7kIFLnH9qfeHDc= +github.com/openziti/metrics v1.2.27 h1:Dw/FSC+QvyqkDmLeSsxzCRD0aFPwgivwQyQsxzlAgoQ= +github.com/openziti/metrics v1.2.27/go.mod h1:mhP2c8MTGL0C5H8yAsNwBq88SW1C3Mx1ICVO6heMbJQ= +github.com/openziti/runzmd v1.0.26 h1:bWJhTD0jwkRi01e/fY72UbJ+x4iNEzE2Lx5chNp1sCU= +github.com/openziti/runzmd v1.0.26/go.mod h1:Lj1MpR8DXhVKxw6MdaSU0bD6Wh8CwzNpEw5Qm/NSWfM= +github.com/openziti/sdk-golang v0.20.67 h1:atesqk/yUAM1sBe5zaMwKrRBYLzeEtUz7BQn72hFyR8= +github.com/openziti/sdk-golang v0.20.67/go.mod h1:zieqsVAB/kawb/Ske7zkArUG2TGUIOdcHyVh79NcnBA= +github.com/openziti/secretstream v0.1.9 h1:mNCMr9oYQ4JAfdU4iU79i3si4vqVVsErzrhXuKC7R3M= +github.com/openziti/secretstream v0.1.9/go.mod h1:tq0XVUwFAT0TwfBpILp4KaeEnasduNTUixOIrmUZUGA= +github.com/openziti/storage v0.2.8 h1:Rbnj6LKfcdR644kXrS4bF0ot+z17zDGCiUifd1eOvZ0= +github.com/openziti/storage v0.2.8/go.mod h1:Cd1YuhqSLbVI0vaujTQl/cHgPCECapLGh/s4bMgKczM= +github.com/openziti/transport/v2 v2.0.91 h1:eEWRSoy9+tDf6K+jJcl5TSHm6GX7IKiBQg8XxmDyELQ= +github.com/openziti/transport/v2 v2.0.91/go.mod h1:FDGkg110LTdmz4Kp1zucomvc++ld7UKXFfNWBTwQIlQ= github.com/openziti/x509-claims v1.0.3 h1:HNdQ8Nf1agB3lBs1gahcO6zfkeS4S5xoQ2/PkY4HRX0= github.com/openziti/x509-claims v1.0.3/go.mod h1:Z0WIpBm6c4ecrpRKrou6Gk2wrLWxJO/+tuUwKh8VewE= github.com/openziti/xweb/v2 v2.0.2 h1:XYlVFriTq/U1wcUrc+XPnWJGhXh9NJPhtQ7+r3aC0cU= @@ -912,8 +913,8 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= -golang.org/x/crypto v0.9.0 h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g= -golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0= +golang.org/x/crypto v0.10.0 h1:LKqV2xt9+kDzSTfOhx4FrkEBcMrAgHSYgzywV9zcGmM= +golang.org/x/crypto v0.10.0/go.mod h1:o4eNf7Ede1fv+hwOwZsTHl9EsPFO6q6ZvYR8vYfY45I= 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= @@ -930,8 +931,8 @@ golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMx golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/image v0.0.0-20191206065243-da761ea9ff43/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/image v0.7.0 h1:gzS29xtG1J5ybQlv0PuyfE3nmc6R4qB73m6LUUmvFuw= -golang.org/x/image v0.7.0/go.mod h1:nd/q4ef1AKKYl/4kft7g+6UyGbdiqWqTP1ZAbRoV7Rg= +golang.org/x/image v0.8.0 h1:agUcRXV/+w6L9ryntYYsF2x9fQTMd4T8fiiYXAVW6Jg= +golang.org/x/image v0.8.0/go.mod h1:PwLxp3opCYg4WR2WO9P0L6ESnsD6bLTWcw8zanLMVFM= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -1011,8 +1012,8 @@ golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= -golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= +golang.org/x/net v0.11.0 h1:Gi2tvZIJyBtO9SDr1q9h5hEQCp/4L2RQ+ar0qjx2oNU= +golang.org/x/net v0.11.0/go.mod h1:2L/ixqYpgIVXmeoSA/4Lu7BzTG4KIyPIryS4IsOd1oQ= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1039,8 +1040,8 @@ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI= -golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= +golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sys v0.0.0-20180606202747-9527bec2660b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180622082034-63fc586f45fe/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1124,14 +1125,15 @@ golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s= +golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/term v0.8.0 h1:n5xxQn2i3PC0yLAbjTpNT85q/Kgzcr2gIoX9OrJUols= -golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= +golang.org/x/term v0.9.0 h1:GRRCnKYhdQrD8kfRAdQ6Zcw1P0OcELxGLKJvtjVMZ28= +golang.org/x/term v0.9.0/go.mod h1:M6DEAAIenWoTxdKrOltXcmDY3rSplQUkrvaDU5FcQyo= 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= @@ -1143,8 +1145,8 @@ golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= -golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.10.0 h1:UpjohKhiEgNc0CSauXmwYftY1+LlaC75SJwh0SgCX58= +golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=