Documentation ¶
Index ¶
- Constants
- func WithAllowCIDR(net ...*net.IPNet) interface{ ... }
- func WithAllowCIDRString(cidr ...string) interface{ ... }
- func WithAppProtocol(proto string) interface{ ... }
- func WithBindings(requestedBindings ...string) interface{ ... }
- func WithDenyCIDR(net ...*net.IPNet) interface{ ... }
- func WithDenyCIDRString(cidr ...string) interface{ ... }
- func WithDomain(name string) interface{ ... }
- func WithHostname(name string) interface{ ... }deprecated
- func WithMetadata(meta string) interface{ ... }
- func WithMutualTLSCA(certs ...*x509.Certificate) interface{ ... }
- func WithPolicy(p po.Policy) interface{ ... }
- func WithPolicyString(str string) interface{ ... }
- func WithProxyProto(version ProxyProtoVersion) interface{ ... }
- func WithSubdomain(name string) interface{ ... }deprecated
- type CommonOption
- type CommonOptionsFunc
- type HTTPEndpointOption
- func WithAllowUserAgent(allow ...string) HTTPEndpointOption
- func WithAllowUserAgentFilter(allow ...string) HTTPEndpointOptiondeprecated
- func WithBasicAuth(username, password string) HTTPEndpointOption
- func WithCircuitBreaker(ratio float64) HTTPEndpointOption
- func WithCompression() HTTPEndpointOption
- func WithDenyUserAgent(deny ...string) HTTPEndpointOption
- func WithDenyUserAgentFilter(allow ...string) HTTPEndpointOptiondeprecated
- func WithHostHeaderRewrite(rewrite bool) HTTPEndpointOption
- func WithOAuth(provider string, opts ...OAuthOption) HTTPEndpointOption
- func WithOIDC(issuerURL string, clientID string, clientSecret string, opts ...OIDCOption) HTTPEndpointOption
- func WithRemoveRequestHeader(name string) HTTPEndpointOption
- func WithRemoveResponseHeader(name string) HTTPEndpointOption
- func WithRequestHeader(name, value string) HTTPEndpointOption
- func WithResponseHeader(name, value string) HTTPEndpointOption
- func WithScheme(scheme Scheme) HTTPEndpointOption
- func WithWebhookVerification(provider string, secret string) HTTPEndpointOption
- func WithWebsocketTCPConversion() HTTPEndpointOption
- type LabeledTunnelOption
- type OAuthOption
- type OIDCOption
- type Options
- type ProxyProtoVersion
- type Scheme
- type TCPEndpointOption
- type TLSEndpointOption
- type TLSTerminationLocation
- type TLSTerminationOption
- type Tunnel
Constants ¶
const ( // PROXY protocol disabled ProxyProtoNone = ProxyProtoVersion(0) // PROXY protocol v1 ProxyProtoV1 = ProxyProtoVersion(1) // PROXY protocol v2 ProxyProtoV2 = ProxyProtoVersion(2) )
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.
func WithAllowCIDRString ¶
func WithAllowCIDRString(cidr ...string) interface { HTTPEndpointOption TCPEndpointOption TLSEndpointOption }
Add the provided CIDRS to the [CIDRRestriction].Allowed list.
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 WithBindings ¶ added in v1.10.0
func WithBindings(requestedBindings ...string) interface { HTTPEndpointOption TLSEndpointOption TCPEndpointOption }
WithBinding configures ingress for an endpoint
The requestedBindings argument specifies the type of ingress for the endpoint.
func WithDenyCIDR ¶
func WithDenyCIDR(net ...*net.IPNet) interface { HTTPEndpointOption TCPEndpointOption TLSEndpointOption }
Add the provided net.IPNet to the [CIDRRestriction].Denied list.
func WithDenyCIDRString ¶
func WithDenyCIDRString(cidr ...string) interface { HTTPEndpointOption TCPEndpointOption TLSEndpointOption }
Add the provided CIDRS to the [CIDRRestriction].Denied list.
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 ¶
func WithMetadata(meta string) interface { HTTPEndpointOption TCPEndpointOption TLSEndpointOption LabeledTunnelOption }
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.
func WithPolicy ¶ added in v1.8.0
func WithPolicy(p po.Policy) interface { HTTPEndpointOption TLSEndpointOption TCPEndpointOption }
WithPolicy is deprecated, use WithPolicyString instead. https://ngrok.com/docs/http/traffic-policy/
func WithPolicyString ¶ added in v1.8.1
func WithPolicyString(str string) interface { HTTPEndpointOption TLSEndpointOption TCPEndpointOption }
WithPolicyString configures this edge with the provided policy configuration passed as a json or yaml 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.
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.
func WithCompression ¶
func WithCompression() HTTPEndpointOption
WithCompression enables gzip 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.
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.
func WithRemoveRequestHeader ¶
func WithRemoveRequestHeader(name string) HTTPEndpointOption
WithRemoveRequestHeader removes a header from requests to this edge.
func WithRemoveResponseHeader ¶
func WithRemoveResponseHeader(name string) HTTPEndpointOption
WithRemoveResponseHeader removes a header from responses from this edge.
func WithRequestHeader ¶
func WithRequestHeader(name, value string) HTTPEndpointOption
WithRequestHeader adds a header to all requests to this edge.
func WithResponseHeader ¶
func WithResponseHeader(name, value string) HTTPEndpointOption
WithRequestHeader adds a header to all responses coming from this edge.
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.
func WithWebsocketTCPConversion ¶
func WithWebsocketTCPConversion() HTTPEndpointOption
WithWebsocketTCPConversion enables the websocket-to-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
type Options interface { HTTPEndpointOption TLSEndpointOption TCPEndpointOption LabeledTunnelOption CommonOption }
func WithForwardsTo ¶
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.
func WithHTTPHandler ¶
WithHTTPHandler adds the provided credentials to the list of basic authentication credentials. Deprecated: Use session.ListenAndHandleHTTP instead.
func WithHTTPServer ¶
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 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.
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.
func LabeledTunnel ¶
func LabeledTunnel(opts ...LabeledTunnelOption) Tunnel
LabeledTunnel constructs a new set options for a labeled Edge.
func TCPEndpoint ¶
func TCPEndpoint(opts ...TCPEndpointOption) Tunnel
TCPEndpoint constructs a new set options for a TCP endpoint.
func TLSEndpoint ¶
func TLSEndpoint(opts ...TLSEndpointOption) Tunnel
TLSEndpoint constructs a new set options for a TLS endpoint.
Source Files ¶
- app_protocol.go
- basic_auth.go
- bindings.go
- cidr_restrictions.go
- circuit_breaker.go
- common.go
- compression.go
- domain.go
- forwards_to.go
- http.go
- http_handler.go
- http_headers.go
- labeled.go
- metadata.go
- mutual_tls.go
- oauth.go
- oidc.go
- policy.go
- proxy_proto.go
- scheme.go
- tcp.go
- tls.go
- tls_termination.go
- tunnel_config.go
- user_agent_filter.go
- webhook_verification.go
- websocket_tcp_conversion.go