Commit Graph

145 Commits

Author SHA1 Message Date
kayos ec9fded9ce juicy j once said: fuck a PR, fuck a commit message 2021-05-22 11:00:22 -07:00
kayos 0c8eb52795 file plugin being converted to bitcask plugin 2021-05-18 15:19:26 -07:00
kayos 117fc49e26 further work on converting logging engine to zerolog 2021-05-18 15:19:02 -07:00
kayos 2dccfa0aea fixing packages 2021-05-18 13:41:05 -07:00
kayos bee22c094f absolutely defiled 2021-05-18 13:24:25 -07:00
insomniac eface94a0d Create CNAME 2021-04-26 14:50:22 +01:00
insomniac d1ab397b06 Set theme jekyll-theme-tactile 2021-04-26 14:49:48 +01:00
dza1 15f169d55b
server/dhcpv4: Send unicast responses to peers with no IP (#123)
When the broadcast bit isn't set in the request, send responses to the L3 address we're assigning, using the peer L2 address, as that's the preferred behavior according to the RFC

Signed-off-by: Daniel Zainzinger <dza1@mailbox.org>

Co-authored-by: Daniel Zainzinger <dza1@mailbox.org>
2021-04-16 09:33:54 +02:00
Andrea Barberio 00cc6002b6 Created sleep plugin
The `sleep` plugin introduces a delay in the chain of response to a DHCP
transaction.

Signed-off-by: Andrea Barberio <insomniac@slackware.it>
2021-03-17 20:04:07 +00:00
Anatole Denis 4f97fe7ae5 ci: Build coredhcp-generator output with modules
Viper doesn't support running from gopath at all anymore
(https://github.com/spf13/viper/blob/master/TROUBLESHOOTING.md#cannot-find-package)
causing the hcl import error.
We can actually just init a stub go module here, and let whichever of
our dependencies specify their own needs in their own go.mod files. This
ends up resolving to "latest" for all our dependencies, which is roughly
equivalent to not having modules at all

Signed-off-by: Anatole Denis <anatole@unverle.fr>
2021-03-16 19:51:01 +01:00
toshic 10c40bd4e9
Fix address usage check (#125)
Signed-off-by: Anton Kortunov <toshik@yandex-team.ru>

Co-authored-by: Anton Kortunov <toshik@yandex-team.ru>
2021-03-10 18:29:21 +01:00
Anatole Denis 8a89011b1f allocators: Export an error for no address available
This is a sentinel error that downstream users should be able to compare
against to identify when the allocator is out of addresses, move it from
the bitmap allocator package to the general allocator interface package

Signed-off-by: Anatole Denis <anatole@unverle.fr>
2021-02-03 14:04:44 +00:00
Anatole Denis 2a7eb16899 plugins/range: Also persist leases when extending them
Signed-off-by: Anatole Denis <anatole@unverle.fr>
2021-02-03 14:04:44 +00:00
Anatole Denis 1ccd30ecc5 plugins/range: Revamp to make use of allocator
Mixed improvements to overhaul the plugin
 * Use the allocator interface to allocate IPs
 * Focus on correctness by wrapping a lock for now; we'll improve that
   with some more fine-grained concurrency later
 * move things related to file storage of leases to a separate source
   file and add some minimal sanity-check tests
 * Don't open and close the file descriptor on every single packet

Signed-off-by: Anatole Denis <anatole@unverle.fr>
2021-02-03 14:04:44 +00:00
Anatole Denis 9d3fd8dbad plugins/range: Remove setup6 function for range
Signed-off-by: Anatole Denis <anatole@unverle.fr>
2021-02-03 14:04:44 +00:00
Anatole Denis b6dcd5d4ac allocators: Create a bitmap allocator for IPv4
Signed-off-by: Anatole Denis <anatole@unverle.fr>
2021-02-03 14:04:44 +00:00
Anatole Denis f4b74e59ca ci: Map paths in codecov to paths in the repo
Codecov uses the location of files on disk during coverage, which in our
action has an additional prefix compared to the path in the repo, making
some of the stats in codecov not work.
https://docs.codecov.io/docs/fixing-paths explains how to address that

Signed-off-by: Anatole Denis <anatole@unverle.fr>
2021-02-03 11:40:25 +00:00
Andrea Barberio 0337e003c5 Integration tests
Based on @natolumin's initial work at c37fbceece

Signed-off-by: Andrea Barberio <insomniac@slackware.it>
2021-01-31 21:17:02 +00:00
Andrea Barberio 77079c4798 Migrate to GitHub Actions
Signed-off-by: Andrea Barberio <insomniac@slackware.it>
2021-01-28 12:25:27 +00:00
Andrea Barberio f4dd4957ef Switch to pflag
Switched `cmd/coredhcp-generator`, and as a consequence also
`cmd/coredhcp`, to `spf13/pflag` instead of the standard `flag`.
`pflag` gives GNU-style flags and supports args before flags, among many
other things.

Also copied `go.mod` and `go.sum` to the destination directory so it can
be built with go modules.

Signed-off-by: Andrea Barberio <insomniac@slackware.it>
2021-01-27 22:29:15 +00:00
Anatole Denis 7b65f6832a plugins/prefix: Fix a panic with empty hints
A missing nilcheck caused prefix allocation to panic for requests
without hints

Signed-off-by: Anatole Denis <anatole@unverle.fr>
2021-01-27 22:28:47 +00:00
William Kronmiller 9e42cc2ca0
Add domain search list plugin (#116)
Add searchdomains plugin to specify a list of default
search domains for DHCPv4 and DHCPv6 clients.

Signed-off-by: William Rory Kronmiller <wkronmiller@Williams-MacBook-Pro.local>
2021-01-18 20:24:24 +01:00
Anatole Denis a9aa31766d allocators/bitmap: Lock the bitmap on use
This allocator was not safe for concurrent access. Add a simple lock
around operations on the bitmap itself to protect from that

Signed-off-by: Anatole Denis <anatole@unverle.fr>
2020-08-09 19:05:58 +02:00
Anatole Denis 373802d292 prefix: Update configuration example
Signed-off-by: Anatole Denis <anatole@unverle.fr>
2020-08-09 19:05:58 +02:00
Anatole Denis de9ac24a42 plugins/prefix: Implement basic lease allocation logic
This implements the meat of the plugin, which stores allocated leases
(only in memory) but also a basic heuristic to allocate leases to
requests.

The logic will not provide the best fit; it tries to do something
reasonable but there is no universal best behavior here.

Performance hasn't been considered at this point, because lease storage
will be moved out into its own plugin(s) in the future.

Signed-off-by: Anatole Denis <anatole@unverle.fr>
2020-08-09 19:05:58 +02:00
Anatole Denis fb0d278233 plugins/allocators: Rename fixedsize to bitmap
Allocators themselves are implementation details for now; bitmap
reflects better the properties of this allocator

Signed-off-by: Anatole Denis <anatole@unverle.fr>
2020-08-09 19:05:58 +02:00
Anatole Denis 6342ac1088 plugins/prefix: Initial plugin handler
Signed-off-by: Anatole Denis <anatole@unverle.fr>
2020-08-09 19:05:58 +02:00
Anatole Denis 6ee08879be plugins: IPv6 Prefix Delegation allocator scaffolding
To build an IPv6 Prefix Delegation plugin, we'll need allocation
strategies as well as the plugin itself.
This adds scaffolding for prefix allocators

 * allocator.go contains interfaces to interact with the allocators
 * ipcalc has helper functions to simplify indexing tables/hash ipv6
   addresses
 * fixedsize is a trivial allocator that always reserves a prefix of the
   same size (eg /64) regardless of what the client requests

Signed-off-by: Anatole Denis <anatole@unverle.fr>
2020-08-09 19:05:58 +02:00
Anatole Denis 88fd284181 travis: Pin the golangci-lint version
golangci-lint's documentation recommends running from a stable version
(and doesn't guarantee master will work). We did not have issues because
we accidentally had it in our go.mod, so we had a pinned version.

Signed-off-by: Anatole Denis <anatole@unverle.fr>
2020-08-09 19:05:58 +02:00
Anatole Denis ff3920260b Update dependencies
This updates dependencies referenced in go.mod to latest versions.

Signed-off-by: Anatole Denis <anatole@unverle.fr>
2020-08-09 19:05:58 +02:00
Anatole Denis 4ef5edf718 Update minimal go version and tests
Go 1.13 introduced a new interface in the standard library to wrap
errors and the %w modifier to fmt.Errorf which we couldn't use before
since our go.mod declares go 1.12

Signed-off-by: Anatole Denis <anatole@unverle.fr>
2020-08-09 19:05:58 +02:00
Anatole Denis 0c3df05476 Clean up go.mod
We had a couple modules in the go.mod that we don't use anymore since
plugins were moved out into a separate repo.
Ran go mod tidy to also add missed indirect deps

Signed-off-by: Anatole Denis <anatole@unverle.fr>
2020-08-09 19:05:58 +02:00
Brad Beam 156c774032 fix: Create leases file if it does not exist
If the leases.txt file was not present on the system, coredhcp would
fail to start --
```
level=info msg="DHCPv4: loading plugin `range`" prefix=plugins
level=warning msg="Failed to close file leases.txt: invalid argument" prefix="plugins/range"
level=fatal msg="cannot open lease file leases.txt: open leases.txt: no such file or directory" prefix=main
```

This changes the call to include the O_CREATE flag to create the
leases file if it does not already exist.

Signed-off-by: Brad Beam <brad.beam@b-rad.info>
2020-08-09 09:52:46 +02:00
Anatole Denis 435f86b27e doc: Detail the example configuration
This revamps the provided example configuration to have a
self-documented example configuration file, with comments explaining
each available option and its meaning

Signed-off-by: Anatole Denis <anatole@unverle.fr>
2020-06-30 21:52:18 +01:00
Andrea Barberio da500d8246 README: update example
Fixes #105

Signed-off-by: Andrea Barberio <insomniac@slackware.it>
2020-06-29 16:01:18 +01:00
Pablo Mazzini 1d46fd693e update contributors
Signed-off-by: Pablo Mazzini <pmazzini@gmail.com>
2020-06-01 13:34:45 +01:00
Marius Karnauskas e080c7407a List plugins
Signed-off-by: Marius Karnauskas <marius.karnauskas@gmail.com>
2020-05-04 12:37:37 +01:00
Anatole Denis 6eeca26bee config: Allow overriding config location from flags
This lets the user specify a configuration file to load, disregarding
the builtin heuristics for locating it

Signed-off-by: Anatole Denis <anatole@unverle.fr>
2020-05-01 19:01:59 +02:00
Anatole Denis 1549302e6c plugin/file: Use an iaid from request in response
Signed-off-by: Anatole Denis <anatole@unverle.fr>
2020-05-01 17:48:01 +01:00
Anatole Denis 637d841e21 travis: Deduplicate linter runs
Linters don't depend on the go version, they can run only once instead
of once per go version, simplifying the standard tests

Signed-off-by: Anatole Denis <anatole@unverle.fr>
2020-04-24 22:49:17 +02:00
Anatole Denis fe92a50808 travis: no need to disable ipv6 anymore
This was a workaround for an old bug in an old travis base image. Not an
issue anymore

Signed-off-by: Anatole Denis <anatole@unverle.fr>
2020-04-24 22:49:17 +02:00
Anatole Denis 785c35f3f8 generator: Add generated file warning to main
Signed-off-by: Anatole Denis <anatole@unverle.fr>
2020-04-24 22:49:17 +02:00
Anatole Denis e4b6639603 travis: Add a job checking coredhcp-generator/coredhcp sync
This ensures modifications in cmds/coredhcp-generator and cmds/coredhcp
are in sync

Signed-off-by: Anatole Denis <anatole@unverle.fr>
2020-04-24 22:49:17 +02:00
Anatole Denis 342345e2de travis: update distro/language
sudo: is deprecated and ignored by travis

Signed-off-by: Anatole Denis <anatole@unverle.fr>
2020-04-24 22:49:17 +02:00
Anatole Denis 75c303c301 cmd: Homogenize plugin list between generator and base
Force the plugin list to be sorted in the generator, and change
cmd/coredhcp/main.go to use the same naming scheme and order as the
generated version

Signed-off-by: Anatole Denis <anatole@unverle.fr>
2020-04-24 22:49:17 +02:00
Anatole Denis 8b706e35dc generator: Tweak template to match main
The template and the base main.go have drifted. This updates the
template to follow the current main.go in cmds/coredhcp.

Signed-off-by: Anatole Denis <anatole@unverle.fr>
2020-04-24 22:49:17 +02:00
Anatole Denis b00e56f059 generator: Un-special-case the range plugin
The "range" plugin has a name that conflicts with a reserved keyword.
Use "pl_<pluginname>" as import name for all plugins, which will not
conflict with any reserved keywords for go 1, removing the special case

Signed-off-by: Anatole Denis <anatole@unverle.fr>
2020-04-24 22:49:17 +02:00
Anatole Denis 604da9f671 generator: Print output directory to stdout
This allows doing something like "cd $(coredhcp-generator) && go build"

Signed-off-by: Anatole Denis <anatole@unverle.fr>
2020-04-24 22:49:17 +02:00
Anatole Denis fa4a1c197d generator: Clarify cli usage for specifying plugins
Including the ability to specify plugins as cli args, and the
possibility of giving builtin plugins as shortnames

Signed-off-by: Anatole Denis <anatole@unverle.fr>
2020-04-24 22:49:17 +02:00
Anatole Denis ae368fd230 generator: Accept bare names for builtin plugins on the cli
For plugins passed on the CLI, accept the bare name (eg "dns") for core
plugins, for simpler invocations for testing eg `./coredhcp-generator dns file`
The -from option (using a separate file) still requires the full import
path

Signed-off-by: Anatole Denis <anatole@unverle.fr>
2020-04-24 22:49:17 +02:00