#115 Add domain search list plugin

Closed Stickler Bot stickler-ci

No flags found

Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.

e.g., #unittest #integration

#production #enterprise

#frontend #backend

Learn more about Codecov Flags here.

Showing 1 of 5 files from the diff.

@@ -0,0 +1,68 @@
Loading
1 +
// Copyright 2018-present the CoreDHCP Authors. All rights reserved
2 +
// This source code is licensed under the MIT license found in the
3 +
// LICENSE file in the root directory of this source tree.
4 +
5 +
package searchdomains
6 +
7 +
// This is an searchdomains plugin that adds default DNS search domains.
8 +
9 +
import (
10 +
	"github.com/coredhcp/coredhcp/handler"
11 +
	"github.com/coredhcp/coredhcp/logger"
12 +
	"github.com/coredhcp/coredhcp/plugins"
13 +
	"github.com/insomniacslk/dhcp/dhcpv4"
14 +
	"github.com/insomniacslk/dhcp/dhcpv6"
15 +
	"github.com/insomniacslk/dhcp/rfc1035label"
16 +
)
17 +
18 +
var log = logger.GetLogger("plugins/searchdomains")
19 +
20 +
// Plugin wraps the default DNS search domain options.
21 +
// Note that importing the plugin is not enough to use it: you have to
22 +
// explicitly specify the intention to use it in the `config.yml` file, in the
23 +
// plugins section. For searchdomains:
24 +
//
25 +
// server6:
26 +
//   listen: '[::]547'
27 +
//   - searchdomains: domain.a domain.b
28 +
//   - server_id: LL aa:bb:cc:dd:ee:ff
29 +
//   - file: "leases.txt"
30 +
//
31 +
var Plugin = plugins.Plugin{
32 +
	Name:   "searchdomains",
33 +
	Setup6: setup6,
34 +
	Setup4: setup4,
35 +
}
36 +
37 +
// These are the DHCP options that are added by the plugin.
38 +
// Note that DHCPv4 and DHCPv6 options are totally independent.
39 +
// If you need the same settings for both, you'll need to configure
40 +
// this plugin once for the v4 and once for the v6 server.
41 +
var v4Option dhcpv4.Option
42 +
var v6Option dhcpv6.Option
43 +
44 +
func setup6(args ...string) (handler.Handler6, error) {
45 +
	v6Option = dhcpv6.OptDomainSearchList(&rfc1035label.Labels{
46 +
		Labels: args,
47 +
	})
48 +
	log.Println(v6Option)
49 +
	return domainSearchListHandler6, nil
50 +
}
51 +
52 +
func setup4(args ...string) (handler.Handler4, error) {
53 +
	v4Option = dhcpv4.OptDomainSearch(&rfc1035label.Labels{
54 +
		Labels: args,
55 +
	})
56 +
	log.Println(v4Option)
57 +
	return domainSearchListHandler4, nil
58 +
}
59 +
60 +
func domainSearchListHandler6(req, resp dhcpv6.DHCPv6) (dhcpv6.DHCPv6, bool) {
61 +
	resp.UpdateOption(v6Option)
62 +
	return resp, false
63 +
}
64 +
65 +
func domainSearchListHandler4(req, resp *dhcpv4.DHCPv4) (*dhcpv4.DHCPv4, bool) {
66 +
	resp.UpdateOption(v4Option)
67 +
	return resp, false
68 +
}

Learn more Showing 9 files with coverage changes found.

Changes in plugins/prefix/plugin.go
-9
-2
-1
Loading file...
Changes in plugins/allocators/bitmap/bitmap.go
-5
Loading file...
Changes in plugins/dns/plugin.go
-2
-4
Loading file...
Changes in plugins/allocators/ipcalc.go
-2
Loading file...
Changes in plugins/serverid/plugin.go
-1
-3
Loading file...
Changes in config/config.go
-1
-15
Loading file...
Changes in config/errors.go
-3
Loading file...
Changes in plugins/allocators/allocator.go
-1
Loading file...
New file plugins/searchdomains/plugin.go
New
Loading file...
Files Coverage
config +<.01% 5.29%
plugins 0.82% 47.52%
Project Totals (9 files) 32.35%
Loading