Skip to content

Commit

Permalink
Merge pull request #189 from ngrok/warrn/allows_pooling
Browse files Browse the repository at this point in the history
config: allows_pooling boolean defaults false
  • Loading branch information
warrn authored Sep 23, 2024
2 parents 06fcb9a + 9a086ba commit 43a9f8c
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 14 deletions.
23 changes: 23 additions & 0 deletions config/allows_pooling.go
Original file line number Diff line number Diff line change
@@ -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)
}
3 changes: 3 additions & 0 deletions config/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 4 additions & 3 deletions config/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}

Expand Down
7 changes: 4 additions & 3 deletions config/tcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}

Expand Down
7 changes: 4 additions & 3 deletions config/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}

Expand Down
11 changes: 6 additions & 5 deletions internal/tunnel/proto/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 43a9f8c

Please sign in to comment.