From 1cf9cc880dcf8aa348006a3fe336ea495a6ed4ca Mon Sep 17 00:00:00 2001 From: Jake Hillion Date: Fri, 9 Apr 2021 18:50:00 +0100 Subject: [PATCH] disable producer/consumer --- config/builder.go | 16 ++++++++++++---- config/config.go | 3 +++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/config/builder.go b/config/builder.go index b83995c..afe29f3 100644 --- a/config/builder.go +++ b/config/builder.go @@ -75,8 +75,12 @@ func buildTcp(ctx context.Context, p *proxy.Proxy, peer Peer, g func() proxy.Mac return err } - p.AddConsumer(ctx, f, g()) - p.AddProducer(ctx, f, v()) + if !peer.DisableConsumer { + p.AddConsumer(ctx, f, g()) + } + if !peer.DisableProducer { + p.AddProducer(ctx, f, v()) + } return nil } @@ -121,8 +125,12 @@ func buildUdp(ctx context.Context, p *proxy.Proxy, peer Peer, g func() proxy.Mac return err } - p.AddConsumer(ctx, f, g()) - p.AddProducer(ctx, f, v()) + if !peer.DisableConsumer { + p.AddConsumer(ctx, f, g()) + } + if !peer.DisableProducer { + p.AddProducer(ctx, f, v()) + } return nil } diff --git a/config/config.go b/config/config.go index 1328116..ed7bea5 100644 --- a/config/config.go +++ b/config/config.go @@ -57,6 +57,9 @@ type Peer struct { KeepAlive uint Timeout uint RetryWait uint + + DisableConsumer bool `validate:"omitempty,nefield=DisableProducer"` + DisableProducer bool `validate:"omitempty,nefield=DisableConsumer"` } func (p Peer) GetLocalHost() string {