Documentation
¶
Index ¶
- func MaxSizeSubjectsListForLog(subjects map[string]struct{}, maxToDisplay int) []string
- func PrivateRangesCIDR() []string
- func SplitUnixSocketPermissionsBits(addr string) (path string, fileMode fs.FileMode, err error)
- func WithBindCapability(network, address string, listen func() (any, error)) (any, error)
- type LogBufferCore
- func (c *LogBufferCore) Check(entry zapcore.Entry, ce *zapcore.CheckedEntry) *zapcore.CheckedEntry
- func (c *LogBufferCore) Enabled(lvl zapcore.Level) bool
- func (c *LogBufferCore) FlushTo(logger *zap.Logger)
- func (c *LogBufferCore) Sync() error
- func (c *LogBufferCore) With(fields []zapcore.Field) zapcore.Core
- func (c *LogBufferCore) Write(entry zapcore.Entry, fields []zapcore.Field) error
- type LogBufferCoreInterface
- type LoggableHTTPHeader
- type LoggableStringArray
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MaxSizeSubjectsListForLog ¶ added in v2.10.0
MaxSizeSubjectsListForLog returns up to maxToDisplay keys from subjects. If any keys are omitted, it appends one additional entry summarising the omitted count. This bounds the number of subject names placed in the log while making truncation explicit.
func PrivateRangesCIDR ¶ added in v2.9.0
func PrivateRangesCIDR() []string
PrivateRangesCIDR returns a list of private CIDR range strings, which can be used as a configuration shortcut.
func SplitUnixSocketPermissionsBits ¶
SplitUnixSocketPermissionsBits takes a unix socket address in the unusual "path|bits" format (e.g. /run/caddy.sock|0222) and tries to split it into socket path (host) and permissions bits (port). Colons (":") can't be used as separator, as socket paths on Windows may include a drive letter (e.g. `unix/c:\absolute\path.sock`). Permission bits will default to 0200 if none are specified. Throws an error, if the first carrying bit does not include write perms (e.g. `0422` or `022`). Symbolic permission representation (e.g. `u=w,g=w,o=w`) is not supported and will throw an error for now!
func WithBindCapability ¶ added in v2.11.8
WithBindCapability calls listen, which should bind to address on network. If that fails with EACCES for a TCP or UDP port, and CAP_NET_BIND_SERVICE is in the permitted set but not the effective set, it raises the capability and calls listen again, lowering the capability afterwards.
Retrying on EACCES, instead of checking the port up front, means the capability is only raised when the kernel actually requires it, which depends on net.ipv4.ip_unprivileged_port_start (often 0 in containers, and possibly above 1024).
This allows the caddy binary to be granted the capability with `setcap cap_net_bind_service=+p` instead of `=+ep`. With the effective bit set, the kernel refuses to execute the binary at all when the capability can't be granted (for example, in containers run with `--cap-drop ALL`, or systemd units with an empty CapabilityBoundingSet), even if Caddy never binds a privileged port. See "Safety checking for capability-dumb binaries" in capabilities(7).
Types ¶
type LogBufferCore ¶ added in v2.11.0
type LogBufferCore struct {
// contains filtered or unexported fields
}
LogBufferCore is a zapcore.Core that buffers log entries in memory.
func NewLogBufferCore ¶ added in v2.11.0
func NewLogBufferCore(level zapcore.LevelEnabler) *LogBufferCore
func (*LogBufferCore) Check ¶ added in v2.11.0
func (c *LogBufferCore) Check(entry zapcore.Entry, ce *zapcore.CheckedEntry) *zapcore.CheckedEntry
func (*LogBufferCore) Enabled ¶ added in v2.11.0
func (c *LogBufferCore) Enabled(lvl zapcore.Level) bool
func (*LogBufferCore) FlushTo ¶ added in v2.11.0
func (c *LogBufferCore) FlushTo(logger *zap.Logger)
FlushTo flushes buffered logs to the given zap.Logger.
func (*LogBufferCore) Sync ¶ added in v2.11.0
func (c *LogBufferCore) Sync() error
type LogBufferCoreInterface ¶ added in v2.11.0
type LoggableHTTPHeader ¶ added in v2.11.3
LoggableHTTPHeader makes an HTTP header loggable with zap.Object(). Headers with potentially sensitive information (Cookie, Set-Cookie, Authorization, and Proxy-Authorization) are logged with empty values.
func (LoggableHTTPHeader) MarshalLogObject ¶ added in v2.11.3
func (h LoggableHTTPHeader) MarshalLogObject(enc zapcore.ObjectEncoder) error
MarshalLogObject satisfies the zapcore.ObjectMarshaler interface.
type LoggableStringArray ¶ added in v2.11.3
type LoggableStringArray []string
LoggableStringArray makes a slice of strings marshalable for logging.
func (LoggableStringArray) MarshalLogArray ¶ added in v2.11.3
func (sa LoggableStringArray) MarshalLogArray(enc zapcore.ArrayEncoder) error
MarshalLogArray satisfies the zapcore.ArrayMarshaler interface.