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 {
|
||||
Name string `json:"name"`
|
||||
Path string `json:"path"`
|
||||
DiskID string `json:"disk_id"`
|
||||
DevicePath string `json:"device_path"`
|
||||
}
|
||||
|
||||
type Client struct {
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
"encoding"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
@ -20,7 +21,7 @@ const (
|
|||
)
|
||||
|
||||
var spaceByte = []byte(" ")
|
||||
var commaByte = []byte(",")
|
||||
var commaByte = []byte(";")
|
||||
|
||||
const (
|
||||
keyID = "id"
|
||||
|
@ -140,9 +141,13 @@ func (am *acceptMessage) UnmarshalBinary(data []byte) error {
|
|||
|
||||
func (am *acceptMessage) MarshalBinary() (data []byte, err error) {
|
||||
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{
|
||||
[]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)
|
||||
return bytes.Join([][]byte{action, param_bytes}, spaceByte), nil
|
||||
|
|
|
@ -20,7 +20,6 @@ type templateBootOption struct {
|
|||
ID string
|
||||
Name string
|
||||
Path string
|
||||
DiskID string
|
||||
Selected bool
|
||||
}
|
||||
|
||||
|
@ -65,9 +64,8 @@ func (uc *UIController) serveUI(w http.ResponseWriter, r *http.Request) (int, in
|
|||
for id, bo := range clt.Options {
|
||||
tplBO = append(tplBO, templateBootOption{
|
||||
Name: bo.Name,
|
||||
Path: bo.Path,
|
||||
Path: bo.DevicePath,
|
||||
ID: id,
|
||||
DiskID: bo.DiskID,
|
||||
Selected: id == clt.SelectedOption,
|
||||
})
|
||||
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())
|
||||
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 {
|
||||
|
|
Loading…
Reference in a new issue