config

package
v1.9.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2024 License: MIT Imports: 13 Imported by: 49

Documentation

Index

Constants

View Source
const (
	// PROXY protocol disabled
	ProxyProtoNone = ProxyProtoVersion(0)
	// PROXY protocol v1
	ProxyProtoV1 = ProxyProtoVersion(1)
	// PROXY protocol v2
	ProxyProtoV2 = ProxyProtoVersion(2)
)
View Source
const (
	SchemeHTTP = Scheme("http")
	// The 'https' URL scheme.
	SchemeHTTPS = Scheme("https")
)

The 'http' URL scheme.

Variables

This section is empty.

Functions

func WithAllowCIDR

func WithAllowCIDR(net ...*net.IPNet) interface {
	HTTPEndpointOption
	TCPEndpointOption
	TLSEndpointOption
}

Add the provided net.IPNet to the [CIDRRestriction].Allowed list.

https://ngrok.com/docs/http/ip-restrictions/

func WithAllowCIDRString

func WithAllowCIDRString(cidr ...string) interface {
	HTTPEndpointOption
	TCPEndpointOption
	TLSEndpointOption
}

Add the provided CIDRS to the [CIDRRestriction].Allowed list.

https://ngrok.com/docs/http/ip-restrictions/

func WithAppProtocol added in v1.7.0

func WithAppProtocol(proto string) interface {
	HTTPEndpointOption
	LabeledTunnelOption
}

WithAppProtocol declares the protocol that the upstream service speaks. This may be used by the ngrok edge to make decisions regarding protocol upgrades or downgrades.

Currently, `http2` is the only valid string, and will cause connections received from HTTP endpoints to always use HTTP/2.

func WithDenyCIDR

func WithDenyCIDR(net ...*net.IPNet) interface {
	HTTPEndpointOption
	TCPEndpointOption
	TLSEndpointOption
}

Add the provided net.IPNet to the [CIDRRestriction].Denied list.

https://ngrok.com/docs/http/ip-restrictions/

func WithDenyCIDRString

func WithDenyCIDRString(cidr ...string) interface {
	HTTPEndpointOption
	TCPEndpointOption
	TLSEndpointOption
}

Add the provided CIDRS to the [CIDRRestriction].Denied list.

https://ngrok.com/docs/http/ip-restrictions/

func WithDomain

func WithDomain(name string) interface {
	HTTPEndpointOption
	TLSEndpointOption
}

WithDomain sets the fully-qualified domain name for this edge.

https://ngrok.com/docs/network-edge/domains-and-tcp-addresses/#domains

func WithHostname deprecated added in v1.1.0

func WithHostname(name string) interface {
	HTTPEndpointOption
	TLSEndpointOption
}

WithHostname sets the hostname for this edge.

Deprecated: use WithDomain instead

func WithMetadata

WithMetadata sets the opaque metadata string for this tunnel.

func WithMutualTLSCA

func WithMutualTLSCA(certs ...*x509.Certificate) interface {
	HTTPEndpointOption
	TLSEndpointOption
}

WithMutualTLSCA adds a list of x509.Certificate's to use for mutual TLS authentication. These will be used to authenticate client certificates for requests at the ngrok edge.

https://ngrok.com/docs/http/mutual-tls/

func WithPolicy added in v1.8.0

WithPolicy configures this edge with the given traffic policy and overwrites any previously-set traffic policy https://ngrok.com/docs/http/traffic-policy/

func WithPolicyString added in v1.8.1

func WithPolicyString(jsonStr string) interface {
	HTTPEndpointOption
	TLSEndpointOption
	TCPEndpointOption
}

WithPolicyString configures this edge with the provided policy configuration passed as a json string and overwrites any previously-set traffic policy https://ngrok.com/docs/http/traffic-policy

func WithProxyProto

func WithProxyProto(version ProxyProtoVersion) interface {
	HTTPEndpointOption
	TCPEndpointOption
	TLSEndpointOption
}

WithProxyProto sets the PROXY protocol version for connections over this tunnel.

func WithSubdomain deprecated added in v1.1.0

func WithSubdomain(name string) interface {
	HTTPEndpointOption
	TLSEndpointOption
}

WithSubdomain sets the subdomain for this edge.

Deprecated: use WithDomain instead

Types

type CommonOption added in v1.5.0

type CommonOption interface {
	ApplyCommon(cfg *commonOpts)
}

type CommonOptionsFunc added in v1.5.0

type CommonOptionsFunc func(cfg *commonOpts)

func (CommonOptionsFunc) ApplyCommon added in v1.5.0

func (of CommonOptionsFunc) ApplyCommon(cfg *commonOpts)

type HTTPEndpointOption

type HTTPEndpointOption interface {
	ApplyHTTP(cfg *httpOptions)
}

func WithAllowUserAgent added in v1.5.0

func WithAllowUserAgent(allow ...string) HTTPEndpointOption

WithAllowUserAgent adds user agent filtering to the endpoint.

The allow argument is a regular expressions for the user-agent header to allow

Any invalid regular expression will result in an error when creating the tunnel.

https://ngrok.com/docs/http/user-agent-filter/ ERR_NGROK_2090 for invalid allow/deny on connect. ERR_NGROK_3211 The server does not authorize requests from your user-agent ERR_NGROK_9022 Your account is not authorized to use user agent filtering.

func WithAllowUserAgentFilter deprecated added in v1.4.1

func WithAllowUserAgentFilter(allow ...string) HTTPEndpointOption

WithAllowUserAgentFilter is a deprecated alias for WithAllowUserAgent.

Deprecated: use WithAllowUserAgent instead.

func WithBasicAuth

func WithBasicAuth(username, password string) HTTPEndpointOption

WithBasicAuth adds the provided credentials to the list of basic authentication credentials.

https://ngrok.com/docs/http/basic-auth/

func WithCircuitBreaker

func WithCircuitBreaker(ratio float64) HTTPEndpointOption

WithCircuitBreaker sets the 5XX response ratio at which the ngrok edge will stop sending requests to this tunnel.

https://ngrok.com/docs/http/circuit-breaker/

func WithCompression

func WithCompression() HTTPEndpointOption

WithCompression enables gzip compression.

https://ngrok.com/docs/http/compression/

func WithDenyUserAgent added in v1.5.0

func WithDenyUserAgent(deny ...string) HTTPEndpointOption

WithDenyUserAgent adds user agent filtering to the endpoint.

The deny argument is a regular expressions to deny, with allows taking precedence over denies.

Any invalid regular expression will result in an error when creating the tunnel.

https://ngrok.com/docs/http/user-agent-filter/ ERR_NGROK_2090 for invalid allow/deny on connect. ERR_NGROK_3211 The server does not authorize requests from your user-agent ERR_NGROK_9022 Your account is not authorized to use user agent filtering.

func WithDenyUserAgentFilter deprecated added in v1.4.1

func WithDenyUserAgentFilter(allow ...string) HTTPEndpointOption

WithDenyUserAgentFilter is a deprecated alias for WithDenyUserAgent.

Deprecated: use WithDenyUserAgent instead.

func WithHostHeaderRewrite added in v1.6.0

func WithHostHeaderRewrite(rewrite bool) HTTPEndpointOption

WithHostHeaderRewrite will automatically set the `Host` header to the one in the URL passed to `ListenAndForward`. Does nothing if using `Listen`. Defaults to `false`.

If you need to set the host header to a specific value, use `WithRequestHeader("host", "some.host.com")` instead.

func WithOAuth

func WithOAuth(provider string, opts ...OAuthOption) HTTPEndpointOption

WithOAuth configures this edge with the the given OAuth provider. Overwrites any previously-set OAuth configuration.

https://ngrok.com/docs/http/oauth/

func WithOIDC

func WithOIDC(issuerURL string, clientID string, clientSecret string, opts ...OIDCOption) HTTPEndpointOption

WithOIDC configures this edge with the the given OIDC provider. Overwrites any previously-set OIDC configuration.

https://ngrok.com/docs/http/openid-connect/

func WithRemoveRequestHeader

func WithRemoveRequestHeader(name string) HTTPEndpointOption

WithRemoveRequestHeader removes a header from requests to this edge.

https://ngrok.com/docs/http/request-headers/

func WithRemoveResponseHeader

func WithRemoveResponseHeader(name string) HTTPEndpointOption

WithRemoveResponseHeader removes a header from responses from this edge.

https://ngrok.com/docs/http/response-headers/

func WithRequestHeader

func WithRequestHeader(name, value string) HTTPEndpointOption

WithRequestHeader adds a header to all requests to this edge.

https://ngrok.com/docs/http/request-headers/

func WithResponseHeader

func WithResponseHeader(name, value string) HTTPEndpointOption

WithRequestHeader adds a header to all responses coming from this edge.

https://ngrok.com/docs/http/response-headers/

func WithScheme

func WithScheme(scheme Scheme) HTTPEndpointOption

WithScheme sets the scheme for this edge.

func WithWebhookVerification

func WithWebhookVerification(provider string, secret string) HTTPEndpointOption

WithWebhookVerification configures webhook verification for this edge.

https://ngrok.com/docs/http/webhook-verification/

func WithWebsocketTCPConversion

func WithWebsocketTCPConversion() HTTPEndpointOption

WithWebsocketTCPConversion enables the websocket-to-tcp converter.

https://ngrok.com/docs/http/websocket-tcp-converter/

type LabeledTunnelOption

type LabeledTunnelOption interface {
	ApplyLabeled(cfg *labeledOptions)
}

func WithLabel

func WithLabel(label, value string) LabeledTunnelOption

WithLabel adds a label to this tunnel's set of label, value pairs.

type OAuthOption

type OAuthOption func(cfg *oauthOptions)

func WithAllowOAuthDomain

func WithAllowOAuthDomain(domain ...string) OAuthOption

Append email domains to the list of allowed domains.

func WithAllowOAuthEmail

func WithAllowOAuthEmail(addr ...string) OAuthOption

Append email addresses to the list of allowed emails.

func WithOAuthClientID added in v1.1.0

func WithOAuthClientID(id string) OAuthOption

WithOAuthClientID provides a client ID for custom OAuth apps.

func WithOAuthClientSecret added in v1.1.0

func WithOAuthClientSecret(secret string) OAuthOption

WithOAuthClientSecret provides a client secret for custom OAuth apps.

func WithOAuthScope

func WithOAuthScope(scope ...string) OAuthOption

Append scopes to the list of scopes to request.

type OIDCOption

type OIDCOption func(cfg *oidcOptions)

func WithAllowOIDCDomain

func WithAllowOIDCDomain(domain ...string) OIDCOption

Append email domains to the list of allowed domains.

func WithAllowOIDCEmail

func WithAllowOIDCEmail(addr ...string) OIDCOption

Append email addresses to the list of allowed emails.

func WithOIDCScope

func WithOIDCScope(scope ...string) OIDCOption

Append scopes to the list of scopes to request.

type Options added in v1.5.0

func WithForwardsTo

func WithForwardsTo(meta string) Options

WithForwardsTo sets the ForwardsTo string for this tunnel. This can be viewed via the API or dashboard.

This overrides the default process info if using golang.ngrok.com/ngrok.Listen, and is in turn overridden by the url provided to golang.ngrok.com/ngrok.ListenAndForward.

https://ngrok.com/docs/api/resources/tunnels/#tunnel-fields

func WithHTTPHandler

func WithHTTPHandler(h http.Handler) Options

WithHTTPHandler adds the provided credentials to the list of basic authentication credentials. Deprecated: Use session.ListenAndHandleHTTP instead.

func WithHTTPServer

func WithHTTPServer(srv *http.Server) Options

WithHTTPServer adds the provided credentials to the list of basic authentication credentials. Deprecated: Use session.ListenAndServeHTTP instead.

type ProxyProtoVersion

type ProxyProtoVersion int32

ProxyProtoVersion is a valid PROXY protocol version

type Scheme

type Scheme string

A URL scheme.

type TCPEndpointOption

type TCPEndpointOption interface {
	ApplyTCP(cfg *tcpOptions)
}

func WithRemoteAddr

func WithRemoteAddr(addr string) TCPEndpointOption

Set the TCP address to request for this edge.

type TLSEndpointOption

type TLSEndpointOption interface {
	ApplyTLS(cfg *tlsOptions)
}

func WithTLSTermination added in v1.1.0

func WithTLSTermination(opts ...TLSTerminationOption) TLSEndpointOption

WithTLSTermination arranges for incoming TLS connections to be automatically terminated. The backend will then receive plaintext streams, rather than raw TLS connections. Defaults to terminating TLS at the ngrok edge with an automatically-provisioned keypair.

https://ngrok.com/docs/tls/tls-termination/

func WithTermination deprecated

func WithTermination(certPEM, keyPEM []byte) TLSEndpointOption

WithTermination sets the key and certificate in PEM format for TLS termination at the ngrok edge.

Deprecated: Use WithCustomEdgeTermination instead.

type TLSTerminationLocation added in v1.1.0

type TLSTerminationLocation int
const (
	// Terminate TLS at the ngrok edge. The backend will receive a plaintext
	// stream.
	TLSAtEdge TLSTerminationLocation = iota
)

type TLSTerminationOption added in v1.1.0

type TLSTerminationOption func(tt *tlsTermination)

func WithTLSTerminationAt added in v1.1.0

func WithTLSTerminationAt(location TLSTerminationLocation) TLSTerminationOption

WithTLSTerminationAt determines where TLS termination should occur. Currently, only `TLSAtEdge` is supported.

func WithTLSTerminationKeyPair added in v1.1.0

func WithTLSTerminationKeyPair(certPEM, keyPEM []byte) TLSTerminationOption

WithTLSTerminationKeyPair sets a custom key and certificate in PEM format for TLS termination. If terminating at the ngrok edge, this uploads the private key and certificate to the ngrok servers.

type Tunnel

type Tunnel interface {
	// contains filtered or unexported methods
}

Tunnel is a marker interface for options that can be used to start tunnels. It should not be implemented outside of this module.

func HTTPEndpoint

func HTTPEndpoint(opts ...HTTPEndpointOption) Tunnel

HTTPEndpoint constructs a new set options for a HTTP endpoint.

https://ngrok.com/docs/http/

func LabeledTunnel

func LabeledTunnel(opts ...LabeledTunnelOption) Tunnel

LabeledTunnel constructs a new set options for a labeled Edge.

https://ngrok.com/docs/network-edge/edges/#tunnel-group

func TCPEndpoint

func TCPEndpoint(opts ...TCPEndpointOption) Tunnel

TCPEndpoint constructs a new set options for a TCP endpoint.

https://ngrok.com/docs/tcp/

func TLSEndpoint

func TLSEndpoint(opts ...TLSEndpointOption) Tunnel

TLSEndpoint constructs a new set options for a TLS endpoint.

https://ngrok.com/docs/tls/

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL