diff --git a/doc/003-local-deploy.md b/doc/003-local-deploy.md index a4d9fc2c0..306bcaef8 100644 --- a/doc/003-local-deploy.md +++ b/doc/003-local-deploy.md @@ -33,8 +33,8 @@ Before you can run the controller will initialize its configuration and database ```bash ZITI_HOME=. \ -ZITI_CTRL_LISTENER_ADDRESS=127.0.0.1 \ -ZITI_CTRL_EDGE_LISTENER_HOST_PORT=127.0.0.1:1280 \ +ZITI_CTRL_ADVERTISED_ADDRESS=127.0.0.1 \ +ZITI_CTRL_EDGE_ADVERTISED_HOST_PORT=127.0.0.1:1280 \ ZITI_EDGE_CTRL_ADVERTISED_HOST_PORT=127.0.0.1:1280 \ 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 \ diff --git a/quickstart/docker/.env b/quickstart/docker/.env index 373aa5811..17e6c43d3 100644 --- a/quickstart/docker/.env +++ b/quickstart/docker/.env @@ -10,9 +10,10 @@ ZITI_PWD= # controller name, address/port information ZITI_CTRL_NAME=ziti-controller #ZITI_CTRL_EDGE_ADVERTISED_ADDRESS=ziti-edge-controller +#ZITI_CTRL_ADVERTISED_ADDRESS=ziti-controller #ZITI_CTRL_EDGE_IP_OVERRIDE=10.10.10.10 #ZITI_CTRL_EDGE_ADVERTISED_PORT=8441 -#ZITI_CTRL_LISTENER_PORT=8440 +#ZITI_CTRL_ADVERTISED_PORT=8440 # The duration of the enrollment period (in minutes), default if not set. shown - 7days ZITI_EDGE_IDENTITY_ENROLLMENT_DURATION=10080 diff --git a/quickstart/docker/docker-compose.yml b/quickstart/docker/docker-compose.yml index 9c1eef4eb..951edf352 100644 --- a/quickstart/docker/docker-compose.yml +++ b/quickstart/docker/docker-compose.yml @@ -6,7 +6,7 @@ services: - ./.env ports: - ${ZITI_CTRL_EDGE_ADVERTISED_PORT:-1280}:${ZITI_CTRL_EDGE_ADVERTISED_PORT:-1280} - - ${ZITI_CTRL_LISTENER_PORT:-6262}:${ZITI_CTRL_LISTENER_PORT:-6262} + - ${ZITI_CTRL_ADVERTISED_PORT:-6262}:${ZITI_CTRL_ADVERTISED_PORT:-6262} environment: - ZITI_EDGE_IDENTITY_ENROLLMENT_DURATION=${ZITI_EDGE_IDENTITY_ENROLLMENT_DURATION} - ZITI_EDGE_ROUTER_ENROLLMENT_DURATION=${ZITI_EDGE_ROUTER_ENROLLMENT_DURATION} diff --git a/quickstart/docker/image/run-router-external.sh b/quickstart/docker/image/run-router-external.sh index 5faf42b0b..040511de7 100755 --- a/quickstart/docker/image/run-router-external.sh +++ b/quickstart/docker/image/run-router-external.sh @@ -57,7 +57,7 @@ if [ ! -f ${ZITI_ROUTER_ADVERTISED_ADDRESS}.jwt ]; then echo "ZITI_EDGE_ROUTER_ROLES = ${ZITI_EDGE_ROUTER_ROLES}" echo "ZITI_EDGE_ROUTER_PORT = ${ZITI_EDGE_ROUTER_PORT}" echo "ZITI_CTRL_EDGE_ADVERTISED_ADDRESS = ${ZITI_CTRL_EDGE_ADVERTISED_ADDRESS}" - echo "ZITI_CTRL_LISTENER_PORT = ${ZITI_CTRL_LISTENER_PORT}" + echo "ZITI_CTRL_ADVERTISED_PORT = ${ZITI_CTRL_ADVERTISED_PORT}" echo "ZITI_USER = ${ZITI_USER}" if [[ ! "${ZITI_PWD}" == "" ]]; then echo "ZITI_PWD = (obscured)"; fi diff --git a/quickstart/docker/image/ziti-cli-functions.sh b/quickstart/docker/image/ziti-cli-functions.sh index b7988d0cd..310b7d8e2 100644 --- a/quickstart/docker/image/ziti-cli-functions.sh +++ b/quickstart/docker/image/ziti-cli-functions.sh @@ -316,9 +316,10 @@ function setupEnvironment { # Controller Values if [[ "${ZITI_CTRL_NAME-}" == "" ]]; then export ZITI_CTRL_NAME="${ZITI_NETWORK}"; else echo "ZITI_CTRL_NAME overridden: ${ZITI_CTRL_NAME}"; fi - if [[ "${ZITI_CTRL_LISTENER_PORT-}" == "" ]]; then export ZITI_CTRL_LISTENER_PORT="6262"; else echo "ZITI_CTRL_LISTENER_PORT overridden: ${ZITI_CTRL_LISTENER_PORT}"; fi if [[ "${ZITI_CTRL_EDGE_ADVERTISED_PORT-}" == "" ]]; then export ZITI_CTRL_EDGE_ADVERTISED_PORT="1280"; else echo "ZITI_CTRL_EDGE_ADVERTISED_PORT overridden: ${ZITI_CTRL_EDGE_ADVERTISED_PORT}"; fi if [[ "${ZITI_CTRL_EDGE_ADVERTISED_ADDRESS-}" == "" ]]; then export ZITI_CTRL_EDGE_ADVERTISED_ADDRESS="${ZITI_NETWORK-}"; else echo "ZITI_CTRL_EDGE_ADVERTISED_ADDRESS overridden: ${ZITI_CTRL_EDGE_ADVERTISED_ADDRESS}"; fi + if [[ "${ZITI_CTRL_ADVERTISED_ADDRESS-}" == "" ]]; then export ZITI_CTRL_ADVERTISED_ADDRESS="${ZITI_NETWORK-}"; else echo "ZITI_CTRL_ADVERTISED_ADDRESS overridden: ${ZITI_CTRL_ADVERTISED_ADDRESS}"; fi + if [[ "${ZITI_CTRL_ADVERTISED_PORT-}" == "" ]]; then export ZITI_CTRL_ADVERTISED_PORT="6262"; else echo "ZITI_CTRL_ADVERTISED_PORT overridden: ${ZITI_CTRL_ADVERTISED_PORT}"; fi if [[ "${ZITI_PKI_CTRL_ROOTCA_NAME-}" == "" ]]; then export ZITI_PKI_CTRL_ROOTCA_NAME="${ZITI_CTRL_EDGE_ADVERTISED_ADDRESS}-root-ca"; else echo "ZITI_PKI_CTRL_ROOTCA_NAME overridden: ${ZITI_PKI_CTRL_ROOTCA_NAME}"; fi if [[ "${ZITI_PKI_CTRL_INTERMEDIATE_NAME-}" == "" ]]; then export ZITI_PKI_CTRL_INTERMEDIATE_NAME="${ZITI_CTRL_EDGE_ADVERTISED_ADDRESS}-intermediate"; else echo "ZITI_PKI_CTRL_INTERMEDIATE_NAME overridden: ${ZITI_PKI_CTRL_INTERMEDIATE_NAME}"; fi if [[ "${ZITI_PKI_CTRL_EDGE_ROOTCA_NAME-}" == "" ]]; then export ZITI_PKI_CTRL_EDGE_ROOTCA_NAME="${ZITI_CTRL_EDGE_ADVERTISED_ADDRESS}-root-ca"; else echo "ZITI_PKI_CTRL_EDGE_ROOTCA_NAME overridden: ${ZITI_PKI_CTRL_EDGE_ROOTCA_NAME}"; fi @@ -529,7 +530,7 @@ function stopRouter { # Checks all ports intended to be used in the Ziti network function checkZitiPorts { local returnCnt=0 - _portCheck "ZITI_CTRL_LISTENER_PORT" "Controller" + _portCheck "ZITI_CTRL_ADVERTISED_PORT" "Controller" returnCnt=$((returnCnt + $?)) _portCheck "ZITI_EDGE_ROUTER_PORT" "Edge Router" returnCnt=$((returnCnt + $?)) @@ -850,8 +851,8 @@ function _create_router_config { # Make sure necessary env variables are set # The following are used by ziti bin to generate the config so they need to be checked: - # ZITI_CTRL_EDGE_ADVERTISED_ADDRESS ZITI_CTRL_LISTENER_PORT - _check_env_variable ZITI_HOME ZITI_BIN_DIR ZITI_CTRL_EDGE_ADVERTISED_ADDRESS ZITI_CTRL_LISTENER_PORT + # ZITI_CTRL_EDGE_ADVERTISED_ADDRESS ZITI_CTRL_ADVERTISED_PORT + _check_env_variable ZITI_HOME ZITI_BIN_DIR ZITI_CTRL_EDGE_ADVERTISED_ADDRESS ZITI_CTRL_ADVERTISED_PORT retVal=$? if [[ "${retVal}" != 0 ]]; then return 1 @@ -1431,13 +1432,12 @@ function performMigration { sed -i '' 's/ZITI_CONTROLLER_INTERMEDIATE_NAME/ZITI_PKI_CTRL_INTERMEDIATE_NAME/g' "${ZITI_ENV_FILE}" sed -i '' 's/ZITI_CONTROLLER_RAWNAME/ZITI_CTRL_EDGE_ADVERTISED_ADDRESS/g' "${ZITI_ENV_FILE}" sed -i '' 's/ZITI_CONTROLLER_ROOTCA_NAME/ZITI_PKI_CTRL_ROOTCA_NAME/g' "${ZITI_ENV_FILE}" - sed -i '' 's/ZITI_CTRL_ADVERTISED_ADDRESS/ZITI_CTRL_EDGE_ADVERTISED_ADDRESS/g' "${ZITI_ENV_FILE}" sed -i '' 's/ZITI_CTRL_EDGE_PORT/ZITI_CTRL_EDGE_ADVERTISED_PORT/g' "${ZITI_ENV_FILE}" sed -i '' 's/ZITI_CTRL_IDENTITY_CA/ZITI_PKI_CTRL_CA/g' "${ZITI_ENV_FILE}" sed -i '' 's/ZITI_CTRL_IDENTITY_CERT/ZITI_PKI_CTRL_CERT/g' "${ZITI_ENV_FILE}" sed -i '' 's/ZITI_CTRL_IDENTITY_KEY/ZITI_PKI_CTRL_KEY/g' "${ZITI_ENV_FILE}" sed -i '' 's/ZITI_CTRL_IDENTITY_SERVER_CERT/ZITI_PKI_CTRL_SERVER_CERT/g' "${ZITI_ENV_FILE}" - sed -i '' 's/ZITI_CTRL_PORT/ZITI_CTRL_LISTENER_PORT/g' "${ZITI_ENV_FILE}" + sed -i '' 's/ZITI_CTRL_PORT/ZITI_CTRL_ADVERTISED_PORT/g' "${ZITI_ENV_FILE}" sed -i '' 's/ZITI_EDGE_CONTROLLER_HOSTNAME/ZITI_CTRL_EDGE_ADVERTISED_ADDRESS/g' "${ZITI_ENV_FILE}" sed -i '' 's/ZITI_EDGE_CONTROLLER_INTERMEDIATE_NAME/ZITI_PKI_CTRL_EDGE_INTERMEDIATE_NAME/g' "${ZITI_ENV_FILE}" sed -i '' 's/ZITI_EDGE_CONTROLLER_PORT/ZITI_CTRL_EDGE_ADVERTISED_PORT/g' "${ZITI_ENV_FILE}" @@ -1462,7 +1462,7 @@ function performMigration { if [[ "${ZITI_CTRL_IDENTITY_CERT-}" != "" ]]; then export ZITI_PKI_CTRL_CERT="${ZITI_CTRL_IDENTITY_CERT}"; fi if [[ "${ZITI_CTRL_IDENTITY_KEY-}" != "" ]]; then export ZITI_PKI_CTRL_KEY="${ZITI_CTRL_IDENTITY_KEY}"; fi if [[ "${ZITI_CTRL_IDENTITY_SERVER_CERT-}" != "" ]]; then export ZITI_PKI_CTRL_SERVER_CERT="${ZITI_CTRL_IDENTITY_SERVER_CERT}"; fi - if [[ "${ZITI_CTRL_PORT-}" != "" ]]; then export ZITI_CTRL_LISTENER_PORT="${ZITI_CTRL_PORT}"; fi + if [[ "${ZITI_CTRL_PORT-}" != "" ]]; then export ZITI_CTRL_ADVERTISED_PORT="${ZITI_CTRL_PORT}"; fi if [[ "${ZITI_EDGE_CONTROLLER_INTERMEDIATE_NAME-}" != "" ]]; then export ZITI_PKI_CTRL_EDGE_INTERMEDIATE_NAME="${ZITI_EDGE_CONTROLLER_INTERMEDIATE_NAME}"; fi if [[ "${ZITI_EDGE_CONTROLLER_RAWNAME-}" != "" ]]; then export ZITI_CTRL_NAME="${ZITI_EDGE_CONTROLLER_RAWNAME}"; fi if [[ "${ZITI_EDGE_CONTROLLER_ROOTCA_NAME-}" != "" ]]; then export ZITI_PKI_CTRL_EDGE_ROOTCA_NAME="${ZITI_EDGE_CONTROLLER_ROOTCA_NAME}"; fi diff --git a/quickstart/docker/simplified-docker-compose.yml b/quickstart/docker/simplified-docker-compose.yml index de8d1c7df..f8610941d 100644 --- a/quickstart/docker/simplified-docker-compose.yml +++ b/quickstart/docker/simplified-docker-compose.yml @@ -6,12 +6,12 @@ services: - ./.env ports: - ${ZITI_CTRL_EDGE_ADVERTISED_PORT:-1280}:${ZITI_CTRL_EDGE_ADVERTISED_PORT:-1280} - - ${ZITI_CTRL_LISTENER_PORT:-6262}:${ZITI_CTRL_LISTENER_PORT:-6262} + - ${ZITI_CTRL_ADVERTISED_PORT:-6262}:${ZITI_CTRL_ADVERTISED_PORT:-6262} environment: - ZITI_CTRL_EDGE_ADVERTISED_ADDRESS=${ZITI_CTRL_EDGE_ADVERTISED_ADDRESS:-ziti-edge-controller} - ZITI_CTRL_EDGE_IP_OVERRIDE=${ZITI_CTRL_EDGE_IP_OVERRIDE:-127.0.0.1} - ZITI_CTRL_EDGE_ADVERTISED_PORT=${ZITI_CTRL_EDGE_ADVERTISED_PORT:-1280} - - ZITI_CTRL_LISTENER_PORT=${ZITI_CTRL_LISTENER_PORT:-6262} + - ZITI_CTRL_ADVERTISED_PORT=${ZITI_CTRL_ADVERTISED_PORT:-6262} - ZITI_EDGE_IDENTITY_ENROLLMENT_DURATION=${ZITI_EDGE_IDENTITY_ENROLLMENT_DURATION} - ZITI_EDGE_ROUTER_ENROLLMENT_DURATION=${ZITI_EDGE_ROUTER_ENROLLMENT_DURATION} - ZITI_USER=${ZITI_USER:-admin} @@ -53,7 +53,7 @@ services: environment: - ZITI_CTRL_EDGE_ADVERTISED_ADDRESS=${ZITI_CTRL_EDGE_ADVERTISED_ADDRESS:-ziti-edge-controller} - ZITI_CTRL_EDGE_ADVERTISED_PORT=${ZITI_CTRL_EDGE_ADVERTISED_PORT:-1280} - - ZITI_CTRL_LISTENER_PORT=${ZITI_CTRL_LISTENER_PORT:-6262} + - ZITI_CTRL_ADVERTISED_PORT=${ZITI_CTRL_ADVERTISED_PORT:-6262} - ZITI_EDGE_ROUTER_NAME=${ZITI_EDGE_ROUTER_NAME:-ziti-edge-router} - ZITI_EDGE_ROUTER_ADVERTISED_HOST=${ZITI_EDGE_ROUTER_ADVERTISED_HOST:-ziti-edge-router} - ZITI_EDGE_ROUTER_PORT=${ZITI_EDGE_ROUTER_PORT:-3022} diff --git a/ziti/cmd/config_templates/controller.yml b/ziti/cmd/config_templates/controller.yml index edd148269..a11703871 100644 --- a/ziti/cmd/config_templates/controller.yml +++ b/ziti/cmd/config_templates/controller.yml @@ -75,7 +75,7 @@ ctrl: #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 }} + listener: tls:{{ .Controller.Ctrl.BindAddress }}:{{ .Controller.Ctrl.AdvertisedPort }} #metrics: # influxdb: diff --git a/ziti/cmd/config_templates/router.yml b/ziti/cmd/config_templates/router.yml index de0c01867..c93e2f83b 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.Web.BindPoints.AddressAddress }}:{{ .Controller.Ctrl.ListenerPort }} + endpoint: tls:{{ .Controller.Ctrl.AdvertisedAddress }}:{{ .Controller.Ctrl.AdvertisedPort }} link: dialers: diff --git a/ziti/cmd/create_config.go b/ziti/cmd/create_config.go index 3ec18ae1f..44666730b 100644 --- a/ziti/cmd/create_config.go +++ b/ziti/cmd/create_config.go @@ -68,8 +68,9 @@ type CtrlValues struct { MinConnectTimeout time.Duration MaxConnectTimeout time.Duration DefaultConnectTimeout time.Duration - ListenerAddress string - ListenerPort string + AdvertisedAddress string + AdvertisedPort string + BindAddress string } type HealthChecksValues struct { @@ -223,11 +224,15 @@ func (data *ConfigTemplateValues) populateConfigValues() { zitiHome, err := cmdHelper.GetZitiHome() handleVariableError(err, constants.ZitiHomeVarName) + // Get Ziti Controller Advertised Address + zitiCtrlAdvertisedAddress, err := cmdHelper.GetCtrlAdvertisedAddress() + handleVariableError(err, constants.CtrlAdvertisedAddressVarName) + // Get Ziti Controller ctrl:listener address and port - ctrlListenerAddress, err := cmdHelper.GetCtrlListenerAddress() - handleVariableError(err, constants.CtrlListenerAddressVarName) - ctrlListenerPort, err := cmdHelper.GetCtrlListenerPort() - handleVariableError(err, constants.CtrlListenerPortVarName) + ctrlBindAddress, err := cmdHelper.GetCtrlBindAddress() + handleVariableError(err, constants.CtrlBindAddressVarName) + ctrlAdvertisedPort, err := cmdHelper.GetCtrlAdvertisedPort() + handleVariableError(err, constants.CtrlAdvertisedPortVarName) // Get Ziti Controller edge:api address and port ctrlEdgeApiAddress, err := cmdHelper.GetCtrlEdgeApiAddress() @@ -276,8 +281,9 @@ func (data *ConfigTemplateValues) populateConfigValues() { 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 + data.Controller.Ctrl.AdvertisedAddress = zitiCtrlAdvertisedAddress + data.Controller.Ctrl.BindAddress = ctrlBindAddress + data.Controller.Ctrl.AdvertisedPort = ctrlAdvertisedPort // healthChecks: data.Controller.HealthChecks.Interval = fabCtrl.DefaultHealthChecksBoltCheckInterval data.Controller.HealthChecks.Timeout = fabCtrl.DefaultHealthChecksBoltCheckTimeout diff --git a/ziti/cmd/create_config_controller.go b/ziti/cmd/create_config_controller.go index 04fb44b21..ad66304ed 100644 --- a/ziti/cmd/create_config_controller.go +++ b/ziti/cmd/create_config_controller.go @@ -103,8 +103,8 @@ func NewCmdCreateConfigController() *cobra.Command { data.populateConfigValues() // Update controller specific values with configOptions passed in if the argument was provided or the value is currently blank - if data.Controller.Ctrl.ListenerPort == "" || controllerOptions.CtrlPort != constants.DefaultCtrlListenerPort { - data.Controller.Ctrl.ListenerPort = controllerOptions.CtrlPort + if data.Controller.Ctrl.AdvertisedPort == "" || controllerOptions.CtrlPort != constants.DefaultCtrlAdvertisedPort { + data.Controller.Ctrl.AdvertisedPort = 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 { @@ -138,7 +138,7 @@ func NewCmdCreateConfigController() *cobra.Command { } func (options *CreateConfigControllerOptions) addFlags(cmd *cobra.Command) { - cmd.Flags().StringVar(&options.CtrlPort, optionCtrlPort, constants.DefaultCtrlListenerPort, "port used for the router to controller communication") + cmd.Flags().StringVar(&options.CtrlPort, optionCtrlPort, constants.DefaultCtrlAdvertisedPort, "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") diff --git a/ziti/cmd/create_config_controller_test.go b/ziti/cmd/create_config_controller_test.go index b42b9b13d..a20974ae2 100644 --- a/ziti/cmd/create_config_controller_test.go +++ b/ziti/cmd/create_config_controller_test.go @@ -131,8 +131,9 @@ func TestCreateConfigControllerTemplateValues(t *testing.T) { ".Controller.Identity.ServerCert", ".Controller.Identity.Key", ".Controller.Identity.Ca", - ".Controller.Ctrl.ListenerAddress", - ".Controller.Ctrl.ListenerPort", + ".Controller.Ctrl.BindAddress", + ".Controller.Ctrl.AdvertisedAddress", + ".Controller.Ctrl.AdvertisedPort", ".Controller.EdgeApi.Address", ".Controller.EdgeApi.Port", ".Controller.EdgeEnrollment.SigningCert", @@ -154,8 +155,9 @@ func TestCreateConfigControllerTemplateValues(t *testing.T) { &data.Controller.Identity.ServerCert, &data.Controller.Identity.Key, &data.Controller.Identity.Ca, - &data.Controller.Ctrl.ListenerAddress, - &data.Controller.Ctrl.ListenerPort, + &data.Controller.Ctrl.BindAddress, + &data.Controller.Ctrl.AdvertisedAddress, + &data.Controller.Ctrl.AdvertisedPort, &data.Controller.EdgeApi.Address, &data.Controller.EdgeApi.Port, &data.Controller.EdgeEnrollment.SigningCert, @@ -273,16 +275,16 @@ func TestCtrlConfigDefaultsWhenUnset(t *testing.T) { }) // ctrl: - t.Run("TestListenerAddress", func(t *testing.T) { - expectedValue := testDefaultCtrlListenerAddress + t.Run("TestBindAddress", func(t *testing.T) { + expectedValue := testDefaultCtrlBindAddress - assert.Equal(t, expectedValue, data.Controller.Ctrl.ListenerAddress) + assert.Equal(t, expectedValue, data.Controller.Ctrl.BindAddress) assert.Equal(t, expectedValue, strings.Split(ctrlConfig.Ctrl.Listener, ":")[1]) }) - t.Run("TestListenerPort", func(t *testing.T) { - expectedValue := testDefaultCtrlListenerPort + t.Run("TestAdvertisedPort", func(t *testing.T) { + expectedValue := testDefaultCtrlAdvertisedPort - assert.Equal(t, expectedValue, data.Controller.Ctrl.ListenerPort) + assert.Equal(t, expectedValue, data.Controller.Ctrl.AdvertisedPort) assert.Equal(t, expectedValue, strings.Split(ctrlConfig.Ctrl.Listener, ":")[2]) }) @@ -338,8 +340,8 @@ func TestCtrlConfigDefaultsWhenUnset(t *testing.T) { // web:bindPoints t.Run("TestEdgeBindpointInterfaceAddress", func(t *testing.T) { - // Should default to the value of Ctrl Listener Address - expectedValue := data.Controller.Ctrl.ListenerAddress + // Should default to the value of Ctrl Listener/bind Address + expectedValue := data.Controller.Ctrl.BindAddress assert.Equal(t, expectedValue, data.Controller.Web.BindPoints.InterfaceAddress) assert.Equal(t, expectedValue, strings.Split(ctrlConfig.Web[0].BindPoints[0].BpInterface, ":")[0]) @@ -473,16 +475,16 @@ func TestCtrlConfigDefaultsWhenBlank(t *testing.T) { }) // ctrl: - t.Run("TestListenerAddress", func(t *testing.T) { - expectedValue := testDefaultCtrlListenerAddress + t.Run("TestBindAddress", func(t *testing.T) { + expectedValue := testDefaultCtrlBindAddress - assert.Equal(t, expectedValue, data.Controller.Ctrl.ListenerAddress) + assert.Equal(t, expectedValue, data.Controller.Ctrl.BindAddress) assert.Equal(t, expectedValue, strings.Split(ctrlConfig.Ctrl.Listener, ":")[1]) }) - t.Run("TestListenerPort", func(t *testing.T) { - expectedValue := testDefaultCtrlListenerPort + t.Run("TestAdvertisedPort", func(t *testing.T) { + expectedValue := testDefaultCtrlAdvertisedPort - assert.Equal(t, expectedValue, data.Controller.Ctrl.ListenerPort) + assert.Equal(t, expectedValue, data.Controller.Ctrl.AdvertisedPort) assert.Equal(t, expectedValue, strings.Split(ctrlConfig.Ctrl.Listener, ":")[2]) }) @@ -546,8 +548,8 @@ func TestCtrlConfigDefaultsWhenBlank(t *testing.T) { // web:bindPoints t.Run("TestEdgeBindpointInterfaceAddress", func(t *testing.T) { - // Should default to the value of Ctrl Listener Address - expectedValue := data.Controller.Ctrl.ListenerAddress + // Should default to the value of Ctrl Listener/bind Address + expectedValue := data.Controller.Ctrl.BindAddress assert.Equal(t, expectedValue, data.Controller.Web.BindPoints.InterfaceAddress) assert.Equal(t, expectedValue, strings.Split(ctrlConfig.Web[0].BindPoints[0].BpInterface, ":")[0]) @@ -661,27 +663,27 @@ func TestZitiCtrlIdentitySection(t *testing.T) { assert.Equal(t, caPath, ctrlConfig.Identity.Ca) } -func TestCtrlListenerAddress(t *testing.T) { +func TestCtrlBindAddress(t *testing.T) { customValue := "123.456.7.8" keys := map[string]string{ - "ZITI_CTRL_LISTENER_ADDRESS": customValue, + "ZITI_CTRL_BIND_ADDRESS": customValue, } ctrlConfig := execCreateConfigControllerCommand(nil, keys) - assert.Equal(t, customValue, data.Controller.Ctrl.ListenerAddress) + assert.Equal(t, customValue, data.Controller.Ctrl.BindAddress) assert.Equal(t, customValue, strings.Split(ctrlConfig.Ctrl.Listener, ":")[1]) } -func TestCtrlListenerPort(t *testing.T) { +func TestCtrlAdvertisedPort(t *testing.T) { customValue := "9999" keys := map[string]string{ - "ZITI_CTRL_LISTENER_PORT": customValue, + "ZITI_CTRL_ADVERTISED_PORT": customValue, } ctrlConfig := execCreateConfigControllerCommand(nil, keys) - assert.Equal(t, customValue, data.Controller.Ctrl.ListenerPort) + assert.Equal(t, customValue, data.Controller.Ctrl.AdvertisedPort) assert.Equal(t, customValue, strings.Split(ctrlConfig.Ctrl.Listener, ":")[2]) } diff --git a/ziti/cmd/create_config_environment.go b/ziti/cmd/create_config_environment.go index 44933dcc1..7236214d9 100644 --- a/ziti/cmd/create_config_environment.go +++ b/ziti/cmd/create_config_environment.go @@ -98,8 +98,9 @@ func NewCmdCreateConfigEnvironment() *cobra.Command { {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.CtrlBindAddressVarName, constants.CtrlBindAddressVarDescription, data.Controller.Ctrl.BindAddress}, + {constants.CtrlAdvertisedAddressVarName, constants.CtrlAdvertisedAddressVarDescription, data.Controller.Ctrl.AdvertisedAddress}, + {constants.CtrlAdvertisedPortVarName, constants.CtrlAdvertisedPortVarDescription, data.Controller.Ctrl.AdvertisedPort}, {constants.CtrlEdgeApiAddressVarName, constants.CtrlEdgeApiAddressVarDescription, data.Controller.EdgeApi.Address}, {constants.CtrlEdgeApiPortVarName, constants.CtrlEdgeApiPortVarDescription, data.Controller.EdgeApi.Port}, {constants.PkiSignerCertVarName, constants.PkiSignerCertVarDescription, data.Controller.EdgeEnrollment.SigningCert}, @@ -191,14 +192,16 @@ func NewCmdCreateConfigEnvironment() *cobra.Command { "%-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.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.CtrlBindAddressVarName, constants.CtrlBindAddressVarDescription, data.Controller.Ctrl.BindAddress, + constants.CtrlAdvertisedAddressVarName, constants.CtrlAdvertisedAddressVarDescription, data.Controller.Ctrl.AdvertisedAddress, + constants.CtrlAdvertisedPortVarName, constants.CtrlAdvertisedPortVarDescription, data.Controller.Ctrl.AdvertisedPort, constants.CtrlEdgeApiAddressVarName, constants.CtrlEdgeApiAddressVarDescription, data.Controller.EdgeApi.Address, constants.CtrlEdgeApiPortVarName, constants.CtrlEdgeApiPortVarDescription, data.Controller.EdgeApi.Port, constants.PkiSignerCertVarName, constants.PkiSignerCertVarDescription, data.Controller.EdgeEnrollment.SigningCert, diff --git a/ziti/cmd/create_config_router_edge_test.go b/ziti/cmd/create_config_router_edge_test.go index 4e061a53e..62368fc8d 100644 --- a/ziti/cmd/create_config_router_edge_test.go +++ b/ziti/cmd/create_config_router_edge_test.go @@ -19,8 +19,8 @@ func TestEdgeRouterAdvertisedAddress(t *testing.T) { routerAdvHostIp := "192.168.10.10" routerAdvHostDns := "controller01.zitinetwork.example.org" keys := map[string]string{ - "ZITI_CTRL_LISTENER_PORT": "80", - "ZITI_EDGE_ROUTER_PORT": "443", + "ZITI_CTRL_ADVERTISED_PORT": "80", + "ZITI_EDGE_ROUTER_PORT": "443", } // Defaults to hostname if nothing is set execCreateConfigCommand(defaultArgs, keys) diff --git a/ziti/cmd/create_config_test.go b/ziti/cmd/create_config_test.go index 09dc5a4f3..5b3f24763 100644 --- a/ziti/cmd/create_config_test.go +++ b/ziti/cmd/create_config_test.go @@ -16,8 +16,9 @@ import ( // 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" + testDefaultCtrlAdvertisedAddress = "0.0.0.0" + testDefaultCtrlBindAddress = "0.0.0.0" + testDefaultCtrlAdvertisedPort = "6262" testDefaultBoltCheckInterval = "30s" testDefaultBoltCheckTimeout = "20s" testDefaultBoltCheckInitialDelay = "30s" @@ -41,8 +42,9 @@ func getZitiEnvironmentVariables() []string { "ZITI_PKI_CTRL_SERVER_CERT", "ZITI_PKI_CTRL_KEY", "ZITI_PKI_CTRL_CA", - "ZITI_CTRL_LISTENER_ADDRESS", - "ZITI_CTRL_LISTENER_PORT", + "ZITI_CTRL_BIND_ADDRESS", + "ZITI_CTRL_ADVERTISED_ADDRESS", + "ZITI_CTRL_ADVERTISED_PORT", "ZITI_CTRL_EDGE_API_ADDRESS", "ZITI_CTRL_EDGE_API_PORT", "ZITI_PKI_SIGNER_CERT", diff --git a/ziti/cmd/helpers/env_helpers.go b/ziti/cmd/helpers/env_helpers.go index 193d4ed39..b79103e82 100644 --- a/ziti/cmd/helpers/env_helpers.go +++ b/ziti/cmd/helpers/env_helpers.go @@ -81,12 +81,16 @@ func HostnameOrNetworkName() string { return val } -func GetCtrlListenerAddress() (string, error) { - return getValueOrSetAndGetDefault(constants.CtrlListenerAddressVarName, constants.DefaultCtrlListenerAddress) +func GetCtrlAdvertisedAddress() (string, error) { + return getValueOrSetAndGetDefault(constants.CtrlAdvertisedAddressVarName, constants.DefaultCtrlAdvertisedAddress) } -func GetCtrlListenerPort() (string, error) { - return getValueOrSetAndGetDefault(constants.CtrlListenerPortVarName, constants.DefaultCtrlListenerPort) +func GetCtrlBindAddress() (string, error) { + return getValueOrSetAndGetDefault(constants.CtrlBindAddressVarName, constants.DefaultCtrlBindAddress) +} + +func GetCtrlAdvertisedPort() (string, error) { + return getValueOrSetAndGetDefault(constants.CtrlAdvertisedPortVarName, constants.DefaultCtrlAdvertisedPort) } func GetCtrlEdgeApiAddress() (string, error) { @@ -117,9 +121,9 @@ func GetCtrlEdgeApiPort() (string, error) { func GetCtrlEdgeInterfaceAddress() (string, error) { // Get the controller's listener hostname to use as the default - defaultHostname, err := GetCtrlListenerAddress() + defaultHostname, err := GetCtrlAdvertisedAddress() if err != nil { - err := errors.Wrap(err, "Unable to get "+constants.CtrlListenerAddressVarName) + err := errors.Wrap(err, "Unable to get "+constants.CtrlAdvertisedAddressVarName) if err != nil { return "", err } diff --git a/ziti/cmd/helpers/helpers_test.go b/ziti/cmd/helpers/helpers_test.go index 6c24a85a0..9496af5e6 100644 --- a/ziti/cmd/helpers/helpers_test.go +++ b/ziti/cmd/helpers/helpers_test.go @@ -93,16 +93,16 @@ func TestGetCtrlEdgeAdvertisedAddressWhenSet(t *testing.T) { assert.Equal(t, expectedValue, actualValue) } -func TestGetCtrlPortWhenUnset(t *testing.T) { +func TestGetCtrlAdvertisedPortWhenUnset(t *testing.T) { // Setup - varName := "ZITI_CTRL_LISTENER_PORT" + varName := "ZITI_CTRL_ADVERTISED_PORT" // Ensure the variable is unset _ = os.Unsetenv(varName) expectedValue := "6262" // Check that the value matches - actualValue, _ := GetCtrlListenerPort() + actualValue, _ := GetCtrlAdvertisedPort() assert.Equal(t, expectedValue, actualValue) // The env variable should be populated with the expected value @@ -110,29 +110,29 @@ func TestGetCtrlPortWhenUnset(t *testing.T) { assert.Equal(t, expectedValue, envValue) } -func TestGetCtrlPortWhenSet(t *testing.T) { +func TestGetCtrlAdvertisedPortWhenSet(t *testing.T) { // Setup - varName := "ZITI_CTRL_LISTENER_PORT" + varName := "ZITI_CTRL_ADVERTISED_PORT" expectedValue := "1234" // Set the env variable _ = os.Setenv(varName, expectedValue) // Check that the value matches - actualValue, _ := GetCtrlListenerPort() + actualValue, _ := GetCtrlAdvertisedPort() assert.Equal(t, expectedValue, actualValue) } -func TestGetCtrlListenerAddressWhenUnset(t *testing.T) { +func TestGetCtrlAdvertisedAddressWhenUnset(t *testing.T) { // Setup - varName := "ZITI_CTRL_LISTENER_ADDRESS" + varName := "ZITI_CTRL_ADVERTISED_ADDRESS" // Ensure the variable is unset _ = os.Unsetenv(varName) expectedValue := "0.0.0.0" // Check that the value matches - actualValue, _ := GetCtrlListenerAddress() + actualValue, _ := GetCtrlAdvertisedAddress() assert.Equal(t, expectedValue, actualValue) // The env variable should be populated with the expected value @@ -140,16 +140,16 @@ func TestGetCtrlListenerAddressWhenUnset(t *testing.T) { assert.Equal(t, expectedValue, envValue) } -func TestGetCtrlListenerAddressWhenSet(t *testing.T) { +func TestGetCtrlAdvertisedAddressWhenSet(t *testing.T) { // Setup - varName := "ZITI_CTRL_LISTENER_ADDRESS" + varName := "ZITI_CTRL_ADVERTISED_ADDRESS" expectedValue := "localhost" // Set the env variable _ = os.Setenv(varName, expectedValue) // Check that the value matches - actualValue, _ := GetCtrlListenerAddress() + actualValue, _ := GetCtrlAdvertisedAddress() assert.Equal(t, expectedValue, actualValue) } diff --git a/ziti/constants/constants.go b/ziti/constants/constants.go index ce746b9fe..12eda1fce 100644 --- a/ziti/constants/constants.go +++ b/ziti/constants/constants.go @@ -41,8 +41,9 @@ const ( DefaultZitiEdgeRouterPort = "3022" DefaultCtrlEdgeAdvertisedPort = "1280" - DefaultCtrlListenerAddress = "0.0.0.0" - DefaultCtrlListenerPort = "6262" + DefaultCtrlAdvertisedAddress = "0.0.0.0" + DefaultCtrlBindAddress = "0.0.0.0" + DefaultCtrlAdvertisedPort = "6262" ) // Env Var Constants @@ -58,10 +59,12 @@ const ( 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" + CtrlBindAddressVarName = "ZITI_CTRL_BIND_ADDRESS" + CtrlBindAddressVarDescription = "The address on which the controller will listen for communication on the control plane." + CtrlAdvertisedAddressVarName = "ZITI_CTRL_ADVERTISED_ADDRESS" + CtrlAdvertisedAddressVarDescription = "The address routers will use to connect to the Ziti Controller" + CtrlAdvertisedPortVarName = "ZITI_CTRL_ADVERTISED_PORT" + CtrlAdvertisedPortVarDescription = "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"