diff --git a/config/common.go b/config/common.go index 79ac877..7e47886 100644 --- a/config/common.go +++ b/config/common.go @@ -17,6 +17,9 @@ type commonOpts struct { // user supplied description of the endpoint Description string + // user supplied name for the endpoint + Name string + // If not set, defaults to a URI in the format `app://hostname/path/to/executable?pid=12345` ForwardsTo string diff --git a/config/http.go b/config/http.go index 978a5aa..5311838 100644 --- a/config/http.go +++ b/config/http.go @@ -147,6 +147,7 @@ func (cfg *httpOptions) WithForwardsTo(url *url.URL) { func (cfg httpOptions) Extra() proto.BindExtra { return proto.BindExtra{ + Name: cfg.Name, Metadata: cfg.Metadata, Description: cfg.Description, Bindings: cfg.Bindings, diff --git a/config/labeled.go b/config/labeled.go index 2fc9542..2f77cc7 100644 --- a/config/labeled.go +++ b/config/labeled.go @@ -66,6 +66,7 @@ func (cfg *labeledOptions) WithForwardsTo(url *url.URL) { func (cfg labeledOptions) Extra() proto.BindExtra { return proto.BindExtra{ + Name: cfg.Name, Metadata: cfg.Metadata, Description: cfg.Description, } diff --git a/config/name.go b/config/name.go new file mode 100644 index 0000000..2db4299 --- /dev/null +++ b/config/name.go @@ -0,0 +1,28 @@ +package config + +type nameOption string + +func WithName(name string) interface { + HTTPEndpointOption + TCPEndpointOption + TLSEndpointOption + LabeledTunnelOption +} { + return nameOption(name) +} + +func (opt nameOption) ApplyHTTP(opts *httpOptions) { + opts.Name = string(opt) +} + +func (opt nameOption) ApplyTLS(opts *tlsOptions) { + opts.Name = string(opt) +} + +func (opt nameOption) ApplyTCP(opts *tcpOptions) { + opts.Name = string(opt) +} + +func (opt nameOption) ApplyLabeled(opts *labeledOptions) { + opts.Name = string(opt) +} diff --git a/config/tcp.go b/config/tcp.go index 909a4b9..64c7a7d 100644 --- a/config/tcp.go +++ b/config/tcp.go @@ -71,6 +71,7 @@ func (cfg *tcpOptions) WithForwardsTo(url *url.URL) { func (cfg tcpOptions) Extra() proto.BindExtra { return proto.BindExtra{ + Name: cfg.Name, Metadata: cfg.Metadata, Description: cfg.Description, Bindings: cfg.Bindings, diff --git a/config/tls.go b/config/tls.go index 7b400b3..170bbe3 100644 --- a/config/tls.go +++ b/config/tls.go @@ -99,6 +99,7 @@ func (cfg *tlsOptions) WithForwardsTo(url *url.URL) { func (cfg tlsOptions) Extra() proto.BindExtra { return proto.BindExtra{ + Name: cfg.Name, Metadata: cfg.Metadata, Description: cfg.Description, Bindings: cfg.Bindings, diff --git a/internal/tunnel/proto/msg.go b/internal/tunnel/proto/msg.go index b3aa856..014941d 100644 --- a/internal/tunnel/proto/msg.go +++ b/internal/tunnel/proto/msg.go @@ -221,6 +221,7 @@ type Bind struct { } type BindExtra struct { + Name string Token string IPPolicyRef string Metadata string