privateip

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2023 License: MPL-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 LocalInterfaces

type LocalInterfaces interface {
	// ScanInteterfaces reads the network interfaces connected to
	// this machine and populates internal data strucutures.
	ScanInterfaces() error

	// GetPrimary returns the interface connected to the
	// default gateway, or nil if such could not be determined.
	GetPrimary() *NIC

	// GetSecondaries returns all other interfaces.
	GetSecondaries() []*NIC

	// GetFirst returns the first NIC found.
	// This is normally the primary, but if no primary then the
	// first seconday in the list; else nil if no interfaces
	GetFirst() *NIC

	// Returns a reason as to why there is no primary interface
	GetPrimaryAbsentReason() string
}

func GetLocalIP4Interfaces

func GetLocalIP4Interfaces(includeLinkLocal bool) (LocalInterfaces, error)

Get all non-loopback interfaces for this host. Primary is defined as the interface that routes to default gateway.

func MustGetLocalIP4Interfaces

func MustGetLocalIP4Interfaces(includeLinkLocal bool) LocalInterfaces

func New

func New() LocalInterfaces

type LocalInterfacesImpl

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

func (*LocalInterfacesImpl) GetFirst

func (i *LocalInterfacesImpl) GetFirst() *NIC

func (*LocalInterfacesImpl) GetPrimary

func (i *LocalInterfacesImpl) GetPrimary() *NIC

func (*LocalInterfacesImpl) GetPrimaryAbsentReason

func (i *LocalInterfacesImpl) GetPrimaryAbsentReason() string

func (*LocalInterfacesImpl) GetSecondaries

func (i *LocalInterfacesImpl) GetSecondaries() []*NIC

func (*LocalInterfacesImpl) ScanInterfaces

func (i *LocalInterfacesImpl) ScanInterfaces() error

type MockLocalInterfaces

type MockLocalInterfaces struct {
	mock.Mock
}

MockLocalInterfaces is an autogenerated mock type for the LocalInterfaces type

func NewMockLocalInterfaces

func NewMockLocalInterfaces(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockLocalInterfaces

NewMockLocalInterfaces creates a new instance of MockLocalInterfaces. 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 (*MockLocalInterfaces) EXPECT

func (*MockLocalInterfaces) GetFirst

func (_m *MockLocalInterfaces) GetFirst() *NIC

GetFirst provides a mock function with given fields:

func (*MockLocalInterfaces) GetPrimary

func (_m *MockLocalInterfaces) GetPrimary() *NIC

GetPrimary provides a mock function with given fields:

func (*MockLocalInterfaces) GetPrimaryAbsentReason

func (_m *MockLocalInterfaces) GetPrimaryAbsentReason() string

GetPrimaryAbsentReason provides a mock function with given fields:

func (*MockLocalInterfaces) GetSecondaries

func (_m *MockLocalInterfaces) GetSecondaries() []*NIC

GetSecondaries provides a mock function with given fields:

func (*MockLocalInterfaces) ScanInterfaces

func (_m *MockLocalInterfaces) ScanInterfaces() error

ScanInterfaces provides a mock function with given fields:

type MockLocalInterfaces_Expecter

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

func (*MockLocalInterfaces_Expecter) GetFirst

GetFirst is a helper method to define mock.On call

func (*MockLocalInterfaces_Expecter) GetPrimary

GetPrimary is a helper method to define mock.On call

func (*MockLocalInterfaces_Expecter) GetPrimaryAbsentReason

GetPrimaryAbsentReason is a helper method to define mock.On call

func (*MockLocalInterfaces_Expecter) GetSecondaries

GetSecondaries is a helper method to define mock.On call

func (*MockLocalInterfaces_Expecter) ScanInterfaces

ScanInterfaces is a helper method to define mock.On call

type MockLocalInterfaces_GetFirst_Call

type MockLocalInterfaces_GetFirst_Call struct {
	*mock.Call
}

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

func (*MockLocalInterfaces_GetFirst_Call) Return

func (*MockLocalInterfaces_GetFirst_Call) Run

func (*MockLocalInterfaces_GetFirst_Call) RunAndReturn

type MockLocalInterfaces_GetPrimaryAbsentReason_Call

type MockLocalInterfaces_GetPrimaryAbsentReason_Call struct {
	*mock.Call
}

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

func (*MockLocalInterfaces_GetPrimaryAbsentReason_Call) Return

func (*MockLocalInterfaces_GetPrimaryAbsentReason_Call) Run

func (*MockLocalInterfaces_GetPrimaryAbsentReason_Call) RunAndReturn

type MockLocalInterfaces_GetPrimary_Call

type MockLocalInterfaces_GetPrimary_Call struct {
	*mock.Call
}

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

func (*MockLocalInterfaces_GetPrimary_Call) Return

func (*MockLocalInterfaces_GetPrimary_Call) Run

func (*MockLocalInterfaces_GetPrimary_Call) RunAndReturn

type MockLocalInterfaces_GetSecondaries_Call

type MockLocalInterfaces_GetSecondaries_Call struct {
	*mock.Call
}

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

func (*MockLocalInterfaces_GetSecondaries_Call) Return

func (*MockLocalInterfaces_GetSecondaries_Call) Run

func (*MockLocalInterfaces_GetSecondaries_Call) RunAndReturn

type MockLocalInterfaces_ScanInterfaces_Call

type MockLocalInterfaces_ScanInterfaces_Call struct {
	*mock.Call
}

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

func (*MockLocalInterfaces_ScanInterfaces_Call) Return

func (*MockLocalInterfaces_ScanInterfaces_Call) Run

func (*MockLocalInterfaces_ScanInterfaces_Call) RunAndReturn

type NIC

type NIC struct {
	Name      string
	Ip        string
	Network   string
	IsPrimary bool
}

Jump to

Keyboard shortcuts

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