udhcpc

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2021 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultHandler = "/usr/lib/net-dhcp/udhcpc-handler"
	VendorID       = "docker-net-dhcp"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DHCPClient

type DHCPClient struct {
	Opts *DHCPClientOptions
	// contains filtered or unexported fields
}

DHCPClient represents a udhcpc(6) client

func NewDHCPClient

func NewDHCPClient(iface string, opts *DHCPClientOptions) (*DHCPClient, error)

NewDHCPClient creates a new udhcpc(6) client

func (*DHCPClient) Finish

func (c *DHCPClient) Finish(ctx context.Context) error

Finish sends SIGTERM to udhcpc(6) and waits for it to exit. SIGTERM will not be sent if `Opts.Once` is set.

func (*DHCPClient) Start

func (c *DHCPClient) Start() (chan Event, error)

Start starts udhcpc(6)

type DHCPClientOptions

type DHCPClientOptions struct {
	Hostname  string
	V6        bool
	Once      bool
	Namespace string

	HandlerScript string
}

type Event

type Event struct {
	Type string
	Data Info
}

type Info

type Info struct {
	IP      string
	Gateway string
	Domain  string
}

func GetIP

func GetIP(ctx context.Context, iface string, opts *DHCPClientOptions) (Info, error)

GetIP is a convenience function that runs udhcpc(6) once and returns the IP info obtained.

Jump to

Keyboard shortcuts

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