diff --git a/config/allows_pooling.go b/config/allows_pooling.go new file mode 100644 index 00000000..493c9ae0 --- /dev/null +++ b/config/allows_pooling.go @@ -0,0 +1,23 @@ +package config + +type allowsPoolingOption bool + +func WithAllowsPooling(allowsPooling bool) interface { + HTTPEndpointOption + TCPEndpointOption + TLSEndpointOption +} { + return allowsPoolingOption(allowsPooling) +} + +func (opt allowsPoolingOption) ApplyHTTP(opts *httpOptions) { + opts.AllowsPooling = bool(opt) +} + +func (opt allowsPoolingOption) ApplyTLS(opts *tlsOptions) { + opts.AllowsPooling = bool(opt) +} + +func (opt allowsPoolingOption) ApplyTCP(opts *tcpOptions) { + opts.AllowsPooling = bool(opt) +} diff --git a/config/common.go b/config/common.go index 1fb60338..79ac8772 100644 --- a/config/common.go +++ b/config/common.go @@ -33,6 +33,9 @@ type commonOpts struct { // Enables ingress for ngrok endpoints. Bindings []string + + // Allows the endpoint to pool with other endpoints with the same host/port/binding + AllowsPooling bool } type CommonOptionsFunc func(cfg *commonOpts) diff --git a/config/http.go b/config/http.go index c09ae81d..978a5aa6 100644 --- a/config/http.go +++ b/config/http.go @@ -147,9 +147,10 @@ func (cfg *httpOptions) WithForwardsTo(url *url.URL) { func (cfg httpOptions) Extra() proto.BindExtra { return proto.BindExtra{ - Metadata: cfg.Metadata, - Description: cfg.Description, - Bindings: cfg.Bindings, + Metadata: cfg.Metadata, + Description: cfg.Description, + Bindings: cfg.Bindings, + AllowsPooling: cfg.AllowsPooling, } } diff --git a/config/tcp.go b/config/tcp.go index b63859af..909a4b9e 100644 --- a/config/tcp.go +++ b/config/tcp.go @@ -71,9 +71,10 @@ func (cfg *tcpOptions) WithForwardsTo(url *url.URL) { func (cfg tcpOptions) Extra() proto.BindExtra { return proto.BindExtra{ - Metadata: cfg.Metadata, - Description: cfg.Description, - Bindings: cfg.Bindings, + Metadata: cfg.Metadata, + Description: cfg.Description, + Bindings: cfg.Bindings, + AllowsPooling: cfg.AllowsPooling, } } diff --git a/config/tls.go b/config/tls.go index 82490357..7b400b30 100644 --- a/config/tls.go +++ b/config/tls.go @@ -99,9 +99,10 @@ func (cfg *tlsOptions) WithForwardsTo(url *url.URL) { func (cfg tlsOptions) Extra() proto.BindExtra { return proto.BindExtra{ - Metadata: cfg.Metadata, - Description: cfg.Description, - Bindings: cfg.Bindings, + Metadata: cfg.Metadata, + Description: cfg.Description, + Bindings: cfg.Bindings, + AllowsPooling: cfg.AllowsPooling, } } diff --git a/internal/tunnel/proto/msg.go b/internal/tunnel/proto/msg.go index 548f9100..b3aa8568 100644 --- a/internal/tunnel/proto/msg.go +++ b/internal/tunnel/proto/msg.go @@ -221,11 +221,12 @@ type Bind struct { } type BindExtra struct { - Token string - IPPolicyRef string - Metadata string - Description string - Bindings []string + Token string + IPPolicyRef string + Metadata string + Description string + Bindings []string + AllowsPooling bool } // The server responds with a BindResp message to notify the client of the