diff --git a/CHANGELOG.md b/CHANGELOG.md index 7efd8db26..00c442c0b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,24 @@ +# Release 0.18.10 + +# What's New + +* Close terminating xgress instances if no start is received with a configurable timeout + * Timeout is set in the router config under listener/dialer options: `sessionStartTimeout` + Default value: `3m` +* Don't add a second shutdown timer if one is already set +* Allow list/updating router forwarding tables if --debug-ops is passed + * new command `ziti ps route ` + * new command `ziti ps dump-routes ` +* If an xgress session fails in retransmit, sends fault notification to controller so + controller can fix path or remove session, depending on session state + # Release 0.18.9 # What's New * Fix PATCH OS Posture Checks clearing data -* Fix ziti-tunnel panic when removing services. [edge#517](https://github.com/openziti/edge/issues/517) +* Fix ziti-tunnel panic when removing + services. [edge#517](https://github.com/openziti/edge/issues/517) * ziti-tunnel tproxy now supports `--lanIf` option to automatically add rules to accept incoming connections for service connections. [edge#519](https://github.com/openziti/edge/issues/519) * Fix orphaned ottca enrollments after `DELETE /cas/' diff --git a/go.mod b/go.mod index 9c71a4867..2e0098b97 100644 --- a/go.mod +++ b/go.mod @@ -25,8 +25,8 @@ require ( github.com/keybase/go-ps v0.0.0-20190827175125-91aafc93ba19 github.com/michaelquigley/pfxlog v0.3.6 github.com/openziti/edge v0.17.67 - github.com/openziti/fabric v0.15.23 - github.com/openziti/foundation v0.15.12 + github.com/openziti/fabric v0.15.24 + github.com/openziti/foundation v0.15.13 github.com/openziti/sdk-golang v0.15.13 github.com/pborman/uuid v1.2.0 github.com/pkg/errors v0.9.1 diff --git a/go.sum b/go.sum index e639b16ec..c1d8a21c0 100644 --- a/go.sum +++ b/go.sum @@ -530,13 +530,14 @@ github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYr github.com/openzipkin/zipkin-go v0.1.1/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTmOf0Erfk+hxe8= github.com/openziti/edge v0.17.67 h1:Un9eLq8ZPaznqr0UqxKGgAR135G9Rm9XylyFViCa+x8= github.com/openziti/edge v0.17.67/go.mod h1:L19G8aGgeHNjHz8vZBNgZlsmSFCSg7CGgXRneKAnDGU= -github.com/openziti/fabric v0.15.21 h1:4rrh9ovQwGW4ecEZ2ykgxkPJ3Sdtxx7FV4SzguwpuwQ= github.com/openziti/fabric v0.15.21/go.mod h1:2Q63EWL1MDcdhZYoaMQDVjbGzRgonIdgRmzxaNDHJI0= -github.com/openziti/fabric v0.15.23 h1:tYG/hQLaFRm2VIcdK4eqcDYiI3vGN8vtQ3NoS5m69ow= -github.com/openziti/fabric v0.15.23/go.mod h1:2Q63EWL1MDcdhZYoaMQDVjbGzRgonIdgRmzxaNDHJI0= +github.com/openziti/fabric v0.15.24 h1:gl5QTxUB2qxpjteAtqIGcuBQ/Sg5rSjDj+82AI+Bds0= +github.com/openziti/fabric v0.15.24/go.mod h1:2Q63EWL1MDcdhZYoaMQDVjbGzRgonIdgRmzxaNDHJI0= github.com/openziti/foundation v0.15.9/go.mod h1:34ifQ24R2EUNjakzZBKY1M4EvnOWeIYJOrJxRGdRNh4= github.com/openziti/foundation v0.15.12 h1:fdhhEsJPfvVIdarY4fd4gPGHkOGIAuxIig2hHweZ9K0= github.com/openziti/foundation v0.15.12/go.mod h1:34ifQ24R2EUNjakzZBKY1M4EvnOWeIYJOrJxRGdRNh4= +github.com/openziti/foundation v0.15.13 h1:eq6FE+4bKqU94XQ++IF80e9JLCbVtqGm772lR4hHSKQ= +github.com/openziti/foundation v0.15.13/go.mod h1:34ifQ24R2EUNjakzZBKY1M4EvnOWeIYJOrJxRGdRNh4= github.com/openziti/sdk-golang v0.15.13 h1:Pd5WqFcPxrM8o/VeqCoKeGCgL+pC9Y5dVb1tqMhRprI= github.com/openziti/sdk-golang v0.15.13/go.mod h1:L1UbvXUV7DV6a3pd50CAJqtt9z6nN53p2cKNJlHZXR8= github.com/orcaman/concurrent-map v0.0.0-20190826125027-8c72a8bb44f6/go.mod h1:Lu3tH6HLW3feq74c2GC+jIMS/K2CFcDWnWD9XkenwhI= @@ -847,6 +848,7 @@ golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201009025420-dfb3f7c4e634/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201118182958-a01c418693c7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 h1:nxC68pudNYkKU6jWhgrqdreuFiOQWj1Fs7T3VrH4Pjw= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201218084310-7d0127a74742/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210110051926-789bb1bd4061 h1:DQmQoKxQWtyybCtX/3dIuDBcAhFszqq8YiNeS6sNu1c= diff --git a/ziti-router/subcmd/root.go b/ziti-router/subcmd/root.go index 844577e88..588ff25cf 100644 --- a/ziti-router/subcmd/root.go +++ b/ziti-router/subcmd/root.go @@ -28,6 +28,7 @@ func init() { root.PersistentFlags().StringVar(&logFormatter, "log-formatter", "", "Specify log formatter [json|pfxlog|text]") root.PersistentFlags().BoolVar(&cliAgentEnabled, "cli-agent", true, "Enable/disable CLI Agent (enabled by default)") root.PersistentFlags().StringVar(&cliAgentAddr, "cli-agent-addr", "", "Specify where CLI Agent should list (ex: unix:/tmp/myfile.sock or tcp:127.0.0.1:10001)") + root.PersistentFlags().BoolVar(&debugOpsEnabled, "debug-ops", false, "Enable/disable debug agent operations (disabled by default)") } var root = &cobra.Command{ @@ -55,6 +56,7 @@ var root = &cobra.Command{ var verbose bool var logFormatter string var cliAgentEnabled bool +var debugOpsEnabled bool var cliAgentAddr string func Execute() { diff --git a/ziti-router/subcmd/run.go b/ziti-router/subcmd/run.go index fc09c6ca9..f8f4c8a10 100644 --- a/ziti-router/subcmd/run.go +++ b/ziti-router/subcmd/run.go @@ -27,6 +27,7 @@ import ( "github.com/sirupsen/logrus" "github.com/spf13/cobra" "github.com/spf13/pflag" + "io" ) func init() { @@ -50,16 +51,22 @@ func run(cmd *cobra.Command, args []string) { Info("starting ziti-router") if config, err := router.LoadConfig(args[0]); err == nil { + config.SetFlags(getFlags(cmd)) + + r := router.Create(config, version.GetCmdBuildInfo()) + if cliAgentEnabled { - if err := agent.Listen(agent.Options{Addr: cliAgentAddr}); err != nil { + options := agent.Options{Addr: cliAgentAddr} + if debugOpsEnabled { + options.CustomOps = map[byte]func(conn io.ReadWriter) error{ + agent.CustomOp: r.HandleDebug, + } + } + if err := agent.Listen(options); err != nil { pfxlog.Logger().WithError(err).Error("unable to start CLI agent") } } - config.SetFlags(getFlags(cmd)) - - r := router.Create(config, version.GetCmdBuildInfo()) - xgressEdgeFactory := xgress_edge.NewFactory(version.GetCmdBuildInfo()) xgress.GlobalRegistry().Register("edge", xgressEdgeFactory) if err := r.RegisterXctrl(xgressEdgeFactory); err != nil { diff --git a/ziti/cmd/ziti/cmd/ps.go b/ziti/cmd/ziti/cmd/ps.go index f3b4200f1..40698bf73 100644 --- a/ziti/cmd/ziti/cmd/ps.go +++ b/ziti/cmd/ziti/cmd/ps.go @@ -82,6 +82,8 @@ func NewCmdPs(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command cmd.AddCommand(NewCmdPsPprofCpu(f, out, errOut)) cmd.AddCommand(NewCmdPsTrace(f, out, errOut)) cmd.AddCommand(NewCmdPsSetLogLevel(f, out, errOut)) + cmd.AddCommand(NewCmdPsRoute(f, out, errOut)) + cmd.AddCommand(NewCmdPsDumpRoutes(f, out, errOut)) // cmd.AddCommand(NewCmdPsController(f, out, errOut)) // cmd.AddCommand(NewCmdPsMgmt(f, out, errOut)) diff --git a/ziti/cmd/ziti/cmd/ps_route.go b/ziti/cmd/ziti/cmd/ps_route.go new file mode 100644 index 000000000..d41b93e7a --- /dev/null +++ b/ziti/cmd/ziti/cmd/ps_route.go @@ -0,0 +1,105 @@ +/* + 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 cmd + +import ( + "encoding/binary" + "github.com/golang/protobuf/proto" + "github.com/openziti/fabric/pb/ctrl_pb" + "github.com/openziti/fabric/router" + "github.com/openziti/foundation/agent" + cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" + cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" + "github.com/spf13/cobra" + "io" + "os" +) + +// PsRouteOptions the options for the create spring command +type PsRouteOptions struct { + PsOptions + CtrlListener string +} + +// NewCmdPsRoute creates a command object for the "create" command +func NewCmdPsRoute(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { + options := &PsRouteOptions{ + PsOptions: PsOptions{ + CommonOptions: CommonOptions{ + Factory: f, + Out: out, + Err: errOut, + }, + }, + } + + 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) + }, + } + + options.addCommonFlags(cmd) + + return cmd +} + +// Run implements the command +func (o *PsRouteOptions) Run() error { + var addr string + var err error + + offset := 0 + if len(o.Args) == 4 { + addr, err = agent.ParseGopsAddress(o.Args) + if err != nil { + return err + } + offset = 1 + } + + route := &ctrl_pb.Route{ + SessionId: o.Args[offset], + Forwards: []*ctrl_pb.Route_Forward{ + { + SrcAddress: o.Args[offset+1], + DstAddress: o.Args[offset+2], + }, + }, + } + + buf, err := proto.Marshal(route) + if err != nil { + return err + } + + fullBuf := make([]byte, len(buf)+5) + fullBuf[0] = router.UpdateRoute + + sizeBuf := make([]byte, 4) + binary.LittleEndian.PutUint32(sizeBuf, uint32(len(buf))) + + copy(fullBuf[1:], sizeBuf) + copy(fullBuf[5:], buf) + + return agent.MakeRequest(addr, agent.CustomOp, fullBuf, os.Stdout) +} diff --git a/ziti/cmd/ziti/cmd/ps_route_dump.go b/ziti/cmd/ziti/cmd/ps_route_dump.go new file mode 100644 index 000000000..618135fa7 --- /dev/null +++ b/ziti/cmd/ziti/cmd/ps_route_dump.go @@ -0,0 +1,73 @@ +/* + 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 cmd + +import ( + "github.com/openziti/fabric/router" + "github.com/openziti/foundation/agent" + cmdutil "github.com/openziti/ziti/ziti/cmd/ziti/cmd/factory" + cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers" + "github.com/spf13/cobra" + "io" + "os" +) + +// PsRouteOptions the options for the create spring command +type PsDumpRoutesOptions struct { + PsOptions + CtrlListener string +} + +// NewCmdPsDumpRoutes creates a command object for the "dump-routes" command +func NewCmdPsDumpRoutes(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { + options := &PsDumpRoutesOptions{ + PsOptions: PsOptions{ + CommonOptions: CommonOptions{ + Factory: f, + Out: out, + Err: errOut, + }, + }, + } + + cmd := &cobra.Command{ + Args: cobra.MaximumNArgs(1), + Use: "dump-routes ", + Run: func(cmd *cobra.Command, args []string) { + options.Cmd = cmd + options.Args = args + err := options.Run() + cmdhelper.CheckErr(err) + }, + } + + options.addCommonFlags(cmd) + + return cmd +} + +// Run implements the command +func (o *PsDumpRoutesOptions) Run() error { + addr, err := agent.ParseGopsAddress(o.Args) + if err != nil { + return err + } + + buf := []byte{router.DumpForwarderTables} + + return agent.MakeRequest(addr, agent.CustomOp, buf, os.Stdout) +}