l4clock

package
v0.0.0-...-ce42594 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MatchClock

type MatchClock struct {
	// After is a mandatory field that must have a value in 15:04:05 format representing the lowest valid time point.
	// Placeholders are supported and evaluated at provision. If Before is lower than After, their values are swapped
	// at provision.
	After string `json:"after,omitempty"`
	// Before is a mandatory field that must have a value in 15:04:05 format representing the highest valid time point
	// plus one second. Placeholders are supported and evaluated at provision. 00:00:00 is treated here as 24:00:00.
	// If Before is lower than After, their values are swapped at provision.
	Before string `json:"before,omitempty"`
	// Timezone is an optional field that may be an IANA time zone location (e.g. America/Los_Angeles), a fixed offset
	// to the east of UTC (e.g. +02, -03:30, or even +12:34:56) or Local (to use the system's local time zone).
	// If Timezone is empty, UTC is used by default.
	Timezone string `json:"timezone,omitempty"`
	// contains filtered or unexported fields
}

MatchClock is able to match any connections using the time when they are wrapped/matched.

func (*MatchClock) CaddyModule

func (m *MatchClock) CaddyModule() caddy.ModuleInfo

CaddyModule returns the Caddy module information.

func (*MatchClock) Match

func (m *MatchClock) Match(cx *layer4.Connection) (bool, error)

Match returns true if the connection wrapping/matching occurs within m's time points.

func (*MatchClock) Provision

func (m *MatchClock) Provision(_ caddy.Context) (err error)

Provision parses m's time points and a time zone (UTC is used by default).

func (*MatchClock) UnmarshalCaddyfile

func (m *MatchClock) UnmarshalCaddyfile(d *caddyfile.Dispenser) error

UnmarshalCaddyfile sets up the MatchClock from Caddyfile tokens. Syntax:

clock <time_after> <time_before> [<time_zone>]
clock <after|from> <time_after> [<time_zone>]
clock <before|till|to|until> <time_before> [<time_zone>]

Note: MatchClock checks if time_now is greater than or equal to time_after AND less than time_before. The lowest value is 00:00:00. If time_before equals 00:00:00, it is treated as 24:00:00. If time_after is greater than time_before, they are swapped. Both "after 00:00:00" and "before 00:00:00" match all day. An IANA time zone location should be used as a value for time_zone. The system's local time zone may be used with "Local" value. If time_zone is empty, UTC is used.

Jump to

Keyboard shortcuts

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