Skip to content

Commit

Permalink
Let's make the 'HTTPClient' identifier const
Browse files Browse the repository at this point in the history
  • Loading branch information
damyan committed Jun 25, 2024
1 parent edcb0b7 commit b4a8ff8
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions plugins/httpboot/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ var Plugin = plugins.Plugin{
Setup4: setup4,
}

const httpClient = "HTTPClient"

func parseArgs(args ...string) (*url.URL, bool, error) {
if len(args) != 1 {
return nil, false, fmt.Errorf("exactly one argument must be passed to the httpboot plugin, got %d", len(args))
Expand Down Expand Up @@ -101,12 +103,12 @@ func handler6(req, resp dhcpv6.DHCPv6) (dhcpv6.DHCPv6, bool) {
optVendorClass := decap.GetOneOption(dhcpv6.OptionVendorClass)
log.Debugf("VendorClass: %s", optVendorClass.String())
vcc := optVendorClass.ToBytes()
if len(vcc) >= 16 && binary.BigEndian.Uint16(vcc[4:6]) >= 10 && string(vcc[6:16]) == "HTTPClient" {
if len(vcc) >= 16 && binary.BigEndian.Uint16(vcc[4:6]) >= 10 && string(vcc[6:16]) == httpClient {
bf := dhcpv6.OptBootFileURL(ukiURL)
resp.AddOption(bf)
log.Infof("Added option BootFileURL(%d): (%s)", dhcpv6.OptionBootfileURL, ukiURL)

buf := []byte("HTTPClient")
buf := []byte(httpClient)
vc := &dhcpv6.OptVendorClass{
EnterpriseNumber: 0,
Data: [][]byte{buf},
Expand Down Expand Up @@ -141,7 +143,7 @@ func handler4(req, resp *dhcpv4.DHCPv4) (*dhcpv4.DHCPv4, bool) {
if req.GetOneOption(dhcpv4.OptionClassIdentifier) != nil {
cic := req.GetOneOption(dhcpv4.OptionClassIdentifier)
log.Debugf("ClassIdentifier: %s (%s)", string(cic), cic)
if len(cic) >= 10 && string(cic[0:10]) == "HTTPClient" {
if len(cic) >= 10 && string(cic[0:10]) == httpClient {
bf := &dhcpv4.Option{
Code: dhcpv4.OptionBootfileName,
Value: dhcpv4.String(ukiURL),
Expand All @@ -151,7 +153,7 @@ func handler4(req, resp *dhcpv4.DHCPv4) (*dhcpv4.DHCPv4, bool) {

ci := &dhcpv4.Option{
Code: dhcpv4.OptionClassIdentifier,
Value: dhcpv4.String("HTTPClient"),
Value: dhcpv4.String(httpClient)

Check failure on line 156 in plugins/httpboot/plugin.go

View workflow job for this annotation

GitHub Actions / run

missing ',' before newline in composite literal

Check failure on line 156 in plugins/httpboot/plugin.go

View workflow job for this annotation

GitHub Actions / lint

syntax error: unexpected newline in composite literal; possibly missing comma or }) (typecheck)

Check failure on line 156 in plugins/httpboot/plugin.go

View workflow job for this annotation

GitHub Actions / lint

syntax error: unexpected newline in composite literal; possibly missing comma or } (typecheck)

Check failure on line 156 in plugins/httpboot/plugin.go

View workflow job for this annotation

GitHub Actions / lint

missing ',' before newline in composite literal (typecheck)
}
resp.Options.Update(*ci)
log.Infof("Added option ClassIdentifier %s", ci.String())
Expand Down

0 comments on commit b4a8ff8

Please sign in to comment.