config

package
v0.0.18 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultConfigFile = ".vpnham.yaml"

	DefaultLogLevel = "info"
	DefaultLogMode  = "prod"

	DefaultPartnerStatusTimeout = time.Second
	DefaultProbeInterval        = 15 * time.Second

	DefaultThresholdDown = 5
	DefaultThresholdUp   = 2

	DefaultAWSTimeout     = 15 * time.Second
	DefaultGCPTimeout     = 15 * time.Second
	DefaultScriptsTimeout = 30 * time.Second

	DefaultRouteIDPrefix = "vpnham"

	DefaultGCPRoutePriority uint32 = 1000

	DefaultMetricsListenAddr = "0.0.0.0:8000"

	DefaultLatencyBucketsCount = 33      // from 1us to 1s
	DefaultMaxLatencyUs        = 1000000 // 1s

	DefaultReapplyFactor = 2.0
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Bridge

type Bridge struct {
	Name string    `yaml:"-"`
	UUID uuid.UUID `yaml:"-"`

	Role types.Role `yaml:"role"`

	BridgeInterface string       `yaml:"bridge_interface"`
	PeerCIDR        types.CIDR   `yaml:"peer_cidr"`
	ExtraPeerCIDRs  []types.CIDR `yaml:"extra_peer_cidrs"`

	SecondaryInterfaces []string `yaml:"secondary_interfaces"`

	StatusAddr                 types.Address `yaml:"status_addr"`
	PartnerURL                 string        `yaml:"partner_url"`
	PartnerPollingInterface    string        `yaml:"partner_polling_interface"`
	PartnerStatusTimeout       time.Duration `yaml:"partner_status_timeout"`
	PartnerStatusThresholdDown int           `yaml:"partner_status_threshold_down"`
	PartnerStatusThresholdUp   int           `yaml:"partner_status_threshold_up"`

	ProbeInterval time.Duration  `yaml:"probe_interval"`
	ProbeLocation types.Location `yaml:"probe_location"`

	TunnelInterfaces map[string]*TunnelInterface `yaml:"tunnel_interfaces"`

	Reconcile *Reconcile `yaml:"reconcile"`
}

func (*Bridge) BridgePeerCIDRs added in v0.0.14

func (b *Bridge) BridgePeerCIDRs() []types.CIDR

func (*Bridge) PostLoad added in v0.0.5

func (b *Bridge) PostLoad(ctx context.Context) error

func (*Bridge) TunnelInterfacesCount

func (b *Bridge) TunnelInterfacesCount() int

func (*Bridge) Validate

func (b *Bridge) Validate(ctx context.Context) error

type Config

type Config struct {
	Version string `yaml:"-"`

	Log    *Log    `yaml:"log"`
	Server *Server `yaml:"server"`
}

type Log

type Log struct {
	Level string `yaml:"level"`
	Mode  string `yaml:"mode"`
}

type Metrics

type Metrics struct {
	ListenAddr types.Address `yaml:"listen_addr"`

	LatencyBucketsCount int `yaml:"latency_buckets_count"`
	MaxLatencyUs        int `yaml:"max_latency_us"`
}

func (*Metrics) PostLoad added in v0.0.5

func (m *Metrics) PostLoad(ctx context.Context) error

func (*Metrics) Validate

func (m *Metrics) Validate(ctx context.Context) error

type Reconcile added in v0.0.5

type Reconcile struct {
	BridgeName          string   `yaml:"-"`
	BridgeInterface     string   `yaml:"-"`
	SecondaryInterfaces []string `yaml:"-"`

	ScriptsTimeout time.Duration `yaml:"scripts_timeout"`

	BridgeActivate      *ReconcileBridgeActivate      `yaml:"bridge_activate"`
	InterfaceActivate   *ReconcileInterfaceActivate   `yaml:"interface_activate"`
	InterfaceDeactivate *ReconcileInterfaceDeactivate `yaml:"interface_deactivate"`
}

func (*Reconcile) PostLoad added in v0.0.5

func (r *Reconcile) PostLoad(ctx context.Context) error

func (*Reconcile) Validate added in v0.0.5

func (r *Reconcile) Validate(ctx context.Context) error

type ReconcileBridgeActivate added in v0.0.5

type ReconcileBridgeActivate struct {
	BridgeName          string   `yaml:"-"`
	BridgeInterface     string   `yaml:"-"`
	SecondaryInterfaces []string `yaml:"-"`

	Reapply *ReconcileReapply `yaml:"reapply"`

	AWS *ReconcileBridgeActivateAWS `yaml:"aws"`
	GCP *ReconcileBridgeActivateGCP `yaml:"gcp"`

	Script types.Script `yaml:"script"`
}

func (*ReconcileBridgeActivate) PostLoad added in v0.0.5

func (r *ReconcileBridgeActivate) PostLoad(ctx context.Context) error

func (*ReconcileBridgeActivate) Validate added in v0.0.5

func (r *ReconcileBridgeActivate) Validate(ctx context.Context) error

type ReconcileBridgeActivateAWS added in v0.0.5

type ReconcileBridgeActivateAWS struct {
	BridgeName          string                                    `yaml:"-"`
	BridgeInterface     string                                    `yaml:"-"`
	SecondaryInterfaces []string                                  `yaml:"-"`
	Vpcs                map[string]*ReconcileBridgeActivateAWSVpc `yaml:"-"`

	Timeout time.Duration `yaml:"timeout"`

	RouteTables []string `yaml:"route_tables"`
}

func (*ReconcileBridgeActivateAWS) PostLoad added in v0.0.9

type ReconcileBridgeActivateAWSVpc added in v0.0.9

type ReconcileBridgeActivateAWSVpc struct {
	ID                 string
	LocalInterfaceID   string
	NetworkInterfaceID string
	RouteTables        []string
}

type ReconcileBridgeActivateGCP added in v0.0.10

type ReconcileBridgeActivateGCP struct {
	BridgeName          string                                    `yaml:"-"`
	BridgeInterface     string                                    `yaml:"-"`
	InstanceName        string                                    `yaml:"-"`
	ProjectID           string                                    `yaml:"-"`
	SecondaryInterfaces []string                                  `yaml:"-"`
	Vpcs                map[string]*ReconcileBridgeActivateGCPVpc `yaml:"-"`

	RouteIDPrefix string   `yaml:"route_id_prefix"`
	RoutePriority uint32   `yaml:"route_priority"`
	RouteTags     []string `yaml:"route_tags"`

	Timeout time.Duration `yaml:"timeout"`
}

func (*ReconcileBridgeActivateGCP) PostLoad added in v0.0.10

type ReconcileBridgeActivateGCPVpc added in v0.0.10

type ReconcileBridgeActivateGCPVpc struct {
	ID               string
	LocalInterfaceID string
}

type ReconcileInterfaceActivate added in v0.0.5

type ReconcileInterfaceActivate struct {
	Reapply *ReconcileReapply `yaml:"reapply"`

	Script types.Script `yaml:"script"`
}

func (*ReconcileInterfaceActivate) PostLoad added in v0.0.5

func (*ReconcileInterfaceActivate) Validate added in v0.0.5

type ReconcileInterfaceDeactivate added in v0.0.5

type ReconcileInterfaceDeactivate struct {
	Script types.Script `yaml:"script"`
}

func (*ReconcileInterfaceDeactivate) PostLoad added in v0.0.5

func (*ReconcileInterfaceDeactivate) Validate added in v0.0.5

type ReconcileReapply added in v0.0.5

type ReconcileReapply struct {
	InitialDelay time.Duration `yaml:"initial_delay"`
	MaximumDelay time.Duration `yaml:"maximum_delay"`

	Factor float64 `yaml:"factor"`
	// contains filtered or unexported fields
}

func (*ReconcileReapply) DelayOnIteration added in v0.0.5

func (rr *ReconcileReapply) DelayOnIteration(iteration int) time.Duration

func (*ReconcileReapply) Enabled added in v0.0.5

func (rr *ReconcileReapply) Enabled() bool

func (*ReconcileReapply) PostLoad added in v0.0.5

func (rr *ReconcileReapply) PostLoad(ctx context.Context) error

func (*ReconcileReapply) Validate added in v0.0.5

func (rr *ReconcileReapply) Validate(ctx context.Context) error

type Scripts

type Scripts struct {
	Timeout time.Duration `yaml:"timeout"`

	BridgeActivate      types.Script `yaml:"bridge_activate"`
	InterfaceActivate   types.Script `yaml:"interface_activate"`
	InterfaceDeactivate types.Script `yaml:"interface_deactivate"`
}

type Server

type Server struct {
	Bridges map[string]*Bridge `yaml:"bridges"`
	Metrics *Metrics           `yaml:"metrics"`
}

func (*Server) BridgesCount

func (s *Server) BridgesCount() int

func (*Server) EventSourcesCount

func (s *Server) EventSourcesCount() int

func (*Server) PostLoad

func (s *Server) PostLoad(ctx context.Context) error

func (*Server) TunnelInterfacesCount

func (s *Server) TunnelInterfacesCount() int

func (*Server) Validate

func (s *Server) Validate(ctx context.Context) error

type TunnelInterface

type TunnelInterface struct {
	Name string

	Role      types.Role    `yaml:"role"`
	Addr      types.Address `yaml:"addr"`
	ProbeAddr types.Address `yaml:"probe_addr"`

	ThresholdDown int `yaml:"threshold_down"`
	ThresholdUp   int `yaml:"threshold_up"`
}

func (*TunnelInterface) PostLoad added in v0.0.5

func (ifs *TunnelInterface) PostLoad(ctx context.Context) error

func (*TunnelInterface) Validate

func (ifs *TunnelInterface) Validate(ctx context.Context) error

Jump to

Keyboard shortcuts

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