file

package
v0.0.0-...-e3f7529 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: MIT Imports: 14 Imported by: 2

Documentation

Overview

Package file enables static mapping of MAC <--> IP addresses. The mapping is stored in a text file, where each mapping is described by one line containing two fields separated by spaces: MAC address, and IP address. For example:

$ cat file_leases.txt
00:11:22:33:44:55 10.0.0.1
01:23:45:67:89:01 10.0.10.10

To specify the plugin configuration in the server6/server4 sections of the config file, just pass the leases file name as plugin argument, e.g.:

$ cat config.yml

server6:
   ...
   plugins:
     - file: "file_leases.txt" [autorefresh]
   ...

If the file path is not absolute, it is relative to the cwd where coredhcp is run.

Optionally, when the 'autorefresh' argument is given, the plugin will try to refresh the lease mapping during runtime whenever the lease file is updated.

Index

Constants

This section is empty.

Variables

View Source
var (
	DHCPv6Records map[string]net.IP
	DHCPv4Records map[string]net.IP
)

DHCPv6Records and DHCPv4Records are mappings between MAC addresses in form of a string, to network configurations.

View Source
var Plugin = plugins.Plugin{
	Name:   "file",
	Setup6: setup6,
	Setup4: setup4,
}

Plugin wraps plugin registration information

View Source
var StaticRecords map[string]net.IP

StaticRecords holds a MAC -> IP address mapping

Functions

func Handler4

func Handler4(req, resp *dhcpv4.DHCPv4) (*dhcpv4.DHCPv4, bool)

Handler4 handles DHCPv4 packets for the file plugin

func Handler6

func Handler6(req, resp dhcpv6.DHCPv6) (dhcpv6.DHCPv6, bool)

Handler6 handles DHCPv6 packets for the file plugin

func LoadDHCPv4Records

func LoadDHCPv4Records(filename string) (map[string]net.IP, error)

LoadDHCPv4Records loads the DHCPv4Records global map with records stored on the specified file. The records have to be one per line, a mac address and an IPv4 address.

func LoadDHCPv6Records

func LoadDHCPv6Records(filename string) (map[string]net.IP, error)

LoadDHCPv6Records loads the DHCPv6Records global map with records stored on the specified file. The records have to be one per line, a mac address and an IPv6 address.

Types

This section is empty.

Jump to

Keyboard shortcuts

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