caddy

package
v0.0.0-...-7578c0e Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2023 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultAlphabet = "0123456789abcdefghijklmnopqrstuvwxyz"
View Source
const (
	NewRoutePath = "/config/apps/http/servers/srv0/routes/0"
)

Variables

View Source
var (
	ErrCaddyExecPathMissing                     = errors.New("caddy executable path missing")
	ErrCaddyExecNotFound                        = errors.New("caddy executable not found")
	ErrCaddyFailedCheckingExecPath              = errors.New("failed checking caddy exec path")
	ErrCaddyUnableToGetCaddyServerVersion       = errors.New("failed getting caddy server version")
	ErrCaddyServerExecutableTooOld              = errors.New("caddy server version too old. please use v2 or later")
	ErrCaddyTunnelsHostAddressMissing           = errors.New("caddy tunnels address missing")
	ErrCaddyTunnelsBaseDomainMissing            = errors.New("caddy tunnels subdomain prefix missing")
	ErrCaddyTunnelsWildcardCertFileMissing      = errors.New("caddy tunnels wildcard domains cert file missing")
	ErrCaddyTunnelsWildcardKeyFileMissing       = errors.New("caddy tunnels wildcard domains key file missing")
	ErrCaddyUnknownLogLevel                     = errors.New("rport log level not a known caddy log level")
	ErrCaddyMissingAPIPort                      = errors.New("when api_hostname specified then api_port must also be set")
	ErrCaddyMissingAPIHostname                  = errors.New("when api_port specified then api_hostname must also be set")
	ErrUnableToGetAddressAndPortFromHostAddress = errors.New("unable to get ip address and port from caddy address. please make sure both are set")
	ErrUnableToCheckIfCertFileExists            = errors.New("unable to check if caddy cert file exists")
	ErrCaddyCertFileNotFound                    = errors.New("caddy cert file not found")
	ErrUnableToCheckIfKeyFileExists             = errors.New("unable to check if caddy key file exists")
	ErrCaddyKeyFileNotFound                     = errors.New("caddy key file not found")
	ErrUnableToCheckIfAPICertFileExists         = errors.New("unable to check if caddy api cert file exists")
	ErrCaddyAPICertFileNotFound                 = errors.New("caddy api cert file not found")
	ErrUnableToCheckIfAPIKeyFileExists          = errors.New("unable to check if caddy api cert file exists")
	ErrCaddyAPIKeyFileNotFound                  = errors.New("caddy api key file not found")
	ErrCaddyUnknownTLSMin                       = errors.New("tls_min not a known tls protocol version")
)
View Source
var (
	HostDomainSocket = "//tmp/caddy-admin.sock"
)
View Source
var NewRouteRequestTemplate string

Functions

func ExecuteTemplate

func ExecuteTemplate(templateName string, t string, params any) (applied []byte, err error)

func ExtractCaddyMajorVersionStr

func ExtractCaddyMajorVersionStr(versionInfo string) (majorVersion string)

func GetExecVersion

func GetExecVersion(cfg *Config) (majorVersion int, err error)

Types

type API

type API interface {
	AddRoute(ctx context.Context, nrr *NewRouteRequest) (res *http.Response, err error)
	DeleteRoute(ctx context.Context, routeID string) (res *http.Response, err error)
}

type APIReverseProxySettings

type APIReverseProxySettings struct {
	CertsFile     string
	KeyFile       string
	ProxyDomain   string
	ProxyPort     string
	APIDomain     string
	APIScheme     string
	APITargetHost string
	APITargetPort string
	TLSMin        string
}

type BaseConfig

type BaseConfig struct {
	IncludeAPIProxy         bool
	GlobalSettings          *GlobalSettings
	DefaultVirtualHost      *DefaultVirtualHost
	APIReverseProxySettings *APIReverseProxySettings
}

type Config

type Config struct {
	ExecPath    string `mapstructure:"caddy"`
	HostAddress string `mapstructure:"address"`
	BaseDomain  string `mapstructure:"subdomain_prefix"`
	CertFile    string `mapstructure:"cert_file"`
	KeyFile     string `mapstructure:"key_file"`
	APIHostname string `mapstructure:"api_hostname"`
	APIPort     string `mapstructure:"api_port"`
	APICertFile string `mapstructure:"api_cert_file"`
	APIKeyFile  string `mapstructure:"api_key_file"`
	TLSMin      string `mapstructure:"tls_min"`

	LogLevel         string `mapstructure:"-"` // taken from the rport server log level
	DataDir          string `mapstructure:"-"` // taken from the rport server datadir
	BaseConfFilename string `mapstructure:"-"`
	Enabled          bool   `mapstructure:"-"`

	SubDomainGenerator SubdomainGenerator
}

func (*Config) APIReverseProxyEnabled

func (c *Config) APIReverseProxyEnabled() (enabled bool)

func (*Config) GetBaseConf

func (c *Config) GetBaseConf(bc *BaseConfig) (text []byte, err error)

func (*Config) GetRandomSubdomain

func (c *Config) GetRandomSubdomain() (subdomain string, err error)

func (*Config) MakeBaseConfFilename

func (c *Config) MakeBaseConfFilename() (filename string)

func (*Config) MakeBaseConfig

func (c *Config) MakeBaseConfig(targetAPIPort string) (bc *BaseConfig, err error)

func (*Config) ParseAndValidate

func (c *Config) ParseAndValidate(serverDataDir string, serverLogLevel string, filesAPI files.FileAPI) error

type DefaultVirtualHost

type DefaultVirtualHost struct {
	ListenAddress string
	ListenPort    string
	CertsFile     string
	KeyFile       string
	TLSMin        string
}

type ExternalReverseProxy

type ExternalReverseProxy struct {
	CertsFile        string
	KeyFile          string
	BaseDomain       string
	Subdomain        string
	AllowedIPAddress string
	TunnelScheme     string
	TunnelIPAddress  string
	TunnelPort       string
}

type GlobalSettings

type GlobalSettings struct {
	LogLevel    string
	AdminSocket string
}

type NewRouteRequest

type NewRouteRequest struct {
	RouteID                   string
	TargetTunnelHost          string
	TargetTunnelPort          string
	DownstreamProxySubdomain  string
	DownstreamProxyBaseDomain string
}

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewCaddyServer

func NewCaddyServer(cfg *Config, l *logger.Logger) (c *Server)

func (*Server) AddRoute

func (s *Server) AddRoute(ctx context.Context, nrr *NewRouteRequest) (res *http.Response, err error)

func (*Server) Close

func (c *Server) Close() (err error)

func (*Server) DeleteRoute

func (s *Server) DeleteRoute(ctx context.Context, routeID string) (res *http.Response, err error)

func (*Server) Run

func (c *Server) Run()

func (*Server) Start

func (c *Server) Start(ctx context.Context) (err error)

func (*Server) Wait

func (c *Server) Wait() (err error)

type SubdomainGenerator

type SubdomainGenerator interface {
	GetRandomSubdomain() (subdomain string, err error)
}

Jump to

Keyboard shortcuts

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