8000 Add a Consul KV storage by sc0rp10 · Pull Request #222 · coredhcp/coredhcp · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add a Consul KV storage #222

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Fast, multithreaded, modular and extensible DHCP server written in Go

This is still a work-in-progress

> The current fork has an additional plugin `consulrange` that allows loading and storing leases in the Consul KV store.

## Example configuration

In CoreDHCP almost everything is implemented as a plugin. The order of plugins in the configuration matters: every request is evaluated calling each plugin in order, until one breaks the evaluation and responds to, or drops, the request.
Expand Down
1 change: 1 addition & 0 deletions cmds/coredhcp-generator/core-plugins.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ github.com/coredhcp/coredhcp/plugins/serverid
github.com/coredhcp/coredhcp/plugins/searchdomains
github.com/coredhcp/coredhcp/plugins/sleep
github.com/coredhcp/coredhcp/plugins/staticroute
github.com/coredhcp/coredhcp/plugins/consulrange
21 changes: 17 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
module github.com/coredhcp/coredhcp

go 1.22.0

toolchain go1.23.2
go 1.23.5

require (
github.com/bits-and-blooms/bitset v1.20.0
github.com/chappjc/logrus-prefix v0.0.0-20180227015900-3a1d64819adb
github.com/coredhcp/coredhcp/plugins/consulrange v0.0.0-00010101000000-000000000000
github.com/fsnotify/fsnotify v1.8.0
github.com/google/gopacket v1.1.19
github.com/insomniacslk/dhcp v0.0.0-20241203100832-a481575ed0ef
github.com/insomniacslk/dhcp v0.0.0-20250109001534-8abf58130905
github.com/mattn/go-sqlite3 v1.14.24
github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5
github.com/sirupsen/logrus v1.9.3
Expand All @@ -22,12 +21,24 @@ require (
)

require (
github.com/armon/go-metrics v0.4.1 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/hashicorp/consul/api v1.31.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-hclog v1.5.0 // indirect
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-rootcerts v1.0.2 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/serf v0.10.1 // indirect
github.com/magiconair/properties v1.8.9 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/onsi/ginkgo v1.14.0 // indirect
github.com/onsi/gomega v1.27.10 // indirect
Expand All @@ -50,3 +61,5 @@ require (
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace github.com/coredhcp/coredhcp/plugins/consulrange => ./plugins/consul_range
186 changes: 183 additions & 3 deletions go.sum

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions plugins/autoconfigure/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestOptionRequested0(t *testing.T) {
}
req.UpdateOption(dhcpv4.OptGeneric(dhcpv4.OptionAutoConfigure, []byte{1}))
stub, err := dhcpv4.NewReplyFromRequest(req,
dhcpv4.WithMessageType(dhcpv4.MessageTypeOffer),
dhcpv4.WithMessageType(dhcpv4.MessageTypeOffer),
)
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -48,7 +48,7 @@ func TestOptionRequested1(t *testing.T) {
}
req.UpdateOption(dhcpv4.OptGeneric(dhcpv4.OptionAutoConfigure, []byte{1}))
stub, err := dhcpv4.NewReplyFromRequest(req,
dhcpv4.WithMessageType(dhcpv4.MessageTypeOffer),
dhcpv4.WithMessageType(dhcpv4.MessageTypeOffer),
)
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -77,7 +77,7 @@ func TestNotRequestedAssignedIP(t *testing.T) {
t.Fatal(err)
}
stub, err := dhcpv4.NewReplyFromRequest(req,
dhcpv4.WithMessageType(dhcpv4.MessageTypeOffer),
dhcpv4.WithMessageType(dhcpv4.MessageTypeOffer),
)
if err != nil {
t.Fatal(err)
Expand All @@ -102,7 +102,7 @@ func TestNotRequestedNoIP(t *testing.T) {
t.Fatal(err)
}
stub, err := dhcpv4.NewReplyFromRequest(req,
dhcpv4.WithMessageType(dhcpv4.MessageTypeOffer),
dhcpv4.WithMessageType(dhcpv4.MessageTypeOffer),
)
if err != nil {
t.Fatal(err)
Expand Down
57 changes: 57 additions & 0 deletions plugins/consul_range/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
module github.com/coredhcp/coredhcp/plugins/consulrange

go 1.23.5

require (
github.com/coredhcp/coredhcp v0.0.0-20250113163832-cbc175753a45
github.com/hashicorp/consul/api v1.31.0
github.com/insomniacslk/dhcp v0.0.0-20250109001534-8abf58130905
github.com/stretchr/testify v1.10.0
)

require (
github.com/armon/go-metrics v0.4.1 // indirect
github.com/bits-and-blooms/bitset v1.20.0 // indirect
github.com/chappjc/logrus-prefix v0.0.0-20180227015900-3a1d64819adb // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/fsnotify/fsnotify v1.8.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-hclog v1.5.0 // indirect
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-rootcerts v1.0.2 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/serf v0.10.1 // indirect
github.com/magiconair/properties v1.8.9 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/nxadm/tail v1.4.11 // indirect
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
github.com/pierrec/lz4/v4 v4.1.22 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5 // indirect
github.com/sagikazarmark/locafero v0.6.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.7.1 // indirect
github.com/spf13/pflag v1.0.6-0.20201009195203-85dd5c8bc61c // indirect
github.com/spf13/viper v1.19.0 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/u-root/uio v0.0.0-20240224005618-d2acac8f3701 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.32.0 // indirect
golang.org/x/exp v0.0.0-20241210194714-1829a127f884 // indirect
golang.org/x/sys v0.29.0 // indirect
golang.org/x/term v0.28.0 // indirect
golang.org/x/text v0.21.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading
0