enable/disable for listeners
This commit is contained in:
parent
1cf9cc880d
commit
a0654b0016
@ -85,7 +85,7 @@ func buildTcp(ctx context.Context, p *proxy.Proxy, peer Peer, g func() proxy.Mac
|
||||
return nil
|
||||
}
|
||||
|
||||
err := tcp.NewListener(ctx, p, laddr(), v, g)
|
||||
err := tcp.NewListener(ctx, p, laddr(), v, g, !peer.DisableConsumer, !peer.DisableProducer)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -135,7 +135,7 @@ func buildUdp(ctx context.Context, p *proxy.Proxy, peer Peer, g func() proxy.Mac
|
||||
return nil
|
||||
}
|
||||
|
||||
err := udp.NewListener(ctx, p, laddr(), v, g, c)
|
||||
err := udp.NewListener(ctx, p, laddr(), v, g, c, !peer.DisableConsumer, !peer.DisableProducer)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
"net"
|
||||
)
|
||||
|
||||
func NewListener(ctx context.Context, p *proxy.Proxy, local string, v func() proxy.MacVerifier, g func() proxy.MacGenerator) error {
|
||||
func NewListener(ctx context.Context, p *proxy.Proxy, local string, v func() proxy.MacVerifier, g func() proxy.MacGenerator, enableConsumers bool, enableProducers bool) error {
|
||||
laddr, err := net.ResolveTCPAddr("tcp", local)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -33,8 +33,12 @@ func NewListener(ctx context.Context, p *proxy.Proxy, local string, v func() pro
|
||||
|
||||
log.Printf("received new tcp connection: %v\n", f)
|
||||
|
||||
p.AddConsumer(ctx, &f, g())
|
||||
p.AddProducer(ctx, &f, v())
|
||||
if enableConsumers {
|
||||
p.AddConsumer(ctx, &f, g())
|
||||
}
|
||||
if enableProducers {
|
||||
p.AddProducer(ctx, &f, v())
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
|
@ -27,7 +27,7 @@ func fromUdpAddress(address net.UDPAddr) ComparableUdpAddress {
|
||||
}
|
||||
}
|
||||
|
||||
func NewListener(ctx context.Context, p *proxy.Proxy, local string, v func() proxy.MacVerifier, g func() proxy.MacGenerator, c func() Congestion) error {
|
||||
func NewListener(ctx context.Context, p *proxy.Proxy, local string, v func() proxy.MacVerifier, g func() proxy.MacGenerator, c func() Congestion, enableConsumers bool, enableProducers bool) error {
|
||||
laddr, err := net.ResolveUDPAddr("udp", local)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -85,8 +85,12 @@ func NewListener(ctx context.Context, p *proxy.Proxy, local string, v func() pro
|
||||
|
||||
receivedConnections[raddr] = &f
|
||||
|
||||
p.AddConsumer(ctx, &f, g)
|
||||
p.AddProducer(ctx, &f, v)
|
||||
if enableConsumers {
|
||||
p.AddConsumer(ctx, &f, g)
|
||||
}
|
||||
if enableProducers {
|
||||
p.AddProducer(ctx, &f, v)
|
||||
}
|
||||
|
||||
log.Println("handling...")
|
||||
if err := f.queueDatagram(ctx, buf[:n]); err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user