From 2206110c52dbd131456ac560d22fde304c316573 Mon Sep 17 00:00:00 2001 From: Ken Bingham Date: Wed, 11 Jan 2023 10:04:49 -0500 Subject: [PATCH 1/9] fix Markdown links to SDKs --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index d37dd257b..8ac9b4759 100644 --- a/README.md +++ b/README.md @@ -129,12 +129,12 @@ The Ziti project welcomes contributions including, but not limited to, code, doc * [fabric](https://github.com/openziti/fabric): fabric project which includes core controller and router * [foundation](https://github.com/openziti/foundation): project which contains library code used across multiple projects * SDKs - * [ziti-sdk-c] (https://github.com/openziti/ziti-sdk-c): C SDK - * [sdk-golang] (https://github.com/openziti/sdk-golang): Go SDK - * [ziti-sdk-jvm] (https://github.com/openziti/ziti-sdk-jvm): SDK for JVM based languages - * [ziti-sdk-swift] (https://github.com/openziti/ziti-sdk-swift): Swift SDK - * [ziti-sdk-nodejs] (https://github.com/openziti/ziti-sdk-nodejs): NodeJS SDK - * [ziti-sdk-csharp] (https://github.com/openziti/ziti-sdk-csharp): C# SDK + * [ziti-sdk-c](https://github.com/openziti/ziti-sdk-c): C SDK + * [sdk-golang](https://github.com/openziti/sdk-golang): Go SDK + * [ziti-sdk-jvm](https://github.com/openziti/ziti-sdk-jvm): SDK for JVM based languages + * [ziti-sdk-swift](https://github.com/openziti/ziti-sdk-swift): Swift SDK + * [ziti-sdk-nodejs](https://github.com/openziti/ziti-sdk-nodejs): NodeJS SDK + * [ziti-sdk-csharp](https://github.com/openziti/ziti-sdk-csharp): C# SDK * [ziti-doc](https://github.com/openziti/ziti-doc): Powers the static documentation site Ziti was developed and open sourced by [Netfoundry, Inc](https://netfoundry.io). NetFoundry continues to fund and From cac05d0b1028a8f3171c7b41b6afedd4cafee6ad Mon Sep 17 00:00:00 2001 From: Shawn Carey Date: Thu, 12 Jan 2023 09:17:58 -0500 Subject: [PATCH 2/9] update deps and changelog for custom tproxy diverter change (edge 0.24.101) (#942) --- CHANGELOG.md | 10 ++++++++++ go.mod | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 423857c21..f4204d388 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +# Release 0.27.3 + +# What's New + +## Component Updates and Bug Fixes + +* github.com/openziti/edge: [v0.24.95 -> v0.24.101](https://github.com/openziti/edge/compare/v0.24.95...v0.24.101) + * [Issue #1292](https://github.com/openziti/edge/issues/1292) - Support alternative tproxy configuration methods + + # Release 0.27.2 # What's New diff --git a/go.mod b/go.mod index e646c3fad..e2cfb004f 100644 --- a/go.mod +++ b/go.mod @@ -22,7 +22,7 @@ require ( github.com/michaelquigley/pfxlog v0.6.9 github.com/openziti/agent v1.0.7 github.com/openziti/channel/v2 v2.0.25 - github.com/openziti/edge v0.24.95 + github.com/openziti/edge v0.24.101 github.com/openziti/fabric v0.22.7 github.com/openziti/foundation/v2 v2.0.10 github.com/openziti/identity v1.0.29 From 8476b4bd7c34ff7dac0229a4fa85a608d4163612 Mon Sep 17 00:00:00 2001 From: dovholuknf <46322585+dovholuknf@users.noreply.github.com> Date: Thu, 12 Jan 2023 11:21:19 -0500 Subject: [PATCH 3/9] make simplified the same as the docker-compose example --- quickstart/docker/simplified-docker-compose.yml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/quickstart/docker/simplified-docker-compose.yml b/quickstart/docker/simplified-docker-compose.yml index 94e0287e8..458e06b18 100644 --- a/quickstart/docker/simplified-docker-compose.yml +++ b/quickstart/docker/simplified-docker-compose.yml @@ -5,7 +5,11 @@ services: env_file: - ./.env ports: - - "1280:1280" + - "${ZITI_EDGE_CONTROLLER_PORT}:${ZITI_EDGE_CONTROLLER_PORT}" + - "${ZITI_CTRL_PORT}:${ZITI_CTRL_PORT}" + environment: + - ZITI_EDGE_IDENTITY_ENROLLMENT_DURATION=${ZITI_EDGE_IDENTITY_ENROLLMENT_DURATION} + - ZITI_EDGE_ROUTER_ENROLLMENT_DURATION=${ZITI_EDGE_ROUTER_ENROLLMENT_DURATION} networks: zitiblue: aliases: @@ -40,14 +44,16 @@ services: - "/var/openziti/scripts/run-with-ziti-cli.sh" command: - "/var/openziti/scripts/access-control.sh" - + ziti-edge-router: image: "${ZITI_IMAGE}:${ZITI_VERSION}" - environment: - - ZITI_EDGE_ROUTER_RAWNAME=ziti-edge-router - - ZITI_EDGE_ROUTER_ROLES=public 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 + - ZITI_EDGE_ROUTER_ROLES=public ports: - "3022:3022" networks: From 58920e6b9d1b3dac4ee1893b84fcdc371cdfb8c8 Mon Sep 17 00:00:00 2001 From: Paul Lorenz Date: Wed, 4 Jan 2023 10:32:58 -0500 Subject: [PATCH 4/9] Update agent commands --- go.mod | 16 +- go.sum | 32 ++-- ziti/cmd/agentcli/agent.go | 138 ++++++++++++++++-- ziti/cmd/agentcli/agent_ch_simple.go | 51 +++---- .../agentcli/agent_clear_channel_log_level.go | 42 ++++-- ziti/cmd/agentcli/agent_controller_init.go | 60 ++------ .../agentcli/agent_controller_init_from_db.go | 58 ++------ .../agentcli/agent_controller_raft_join.go | 63 ++------ .../agentcli/agent_controller_raft_list.go | 49 ++----- ziti/cmd/agentcli/agent_gc.go | 60 -------- ...ent_go_version_action.go => agent_list.go} | 35 +++-- ziti/cmd/agentcli/agent_memstats.go | 61 -------- ziti/cmd/agentcli/agent_pprof_cpu.go | 26 ++++ ziti/cmd/agentcli/agent_pprof_heap.go | 26 ++++ ziti/cmd/agentcli/agent_router_add_route.go | 75 +++++----- ziti/cmd/agentcli/agent_router_forget_link.go | 44 ++---- .../agent_router_toggle_ctrl_channel.go | 90 ++++++++++++ .../agentcli/agent_set_channel_log_level.go | 27 +++- ziti/cmd/agentcli/agent_set_log_level.go | 34 +++-- ziti/cmd/agentcli/agent_setgc.go | 36 +++-- ziti/cmd/agentcli/agent_simple.go | 33 ++++- ziti/cmd/agentcli/agent_stack.go | 11 +- ziti/cmd/agentcli/agent_stats.go | 60 -------- ziti/cmd/agentcli/agent_trace.go | 17 +-- .../cmd/demo/echo_server_update_terminator.go | 2 +- ziti/controller/root.go | 2 + ziti/controller/run.go | 9 +- ziti/router/root.go | 2 + ziti/router/run.go | 9 +- 29 files changed, 587 insertions(+), 581 deletions(-) delete mode 100644 ziti/cmd/agentcli/agent_gc.go rename ziti/cmd/agentcli/{agent_go_version_action.go => agent_list.go} (56%) delete mode 100644 ziti/cmd/agentcli/agent_memstats.go create mode 100644 ziti/cmd/agentcli/agent_router_toggle_ctrl_channel.go delete mode 100644 ziti/cmd/agentcli/agent_stats.go diff --git a/go.mod b/go.mod index e2cfb004f..40d5c6250 100644 --- a/go.mod +++ b/go.mod @@ -20,14 +20,14 @@ require ( github.com/jedib0t/go-pretty/v6 v6.4.0 github.com/keybase/go-ps v0.0.0-20190827175125-91aafc93ba19 github.com/michaelquigley/pfxlog v0.6.9 - github.com/openziti/agent v1.0.7 + github.com/openziti/agent v1.0.8 github.com/openziti/channel/v2 v2.0.25 - github.com/openziti/edge v0.24.101 - github.com/openziti/fabric v0.22.7 + github.com/openziti/edge v0.24.100 + github.com/openziti/fabric v0.22.9 github.com/openziti/foundation/v2 v2.0.10 github.com/openziti/identity v1.0.29 - github.com/openziti/runzmd v1.0.7 - github.com/openziti/sdk-golang v0.18.21 + github.com/openziti/runzmd v1.0.8 + github.com/openziti/sdk-golang v0.18.24 github.com/openziti/storage v0.1.31 github.com/openziti/transport/v2 v2.0.49 github.com/openziti/xweb/v2 v2.0.2 @@ -119,7 +119,7 @@ require ( github.com/kyokomi/emoji/v2 v2.2.11 // indirect github.com/lucasb-eyer/go-colorful v1.2.0 // indirect github.com/lucsky/cuid v1.2.1 // indirect - github.com/lufia/plan9stats v0.0.0-20220913051719-115f729f3c8c // indirect + github.com/lufia/plan9stats v0.0.0-20230110061619-bbe2e5e100de // indirect github.com/magiconair/properties v1.8.5 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect @@ -172,8 +172,8 @@ require ( go.mozilla.org/pkcs7 v0.0.0-20210826202110-33d05740a352 // indirect go.opentelemetry.io/otel v1.11.1 // indirect go.opentelemetry.io/otel/trace v1.11.1 // indirect - golang.org/x/crypto v0.4.0 // indirect - golang.org/x/exp v0.0.0-20221230185412-738e83a70c30 // indirect + golang.org/x/crypto v0.5.0 // indirect + golang.org/x/exp v0.0.0-20230111222715-75897c7a292a // indirect golang.org/x/image v0.3.0 // indirect golang.org/x/mod v0.6.0 // indirect golang.org/x/sync v0.1.0 // indirect diff --git a/go.sum b/go.sum index da20b6352..192743f80 100644 --- a/go.sum +++ b/go.sum @@ -561,8 +561,8 @@ github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i github.com/lucsky/cuid v1.2.1 h1:MtJrL2OFhvYufUIn48d35QGXyeTC8tn0upumW9WwTHg= github.com/lucsky/cuid v1.2.1/go.mod h1:QaaJqckboimOmhRSJXSx/+IT+VTfxfPGSo/6mfgUfmE= github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I= -github.com/lufia/plan9stats v0.0.0-20220913051719-115f729f3c8c h1:VtwQ41oftZwlMnOEbMWQtSEUgU64U4s+GHk7hZK+jtY= -github.com/lufia/plan9stats v0.0.0-20220913051719-115f729f3c8c/go.mod h1:JKx41uQRwqlTZabZc+kILPrO/3jlKnQ2Z8b7YiVw5cE= +github.com/lufia/plan9stats v0.0.0-20230110061619-bbe2e5e100de h1:V53FWzU6KAZVi1tPp5UIsMoUWJ2/PNwYIDXnu7QuBCE= +github.com/lufia/plan9stats v0.0.0-20230110061619-bbe2e5e100de/go.mod h1:JKx41uQRwqlTZabZc+kILPrO/3jlKnQ2Z8b7YiVw5cE= github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI= github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.5 h1:b6kJs+EmPFMYGkow9GiUyCyOvIwYetYJ3fSaWak/Gls= @@ -693,16 +693,16 @@ github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+ github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= github.com/openzipkin/zipkin-go v0.1.1/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTmOf0Erfk+hxe8= github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw= -github.com/openziti/agent v1.0.7 h1:tEZlYQ5/y7oeuYUAdqN6AAayQAloL8Ms6prSddaUDVY= -github.com/openziti/agent v1.0.7/go.mod h1:6APWgkPP6Uxf1/VyirdTVLAJxwam2vVyakrVw6yvs40= +github.com/openziti/agent v1.0.8 h1:qB4zQO9dz3PL8qbeyzCWbwTrtHZPEZlYtjkJJ78SJPo= +github.com/openziti/agent v1.0.8/go.mod h1:6APWgkPP6Uxf1/VyirdTVLAJxwam2vVyakrVw6yvs40= github.com/openziti/channel/v2 v2.0.25 h1:ihw9DDTfMHDL33gZFLqDyADFGKBec4beaThV/VJLWhI= github.com/openziti/channel/v2 v2.0.25/go.mod h1:eHPS7dmvDV+Q/SmbB2gwvdvdz/NcnetFshHsdNzAnZs= 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.95 h1:Lj7ycWVOXbqt3TK6NSGPWXj5bp3/5rX7rA+bR5wA8Nc= -github.com/openziti/edge v0.24.95/go.mod h1:nVamtrBekK372q8bbKK/D6t0W7LBqQ+Miu0YE1u3od4= -github.com/openziti/fabric v0.22.7 h1:o0k/QnCpVZPiC77fh/NoUVCoeQNhfBm4oOICcJsdkWc= -github.com/openziti/fabric v0.22.7/go.mod h1:NITYnGTCeu0ENixTd7qXFzGyIDm5GkyJhxKYTnmFzjk= +github.com/openziti/edge v0.24.100 h1:sBoG0GtyFCyodukuG1IDCoXm2PjLyjt8jxKhVQjc0ww= +github.com/openziti/edge v0.24.100/go.mod h1:Yn3eOldLoe6BZyJvOQbgY02LDOpo9oW48v1ZKhTwqZs= +github.com/openziti/fabric v0.22.9 h1:8bI+yeWMBwBYwpteg8A2fxI4rYB65B6UBkIkLSsdh8s= +github.com/openziti/fabric v0.22.9/go.mod h1:8i3qG7UJbqWHH3V6nZlhzaaGyqiecn4cCsj9qGf4Rec= github.com/openziti/foundation/v2 v2.0.10 h1:IeOkcPbgBpBTw4JrWz8s9Z76vO/m+i2uIE0cMZ0C2DM= github.com/openziti/foundation/v2 v2.0.10/go.mod h1:Z0gnQsGJb/H/B+pixLtmCIpw1dBllD4QoT6LeD35WzA= github.com/openziti/identity v1.0.29 h1:FkY/Hzpfh2/U2cUzYR2X3380/IKGIQYpJaKWqXpOIAg= @@ -711,10 +711,10 @@ github.com/openziti/jwks v1.0.2 h1:32BGXIAnefS+v7uXKPb1x8/cQ7srek6Ai06dsrMTY4E= github.com/openziti/jwks v1.0.2/go.mod h1:KwO0x9FBG0aoJS5f6nH5xeHoplyR1H143SMI9kF0mC8= github.com/openziti/metrics v1.2.3 h1:h9+mSU673QLSMOb3YibD1vNgE0yIDZ5leiUqDwN5szE= github.com/openziti/metrics v1.2.3/go.mod h1:jK8BfZ9nXMhO+LPcUPpN/sebrLfIeF4uaHlm5JIF7BY= -github.com/openziti/runzmd v1.0.7 h1:2EC3bVjjAuFsECaZbwTOJdDbSk3I8JpfaI2ruGdEGiA= -github.com/openziti/runzmd v1.0.7/go.mod h1:0AlunP33eJ/S21az+ACP9/INVeUSR80pELXYXs2hK0I= -github.com/openziti/sdk-golang v0.18.21 h1:oWJXrvMbXvTGkQ0MF3oFKmAw6dBBKhNt2WxNjj/Z1zA= -github.com/openziti/sdk-golang v0.18.21/go.mod h1:LT+IOT2GqsmYLwjjO3YOlcejgBROyMI1a01xo8Xh+A8= +github.com/openziti/runzmd v1.0.8 h1:snjZebyVVeXL4UfSYhJxHTzo/jeSKFkvjMwWWZ7uRMg= +github.com/openziti/runzmd v1.0.8/go.mod h1:og+vSXZFDZiAturQQJVyfo2j41XFTmv+oZptzKZnPqI= +github.com/openziti/sdk-golang v0.18.24 h1:pKNupqa3ZnaLxNRL1tKn7JUT22xAeKcTIWFUSQaHtRk= +github.com/openziti/sdk-golang v0.18.24/go.mod h1:MEHIen3YTNwPaDGMgDgcTf04RqG5fCti4CnNRJhk70g= github.com/openziti/storage v0.1.31 h1:YO1c1mzn+DfmBOtzhBlMe6q5cgjSOUv+sY8iUOwXals= github.com/openziti/storage v0.1.31/go.mod h1:DFRIpfCkI7lLuhGUl4CgZR6sGbsMJ/+nGnjkVIqCgrw= github.com/openziti/transport/v2 v2.0.49 h1:P3gUazaC8Z7iy4eXk510wjTKot6GucWMtqexU3mn83U= @@ -1008,8 +1008,8 @@ golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= 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.4.0 h1:UVQgzMY87xqpKNgb+kDsll2Igd33HszWHFLmpaRMq/8= -golang.org/x/crypto v0.4.0/go.mod h1:3quD/ATkf6oY+rnes5c3ExXTbLc8mueNue5/DoinL80= +golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE= +golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU= 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= @@ -1020,8 +1020,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20221230185412-738e83a70c30 h1:m9O6OTJ627iFnN2JIWfdqlZCzneRO6EEBsHXI25P8ws= -golang.org/x/exp v0.0.0-20221230185412-738e83a70c30/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= +golang.org/x/exp v0.0.0-20230111222715-75897c7a292a h1:/YWeLOBWYV5WAQORVPkZF3Pq9IppkcT72GKnWjNf5W8= +golang.org/x/exp v0.0.0-20230111222715-75897c7a292a/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= 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= diff --git a/ziti/cmd/agentcli/agent.go b/ziti/cmd/agentcli/agent.go index d05f4663e..dd9d8ad6f 100644 --- a/ziti/cmd/agentcli/agent.go +++ b/ziti/cmd/agentcli/agent.go @@ -1,6 +1,7 @@ package agentcli import ( + "fmt" "github.com/openziti/agent" "github.com/openziti/channel/v2" "github.com/openziti/edge/router/debugops" @@ -10,8 +11,12 @@ import ( "github.com/openziti/identity" "github.com/openziti/ziti/ziti/cmd/common" cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/pkg/errors" "github.com/spf13/cobra" + "io" "net" + "os" + "strings" "time" ) @@ -32,12 +37,13 @@ func NewAgentCmd(p common.OptionsProvider) *cobra.Command { } agentCmd.AddCommand(NewPsCmd(p)) - agentCmd.AddCommand(NewGoVersionCmd(p)) - agentCmd.AddCommand(NewGcCmd(p)) + agentCmd.AddCommand(NewListCmd(p)) + agentCmd.AddCommand(NewSimpleAgentCmd("goversion", agent.Version, p, "Returns the golang version of the target application")) + agentCmd.AddCommand(NewSimpleAgentCmd("gc", agent.GC, p, "Run garbage collection in the target application")) agentCmd.AddCommand(NewSetGcCmd(p)) agentCmd.AddCommand(NewStackCmd(p)) - agentCmd.AddCommand(NewMemstatsCmd(p)) - agentCmd.AddCommand(NewStatsCmd(p)) + agentCmd.AddCommand(NewSimpleAgentCmd("memstats", agent.MemStats, p, "Returns memory use summary of the target application")) + agentCmd.AddCommand(NewSimpleAgentCmd("stats", agent.Stats, p, "Emits some runtime information (# go-routines, threads, cpus, etc) from the target application")) agentCmd.AddCommand(NewPprofHeapCmd(p)) agentCmd.AddCommand(NewPprofCpuCmd(p)) agentCmd.AddCommand(NewTraceCmd(p)) @@ -73,12 +79,12 @@ func NewAgentCmd(p common.OptionsProvider) *cobra.Command { agentCmd.AddCommand(routerCmd) routerCmd.AddCommand(NewRouteCmd(p)) - routerCmd.AddCommand(NewSimpleAgentCustomCmd("dump-routes", AgentAppRouter, router.DumpForwarderTables, p)) - routerCmd.AddCommand(NewSimpleAgentCustomCmd("disconnect", AgentAppRouter, router.CloseControlChannel, p)) - routerCmd.AddCommand(NewSimpleAgentCustomCmd("reconnect", AgentAppRouter, router.OpenControlChannel, p)) routerCmd.AddCommand(NewSimpleAgentCustomCmd("dump-api-sessions", AgentAppRouter, debugops.DumpApiSessions, p)) - routerCmd.AddCommand(NewSimpleAgentCustomCmd("dump-links", AgentAppRouter, router.DumpLinks, p)) + routerCmd.AddCommand(NewSimpleChAgentCustomCmd("dump-routes", AgentAppRouter, int32(mgmt_pb.ContentType_RouterDebugDumpForwarderTablesRequestType), p)) + routerCmd.AddCommand(NewSimpleChAgentCustomCmd("dump-links", AgentAppRouter, int32(mgmt_pb.ContentType_RouterDebugDumpLinksRequestType), p)) routerCmd.AddCommand(NewForgetLinkAgentCmd(p)) + routerCmd.AddCommand(NewToggleCtrlChannelAgentCmd(p, "disconnect", false)) + routerCmd.AddCommand(NewToggleCtrlChannelAgentCmd(p, "reconnect", true)) return agentCmd } @@ -86,6 +92,112 @@ func NewAgentCmd(p common.OptionsProvider) *cobra.Command { // AgentOptions contains the command line options type AgentOptions struct { common.CommonOptions + pid uint16 + processName string + appId string + appType string + appAlias string + tcpAddr string + timeout time.Duration +} + +func (self *AgentOptions) AddAgentOptions(cmd *cobra.Command) { + cmd.Flags().Uint16VarP(&self.pid, "pid", "p", 0, "Process ID of host application to talk to") + cmd.Flags().StringVarP(&self.processName, "process-name", "n", "", "Process name of host application to talk to") + cmd.Flags().StringVarP(&self.appId, "app-id", "i", "", "Id of host application to talk to (like controller or router id)") + cmd.Flags().StringVarP(&self.appType, "app-type", "t", "", "Type of host application to talk to (like controller or router)") + cmd.Flags().StringVarP(&self.appType, "app-alias", "a", "", "Alias of host application to talk to (specified in host application)") + cmd.Flags().StringVar(&self.tcpAddr, "tcp-addr", "", "Type of host application to talk to (like controller or router)") +} + +func (self *AgentOptions) GetProcess() (*agent.Process, error) { + procList, err := agent.GetGopsProcesses() + if err != nil { + return nil, err + } + var result []*agent.Process + for _, p := range procList { + if !p.Contactable { + continue + } + if self.Cmd.Flags().Changed("pid") && p.Pid != int(self.pid) { + continue + } + if self.Cmd.Flags().Changed("process-name") && p.Executable != self.processName { + continue + } + if self.Cmd.Flags().Changed("app-id") && p.AppId != self.appId { + continue + } + if self.Cmd.Flags().Changed("app-type") && p.AppType != self.appType { + continue + } + if self.Cmd.Flags().Changed("app-alias") && p.AppAlias != self.appAlias { + continue + } + + result = append(result, p) + } + + if len(result) == 0 { + return nil, errors.New("no processes found matching filter, use 'ziti agent ps' to list candidates") + } + + if len(result) > 1 { + var pids []string + for _, r := range result { + pids = append(pids, fmt.Sprintf("%v", r.Pid)) + } + return nil, errors.Errorf("too many processes found matching filter: [%v] use 'ziti agent list' for more information", strings.Join(pids, " ")) + } + + return result[0], nil +} + +func (self *AgentOptions) MakeChannelRequest(appId byte, f func(ch channel.Channel) error) error { + return self.MakeRequest(agent.CustomOpAsync, []byte{appId}, connToChannelMapper(f)) +} + +func (self *AgentOptions) MakeRequest(signal byte, params []byte, f func(c net.Conn) error) error { + if self.Cmd.Flags().Changed("tcp-addr") { + conn, err := net.Dial("tcp", self.tcpAddr) + if err != nil { + return err + } + return agent.MakeRequestToConn(conn, signal, params, f) + } + + p, err := self.GetProcess() + if err != nil { + return err + } + return agent.MakeProcessRequest(p, signal, params, f) +} + +func (self *AgentOptions) CopyToWriter(out io.Writer) func(conn net.Conn) error { + return func(conn net.Conn) error { + _, err := io.Copy(out, conn) + return err + } +} + +func (self *AgentOptions) RunCopyOut(op byte, params []byte, out io.Writer) error { + if self.Cmd.Flags().Changed("timeout") { + time.AfterFunc(self.timeout, func() { + fmt.Println("operation timed out") + os.Exit(-1) + }) + } + + if len(self.Args) == 0 { + return self.MakeRequest(op, params, self.CopyToWriter(out)) + } + + addr, err := agent.ParseGopsAddress(self.Args) + if err != nil { + return err + } + return agent.MakeRequest(addr, op, params, os.Stdout) } func NewAgentChannel(conn net.Conn) (channel.Channel, error) { @@ -95,12 +207,16 @@ func NewAgentChannel(conn net.Conn) (channel.Channel, error) { return channel.NewChannel("agent", dialer, nil, options) } -func MakeAgentChannelRequest(addr string, signal byte, params []byte, f func(ch channel.Channel) error) error { - return agent.MakeRequestF(addr, signal, params, func(conn net.Conn) error { +func MakeAgentChannelRequest(addr string, appId byte, f func(ch channel.Channel) error) error { + return agent.MakeRequestF(addr, agent.CustomOpAsync, []byte{appId}, connToChannelMapper(f)) +} + +func connToChannelMapper(f func(ch channel.Channel) error) func(conn net.Conn) error { + return func(conn net.Conn) error { ch, err := NewAgentChannel(conn) if err != nil { return err } return f(ch) - }) + } } diff --git a/ziti/cmd/agentcli/agent_ch_simple.go b/ziti/cmd/agentcli/agent_ch_simple.go index 1931974a9..c5c914c95 100644 --- a/ziti/cmd/agentcli/agent_ch_simple.go +++ b/ziti/cmd/agentcli/agent_ch_simple.go @@ -20,22 +20,17 @@ import ( "fmt" "github.com/openziti/agent" "github.com/openziti/channel/v2" - "github.com/openziti/identity" "github.com/openziti/ziti/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "github.com/spf13/cobra" - "net" - "time" ) -type SimpleChAgentCmdOptions struct { +type SimpleChAgentCmdAction struct { AgentOptions requestType int32 - timeout time.Duration } func NewSimpleChAgentCustomCmd(name string, appId AgentAppId, op int32, p common.OptionsProvider) *cobra.Command { - options := &SimpleChAgentCmdOptions{ + action := &SimpleChAgentCmdAction{ AgentOptions: AgentOptions{ CommonOptions: p(), }, @@ -45,47 +40,45 @@ func NewSimpleChAgentCustomCmd(name string, appId AgentAppId, op int32, p common cmd := &cobra.Command{ Args: cobra.MaximumNArgs(1), Use: name + " ", - Run: func(cmd *cobra.Command, args []string) { - options.Cmd = cmd - options.Args = args - err := options.Run(appId) - cmdhelper.CheckErr(err) + RunE: func(cmd *cobra.Command, args []string) error { + action.Cmd = cmd + action.Args = args + return action.Run(appId) }, } - cmd.Flags().DurationVarP(&options.timeout, "timeout", "t", 5*time.Second, "How long to wait for operation to complete") + action.AddAgentOptions(cmd) return cmd } // Run implements the command -func (o *SimpleChAgentCmdOptions) Run(appId AgentAppId) error { - addr, err := agent.ParseGopsAddress(o.Args) +func (self *SimpleChAgentCmdAction) Run(appId AgentAppId) error { + if len(self.Args) == 0 { + return self.MakeChannelRequest(byte(appId), self.makeRequest) + } + + addr, err := agent.ParseGopsAddress(self.Args) if err != nil { return err } - - return agent.MakeRequestF(addr, agent.CustomOpAsync, []byte{byte(appId)}, o.makeRequest) + return MakeAgentChannelRequest(addr, byte(appId), self.makeRequest) } -func (o *SimpleChAgentCmdOptions) makeRequest(conn net.Conn) error { - options := channel.DefaultOptions() - options.ConnectTimeout = time.Second - dialer := channel.NewExistingConnDialer(&identity.TokenId{Token: "agent"}, conn, nil) - ch, err := channel.NewChannel("agent", dialer, nil, options) - if err != nil { - return err - } - - msg := channel.NewMessage(o.requestType, nil) - reply, err := msg.WithTimeout(o.timeout).SendForReply(ch) +func (self *SimpleChAgentCmdAction) makeRequest(ch channel.Channel) error { + msg := channel.NewMessage(self.requestType, nil) + reply, err := msg.WithTimeout(self.timeout).SendForReply(ch) if err != nil { return err } if reply.ContentType == channel.ContentTypeResultType { result := channel.UnmarshalResult(reply) if result.Success { - fmt.Println("success") + if len(result.Message) != 0 { + fmt.Print(result.Message) + } else { + fmt.Println("success") + } } else { fmt.Printf("error: %v\n", result.Message) } diff --git a/ziti/cmd/agentcli/agent_clear_channel_log_level.go b/ziti/cmd/agentcli/agent_clear_channel_log_level.go index c307b00e7..e29d5db5a 100644 --- a/ziti/cmd/agentcli/agent_clear_channel_log_level.go +++ b/ziti/cmd/agentcli/agent_clear_channel_log_level.go @@ -19,11 +19,13 @@ package agentcli import ( "bytes" "encoding/binary" + "fmt" "github.com/openziti/agent" "github.com/openziti/ziti/ziti/cmd/common" cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "github.com/spf13/cobra" "os" + "time" ) type AgentClearChannelLogLevelAction struct { @@ -31,7 +33,7 @@ type AgentClearChannelLogLevelAction struct { } func NewClearChannelLogLevelCmd(p common.OptionsProvider) *cobra.Command { - options := &AgentClearChannelLogLevelAction{ + action := &AgentClearChannelLogLevelAction{ AgentOptions: AgentOptions{ CommonOptions: p(), }, @@ -42,31 +44,33 @@ func NewClearChannelLogLevelCmd(p common.OptionsProvider) *cobra.Command { Short: "Clears a channel-specific log level in the target application", Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { - options.Cmd = cmd - options.Args = args - err := options.Run() + action.Cmd = cmd + action.Args = args + err := action.Run() cmdhelper.CheckErr(err) }, } + action.AddAgentOptions(cmd) + return cmd } // Run implements the command func (self *AgentClearChannelLogLevelAction) Run() error { - var addr string - var err error - var channelArg string - if len(self.Args) == 1 { - addr, err = agent.ParseGopsAddress(nil) - channelArg = self.Args[0] - } else { - addr, err = agent.ParseGopsAddress(self.Args) - channelArg = self.Args[1] + if self.Cmd.Flags().Changed("timeout") { + time.AfterFunc(self.timeout, func() { + fmt.Println("operation timed out") + os.Exit(-1) + }) } - if err != nil { - return err + var channelArg string + + if len(self.Args) == 1 { + channelArg = self.Args[0] + } else { + channelArg = self.Args[1] } lenBuf := make([]byte, 8) @@ -75,5 +79,13 @@ func (self *AgentClearChannelLogLevelAction) Run() error { buf.Write(lenBuf[:lenLen]) buf.Write([]byte(channelArg)) + if len(self.Args) == 1 { + return self.MakeRequest(agent.ClearChannelLogLevel, buf.Bytes(), self.CopyToWriter(os.Stdout)) + } + + addr, err := agent.ParseGopsAddress(self.Args) + if err != nil { + return err + } return agent.MakeRequest(addr, agent.ClearChannelLogLevel, buf.Bytes(), os.Stdout) } diff --git a/ziti/cmd/agentcli/agent_controller_init.go b/ziti/cmd/agentcli/agent_controller_init.go index ffe9b960c..ecdcf865f 100644 --- a/ziti/cmd/agentcli/agent_controller_init.go +++ b/ziti/cmd/agentcli/agent_controller_init.go @@ -18,16 +18,11 @@ package agentcli import ( "fmt" - "github.com/openziti/agent" "github.com/openziti/channel/v2" "github.com/openziti/channel/v2/protobufs" "github.com/openziti/edge/pb/edge_mgmt_pb" - "github.com/openziti/identity" "github.com/openziti/ziti/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "github.com/spf13/cobra" - "net" - "time" ) type AgentCtrlInitOptions struct { @@ -35,62 +30,35 @@ type AgentCtrlInitOptions struct { } func NewAgentCtrlInit(p common.OptionsProvider) *cobra.Command { - options := &AgentCtrlInitOptions{ + action := &AgentCtrlInitOptions{ AgentOptions: AgentOptions{ CommonOptions: p(), }, } cmd := &cobra.Command{ - Args: cobra.RangeArgs(3, 4), - Use: "init ", - Run: func(cmd *cobra.Command, args []string) { - options.Cmd = cmd - options.Args = args - err := options.Run() - cmdhelper.CheckErr(err) + Args: cobra.ExactArgs(3), + Use: "init ", + RunE: func(cmd *cobra.Command, args []string) error { + action.Cmd = cmd + action.Args = args + return action.MakeChannelRequest(byte(AgentAppController), action.makeRequest) }, } + action.AddAgentOptions(cmd) + return cmd } -// Run implements the command -func (o *AgentCtrlInitOptions) Run() error { - var addr string - var err error - - if len(o.Args) == 4 { - addr, err = agent.ParseGopsAddress(o.Args) - if err != nil { - return err - } - } - - return agent.MakeRequestF(addr, agent.CustomOpAsync, []byte{byte(AgentAppController)}, o.makeRequest) -} - -func (o *AgentCtrlInitOptions) makeRequest(conn net.Conn) error { - options := channel.DefaultOptions() - options.ConnectTimeout = time.Second - dialer := channel.NewExistingConnDialer(&identity.TokenId{Token: "agent"}, conn, nil) - ch, err := channel.NewChannel("agent", dialer, nil, options) - if err != nil { - return err - } - - offset := 0 - if len(o.Args) == 4 { - offset = 1 - } - +func (self *AgentCtrlInitOptions) makeRequest(ch channel.Channel) error { initEdgeRequest := &edge_mgmt_pb.InitEdgeRequest{ - Username: o.Args[offset], - Password: o.Args[offset+1], - Name: o.Args[offset+2], + Username: self.Args[0], + Password: self.Args[1], + Name: self.Args[2], } - reply, err := protobufs.MarshalTyped(initEdgeRequest).WithTimeout(5 * time.Second).SendForReply(ch) + reply, err := protobufs.MarshalTyped(initEdgeRequest).WithTimeout(self.timeout).SendForReply(ch) if err != nil { return err } diff --git a/ziti/cmd/agentcli/agent_controller_init_from_db.go b/ziti/cmd/agentcli/agent_controller_init_from_db.go index 44243a532..2ecc68dfc 100644 --- a/ziti/cmd/agentcli/agent_controller_init_from_db.go +++ b/ziti/cmd/agentcli/agent_controller_init_from_db.go @@ -18,76 +18,44 @@ package agentcli import ( "fmt" - "github.com/openziti/agent" "github.com/openziti/channel/v2" "github.com/openziti/fabric/pb/mgmt_pb" - "github.com/openziti/identity" "github.com/openziti/ziti/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "github.com/spf13/cobra" - "net" - "time" ) -type AgentCtrlInitFromDbOptions struct { +type AgentCtrlInitFromDbAction struct { AgentOptions Voter bool MemberId string } func NewAgentCtrlInitFromDb(p common.OptionsProvider) *cobra.Command { - options := &AgentCtrlInitFromDbOptions{ + action := &AgentCtrlInitFromDbAction{ AgentOptions: AgentOptions{ CommonOptions: p(), }, } cmd := &cobra.Command{ - Args: cobra.RangeArgs(1, 2), - Use: "init-from-db path/to/source.db", - Run: func(cmd *cobra.Command, args []string) { - options.Cmd = cmd - options.Args = args - err := options.Run() - cmdhelper.CheckErr(err) + Args: cobra.ExactArgs(1), + Use: "init-from-db path/to/source.db", + RunE: func(cmd *cobra.Command, args []string) error { + action.Cmd = cmd + action.Args = args + return action.MakeChannelRequest(byte(AgentAppController), action.makeRequest) }, } + action.AddAgentOptions(cmd) + return cmd } -// Run implements the command -func (o *AgentCtrlInitFromDbOptions) Run() error { - var addr string - var err error +func (self *AgentCtrlInitFromDbAction) makeRequest(ch channel.Channel) error { + msg := channel.NewMessage(int32(mgmt_pb.ContentType_RaftInitFromDb), []byte(self.Args[0])) - if len(o.Args) == 2 { - addr, err = agent.ParseGopsAddress(o.Args) - if err != nil { - return err - } - } - - return agent.MakeRequestF(addr, agent.CustomOpAsync, []byte{byte(AgentAppController)}, o.makeRequest) -} - -func (o *AgentCtrlInitFromDbOptions) makeRequest(conn net.Conn) error { - options := channel.DefaultOptions() - options.ConnectTimeout = time.Second - dialer := channel.NewExistingConnDialer(&identity.TokenId{Token: "agent"}, conn, nil) - ch, err := channel.NewChannel("agent", dialer, nil, options) - if err != nil { - return err - } - - offset := 0 - if len(o.Args) == 2 { - offset = 1 - } - - msg := channel.NewMessage(int32(mgmt_pb.ContentType_RaftInitFromDb), []byte(o.Args[offset])) - - reply, err := msg.WithTimeout(5 * time.Second).SendForReply(ch) + reply, err := msg.WithTimeout(self.timeout).SendForReply(ch) if err != nil { return err } diff --git a/ziti/cmd/agentcli/agent_controller_raft_join.go b/ziti/cmd/agentcli/agent_controller_raft_join.go index bda3a55a5..58083a6f3 100644 --- a/ziti/cmd/agentcli/agent_controller_raft_join.go +++ b/ziti/cmd/agentcli/agent_controller_raft_join.go @@ -18,86 +18,55 @@ package agentcli import ( "fmt" - "github.com/openziti/agent" "github.com/openziti/channel/v2" "github.com/openziti/fabric/controller" "github.com/openziti/fabric/pb/mgmt_pb" - "github.com/openziti/identity" "github.com/openziti/ziti/ziti/cmd/common" cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "github.com/spf13/cobra" - "net" - "time" ) -type AgentCtrlRaftJoinOptions struct { +type AgentCtrlRaftJoinAction struct { AgentOptions Voter bool MemberId string } func NewAgentCtrlRaftJoin(p common.OptionsProvider) *cobra.Command { - options := &AgentCtrlRaftJoinOptions{ + action := &AgentCtrlRaftJoinAction{ AgentOptions: AgentOptions{ CommonOptions: p(), }, } cmd := &cobra.Command{ - Args: cobra.RangeArgs(1, 2), - Use: "raft-join ", + Args: cobra.ExactArgs(1), + Use: "raft-join ", Run: func(cmd *cobra.Command, args []string) { - options.Cmd = cmd - options.Args = args - err := options.Run() + action.Cmd = cmd + action.Args = args + err := action.MakeChannelRequest(byte(AgentAppController), action.makeRequest) cmdhelper.CheckErr(err) }, } - cmd.Flags().BoolVar(&options.Voter, "voter", true, "Is this member a voting member") - cmd.Flags().StringVar(&options.MemberId, "id", "", "The member id. If not provided, it will be looked up") + action.AddAgentOptions(cmd) + cmd.Flags().BoolVar(&action.Voter, "voter", true, "Is this member a voting member") + cmd.Flags().StringVar(&action.MemberId, "id", "", "The member id. If not provided, it will be looked up") return cmd } -// Run implements the command -func (o *AgentCtrlRaftJoinOptions) Run() error { - var addr string - var err error - - if len(o.Args) == 2 { - addr, err = agent.ParseGopsAddress(o.Args) - if err != nil { - return err - } - } - - return agent.MakeRequestF(addr, agent.CustomOpAsync, []byte{byte(AgentAppController)}, o.makeRequest) -} - -func (o *AgentCtrlRaftJoinOptions) makeRequest(conn net.Conn) error { - options := channel.DefaultOptions() - options.ConnectTimeout = time.Second - dialer := channel.NewExistingConnDialer(&identity.TokenId{Token: "agent"}, conn, nil) - ch, err := channel.NewChannel("agent", dialer, nil, options) - if err != nil { - return err - } - - offset := 0 - if len(o.Args) == 2 { - offset = 1 - } - +func (self *AgentCtrlRaftJoinAction) makeRequest(ch channel.Channel) error { msg := channel.NewMessage(int32(mgmt_pb.ContentType_RaftJoinRequestType), nil) - msg.PutStringHeader(controller.AgentAddrHeader, o.Args[offset]) - msg.PutBoolHeader(controller.AgentIsVoterHeader, o.Voter) + msg.PutStringHeader(controller.AgentAddrHeader, self.Args[0]) + msg.PutBoolHeader(controller.AgentIsVoterHeader, self.Voter) - if o.MemberId != "" { - msg.PutStringHeader(controller.AgentIdHeader, o.MemberId) + if self.MemberId != "" { + msg.PutStringHeader(controller.AgentIdHeader, self.MemberId) } - reply, err := msg.WithTimeout(5 * time.Second).SendForReply(ch) + reply, err := msg.WithTimeout(self.timeout).SendForReply(ch) if err != nil { return err } diff --git a/ziti/cmd/agentcli/agent_controller_raft_list.go b/ziti/cmd/agentcli/agent_controller_raft_list.go index 4bf2176fb..6429a3623 100644 --- a/ziti/cmd/agentcli/agent_controller_raft_list.go +++ b/ziti/cmd/agentcli/agent_controller_raft_list.go @@ -19,23 +19,18 @@ package agentcli import ( "fmt" "github.com/golang/protobuf/proto" - "github.com/openziti/agent" "github.com/openziti/channel/v2" "github.com/openziti/fabric/pb/mgmt_pb" - "github.com/openziti/identity" "github.com/openziti/ziti/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "github.com/spf13/cobra" - "net" - "time" ) -type AgentCtrlRaftListOptions struct { +type AgentCtrlRaftListAction struct { AgentOptions } func NewAgentCtrlRaftList(p common.OptionsProvider) *cobra.Command { - options := &AgentCtrlRaftListOptions{ + action := &AgentCtrlRaftListAction{ AgentOptions: AgentOptions{ CommonOptions: p(), }, @@ -43,44 +38,22 @@ func NewAgentCtrlRaftList(p common.OptionsProvider) *cobra.Command { cmd := &cobra.Command{ Args: cobra.RangeArgs(0, 1), - Use: "raft-list ", - Run: func(cmd *cobra.Command, args []string) { - options.Cmd = cmd - options.Args = args - err := options.Run() - cmdhelper.CheckErr(err) + Use: "raft-list", + RunE: func(cmd *cobra.Command, args []string) error { + action.Cmd = cmd + action.Args = args + return action.MakeChannelRequest(byte(AgentAppController), action.makeRequest) }, } + action.AddAgentOptions(cmd) + return cmd } -// Run implements the command -func (o *AgentCtrlRaftListOptions) Run() error { - var addr string - var err error - - if len(o.Args) == 1 { - addr, err = agent.ParseGopsAddress(o.Args) - if err != nil { - return err - } - } - - return agent.MakeRequestF(addr, agent.CustomOpAsync, []byte{byte(AgentAppController)}, o.makeRequest) -} - -func (o *AgentCtrlRaftListOptions) makeRequest(conn net.Conn) error { - options := channel.DefaultOptions() - options.ConnectTimeout = time.Second - dialer := channel.NewExistingConnDialer(&identity.TokenId{Token: "agent"}, conn, nil) - ch, err := channel.NewChannel("agent", dialer, nil, options) - if err != nil { - return err - } - +func (self *AgentCtrlRaftListAction) makeRequest(ch channel.Channel) error { msg := channel.NewMessage(int32(mgmt_pb.ContentType_RaftListMembersRequestType), nil) - reply, err := msg.WithTimeout(5 * time.Second).SendForReply(ch) + reply, err := msg.WithTimeout(self.timeout).SendForReply(ch) if err != nil { return err } diff --git a/ziti/cmd/agentcli/agent_gc.go b/ziti/cmd/agentcli/agent_gc.go deleted file mode 100644 index ad56c6db9..000000000 --- a/ziti/cmd/agentcli/agent_gc.go +++ /dev/null @@ -1,60 +0,0 @@ -/* - Copyright NetFoundry Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package agentcli - -import ( - "github.com/openziti/agent" - "github.com/openziti/ziti/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" - "github.com/spf13/cobra" - "os" -) - -type AgentGcAction struct { - AgentOptions -} - -func NewGcCmd(p common.OptionsProvider) *cobra.Command { - action := &AgentGcAction{ - AgentOptions: AgentOptions{ - CommonOptions: p(), - }, - } - - cmd := &cobra.Command{ - Use: "gc ", - Short: "Run garbage collection in the target application", - Args: cobra.MaximumNArgs(1), - Run: func(cmd *cobra.Command, args []string) { - action.Cmd = cmd - action.Args = args - err := action.Run() - cmdhelper.CheckErr(err) - }, - } - - return cmd -} - -// Run implements the command -func (self *AgentGcAction) Run() error { - addr, err := agent.ParseGopsAddress(self.Args) - if err != nil { - return err - } - return agent.MakeRequest(addr, agent.GC, nil, os.Stdout) -} diff --git a/ziti/cmd/agentcli/agent_go_version_action.go b/ziti/cmd/agentcli/agent_list.go similarity index 56% rename from ziti/cmd/agentcli/agent_go_version_action.go rename to ziti/cmd/agentcli/agent_list.go index 94e0a9099..9dc1fd029 100644 --- a/ziti/cmd/agentcli/agent_go_version_action.go +++ b/ziti/cmd/agentcli/agent_list.go @@ -17,6 +17,8 @@ package agentcli import ( + "fmt" + "github.com/jedib0t/go-pretty/v6/table" "github.com/openziti/agent" "github.com/openziti/ziti/ziti/cmd/common" cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" @@ -24,22 +26,22 @@ import ( "os" ) -type AgentGoVersionAction struct { +type AgentListAction struct { AgentOptions - CtrlListener string } -func NewGoVersionCmd(p common.OptionsProvider) *cobra.Command { - action := &AgentGoVersionAction{ +// NewListCmd Pss a command object for the "list" command +func NewListCmd(p common.OptionsProvider) *cobra.Command { + action := &AgentListAction{ AgentOptions: AgentOptions{ CommonOptions: p(), }, } cmd := &cobra.Command{ - Use: "goversion ", - Short: "Returns the golang version of the target application", - Args: cobra.MaximumNArgs(1), + Use: "list", + Short: "List ziti processes", + Long: "Show information about currently running Ziti processes", Run: func(cmd *cobra.Command, args []string) { action.Cmd = cmd action.Args = args @@ -51,11 +53,22 @@ func NewGoVersionCmd(p common.OptionsProvider) *cobra.Command { return cmd } -// Run implements the command -func (self *AgentGoVersionAction) Run() error { - addr, err := agent.ParseGopsAddress(self.Args) +func (self *AgentListAction) Run() error { + processes, err := agent.GetGopsProcesses() if err != nil { return err } - return agent.MakeRequest(addr, agent.Version, nil, os.Stdout) + + t := table.NewWriter() + t.SetStyle(table.StyleRounded) + t.AppendHeader(table.Row{"PID", "Executable", "App ID", "Unix Socket", "App Type", "App Version", "App Alias"}) + + for _, p := range processes { + t.AppendRow(table.Row{p.Pid, p.Executable, p.AppId, p.UnixSocket, p.AppType, p.AppVersion, p.AppAlias}) + } + + if _, err = fmt.Fprintln(os.Stdout, t.Render()); err != nil { + panic(err) + } + return nil } diff --git a/ziti/cmd/agentcli/agent_memstats.go b/ziti/cmd/agentcli/agent_memstats.go deleted file mode 100644 index 8004b8eda..000000000 --- a/ziti/cmd/agentcli/agent_memstats.go +++ /dev/null @@ -1,61 +0,0 @@ -/* - Copyright NetFoundry Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package agentcli - -import ( - "github.com/openziti/agent" - "github.com/openziti/ziti/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" - "github.com/spf13/cobra" - "os" -) - -type AgentMemstatsAction struct { - AgentOptions - CtrlListener string -} - -func NewMemstatsCmd(p common.OptionsProvider) *cobra.Command { - action := &AgentMemstatsAction{ - AgentOptions: AgentOptions{ - CommonOptions: p(), - }, - } - - cmd := &cobra.Command{ - Use: "memstats ", - Short: "Returns memory use summary of the target application", - Args: cobra.MaximumNArgs(1), - Run: func(cmd *cobra.Command, args []string) { - action.Cmd = cmd - action.Args = args - err := action.Run() - cmdhelper.CheckErr(err) - }, - } - - return cmd -} - -// Run implements the command -func (o *AgentMemstatsAction) Run() error { - addr, err := agent.ParseGopsAddress(o.Args) - if err != nil { - return err - } - return agent.MakeRequest(addr, agent.MemStats, nil, os.Stdout) -} diff --git a/ziti/cmd/agentcli/agent_pprof_cpu.go b/ziti/cmd/agentcli/agent_pprof_cpu.go index ad590e17e..7cf61f47b 100644 --- a/ziti/cmd/agentcli/agent_pprof_cpu.go +++ b/ziti/cmd/agentcli/agent_pprof_cpu.go @@ -17,16 +17,19 @@ package agentcli import ( + "fmt" "github.com/openziti/agent" "github.com/openziti/ziti/ziti/cmd/common" cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "github.com/spf13/cobra" "io" "os" + "time" ) type AgentPprofCpuAction struct { AgentOptions + outputFile string } func NewPprofCpuCmd(p common.OptionsProvider) *cobra.Command { @@ -48,11 +51,34 @@ func NewPprofCpuCmd(p common.OptionsProvider) *cobra.Command { }, } + action.AddAgentOptions(cmd) + cmd.Flags().StringVarP(&action.outputFile, "output-file", "o", "", "Output file for pprof") + return cmd } // Run implements the command func (self *AgentPprofCpuAction) Run() error { + if self.Cmd.Flags().Changed("timeout") { + time.AfterFunc(self.timeout, func() { + fmt.Println("operation timed out") + os.Exit(-1) + }) + } + + if len(self.Args) == 0 { + var out io.WriteCloser = os.Stdout + var err error + if self.outputFile != "" { + out, err = os.Create(self.outputFile) + if err != nil { + return err + } + defer out.Close() + } + return self.RunCopyOut(agent.CPUProfile, nil, out) + } + addr, err := agent.ParseGopsAddress(self.Args) if err != nil { return err diff --git a/ziti/cmd/agentcli/agent_pprof_heap.go b/ziti/cmd/agentcli/agent_pprof_heap.go index 04776721c..c46f91598 100644 --- a/ziti/cmd/agentcli/agent_pprof_heap.go +++ b/ziti/cmd/agentcli/agent_pprof_heap.go @@ -17,16 +17,19 @@ package agentcli import ( + "fmt" "github.com/openziti/agent" "github.com/openziti/ziti/ziti/cmd/common" cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "github.com/spf13/cobra" "io" "os" + "time" ) type AgentPprofHeapAction struct { AgentOptions + outputFile string } func NewPprofHeapCmd(p common.OptionsProvider) *cobra.Command { @@ -47,11 +50,34 @@ func NewPprofHeapCmd(p common.OptionsProvider) *cobra.Command { }, } + action.AddAgentOptions(cmd) + cmd.Flags().StringVarP(&action.outputFile, "output-file", "o", "", "Output file for pprof") + return cmd } // Run implements the command func (self *AgentPprofHeapAction) Run() error { + if self.Cmd.Flags().Changed("timeout") { + time.AfterFunc(self.timeout, func() { + fmt.Println("operation timed out") + os.Exit(-1) + }) + } + + if len(self.Args) == 0 { + var out io.WriteCloser = os.Stdout + var err error + if self.outputFile != "" { + out, err = os.Create(self.outputFile) + if err != nil { + return err + } + defer out.Close() + } + return self.RunCopyOut(agent.HeapProfile, nil, out) + } + addr, err := agent.ParseGopsAddress(self.Args) if err != nil { return err diff --git a/ziti/cmd/agentcli/agent_router_add_route.go b/ziti/cmd/agentcli/agent_router_add_route.go index 0cd14bd8e..71e338ed5 100644 --- a/ziti/cmd/agentcli/agent_router_add_route.go +++ b/ziti/cmd/agentcli/agent_router_add_route.go @@ -17,24 +17,22 @@ package agentcli import ( - "encoding/binary" - "github.com/openziti/agent" + "fmt" + "github.com/openziti/channel/v2" "github.com/openziti/fabric/pb/ctrl_pb" + "github.com/openziti/fabric/pb/mgmt_pb" "github.com/openziti/fabric/router" "github.com/openziti/ziti/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "github.com/spf13/cobra" "google.golang.org/protobuf/proto" - "os" ) type AgentRouteAction struct { AgentOptions - CtrlListener string } func NewRouteCmd(p common.OptionsProvider) *cobra.Command { - options := &AgentRouteAction{ + action := &AgentRouteAction{ AgentOptions: AgentOptions{ CommonOptions: p(), }, @@ -42,38 +40,26 @@ func NewRouteCmd(p common.OptionsProvider) *cobra.Command { cmd := &cobra.Command{ Args: cobra.RangeArgs(3, 4), - Use: "route ", - Run: func(cmd *cobra.Command, args []string) { - options.Cmd = cmd - options.Args = args - err := options.Run() - cmdhelper.CheckErr(err) + Use: "route ", + RunE: func(cmd *cobra.Command, args []string) error { + action.Cmd = cmd + action.Args = args + return action.MakeChannelRequest(router.AgentAppId, action.makeRequest) }, } + action.AddAgentOptions(cmd) + return cmd } -// Run implements the command -func (self *AgentRouteAction) Run() error { - var addr string - var err error - - offset := 0 - if len(self.Args) == 4 { - addr, err = agent.ParseGopsAddress(self.Args) - if err != nil { - return err - } - offset = 1 - } - +func (self *AgentRouteAction) makeRequest(ch channel.Channel) error { route := &ctrl_pb.Route{ - CircuitId: self.Args[offset], + CircuitId: self.Args[1], Forwards: []*ctrl_pb.Route_Forward{ { - SrcAddress: self.Args[offset+1], - DstAddress: self.Args[offset+2], + SrcAddress: self.Args[2], + DstAddress: self.Args[3], }, }, } @@ -83,15 +69,26 @@ func (self *AgentRouteAction) Run() error { return err } - fullBuf := make([]byte, len(buf)+6) - fullBuf[0] = byte(AgentAppRouter) - fullBuf[1] = router.UpdateRoute + msg := channel.NewMessage(int32(mgmt_pb.ContentType_RouterDebugUpdateRouteRequestType), buf) + msg.PutStringHeader(int32(mgmt_pb.Header_ControllerId), self.Args[0]) + reply, err := msg.WithTimeout(self.timeout).SendForReply(ch) + if err != nil { + return err + } - sizeBuf := make([]byte, 4) - binary.LittleEndian.PutUint32(sizeBuf, uint32(len(buf))) - - copy(fullBuf[2:], sizeBuf) - copy(fullBuf[6:], buf) - - return agent.MakeRequest(addr, agent.CustomOp, fullBuf, os.Stdout) + if reply.ContentType == channel.ContentTypeResultType { + result := channel.UnmarshalResult(reply) + if result.Success { + if len(result.Message) > 0 { + fmt.Printf("success: %v\n", result.Message) + } else { + fmt.Println("success") + } + } else { + fmt.Printf("error: %v\n", result.Message) + } + } else { + fmt.Printf("unexpected response type %v\n", reply.ContentType) + } + return nil } diff --git a/ziti/cmd/agentcli/agent_router_forget_link.go b/ziti/cmd/agentcli/agent_router_forget_link.go index 1ed92255e..e4cab0e1e 100644 --- a/ziti/cmd/agentcli/agent_router_forget_link.go +++ b/ziti/cmd/agentcli/agent_router_forget_link.go @@ -18,16 +18,12 @@ package agentcli import ( "fmt" - "github.com/openziti/agent" "github.com/openziti/channel/v2" "github.com/openziti/fabric/pb/mgmt_pb" "github.com/openziti/fabric/router" - "github.com/openziti/identity" "github.com/openziti/ziti/ziti/cmd/common" cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "github.com/spf13/cobra" - "net" - "time" ) type ForgetLinkAgentAction struct { @@ -35,56 +31,38 @@ type ForgetLinkAgentAction struct { } func NewForgetLinkAgentCmd(p common.OptionsProvider) *cobra.Command { - options := &ForgetLinkAgentAction{ + action := &ForgetLinkAgentAction{ AgentOptions: AgentOptions{ CommonOptions: p(), }, } cmd := &cobra.Command{ - Args: cobra.RangeArgs(1, 2), - Use: "forget-link ", + Args: cobra.ExactArgs(1), + Use: "forget-link ", Run: func(cmd *cobra.Command, args []string) { - options.Cmd = cmd - options.Args = args - err := options.Run() + action.Cmd = cmd + action.Args = args + err := action.Run() cmdhelper.CheckErr(err) }, } + action.AddAgentOptions(cmd) + return cmd } // Run implements the command func (self *ForgetLinkAgentAction) Run() error { - var addr string - var err error - if len(self.Args) == 2 { - addr, err = agent.ParseGopsAddress(self.Args) - if err != nil { - return err - } - } - - return agent.MakeRequestF(addr, agent.CustomOpAsync, []byte{router.AgentAppId}, self.makeRequest) + return self.MakeChannelRequest(router.AgentAppId, self.makeRequest) } -func (self *ForgetLinkAgentAction) makeRequest(conn net.Conn) error { - options := channel.DefaultOptions() - options.ConnectTimeout = time.Second - dialer := channel.NewExistingConnDialer(&identity.TokenId{Token: "agent"}, conn, nil) - ch, err := channel.NewChannel("agent", dialer, nil, options) - if err != nil { - return err - } - +func (self *ForgetLinkAgentAction) makeRequest(ch channel.Channel) error { linkId := self.Args[0] - if len(self.Args) == 2 { - linkId = self.Args[1] - } msg := channel.NewMessage(int32(mgmt_pb.ContentType_RouterDebugForgetLinkRequestType), []byte(linkId)) - reply, err := msg.WithTimeout(5 * time.Second).SendForReply(ch) + reply, err := msg.WithTimeout(self.timeout).SendForReply(ch) if err != nil { return err } diff --git a/ziti/cmd/agentcli/agent_router_toggle_ctrl_channel.go b/ziti/cmd/agentcli/agent_router_toggle_ctrl_channel.go new file mode 100644 index 000000000..57870f6a4 --- /dev/null +++ b/ziti/cmd/agentcli/agent_router_toggle_ctrl_channel.go @@ -0,0 +1,90 @@ +/* + Copyright NetFoundry Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package agentcli + +import ( + "fmt" + "github.com/openziti/channel/v2" + "github.com/openziti/fabric/pb/mgmt_pb" + "github.com/openziti/fabric/router" + "github.com/openziti/ziti/ziti/cmd/common" + cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" + "github.com/spf13/cobra" +) + +type ToggleCtrlChannelAgentAction struct { + AgentOptions + enable bool +} + +func NewToggleCtrlChannelAgentCmd(p common.OptionsProvider, name string, enable bool) *cobra.Command { + options := &ToggleCtrlChannelAgentAction{ + AgentOptions: AgentOptions{ + CommonOptions: p(), + }, + enable: enable, + } + + cmd := &cobra.Command{ + Args: cobra.RangeArgs(0, 1), + Use: name + " ", + Run: func(cmd *cobra.Command, args []string) { + options.Cmd = cmd + options.Args = args + err := options.Run() + cmdhelper.CheckErr(err) + }, + } + + options.AddAgentOptions(cmd) + + return cmd +} + +// Run implements the command +func (self *ToggleCtrlChannelAgentAction) Run() error { + return self.MakeChannelRequest(router.AgentAppId, self.makeRequest) +} + +func (self *ToggleCtrlChannelAgentAction) makeRequest(ch channel.Channel) error { + var ctrlId string + if len(self.Args) > 0 { + ctrlId = self.Args[0] + } + + msg := channel.NewMessage(int32(mgmt_pb.ContentType_RouterDebugToggleCtrlChannelRequestType), []byte(ctrlId)) + msg.PutBoolHeader(int32(mgmt_pb.Header_CtrlChanToggle), self.enable) + reply, err := msg.WithTimeout(self.timeout).SendForReply(ch) + if err != nil { + return err + } + if reply.ContentType == channel.ContentTypeResultType { + result := channel.UnmarshalResult(reply) + if result.Success { + if len(result.Message) > 0 { + fmt.Printf("success: %v\n", result.Message) + } else { + fmt.Println("success") + } + } else { + fmt.Printf("error: %v\n", result.Message) + } + } else { + fmt.Printf("unexpected response type %v\n", reply.ContentType) + } + return nil +} diff --git a/ziti/cmd/agentcli/agent_set_channel_log_level.go b/ziti/cmd/agentcli/agent_set_channel_log_level.go index a92e8dd11..fe8ba3f71 100644 --- a/ziti/cmd/agentcli/agent_set_channel_log_level.go +++ b/ziti/cmd/agentcli/agent_set_channel_log_level.go @@ -19,6 +19,7 @@ package agentcli import ( "bytes" "encoding/binary" + "fmt" "github.com/openziti/agent" "github.com/openziti/ziti/ziti/cmd/common" cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" @@ -27,6 +28,7 @@ import ( "github.com/spf13/cobra" "os" "strings" + "time" ) type AgentSetChannelLogLevelAction struct { @@ -52,29 +54,30 @@ func NewSetChannelLogLevelCmd(p common.OptionsProvider) *cobra.Command { }, } + action.AddAgentOptions(cmd) + return cmd } // Run implements the command func (self *AgentSetChannelLogLevelAction) Run() error { - var addr string - var err error + if self.Cmd.Flags().Changed("timeout") { + time.AfterFunc(self.timeout, func() { + fmt.Println("operation timed out") + os.Exit(-1) + }) + } + var channelArg string var levelArg string if len(self.Args) == 2 { - addr, err = agent.ParseGopsAddress(nil) channelArg = self.Args[0] levelArg = self.Args[1] } else { - addr, err = agent.ParseGopsAddress(self.Args) channelArg = self.Args[1] levelArg = self.Args[2] } - if err != nil { - return err - } - var level logrus.Level var found bool for _, l := range logrus.AllLevels { @@ -95,5 +98,13 @@ func (self *AgentSetChannelLogLevelAction) Run() error { buf.Write([]byte(channelArg)) buf.WriteByte(byte(level)) + if len(self.Args) == 2 { + return self.MakeRequest(agent.SetChannelLogLevel, buf.Bytes(), self.CopyToWriter(os.Stdout)) + } + + addr, err := agent.ParseGopsAddress(self.Args) + if err != nil { + return err + } return agent.MakeRequest(addr, agent.SetChannelLogLevel, buf.Bytes(), os.Stdout) } diff --git a/ziti/cmd/agentcli/agent_set_log_level.go b/ziti/cmd/agentcli/agent_set_log_level.go index be306648f..0c1d08bc5 100644 --- a/ziti/cmd/agentcli/agent_set_log_level.go +++ b/ziti/cmd/agentcli/agent_set_log_level.go @@ -17,6 +17,7 @@ package agentcli import ( + "fmt" "github.com/openziti/agent" "github.com/openziti/ziti/ziti/cmd/common" cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" @@ -25,6 +26,7 @@ import ( "github.com/spf13/cobra" "os" "strings" + "time" ) type AgentSetLogLevelAction struct { @@ -50,24 +52,25 @@ func NewSetLogLevelCmd(p common.OptionsProvider) *cobra.Command { }, } + action.AddAgentOptions(cmd) + return cmd } // Run implements the command func (self *AgentSetLogLevelAction) Run() error { - var addr string - var err error - var levelArg string - if len(self.Args) == 1 { - addr, err = agent.ParseGopsAddress(nil) - levelArg = self.Args[0] - } else { - addr, err = agent.ParseGopsAddress(self.Args) - levelArg = self.Args[1] + if self.Cmd.Flags().Changed("timeout") { + time.AfterFunc(self.timeout, func() { + fmt.Println("operation timed out") + os.Exit(-1) + }) } - if err != nil { - return err + var levelArg string + if len(self.Args) == 1 { + levelArg = self.Args[0] + } else { + levelArg = self.Args[1] } var level logrus.Level @@ -84,5 +87,14 @@ func (self *AgentSetLogLevelAction) Run() error { } buf := []byte{byte(level)} + + if len(self.Args) == 1 { + return self.MakeRequest(agent.SetLogLevel, buf, self.CopyToWriter(os.Stdout)) + } + + addr, err := agent.ParseGopsAddress(self.Args) + if err != nil { + return err + } return agent.MakeRequest(addr, agent.SetLogLevel, buf, os.Stdout) } diff --git a/ziti/cmd/agentcli/agent_setgc.go b/ziti/cmd/agentcli/agent_setgc.go index ca1a9663d..3d6176e53 100644 --- a/ziti/cmd/agentcli/agent_setgc.go +++ b/ziti/cmd/agentcli/agent_setgc.go @@ -18,12 +18,14 @@ package agentcli import ( "encoding/binary" + "fmt" "github.com/openziti/agent" "github.com/openziti/ziti/ziti/cmd/common" cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "github.com/spf13/cobra" "os" "strconv" + "time" ) type AgentSetGcAction struct { @@ -49,24 +51,25 @@ func NewSetGcCmd(p common.OptionsProvider) *cobra.Command { }, } + action.AddAgentOptions(cmd) + return cmd } // Run implements the command -func (o *AgentSetGcAction) Run() error { - var addr string - var err error - var pctArg string - if len(o.Args) == 1 { - addr, err = agent.ParseGopsAddress(nil) - pctArg = o.Args[0] - } else { - addr, err = agent.ParseGopsAddress(o.Args) - pctArg = o.Args[1] +func (self *AgentSetGcAction) Run() error { + if self.Cmd.Flags().Changed("timeout") { + time.AfterFunc(self.timeout, func() { + fmt.Println("operation timed out") + os.Exit(-1) + }) } - if err != nil { - return err + var pctArg string + if len(self.Args) == 1 { + pctArg = self.Args[0] + } else { + pctArg = self.Args[1] } perc, err := strconv.ParseInt(pctArg, 10, strconv.IntSize) @@ -76,5 +79,14 @@ func (o *AgentSetGcAction) Run() error { buf := make([]byte, binary.MaxVarintLen64) binary.PutVarint(buf, perc) + if len(self.Args) == 1 { + return self.MakeRequest(agent.SetGCPercent, buf, self.CopyToWriter(os.Stdout)) + } + + addr, err := agent.ParseGopsAddress(self.Args) + if err != nil { + return err + } + return agent.MakeRequest(addr, agent.SetGCPercent, buf, os.Stdout) } diff --git a/ziti/cmd/agentcli/agent_simple.go b/ziti/cmd/agentcli/agent_simple.go index 38701e896..ff8f0dc4c 100644 --- a/ziti/cmd/agentcli/agent_simple.go +++ b/ziti/cmd/agentcli/agent_simple.go @@ -28,6 +28,29 @@ type SimpleAgentAction struct { AgentOptions } +func NewSimpleAgentCmd(name string, op byte, p common.OptionsProvider, desc string) *cobra.Command { + action := &SimpleAgentAction{ + AgentOptions: AgentOptions{ + CommonOptions: p(), + }, + } + + cmd := &cobra.Command{ + Args: cobra.MaximumNArgs(1), + Use: name + " ", + Short: desc, + RunE: func(cmd *cobra.Command, args []string) error { + action.Cmd = cmd + action.Args = args + return action.RunCopyOut(op, nil, os.Stdout) + }, + } + + action.AddAgentOptions(cmd) + + return cmd +} + func NewSimpleAgentCustomCmd(name string, appId AgentAppId, op byte, p common.OptionsProvider) *cobra.Command { action := &SimpleAgentAction{ AgentOptions: AgentOptions{ @@ -46,17 +69,13 @@ func NewSimpleAgentCustomCmd(name string, appId AgentAppId, op byte, p common.Op }, } + action.AddAgentOptions(cmd) + return cmd } // Run implements the command func (self *SimpleAgentAction) Run(appId AgentAppId, op byte) error { - addr, err := agent.ParseGopsAddress(self.Args) - if err != nil { - return err - } - buf := []byte{byte(appId), op} - - return agent.MakeRequest(addr, agent.CustomOp, buf, os.Stdout) + return self.RunCopyOut(agent.CustomOpAsync, buf, os.Stdout) } diff --git a/ziti/cmd/agentcli/agent_stack.go b/ziti/cmd/agentcli/agent_stack.go index 338a4a113..f5ba0d662 100644 --- a/ziti/cmd/agentcli/agent_stack.go +++ b/ziti/cmd/agentcli/agent_stack.go @@ -17,6 +17,7 @@ package agentcli import ( + "fmt" "github.com/openziti/agent" "github.com/openziti/ziti/ziti/cmd/common" cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" @@ -49,7 +50,8 @@ func NewStackCmd(p common.OptionsProvider) *cobra.Command { }, } - cmd.Flags().DurationVar(&action.StackTimeout, "stack-timeout", 5*time.Second, "Timeout for stack operation") + action.AddAgentOptions(cmd) + cmd.Flags().DurationVar(&action.StackTimeout, "stack-timeout", 5*time.Second, "Timeout for stack operation (deprecated, use --timeout instead)") return cmd } @@ -57,11 +59,8 @@ func NewStackCmd(p common.OptionsProvider) *cobra.Command { // Run implements the command func (o *AgentStackAction) Run() error { time.AfterFunc(o.StackTimeout, func() { + fmt.Println("operation timed out") os.Exit(-1) }) - addr, err := agent.ParseGopsAddress(o.Args) - if err != nil { - return err - } - return agent.MakeRequest(addr, agent.StackTrace, nil, os.Stdout) + return o.RunCopyOut(agent.Stats, nil, os.Stdout) } diff --git a/ziti/cmd/agentcli/agent_stats.go b/ziti/cmd/agentcli/agent_stats.go deleted file mode 100644 index adeba86d4..000000000 --- a/ziti/cmd/agentcli/agent_stats.go +++ /dev/null @@ -1,60 +0,0 @@ -/* - Copyright NetFoundry Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package agentcli - -import ( - "github.com/openziti/agent" - "github.com/openziti/ziti/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" - "github.com/spf13/cobra" - "os" -) - -type AgentStatsAction struct { - AgentOptions -} - -func NewStatsCmd(p common.OptionsProvider) *cobra.Command { - action := &AgentStatsAction{ - AgentOptions: AgentOptions{ - CommonOptions: p(), - }, - } - - cmd := &cobra.Command{ - Use: "stats ", - Short: "Emits some runtime information (# go-routines, threads, cpus, etc) from the target application", - Args: cobra.MaximumNArgs(1), - Run: func(cmd *cobra.Command, args []string) { - action.Cmd = cmd - action.Args = args - err := action.Run() - cmdhelper.CheckErr(err) - }, - } - - return cmd -} - -// Run implements the command -func (self *AgentStatsAction) Run() error { - addr, err := agent.ParseGopsAddress(self.Args) - if err != nil { - return err - } - return agent.MakeRequest(addr, agent.Stats, nil, os.Stdout) -} diff --git a/ziti/cmd/agentcli/agent_trace.go b/ziti/cmd/agentcli/agent_trace.go index ac704a74a..5cd750c12 100644 --- a/ziti/cmd/agentcli/agent_trace.go +++ b/ziti/cmd/agentcli/agent_trace.go @@ -19,7 +19,6 @@ package agentcli import ( "github.com/openziti/agent" "github.com/openziti/ziti/ziti/cmd/common" - cmdhelper "github.com/openziti/ziti/ziti/cmd/helpers" "github.com/spf13/cobra" "os" ) @@ -38,22 +37,14 @@ func NewTraceCmd(p common.OptionsProvider) *cobra.Command { cmd := &cobra.Command{ Use: "trace", Short: "Turn tracing on for 5 seconds in the target application", - Run: func(cmd *cobra.Command, args []string) { + RunE: func(cmd *cobra.Command, args []string) error { action.Cmd = cmd action.Args = args - err := action.Run() - cmdhelper.CheckErr(err) + return action.RunCopyOut(agent.Trace, nil, os.Stdout) }, } + action.AddAgentOptions(cmd) + return cmd } - -// Run implements the command -func (self *AgentTraceAction) Run() error { - addr, err := agent.ParseGopsAddress(self.Args) - if err != nil { - return err - } - return agent.MakeRequest(addr, agent.Trace, nil, os.Stdout) -} diff --git a/ziti/cmd/demo/echo_server_update_terminator.go b/ziti/cmd/demo/echo_server_update_terminator.go index 4bd27c748..202b9a5ee 100644 --- a/ziti/cmd/demo/echo_server_update_terminator.go +++ b/ziti/cmd/demo/echo_server_update_terminator.go @@ -70,7 +70,7 @@ func (self *AgentEchoServerUpdateTerminatorAction) Run() error { } } - return agentcli.MakeAgentChannelRequest(addr, agent.CustomOpAsync, []byte{byte(EchoServerAppId)}, self.makeRequest) + return agentcli.MakeAgentChannelRequest(addr, EchoServerAppId, self.makeRequest) } func (self *AgentEchoServerUpdateTerminatorAction) makeRequest(ch channel.Channel) error { diff --git a/ziti/controller/root.go b/ziti/controller/root.go index 4d3d0dff3..55f65fda1 100644 --- a/ziti/controller/root.go +++ b/ziti/controller/root.go @@ -54,6 +54,7 @@ func NewControllerCmd() *cobra.Command { cmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "Enable verbose logging") cmd.PersistentFlags().BoolVarP(&cliAgentEnabled, "cliagent", "a", true, "Enable/disabled CLI Agent (enabled by default)") cmd.PersistentFlags().StringVar(&cliAgentAddr, "cli-agent-addr", "", "Specify where CLI Agent should list (ex: unix:/tmp/myfile.sock or tcp:127.0.0.1:10001)") + cmd.PersistentFlags().StringVar(&cliAgentAlias, "cli-agent-alias", "", "Alias which can be used by ziti agent commands to find this instance") cmd.PersistentFlags().StringVar(&logFormatter, "log-formatter", "", "Specify log formatter [json|pfxlog|text]") cmd.AddCommand(NewRunCmd()) @@ -68,6 +69,7 @@ func NewControllerCmd() *cobra.Command { var verbose bool var cliAgentEnabled bool var cliAgentAddr string +var cliAgentAlias string var logFormatter string func Execute() { diff --git a/ziti/controller/run.go b/ziti/controller/run.go index 875ac2f49..8941b3cfb 100644 --- a/ziti/controller/run.go +++ b/ziti/controller/run.go @@ -74,9 +74,14 @@ func run(cmd *cobra.Command, args []string) { edgeController.Initialize() if cliAgentEnabled { - options := agent.Options{Addr: cliAgentAddr} + options := agent.Options{ + Addr: cliAgentAddr, + AppId: config.Id.Token, + AppType: "controller", + AppVersion: version.GetVersion(), + AppAlias: cliAgentAlias, + } options.CustomOps = map[byte]func(conn net.Conn) error{ - agent.CustomOp: fabricController.HandleCustomAgentOp, agent.CustomOpAsync: fabricController.HandleCustomAgentAsyncOp, } if err := agent.Listen(options); err != nil { diff --git a/ziti/router/root.go b/ziti/router/root.go index eb962e88a..3a9c6f66d 100644 --- a/ziti/router/root.go +++ b/ziti/router/root.go @@ -53,6 +53,7 @@ func NewRouterCmd() *cobra.Command { routerCmd.PersistentFlags().StringVar(&logFormatter, "log-formatter", "", "Specify log formatter [json|pfxlog|text]") routerCmd.PersistentFlags().BoolVar(&cliAgentEnabled, "cli-agent", true, "Enable/disable CLI Agent (enabled by default)") routerCmd.PersistentFlags().StringVar(&cliAgentAddr, "cli-agent-addr", "", "Specify where CLI Agent should list (ex: unix:/tmp/myfile.sock or tcp:127.0.0.1:10001)") + routerCmd.PersistentFlags().StringVar(&cliAgentAlias, "cli-agent-alias", "", "Alias which can be used by ziti agent commands to find this instance") routerCmd.PersistentFlags().BoolVar(&enableDebugOps, "debug-ops", false, "Enable/disable debug agent operations (disabled by default)") routerCmd.AddCommand(NewRunCmd()) @@ -67,6 +68,7 @@ var logFormatter string var cliAgentEnabled bool var enableDebugOps bool var cliAgentAddr string +var cliAgentAlias string func Execute() { if err := NewRouterCmd().Execute(); err != nil { diff --git a/ziti/router/run.go b/ziti/router/run.go index 958cffde6..537f11560 100644 --- a/ziti/router/run.go +++ b/ziti/router/run.go @@ -49,7 +49,6 @@ func NewRunCmd() *cobra.Command { //flags are added to an internal map and read later on, see getFlags() runCmd.Flags().BoolP("extend", "e", false, "force the router on startup to extend enrollment certificates") - return runCmd } @@ -94,7 +93,13 @@ func run(cmd *cobra.Command, args []string) { } if cliAgentEnabled { - options := agent.Options{Addr: cliAgentAddr} + options := agent.Options{ + Addr: cliAgentAddr, + AppId: config.Id.Token, + AppType: "router", + AppVersion: version.GetVersion(), + AppAlias: cliAgentAlias, + } if config.EnableDebugOps { enableDebugOps = true } From 26257204927e19a16e0bfd272f3f38f40c91aec3 Mon Sep 17 00:00:00 2001 From: Shawn Carey Date: Fri, 13 Jan 2023 14:55:38 -0500 Subject: [PATCH 5/9] include arm64 build of quickstart image (#947) include arm64 build of quickstart image --- quickstart/docker/image/ziti-cli-functions.sh | 4 +- quickstart/docker/pushLatestDocker.sh | 56 ++++++++----------- 2 files changed, 25 insertions(+), 35 deletions(-) diff --git a/quickstart/docker/image/ziti-cli-functions.sh b/quickstart/docker/image/ziti-cli-functions.sh index b3dbb670a..358f5433a 100755 --- a/quickstart/docker/image/ziti-cli-functions.sh +++ b/quickstart/docker/image/ziti-cli-functions.sh @@ -173,6 +173,7 @@ function verifyZitiVersionExists { } function detectArchitecture { + if [ -n "${ZITI_ARCH}" ]; then return; fi ZITI_ARCH="amd64" detected_arch="$(uname -m)" # Apple M1 silicon @@ -238,7 +239,7 @@ function getZiti { if [[ "${ZITI_BIN_DIR-}" == "" ]]; then export ZITI_BIN_DIR="${ziti_bin_root}/ziti-${ZITI_BINARIES_VERSION}"; else echo "Using ZITI_BIN_DIR: ${ZITI_BIN_DIR}"; fi - ZITI_BINARIES_FILE_ABSPATH="${ZITI_HOME-}/ziti-bin/${ZITI_BINARIES_FILE}" + ZITI_BINARIES_FILE_ABSPATH="${ziti_bin_root}/${ZITI_BINARIES_FILE}" if ! test -f "${ZITI_BINARIES_FILE_ABSPATH}"; then zitidl="https://github.com/openziti/ziti/releases/download/${ZITI_BINARIES_VERSION-}/${ZITI_BINARIES_FILE}" echo -e 'Downloading '"$(BLUE "${zitidl}")"' to '"$(BLUE "${ZITI_BINARIES_FILE_ABSPATH}")" @@ -1487,6 +1488,7 @@ HeredocForSystemd } function setOs { + if [ -n "${ZITI_OSTYPE}" ]; then return; fi if [[ "$OSTYPE" == "linux-gnu"* ]]; then export ZITI_OSTYPE="linux" elif [[ "$OSTYPE" == "darwin"* ]]; then diff --git a/quickstart/docker/pushLatestDocker.sh b/quickstart/docker/pushLatestDocker.sh index 7584a59a6..b3d7e4ff6 100755 --- a/quickstart/docker/pushLatestDocker.sh +++ b/quickstart/docker/pushLatestDocker.sh @@ -6,41 +6,29 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" ZITI_QUICKSTART_ROOT="$(realpath ${SCRIPT_DIR}/..)" ZITI_BIN_ROOT="${ZITI_QUICKSTART_ROOT}/docker" -mkdir -p "${ZITI_BIN_ROOT}/ziti-bin" +for arch in amd64 arm64; do + (export ZITI_OSTYPE=linux; export ZITI_ARCH="${arch}" + source "${ZITI_QUICKSTART_ROOT}/ziti-cli-functions.sh" + if [ -d "${SCRIPT_DIR}/image/ziti.ignore" ]; then + rm -rf "${SCRIPT_DIR}/image/ziti.ignore" + fi -source "${ZITI_QUICKSTART_ROOT}/ziti-cli-functions.sh" + getZiti -ZITI_HOME="${ZITI_BIN_ROOT}" + mv "${ZITI_BIN_DIR}" "${SCRIPT_DIR}/image/ziti.ignore/" + docker build --platform linux/${arch} "${SCRIPT_DIR}/image" -t openziti/quickstart -if [ -d "${ZITI_BIN_ROOT}/image/ziti.ignore" ]; then - rm -rf "${ZITI_BIN_ROOT}/image/ziti.ignore" -fi + if [ -d "${SCRIPT_DIR}/image/ziti.ignore" ]; then + rm -rf "${SCRIPT_DIR}/image/ziti.ignore" + fi -getZiti - -mv "${ZITI_BIN_DIR}" "${SCRIPT_DIR}/image/ziti.ignore/" -docker build "${SCRIPT_DIR}/image" -t openziti/quickstart - -if [ -d "${ZITI_BIN_ROOT}/image/ziti.ignore" ]; then - rm -rf "${ZITI_BIN_ROOT}/image/ziti.ignore" -fi - -#if [ -f "${ZITI_BIN_ROOT}/ziti-*tar.gz" ]; then -# rm "${ZITI_BIN_ROOT}/ziti-*tar.gz" -#fi -if [ -d "${ZITI_BIN_ROOT}/ziti-bin" ]; then - rm -rf "${ZITI_BIN_ROOT}/ziti-bin" -fi -if [ -d "${ZITI_BIN_ROOT}/image/ziti.ignore" ]; then - rm -rf "${ZITI_BIN_ROOT}/image/ziti.ignore/" -fi - -vers="$(echo "${ZITI_BINARIES_VERSION}" | cut -c 2-100)" -echo DOCKERTAG: docker tag openziti/quickstart "openziti/quickstart:${vers}" -docker tag openziti/quickstart "openziti/quickstart:${vers}" -echo DOCKERTAG: docker tag openziti/quickstart "openziti/quickstart:latest" -docker tag openziti/quickstart "openziti/quickstart:latest" -echo DOCKERPUSH: docker push "openziti/quickstart:${vers}" -docker push "openziti/quickstart:${vers}" -echo DOCKERPUSH: docker push "openziti/quickstart:latest" -docker push "openziti/quickstart:latest" + vers="$(echo "${ZITI_BINARIES_VERSION}" | cut -c 2-100)" + echo DOCKERTAG: docker tag openziti/quickstart "openziti/quickstart:${vers}" + docker tag openziti/quickstart "openziti/quickstart:${vers}" + echo DOCKERTAG: docker tag openziti/quickstart "openziti/quickstart:latest" + docker tag openziti/quickstart "openziti/quickstart:latest" + echo DOCKERPUSH: docker push "openziti/quickstart:${vers}" + docker push "openziti/quickstart:${vers}" + echo DOCKERPUSH: docker push "openziti/quickstart:latest" + docker push "openziti/quickstart:latest") +done \ No newline at end of file From fe904d28a9332c26f78982a7d8dac67598d0534e Mon Sep 17 00:00:00 2001 From: dovholuknf <46322585+dovholuknf@users.noreply.github.com> Date: Tue, 17 Jan 2023 11:45:40 -0500 Subject: [PATCH 6/9] update readme, add some badges and a logo --- README.md | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 8ac9b4759..44d565a1d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,10 @@ -# Ziti +[![Build Status](https://github.com/openziti/ziti/actions/workflows/main.yml/badge.svg)](https://github.com/openziti/ziti/actions/workflows/main.yml) +[![Go Report Card](https://goreportcard.com/badge/github.com/openziti/ziti)](https://goreportcard.com/report/github.com/openziti/ziti) +![OpenZiti Logo](https://raw.githubusercontent.com/openziti/ziti-doc/main/docusaurus/static/img/ziti-logo-dark.svg) -Ziti represents the next generation of secure, open-source networking for your applications. Ziti has several components. +# OpenZiti + +OpenZiti represents the next generation of secure, open-source networking for your applications. OpenZiti has several components. ## Quick Reference @@ -17,8 +21,8 @@ Ziti represents the next generation of secure, open-source networking for your a * The OpenZiti fabric provides a scalable, plugable, networking mesh with built in smart routing * The OpenZiti edge components provide a secure, Zero Trust entry point into your network -* The OpenZiti SDKs allow you to integrate Ziti directly into your applications -* The OpenZiti tunnelers and proxies allow existing applications and networks to take advantage of a Ziti deployment +* The OpenZiti SDKs allow you to integrate OpenZiti directly into your applications +* The OpenZiti tunnelers and proxies allow existing applications and networks to take advantage of a OpenZiti deployment ### Security Features @@ -56,11 +60,11 @@ Let's break some of these buzzwords down. Many networking security solutions act like a wall around an internal network. Once you are through the wall, you have access to everything inside. Zero trust solutions enforce not just access to a network, but access to individual applications within that network. -Every client in a Ziti system must have an identity with provisioned certificates. The certificates are used to establish secure communications channels as well as for authentication and authorization of the associated identity. Whenever the client attempts to access a network application, Ziti will first ensure that the identity has access to the application. If access is revoked, open network connections will be closed. +Every client in a OpenZiti system must have an identity with provisioned certificates. The certificates are used to establish secure communications channels as well as for authentication and authorization of the associated identity. Whenever the client attempts to access a network application, OpenZiti will first ensure that the identity has access to the application. If access is revoked, open network connections will be closed. -This model enables Ziti systems to provide access to multiple applications while ensuring that clients only get access to those applications to which they have been granted access. +This model enables OpenZiti systems to provide access to multiple applications while ensuring that clients only get access to those applications to which they have been granted access. -In addition to requiring cert based authentication for clients, Ziti uses certificates to authorize communication between Ziti components. +In addition to requiring cert based authentication for clients, OpenZiti uses certificates to authorize communication between OpenZiti components. ### Dark Services and Routers @@ -74,15 +78,15 @@ There are various levels of accessibility a network application/service can have 1. For end users, VPNs add an extra step that needs to be done each time they want to access the service. 1. Services can be made dark, meaning they do not have any ports open for anyone to even try and connect to. -Making something dark can be done in a few ways, but the way it's generally handled in Ziti is that services reach out and establish one or more connections to the Ziti network fabric. Clients coming into the fabric can then reach the service through these connections after being authenticated and authorized. +Making something dark can be done in a few ways, but the way it's generally handled in OpenZiti is that services reach out and establish one or more connections to the OpenZiti network fabric. Clients coming into the fabric can then reach the service through these connections after being authenticated and authorized. -Ziti routers, which make up the fabric, can also be dark. Routers located in private networks will usually be made dark. These routers will reach out of the private network to talk to the controller and to make connections to join the network fabric mesh. This allows the services and routers in your private networks to make only outbound connections, so no holes have to be opened for inbound traffic. +OpenZiti routers, which make up the fabric, can also be dark. Routers located in private networks will usually be made dark. These routers will reach out of the private network to talk to the controller and to make connections to join the network fabric mesh. This allows the services and routers in your private networks to make only outbound connections, so no holes have to be opened for inbound traffic. -Services can be completely dark if they are implemented with a Ziti SDK. If this is not possible a Ziti tunneler or proxy can be colocated with the service. The service then only needs to allow connections from the local machine or network, depending on how close you colocate the proxy to the service. +Services can be completely dark if they are implemented with a OpenZiti SDK. If this is not possible a OpenZiti tunneler or proxy can be colocated with the service. The service then only needs to allow connections from the local machine or network, depending on how close you colocate the proxy to the service. ### End to End Encryption -If you take advantage of Ziti's developer SDKs and embed Ziti in your client and server applications, your traffic can be configured to be seamlessly encrypted from the client application to server application. If you prefer to use tunnelers or proxy applications, the traffic can be encrypted for you from machine to machine or private network to private network. Various combinations of the above are also supported. +If you take advantage of OpenZiti's developer SDKs and embed OpenZiti in your client and server applications, your traffic can be configured to be seamlessly encrypted from the client application to server application. If you prefer to use tunnelers or proxy applications, the traffic can be encrypted for you from machine to machine or private network to private network. Various combinations of the above are also supported. End-to-end encryption means that even if systems between the client and server are compromised, your traffic cannot be decrypted or tampered with. @@ -94,7 +98,7 @@ If you are looking to jump right in feet first you can follow along with one of guides](https://openziti.github.io/ziti/quickstarts/quickstart-overview.html). These guides are designed to get an overlay network quickly and allow you to run it all locally, use Docker or host it anywhere. -This environment is perfect for evaluators to get to know Ziti and the capabilities it offers. The environment was not +This environment is perfect for evaluators to get to know OpenZiti and the capabilities it offers. The environment was not designed for large scale deployment or for long-term usage. If you are looking for a managed service to help you run a truly global, scalable network browse over [the NetFoundry web site](https://netfoundry.io) to learn more. @@ -121,10 +125,10 @@ cruise on over to [the OpenZiti Discourse forum](https://openziti.discourse.grou ### Contributing -The Ziti project welcomes contributions including, but not limited to, code, documentation and bug reports. +The OpenZiti project welcomes contributions including, but not limited to, code, documentation and bug reports. -* All Ziti code is found on Github under the [OpenZiti](https://github.com/openziti) organization. - * [ziti](https://github.com/openziti/ziti): top level project which builds all Ziti executables +* All OpenZiti code is found on Github under the [OpenZiti](https://github.com/openziti) organization. + * [ziti](https://github.com/openziti/ziti): top level project which builds all OpenZiti executables * [edge](https://github.com/openziti/edge): edge components and model which includes identity, polices and config * [fabric](https://github.com/openziti/fabric): fabric project which includes core controller and router * [foundation](https://github.com/openziti/foundation): project which contains library code used across multiple projects @@ -137,5 +141,5 @@ The Ziti project welcomes contributions including, but not limited to, code, doc * [ziti-sdk-csharp](https://github.com/openziti/ziti-sdk-csharp): C# SDK * [ziti-doc](https://github.com/openziti/ziti-doc): Powers the static documentation site -Ziti was developed and open sourced by [Netfoundry, Inc](https://netfoundry.io). NetFoundry continues to fund and +OpenZiti was developed and open sourced by [Netfoundry, Inc](https://netfoundry.io). NetFoundry continues to fund and contribute to OpenZiti. From 56f9852ed3059132d52b4dbb4a2eb5fc15d4845c Mon Sep 17 00:00:00 2001 From: Paul Lorenz Date: Tue, 17 Jan 2023 13:21:01 -0500 Subject: [PATCH 7/9] Fix CODEOWNERS, update example config with adv addr, fix missing agent timeout --- .github/CODEOWNERS | 3 +-- doc/ha/ctrl1.yml | 4 ++-- doc/ha/ctrl2.yml | 3 ++- doc/ha/ctrl3.yml | 3 ++- ziti/cmd/agentcli/agent.go | 1 + 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 85e37db81..a3faf4834 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,4 +1,3 @@ # see: # https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/creating-a-repository-on-github/about-code-owners -* @openziti/sig-core -* @openziti/maintainers +* @openziti/sig-core @openziti/maintainers diff --git a/doc/ha/ctrl1.yml b/doc/ha/ctrl1.yml index 8ec3eb0a3..73ce18051 100644 --- a/doc/ha/ctrl1.yml +++ b/doc/ha/ctrl1.yml @@ -1,8 +1,6 @@ v: 3 - raft: minClusterSize: 3 - advertiseAddress: tls:localhost:6262 dataDir: ./data/ctrl1 bootstrapMembers: - tls:127.0.0.1:6363 @@ -15,6 +13,8 @@ identity: ctrl: listener: tls:127.0.0.1:6262 + options: + advertiseAddress: tls:localhost:6262 healthChecks: boltCheck: diff --git a/doc/ha/ctrl2.yml b/doc/ha/ctrl2.yml index bdbf2b983..7bb51706d 100644 --- a/doc/ha/ctrl2.yml +++ b/doc/ha/ctrl2.yml @@ -2,7 +2,6 @@ v: 3 raft: minClusterSize: 3 - advertiseAddress: tls:localhost:6363 dataDir: ./data/ctrl2 identity: @@ -12,6 +11,8 @@ identity: ctrl: listener: tls:127.0.0.1:6363 + options: + advertiseAddress: tls:localhost:6363 healthChecks: boltCheck: diff --git a/doc/ha/ctrl3.yml b/doc/ha/ctrl3.yml index cdbb4123d..4d5c5dac3 100644 --- a/doc/ha/ctrl3.yml +++ b/doc/ha/ctrl3.yml @@ -2,7 +2,6 @@ v: 3 raft: minClusterSize: 3 - advertiseAddress: tls:localhost:6464 dataDir: ./data/ctrl3 identity: @@ -12,6 +11,8 @@ identity: ctrl: listener: tls:127.0.0.1:6464 + options: + advertiseAddress: tls:localhost:6464 healthChecks: boltCheck: diff --git a/ziti/cmd/agentcli/agent.go b/ziti/cmd/agentcli/agent.go index dd9d8ad6f..55f809d4c 100644 --- a/ziti/cmd/agentcli/agent.go +++ b/ziti/cmd/agentcli/agent.go @@ -108,6 +108,7 @@ func (self *AgentOptions) AddAgentOptions(cmd *cobra.Command) { cmd.Flags().StringVarP(&self.appType, "app-type", "t", "", "Type of host application to talk to (like controller or router)") cmd.Flags().StringVarP(&self.appType, "app-alias", "a", "", "Alias of host application to talk to (specified in host application)") cmd.Flags().StringVar(&self.tcpAddr, "tcp-addr", "", "Type of host application to talk to (like controller or router)") + cmd.Flags().DurationVar(&self.timeout, "timeout", 5*time.Second, "Operation timeout") } func (self *AgentOptions) GetProcess() (*agent.Process, error) { From 2af4c0227597b22a33d937a4c97b66aab1adcf84 Mon Sep 17 00:00:00 2001 From: Shawn Carey Date: Tue, 17 Jan 2023 16:12:39 -0500 Subject: [PATCH 8/9] go mod tidy, and update edge to fix nonlinux builds (#944) --- CHANGELOG.md | 2 +- go.mod | 4 ++-- go.sum | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f4204d388..035a0ba72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ ## Component Updates and Bug Fixes -* github.com/openziti/edge: [v0.24.95 -> v0.24.101](https://github.com/openziti/edge/compare/v0.24.95...v0.24.101) +* github.com/openziti/edge: [v0.24.95 -> v0.24.104](https://github.com/openziti/edge/compare/v0.24.95...v0.24.104) * [Issue #1292](https://github.com/openziti/edge/issues/1292) - Support alternative tproxy configuration methods diff --git a/go.mod b/go.mod index 40d5c6250..3c0a018ce 100644 --- a/go.mod +++ b/go.mod @@ -22,8 +22,8 @@ require ( github.com/michaelquigley/pfxlog v0.6.9 github.com/openziti/agent v1.0.8 github.com/openziti/channel/v2 v2.0.25 - github.com/openziti/edge v0.24.100 - github.com/openziti/fabric v0.22.9 + github.com/openziti/edge v0.24.104 + github.com/openziti/fabric v0.22.10 github.com/openziti/foundation/v2 v2.0.10 github.com/openziti/identity v1.0.29 github.com/openziti/runzmd v1.0.8 diff --git a/go.sum b/go.sum index 192743f80..b0271e5a2 100644 --- a/go.sum +++ b/go.sum @@ -699,10 +699,10 @@ github.com/openziti/channel/v2 v2.0.25 h1:ihw9DDTfMHDL33gZFLqDyADFGKBec4beaThV/V github.com/openziti/channel/v2 v2.0.25/go.mod h1:eHPS7dmvDV+Q/SmbB2gwvdvdz/NcnetFshHsdNzAnZs= 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.100 h1:sBoG0GtyFCyodukuG1IDCoXm2PjLyjt8jxKhVQjc0ww= -github.com/openziti/edge v0.24.100/go.mod h1:Yn3eOldLoe6BZyJvOQbgY02LDOpo9oW48v1ZKhTwqZs= -github.com/openziti/fabric v0.22.9 h1:8bI+yeWMBwBYwpteg8A2fxI4rYB65B6UBkIkLSsdh8s= -github.com/openziti/fabric v0.22.9/go.mod h1:8i3qG7UJbqWHH3V6nZlhzaaGyqiecn4cCsj9qGf4Rec= +github.com/openziti/edge v0.24.104 h1:+95zy3rYeAtn4DDpYTxNFGqNGqwPCcD44JUB2ezbLxg= +github.com/openziti/edge v0.24.104/go.mod h1:qQhaMTwWE++B+57WDqjWHQJ4tocgL7M7gODNnEzXaNI= +github.com/openziti/fabric v0.22.10 h1:h4wpH9yON4vZHQ1PPyWl8cJfbMC2LpsUC6UT/zM1TSs= +github.com/openziti/fabric v0.22.10/go.mod h1:8i3qG7UJbqWHH3V6nZlhzaaGyqiecn4cCsj9qGf4Rec= github.com/openziti/foundation/v2 v2.0.10 h1:IeOkcPbgBpBTw4JrWz8s9Z76vO/m+i2uIE0cMZ0C2DM= github.com/openziti/foundation/v2 v2.0.10/go.mod h1:Z0gnQsGJb/H/B+pixLtmCIpw1dBllD4QoT6LeD35WzA= github.com/openziti/identity v1.0.29 h1:FkY/Hzpfh2/U2cUzYR2X3380/IKGIQYpJaKWqXpOIAg= From 57e096aefee57643d2c3c707392d7082c5cd6b85 Mon Sep 17 00:00:00 2001 From: Kenneth Bingham Date: Tue, 17 Jan 2023 16:14:47 -0500 Subject: [PATCH 9/9] force single-byte locale in command "tr" when generating random password --- quickstart/docker/image/ziti-cli-functions.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quickstart/docker/image/ziti-cli-functions.sh b/quickstart/docker/image/ziti-cli-functions.sh index 358f5433a..87f12020c 100755 --- a/quickstart/docker/image/ziti-cli-functions.sh +++ b/quickstart/docker/image/ziti-cli-functions.sh @@ -1077,7 +1077,7 @@ function ziti_createEnvFile { if [[ "${ZITI_USER-}" == "" ]]; then export ZITI_USER="admin"; fi if [[ "${ZITI_PWD-}" == "" ]]; then - ZITI_PWD="$(tr -dc _A-Z-a-z-0-9 < /dev/urandom | head -c32)" + 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 read -r pwd_reply