wireguard

package
v0.0.0-...-349a466 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PrometheusPeerName = "prometheus"
	APIServerPeerName  = "apiserver"
)

Variables

View Source
var ErrNetworkUnreachable error = errors.New("network is unreachable")

Functions

This section is empty.

Types

type Config

type Config struct {
	AddressV4  string
	AddressV6  string
	ListenPort int
	MTU        int
	Peers      []Peer
	PrivateKey string
}

func (*Config) MarshalINI

func (cfg *Config) MarshalINI(w io.Writer) error

type IPTables

type IPTables interface {
	AppendUnique(table, chain string, rulespec ...string) error
	NewChain(table, chain string) error
	ChangePolicy(table, chain, target string) error
}

type MockNetworkConfigurer

type MockNetworkConfigurer struct {
	mock.Mock
}

MockNetworkConfigurer is an autogenerated mock type for the NetworkConfigurer type

func NewMockNetworkConfigurer

func NewMockNetworkConfigurer(t interface {
	mock.TestingT
	Cleanup(func())
},
) *MockNetworkConfigurer

NewMockNetworkConfigurer creates a new instance of MockNetworkConfigurer. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockNetworkConfigurer) ApplyWireGuardConfig

func (_m *MockNetworkConfigurer) ApplyWireGuardConfig(peers []Peer) error

ApplyWireGuardConfig provides a mock function with given fields: peers

func (*MockNetworkConfigurer) EXPECT

func (*MockNetworkConfigurer) ForwardRoutesV4

func (_m *MockNetworkConfigurer) ForwardRoutesV4(routes []string) error

ForwardRoutesV4 provides a mock function with given fields: routes

func (*MockNetworkConfigurer) ForwardRoutesV6

func (_m *MockNetworkConfigurer) ForwardRoutesV6(routes []string) error

ForwardRoutesV6 provides a mock function with given fields: routes

func (*MockNetworkConfigurer) SetupIPTables

func (_m *MockNetworkConfigurer) SetupIPTables() error

SetupIPTables provides a mock function with given fields:

func (*MockNetworkConfigurer) SetupInterface

func (_m *MockNetworkConfigurer) SetupInterface() error

SetupInterface provides a mock function with given fields:

type MockNetworkConfigurer_ApplyWireGuardConfig_Call

type MockNetworkConfigurer_ApplyWireGuardConfig_Call struct {
	*mock.Call
}

MockNetworkConfigurer_ApplyWireGuardConfig_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ApplyWireGuardConfig'

func (*MockNetworkConfigurer_ApplyWireGuardConfig_Call) Return

func (*MockNetworkConfigurer_ApplyWireGuardConfig_Call) Run

func (*MockNetworkConfigurer_ApplyWireGuardConfig_Call) RunAndReturn

type MockNetworkConfigurer_Expecter

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

func (*MockNetworkConfigurer_Expecter) ApplyWireGuardConfig

func (_e *MockNetworkConfigurer_Expecter) ApplyWireGuardConfig(peers interface{}) *MockNetworkConfigurer_ApplyWireGuardConfig_Call

ApplyWireGuardConfig is a helper method to define mock.On call

  • peers []Peer

func (*MockNetworkConfigurer_Expecter) ForwardRoutesV4

func (_e *MockNetworkConfigurer_Expecter) ForwardRoutesV4(routes interface{}) *MockNetworkConfigurer_ForwardRoutesV4_Call

ForwardRoutesV4 is a helper method to define mock.On call

  • routes []string

func (*MockNetworkConfigurer_Expecter) ForwardRoutesV6

func (_e *MockNetworkConfigurer_Expecter) ForwardRoutesV6(routes interface{}) *MockNetworkConfigurer_ForwardRoutesV6_Call

ForwardRoutesV6 is a helper method to define mock.On call

  • routes []string

func (*MockNetworkConfigurer_Expecter) SetupIPTables

SetupIPTables is a helper method to define mock.On call

func (*MockNetworkConfigurer_Expecter) SetupInterface

SetupInterface is a helper method to define mock.On call

type MockNetworkConfigurer_ForwardRoutesV4_Call

type MockNetworkConfigurer_ForwardRoutesV4_Call struct {
	*mock.Call
}

MockNetworkConfigurer_ForwardRoutesV4_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ForwardRoutesV4'

func (*MockNetworkConfigurer_ForwardRoutesV4_Call) Return

func (*MockNetworkConfigurer_ForwardRoutesV4_Call) Run

func (*MockNetworkConfigurer_ForwardRoutesV4_Call) RunAndReturn

type MockNetworkConfigurer_ForwardRoutesV6_Call

type MockNetworkConfigurer_ForwardRoutesV6_Call struct {
	*mock.Call
}

MockNetworkConfigurer_ForwardRoutesV6_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ForwardRoutesV6'

func (*MockNetworkConfigurer_ForwardRoutesV6_Call) Return

func (*MockNetworkConfigurer_ForwardRoutesV6_Call) Run

func (*MockNetworkConfigurer_ForwardRoutesV6_Call) RunAndReturn

type MockNetworkConfigurer_SetupIPTables_Call

type MockNetworkConfigurer_SetupIPTables_Call struct {
	*mock.Call
}

MockNetworkConfigurer_SetupIPTables_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetupIPTables'

func (*MockNetworkConfigurer_SetupIPTables_Call) Return

func (*MockNetworkConfigurer_SetupIPTables_Call) Run

func (*MockNetworkConfigurer_SetupIPTables_Call) RunAndReturn

type MockNetworkConfigurer_SetupInterface_Call

type MockNetworkConfigurer_SetupInterface_Call struct {
	*mock.Call
}

MockNetworkConfigurer_SetupInterface_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetupInterface'

func (*MockNetworkConfigurer_SetupInterface_Call) Return

func (*MockNetworkConfigurer_SetupInterface_Call) Run

func (*MockNetworkConfigurer_SetupInterface_Call) RunAndReturn

type NetworkConfigurer

type NetworkConfigurer interface {
	ApplyWireGuardConfig(peers []Peer) error
	ForwardRoutesV4(routes []string) error
	ForwardRoutesV6(routes []string) error
	SetupInterface() error
	SetupIPTables() error
}

func NewConfigurer

func NewConfigurer(log *logrus.Entry, configPath string, ipv4 *netip.Prefix, ipv6 *netip.Prefix, privateKey, wireguardInterface string, listenPort int, iptablesV4, iptablesV6 IPTables, router routing.Router) (NetworkConfigurer, error)

func NewNoOpConfigurer

func NewNoOpConfigurer(log *logrus.Entry) NetworkConfigurer

type Peer

type Peer interface {
	GetName() string
	GetPublicKey() string
	GetAllowedIPs() []string
	GetEndpoint() string
}

func CastPeerList

func CastPeerList[T Peer](peers []T) []Peer

type PrivateKey

type PrivateKey []byte

func GenKey

func GenKey() (PrivateKey, error)

func ReadOrCreatePrivateKey

func ReadOrCreatePrivateKey(path string, log *logrus.Entry) (PrivateKey, error)

func (PrivateKey) Private

func (p PrivateKey) Private() []byte

Private returns the private key base64 encoded

func (PrivateKey) Public

func (p PrivateKey) Public() []byte

Public returns the public key base64 encoded

type WireGuardPeerConfig

type WireGuardPeerConfig interface {
	GetTunnelIP() string
	GetWireGuardConfigPath() string
	WriteWireGuardBase(io.Writer) error
}

Jump to

Keyboard shortcuts

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