Files
threshold/internal/daemon/worker/proxy/options.go
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

63 lines
1.7 KiB
Go
Raw Normal View History

2023-01-09 13:43:02 -05:00
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1
2023-02-02 17:15:17 -08:00
package proxy
import (
2023-01-09 13:43:02 -05:00
"net"
2021-12-17 11:26:42 -08:00
serverpb "github.com/hashicorp/boundary/internal/gen/controller/servers/services"
)
// Option - how Options are passed as arguments.
type Option func(*Options)
// GetOpts - iterate the inbound Options and return a struct.
func GetOpts(opt ...Option) Options {
opts := getDefaultOptions()
for _, o := range opt {
o(&opts)
}
return opts
}
// Options = how options are represented
type Options struct {
WithInjectedApplicationCredentials []*serverpb.Credential
2023-01-09 13:43:02 -05:00
WithPostConnectionHook func(net.Conn)
2023-10-20 11:26:58 -07:00
WithDnsServerAddress string
}
func getDefaultOptions() Options {
return Options{
WithInjectedApplicationCredentials: nil,
2023-01-09 13:43:02 -05:00
WithPostConnectionHook: nil,
}
}
// WithInjectedApplicationCredentials provides an optional injected application
// credentials to use when establishing a proxy
func WithInjectedApplicationCredentials(creds []*serverpb.Credential) Option {
return func(o *Options) {
o.WithInjectedApplicationCredentials = creds
}
}
2023-01-09 13:43:02 -05:00
// WithPostConnectionHook provides a hook function to be called after a
// connection is established in a dialFunction. When a dialer accepts
// WithPostConnectionHook the passed in function should be called prior to any
// other blocking call.
func WithPostConnectionHook(fn func(net.Conn)) Option {
return func(o *Options) {
o.WithPostConnectionHook = fn
}
}
2023-10-20 11:26:58 -07:00
// WithDnsServerAddress allows specifying lookup of the endpoint to happen via
// an alternate DNS server. Must be in scheme://host:port form where scheme is
// "udp" or "tcp".
func WithDnsServerAddress(with string) Option {
return func(o *Options) {
o.WithDnsServerAddress = with
}
}