Skip to content
This repository was archived by the owner on Feb 26, 2023. It is now read-only.

Commit bc21468

Browse files
committed
feat: Add List RPC to dhclientd (#10)
1 parent 636a5fa commit bc21468

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

pkg/svc/dhclient.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,23 @@ func (m *DHClientManager) Create(_ context.Context, args *godhcpd.DHClient) (*go
5858
}, nil
5959
}
6060

61+
// List lists the managed dhcp clients.
62+
func (m *DHClientManager) List(_ context.Context, args *godhcpd.DHClientManagerListArgs) (*godhcpd.DHClientManagerListReply, error) {
63+
log.Info("Listing dhcp clients")
64+
65+
var DHClients []*godhcpd.DHClientManaged
66+
for id, DHClient := range m.DHClientsManaged {
67+
DHClients = append(DHClients, &godhcpd.DHClientManaged{
68+
Id: id,
69+
Device: DHClient.Device,
70+
})
71+
}
72+
73+
return &godhcpd.DHClientManagerListReply{
74+
DHClientsManaged: DHClients,
75+
}, nil
76+
}
77+
6178
// Extract extracts the ISC DHCP client binary.
6279
func (m *DHClientManager) Extract() error {
6380
statikFS, err := fs.New()

pkg/svc/dhcpd.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ func (m *DHCPDManager) List(_ context.Context, args *godhcpd.DHCPDManagerListArg
115115
log.Info("Listing dhcp servers")
116116

117117
var DHCPDsManaged []*godhcpd.DHCPDManaged
118-
119118
for id, DHCPD := range m.DHCPDsManaged {
120119
DHCPDsManaged = append(DHCPDsManaged, m.getReplyDHCPDManagerFromDHCPDManaged(id, DHCPD))
121120
}

0 commit comments

Comments
 (0)