config

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package config defines the proxy configuration schema and parses it from command-line endpoint strings or a config file.

Index

Constants

View Source
const (
	// DefaultLocalPort is the local port a ProxyConfig uses when it does not set one.
	DefaultLocalPort uint16 = 8888
	// DefaultDestinationPort is the destination port a ProxyConfig uses when it does not set one.
	DefaultDestinationPort uint16 = 443
)

Variables

This section is empty.

Functions

func SetDefaults

func SetDefaults(proxies []ProxyConfig)

SetDefaults sets the default values, if not provided, for the proxy configuration.

Types

type Config

type Config struct {
	// Listen is the default for proxies that do not set their own Listen.
	Listen  string        `mapstructure:"listen"`
	Proxies []ProxyConfig `mapstructure:"proxies"`
}

Config is the top-level configuration file schema.

type ProxyConfig

type ProxyConfig struct {
	Hostname        string `mapstructure:"hostname"`
	DestinationPort uint16 `mapstructure:"destinationPort"`
	LocalPort       uint16 `mapstructure:"localPort"`
	SkipTLS         bool   `mapstructure:"skipTLS"`
	// Listen is the IP address the proxy binds to, without a port. Empty means
	// loopback (127.0.0.1); use 0.0.0.0 or a specific interface address to
	// expose the proxy to other machines.
	Listen string `mapstructure:"listen"`
}

ProxyConfig describes a single reverse proxy to a Cloudflare Access application.

func ParseEndpointString

func ParseEndpointString(endpoint string) (*ProxyConfig, error)

ParseEndpointString parses a string representation of a proxy endpoint into a ProxyConfig struct. The format is [LOCAL_PORT:]HOSTNAME[:DEST_PORT].

A part is a port only if the whole token is a number from 1 to 65535, so "8x8.com" is a hostname. With two parts, the first is the local port if it is a port and the second is the destination port otherwise. This leaves one ambiguity: "12345:443" is local port 12345 and hostname "443". Use the three-part form ("8888:12345:443") for a numeric hostname.

func (*ProxyConfig) Address

func (c *ProxyConfig) Address() string

Address returns the full address of the target application.

Jump to

Keyboard shortcuts

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