strongswan

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2019 License: GPL-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseDuration

func ParseDuration(str string) (time.Duration, error)

ParseDuration is function to parse string to time.Duration

Types

type AuthType

type AuthType uint

AuthType is type to enumerate types of peers/hosts authentication

const (
	UnknownAuth AuthType = iota
	NoAuth
	AnyAuth
	EAPMSCHAPv2Auth
	PublicKeyAuth
	PreSharedKeyAuth
)

Types of peers/hosts authentication

func ParseAuthType

func ParseAuthType(str string) AuthType

ParseAuthType returns AuthType according to str

func (AuthType) String

func (a AuthType) String() string

type BitNum

type BitNum uint64

BitNum is Stringer type for handling bit numbers

const (
	BitMultiplier BitNum = 1000
	KBit          BitNum = BitMultiplier
	MBit          BitNum = KBit * BitMultiplier
	GBit          BitNum = MBit * BitMultiplier
	TBit          BitNum = GBit * BitMultiplier
)

BitNum units

func (BitNum) ByteNum

func (bn BitNum) ByteNum() ByteNum

ByteNum returns ByteNum of this BitNum

func (BitNum) String

func (bn BitNum) String() string

type ByteNum

type ByteNum uint64

ByteNum is Stringer type for handling byte numbers

const (
	ByteMultiplier ByteNum = 1024
	KiByte         ByteNum = ByteMultiplier
	MiByte         ByteNum = KiByte * ByteMultiplier
	GiByte         ByteNum = MiByte * ByteMultiplier
	TiByte         ByteNum = GiByte * ByteMultiplier
)

ByteNum units

func (ByteNum) BitNum

func (bn ByteNum) BitNum() BitNum

BitNum returns BitNum of this ByteNum

func (ByteNum) String

func (bn ByteNum) String() string

type CRL

type CRL struct {
	Issuer      *Cert
	UpdateThis  time.Time
	UpdateNext  time.Time
	Serial      uint64
	AuthKeyID   string
	Revokations []*Revokation
}

CRL is a struct storing CRL data

type Callback

type Callback func(...interface{})

Callback is type for callback functions

type Cert

type Cert struct {
	Cert   *x509.Certificate
	Issued []*Cert
	Issuer *Cert
	CRL    *CRL
}

Cert is a struct storing Certificate and CA-tree info

type CertsGetter

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

CertsGetter is a struct to handle with Certs getting

func NewCertsGetter

func NewCertsGetter() (*CertsGetter, error)

NewCertsGetter return instance of CertsGetter or error if it is not possible to init any CertsReader

func (*CertsGetter) GetCerts

func (cg *CertsGetter) GetCerts() ([]*Cert, error)

GetCerts is function which returns *Cert slice or error

type CertsReader

type CertsReader interface {
	Read(io.Reader) ([]*Cert, error)
}

CertsReader is interface for types which can read slice of Certs from io.Reader

type Child

type Child struct {
	Mode             ConnectionMode
	Rekeying, Reauth time.Duration
	Local, Remote    []string
}

Child is type for storing info about child association of connection

func (Child) String

func (c Child) String() string

type ChildSA

type ChildSA struct {
	Mode                  ConnectionMode
	Proto                 IPsecProto
	UDPEncaps             bool
	ReqID                 int64
	InputSPI, OutputSPI   string
	LocalNet, RemoteNet   string
	IsLocalInitiator      bool
	Security              string
	BytesIn, BytesOut     ByteNum
	PktsIn, PktsOut       uint64
	LastInAgo, LastOutAgo string
	UntilRekey            string
	Installed             bool
}

ChildSA is struct to store info about Child SA

type Connection

type Connection struct {
	Name                  string
	LocalAddr, RemoteAddr []string
	LocalAuth, RemoteAuth []AuthType
	LocalID, RemoteID     []string
	Children              []Child
	Version               IKEVersion
	SAs                   []*SA
}

Connection is type for storing info about connection

type ConnectionMode

type ConnectionMode uint

ConnectionMode is type to enumerate connection modes

const (
	UnknownMode ConnectionMode = iota
	TransportMode
	TunnelMode
	PassMode
)

There is two connection modes: TRANSPORT and TUNNEL

func ParseConnectionMode

func ParseConnectionMode(str string) ConnectionMode

ParseConnectionMode returns ConnectionMode according to str

func (ConnectionMode) String

func (cm ConnectionMode) String() string

type ConnectionsGetter

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

ConnectionsGetter is a struct to handle with Connections getting

func NewConnectionsGetter

func NewConnectionsGetter() (*ConnectionsGetter, error)

NewConnectionsGetter return instance of ConnectionsGetter or error if it is not possible to init any ConnectionsReader

func (*ConnectionsGetter) GetConns

func (cg *ConnectionsGetter) GetConns() ([]*Connection, error)

GetConns is function which returns *Connection slice or error

type ConnectionsReader

type ConnectionsReader interface {
	Read(io.Reader) ([]*Connection, error)
}

ConnectionsReader is interface for types which can read slice of Connections from io.Reader

type IKESA

type IKESA struct {
	Alive                      string
	LocalAddr, RemoteAddr      string
	LocalID, RemoteID          string
	InitiatorSPI, ResponderSPI string
	IsInitiator                bool
	Version                    IKEVersion
	Auth                       AuthType
	UntilReauth                string
	Security                   string
	Established                bool
	Deleting                   bool
}

IKESA is struct to store info about IKE SA

type IKEVersion

type IKEVersion uint

IKEVersion is type to enumerate version of IKE protocol

const (
	IKEUnknown IKEVersion = 0
	IKEv1      IKEVersion = 1
	IKEv2      IKEVersion = 1 << 1
)

There is two versions of IKE: IKEv1 and IKEv2

func ParseIKEVersion

func ParseIKEVersion(str string) IKEVersion

ParseIKEVersion parses IKEVersion from string

func (IKEVersion) String

func (i IKEVersion) String() string

type IPsecProto

type IPsecProto uint

IPsecProto is type to enumerate IPsec Phase2 protocols

const (
	UnknownProto IPsecProto = iota
	AHProto
	ESPProto
)

There is two IPsec Phase2 protocols: AH and ESP

func ParseIPsecProto

func ParseIPsecProto(str string) IPsecProto

ParseIPsecProto returns IPsecProto according to str

func (IPsecProto) String

func (p IPsecProto) String() string

type Info

type Info struct {
	sync.RWMutex
	Uptime        time.Duration
	Since         time.Time
	Connections   []*Connection
	Pools         []Pool
	Certs         []*Cert
	UptimeRoutine *PeriodicObservableRoutine
	ConnsRoutine  *PeriodicObservableRoutine
	CertsRoutine  *PeriodicObservableRoutine
	PoolsRoutine  *PeriodicObservableRoutine
	// contains filtered or unexported fields
}

Info is type to store all StrongSwan daemon info

func NewInfo

func NewInfo(uptimePeriod, poolsPeriod, connectionsPeriod, certsPeriod time.Duration) (*Info, error)

NewInfo creates new instance of Info structure

func (*Info) Start

func (info *Info) Start()

Start starts all Info's goroutines

func (*Info) Stop

func (info *Info) Stop()

Stop stops all Info's goroutines

type IpsecCertsReader

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

IpsecCertsReader is type to Read slice of Certs with `ipsec listall` format

func (*IpsecCertsReader) Read

func (icr *IpsecCertsReader) Read(r io.Reader) ([]*Cert, error)

type IpsecConnReader

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

IpsecConnReader is type to Read slice of Connections with `ipsec statusall` format

func (*IpsecConnReader) Read

func (icr *IpsecConnReader) Read(r io.Reader) ([]*Connection, error)

type IpsecPoolsReader

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

IpsecPoolsReader is type to Read slice of Pools with `ipsec statusall` format

func (*IpsecPoolsReader) Read

func (ipr *IpsecPoolsReader) Read(r io.Reader) ([]Pool, error)

type IpsecSummaryReader

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

IpsecSummaryReader is type to Read Summary struct with `ipsec statusall` format

func (*IpsecSummaryReader) Read

type Observable

type Observable interface {
	RegObserver() chan int
	UnregObserver(chan int)
	Notify(int)
}

Observable is interface for types who can register and unregister observers callbacks

type PeriodicObservableRoutine

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

PeriodicObservableRoutine is type which is observable and can start goroutine with periodic-executable function

func NewPeriodicObservableRoutine

func NewPeriodicObservableRoutine(period time.Duration, routine func(*PeriodicObservableRoutine)) *PeriodicObservableRoutine

NewPeriodicObservableRoutine returns pointer to new instance of PeriodicObservableRoutine

func (*PeriodicObservableRoutine) Go

func (por *PeriodicObservableRoutine) Go()

Go starts gorotine which runs PeriodicObservableRoutine.routine every PeriodicObservableRoutine.period and can be stopped by writing some data to PeriodicObservableRoutine.stopChan

func (*PeriodicObservableRoutine) Notify

func (por *PeriodicObservableRoutine) Notify(val int)

Notify implements Observable interface

func (*PeriodicObservableRoutine) RegObserver

func (por *PeriodicObservableRoutine) RegObserver() chan int

RegObserver implements Observable interface

func (*PeriodicObservableRoutine) UnregObserver

func (por *PeriodicObservableRoutine) UnregObserver(ch chan int)

UnregObserver implements Observable interface

type Pool

type Pool struct {
	Addr, Name    string
	On, Off, Size int
}

Pool is struct to store strongswan virtual pools info

func (Pool) String

func (p Pool) String() string

type PoolsGetter

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

PoolsGetter is a struct to handle with Pools getting

func NewPoolsGetter

func NewPoolsGetter() (*PoolsGetter, error)

NewPoolsGetter return instance of PoolsGetter or error if it is not possible to init any PoolsReader

func (*PoolsGetter) GetPools

func (pg *PoolsGetter) GetPools() ([]Pool, error)

GetPools is function which returns Pools slice or error

type PoolsReader

type PoolsReader interface {
	Read(io.Reader) ([]Pool, error)
}

PoolsReader is interface for types which can read slice of Pools from io.Reader

type Revokation

type Revokation struct {
	Serial  uint64
	Time    time.Time
	Reaseon RevokationReason
}

Revokation is a struct storing info about revoked certificate

type RevokationReason

type RevokationReason int

RevokationReason is a type enumerating revokation reasons of certificates

const (
	UnknownReason RevokationReason = iota
	CACompromisedReason
	KeyCompromisedReason
)

RevokationReason enumeration

type SA

type SA struct {
	IKESA    IKESA
	ChildSAs []ChildSA
}

SA is struct to store info about IPsec Security Association

type Summary

type Summary struct {
	Uptime                      string
	Since                       time.Time
	SATotal, SAHalfOpened       int
	TotalBytesIn, TotalBytesOut int64
	TotalPktsIn, TotalPktsOut   int64
}

Summary is struct to store summary strongswan daemon info

func (*Summary) String

func (s *Summary) String() string

type SwanctlSummaryReader

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

SwanctlSummaryReader is type to Read Summary struct with `swanctl --stats` format

func (*SwanctlSummaryReader) Read

type UptimeGetter

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

UptimeGetter is a struct to handle with Uptime getting

func NewUptimeGetter

func NewUptimeGetter() (*UptimeGetter, error)

NewUptimeGetter return instance of UptimeGetter or error if it is not possible to init any UptimeReader

func (*UptimeGetter) GetUptime

func (ug *UptimeGetter) GetUptime() (time.Duration, time.Time, error)

GetUptime is function which returns uptime and lifetime or error

type UptimeReader

type UptimeReader interface {
	Read(io.Reader) (time.Duration, time.Time, error)
}

UptimeReader is interface for types which can read Summary struct from io.Reader

type ViciCertsReader

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

ViciCertsReader is CertReader which reads from vici socket

func NewViciCertsReader

func NewViciCertsReader() (*ViciCertsReader, error)

NewViciCertsReader creates new ViciCertsReader

func (*ViciCertsReader) Read

func (vcr *ViciCertsReader) Read(io.Reader) ([]*Cert, error)

type ViciConnReader

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

ViciConnReader is ConnectionsReader which reads from vici socket

func NewViciConnReader

func NewViciConnReader() (*ViciConnReader, error)

NewViciConnReader creates new ViciConnReader

func (*ViciConnReader) Read

func (vcr *ViciConnReader) Read(io.Reader) ([]*Connection, error)

type ViciOptions

type ViciOptions struct {
	IKE string `vici:"ike"`
}

ViciOptions is struct representing vici message sending to vici socket

Jump to

Keyboard shortcuts

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