cleaned up var names

This commit is contained in:
Adrian 2025-01-25 16:56:59 -06:00
parent 382c07b87a
commit bffac9a6b5
3 changed files with 32 additions and 32 deletions

View File

@ -12,11 +12,11 @@ type WakeOnLanDevice struct {
}
type UsbConfig struct {
UsbVendorId string `json:"usb_vendor_id"`
UsbProductId string `json:"usb_product_id"`
UsbSerialNumber string `json:"usb_serial_number"`
UsbManufacturer string `json:"usb_manufacturer"`
UsbProduct string `json:"usb_product"`
VendorId string `json:"vendor_id"`
ProductId string `json:"product_id"`
SerialNumber string `json:"serial_number"`
Manufacturer string `json:"manufacturer"`
Product string `json:"product"`
}
type Config struct {
@ -39,11 +39,11 @@ var defaultConfig = &Config{
CloudURL: "https://api.jetkvm.com",
AutoUpdateEnabled: true, // Set a default value
UsbConfig: UsbConfig{
UsbVendorId: "0x1d6b", //The Linux Foundation
UsbProductId: "0x0104", //Multifunction Composite Gadget¬
UsbSerialNumber: "",
UsbManufacturer: "JetKVM",
UsbProduct: "JetKVM USB Emulation Device",
VendorId: "0x1d6b", //The Linux Foundation
ProductId: "0x0104", //Multifunction Composite Gadget¬
SerialNumber: "",
Manufacturer: "JetKVM",
Product: "JetKVM USB Emulation Device",
},
}

View File

@ -79,11 +79,11 @@ function UpdateUsbConfigModal({
error: string | null;
}) {
const [usbConfig, setUsbConfig] = useState({
usb_vendor_id: '',
usb_product_id: '',
usb_serial_number: '',
usb_manufacturer: '',
usb_product: '',
vendor_id: '',
product_id: '',
serial_number: '',
manufacturer: '',
product: '',
})
const [usbConfigState, setUsbConfigState] = useState<UsbConfigState>();
@ -91,11 +91,11 @@ function UpdateUsbConfigModal({
const syncUsbConfig = useCallback(() => {
send("getUsbConfig", {}, resp => {
if ("result" in resp) {
if ("error" in resp) {
console.error("Failed to load USB Config:", resp.error);
} else {
console.info("Successfully synced USB Config: ", resp.result);
setUsbConfigState(resp.result as UsbConfigState);
} else {
console.error("Failed to load USB Config:", resp.error);
}
});
}, [send, setUsbConfigState]);
@ -106,23 +106,23 @@ function UpdateUsbConfigModal({
}, [syncUsbConfig]);
const handleUsbVendorIdChange = (vendorId: string) => {
setUsbConfig({... usbConfig, usb_vendor_id: vendorId})
setUsbConfig({... usbConfig, vendor_id: vendorId})
};
const handleUsbProductIdChange = (productId: string) => {
setUsbConfig({... usbConfig, usb_product_id: productId})
setUsbConfig({... usbConfig, product_id: productId})
};
const handleUsbSerialChange = (serialNumber: string) => {
setUsbConfig({... usbConfig, usb_serial_number: serialNumber})
setUsbConfig({... usbConfig, serial_number: serialNumber})
};
const handleUsbManufacturer = (manufacturer: string) => {
setUsbConfig({... usbConfig, usb_manufacturer: manufacturer})
setUsbConfig({... usbConfig, manufacturer: manufacturer})
};
const handleUsbProduct = (name: string) => {
setUsbConfig({... usbConfig, usb_product: name})
setUsbConfig({... usbConfig, product: name})
};
return (

18
usb.go
View File

@ -61,8 +61,8 @@ func init() {
func UpdateGadgetConfig() error {
LoadConfig()
gadgetAttrs := [][]string{
{"idVendor", config.UsbConfig.UsbVendorId},
{"idProduct", config.UsbConfig.UsbProductId},
{"idVendor", config.UsbConfig.VendorId},
{"idProduct", config.UsbConfig.ProductId},
}
err := writeGadgetAttrs(kvmGadgetPath, gadgetAttrs)
if err != nil {
@ -72,9 +72,9 @@ func UpdateGadgetConfig() error {
log.Printf("Successfully updated usb gadget attributes: %v", gadgetAttrs)
strAttrs := [][]string{
{"serialnumber", config.UsbConfig.UsbSerialNumber},
{"manufacturer", config.UsbConfig.UsbManufacturer},
{"product", config.UsbConfig.UsbProduct},
{"serialnumber", config.UsbConfig.SerialNumber},
{"manufacturer", config.UsbConfig.Manufacturer},
{"product", config.UsbConfig.Product},
}
gadgetStringsPath := filepath.Join(kvmGadgetPath, "strings", "0x409")
err = os.MkdirAll(gadgetStringsPath, 0755)
@ -120,8 +120,8 @@ func writeGadgetConfig() error {
LoadConfig()
err = writeGadgetAttrs(kvmGadgetPath, [][]string{
{"bcdUSB", "0x0200"}, //USB 2.0
{"idVendor", config.UsbConfig.UsbVendorId},
{"idProduct", config.UsbConfig.UsbProductId},
{"idVendor", config.UsbConfig.VendorId},
{"idProduct", config.UsbConfig.ProductId},
{"bcdDevice", "0100"},
})
if err != nil {
@ -136,8 +136,8 @@ func writeGadgetConfig() error {
err = writeGadgetAttrs(gadgetStringsPath, [][]string{
{"serialnumber", GetDeviceID()},
{"manufacturer", config.UsbConfig.UsbManufacturer},
{"product", config.UsbConfig.UsbProduct},
{"manufacturer", config.UsbConfig.Manufacturer},
{"product", config.UsbConfig.Product},
})
if err != nil {
return err