Version: v0.0.0-...-da1f172 Latest Latest

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

Go to latest
Published: Jan 6, 2019 License: GPL-3.0 Imports: 14 Imported by: 0




This section is empty.


This section is empty.


This section is empty.


type ARPProxyAdapter

type ARPProxyAdapter struct {
	ARPTable ARPTable

ARPProxyAdapter implements fake ARP support.

All ARPv4 requests sent on the interface will be transparently handled.

Gratuitous ARP requests are never replied to. All other ARP requests on the configured ARP network are replied to with the interface ethernet address.

func (*ARPProxyAdapter) Read

func (a *ARPProxyAdapter) Read(b []byte) (n int, err error)

type ARPTable

type ARPTable interface {
	Register(*net.IPNet, net.HardwareAddr)
	Resolve(net.IP) net.HardwareAddr

ARPTable represents an ARP table.

func NewARPTable

func NewARPTable() ARPTable

NewARPTable instanciates a new ARP table.

type Adapter

type Adapter interface {
	Interface() *net.Interface
	Config() AdapterConfig

Adapter is the base interface for tun & tap adapters.

func NewTapAdapter

func NewTapAdapter(config *AdapterConfig) (Adapter, error)

NewTapAdapter instantiates a new tap adapter.

func NewTunAdapter

func NewTunAdapter(config *AdapterConfig) (Adapter, error)

NewTunAdapter instantiates a new tun adapter.

type AdapterConfig

type AdapterConfig struct {
	// Name is the name of the tap adapter to open.
	// The exact value of this field is operating-system-dependant.
	// On most systems, specifying an empty name will trigger auto-assignation
	// or device creation.
	Name string

	// IPv4 is an IPv4 address to set on the interface after its goes up.
	IPv4 *net.IPNet

	// IPv6 is an IPv6 address to set on the interface after its goes up.
	IPv6 *net.IPNet

	// DisableARP disables the ARP proxy.
	// This is ignored on TUN adapters.
	DisableARP bool

	// DisableDHCP disables the fake DHCP server.
	DisableDHCP bool

AdapterConfig represents a tap adapter config.

func NewAdapterConfig

func NewAdapterConfig() *AdapterConfig

NewAdapterConfig instantiate a new default configuration.

type DHCPEntries

type DHCPEntries []DHCPEntry

DHCPEntries represents a list of DHCP entries.

func (DHCPEntries) Find

func (e DHCPEntries) Find(addr net.HardwareAddr) (DHCPEntry, bool)

Find a DHCP entry from its hardward address.

type DHCPEntry

type DHCPEntry struct {
	HardwareAddr net.HardwareAddr
	IPv4         *net.IPNet
	LeaseTime    time.Duration

DHCPEntry represents a DHCP entry.

type DHCPProxyAdapter

type DHCPProxyAdapter struct {
	RootLayer          gopacket.LayerType
	ServerHardwareAddr net.HardwareAddr
	Entries            DHCPEntries

DHCPProxyAdapter implements a fake DHCP server as part of the adapter.

All DHCP requests sent on the interface will be transparently handled.

func (*DHCPProxyAdapter) Read

func (a *DHCPProxyAdapter) Read(b []byte) (n int, err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL