Use device path to describe boot apps
This commit is contained in:
parent
2ae7327f6b
commit
ebfd2ea96c
4 changed files with 11 additions and 9 deletions
|
@ -4,8 +4,7 @@ import "github.com/google/uuid"
|
||||||
|
|
||||||
type EFIApp struct {
|
type EFIApp struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Path string `json:"path"`
|
DevicePath string `json:"device_path"`
|
||||||
DiskID string `json:"disk_id"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Client struct {
|
type Client struct {
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"encoding"
|
"encoding"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
)
|
)
|
||||||
|
@ -20,7 +21,7 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
var spaceByte = []byte(" ")
|
var spaceByte = []byte(" ")
|
||||||
var commaByte = []byte(",")
|
var commaByte = []byte(";")
|
||||||
|
|
||||||
const (
|
const (
|
||||||
keyID = "id"
|
keyID = "id"
|
||||||
|
@ -140,9 +141,13 @@ func (am *acceptMessage) UnmarshalBinary(data []byte) error {
|
||||||
|
|
||||||
func (am *acceptMessage) MarshalBinary() (data []byte, err error) {
|
func (am *acceptMessage) MarshalBinary() (data []byte, err error) {
|
||||||
action := []byte(am.Action().String())
|
action := []byte(am.Action().String())
|
||||||
|
// efiApp := strings.ReplaceAll(am.efiApp, `\`, `\\`)
|
||||||
|
// efiApp = strings.ReplaceAll(efiApp, "File(", "")
|
||||||
|
efiApp := strings.ReplaceAll(am.efiApp, "File(", "")
|
||||||
|
efiApp, _ = strings.CutSuffix(efiApp, ")")
|
||||||
params := [][]byte{
|
params := [][]byte{
|
||||||
[]byte(fmt.Sprintf("%s=%s", keyID, am.id.String())),
|
[]byte(fmt.Sprintf("%s=%s", keyID, am.id.String())),
|
||||||
[]byte(fmt.Sprintf("%s=%s", keyEfiApp, am.efiApp)),
|
[]byte(fmt.Sprintf("%s=%s", keyEfiApp, efiApp)),
|
||||||
}
|
}
|
||||||
param_bytes := bytes.Join(params, commaByte)
|
param_bytes := bytes.Join(params, commaByte)
|
||||||
return bytes.Join([][]byte{action, param_bytes}, spaceByte), nil
|
return bytes.Join([][]byte{action, param_bytes}, spaceByte), nil
|
||||||
|
|
|
@ -20,7 +20,6 @@ type templateBootOption struct {
|
||||||
ID string
|
ID string
|
||||||
Name string
|
Name string
|
||||||
Path string
|
Path string
|
||||||
DiskID string
|
|
||||||
Selected bool
|
Selected bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,9 +64,8 @@ func (uc *UIController) serveUI(w http.ResponseWriter, r *http.Request) (int, in
|
||||||
for id, bo := range clt.Options {
|
for id, bo := range clt.Options {
|
||||||
tplBO = append(tplBO, templateBootOption{
|
tplBO = append(tplBO, templateBootOption{
|
||||||
Name: bo.Name,
|
Name: bo.Name,
|
||||||
Path: bo.Path,
|
Path: bo.DevicePath,
|
||||||
ID: id,
|
ID: id,
|
||||||
DiskID: bo.DiskID,
|
|
||||||
Selected: id == clt.SelectedOption,
|
Selected: id == clt.SelectedOption,
|
||||||
})
|
})
|
||||||
sort.Slice(tplBO, func(i, j int) bool {
|
sort.Slice(tplBO, func(i, j int) bool {
|
||||||
|
|
|
@ -78,7 +78,7 @@ func (l *UDPListener) handleBootRequest(msg bootprotocol.Message, subLogger logr
|
||||||
requestLogger.Errorf("Failed to get config for client: %s", err.Error())
|
requestLogger.Errorf("Failed to get config for client: %s", err.Error())
|
||||||
return bootprotocol.Deny(msg.ID(), "unknown server error")
|
return bootprotocol.Deny(msg.ID(), "unknown server error")
|
||||||
}
|
}
|
||||||
return bootprotocol.Accept(msg.ID(), bootOption.Path)
|
return bootprotocol.Accept(msg.ID(), bootOption.DevicePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *UDPListener) handleClient(msg *udpMessage) error {
|
func (l *UDPListener) handleClient(msg *udpMessage) error {
|
||||||
|
|
Loading…
Reference in a new issue