mirror of https://github.com/jetkvm/kvm.git
cleaned up var names
This commit is contained in:
parent
382c07b87a
commit
bffac9a6b5
20
config.go
20
config.go
|
@ -12,11 +12,11 @@ type WakeOnLanDevice struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type UsbConfig struct {
|
type UsbConfig struct {
|
||||||
UsbVendorId string `json:"usb_vendor_id"`
|
VendorId string `json:"vendor_id"`
|
||||||
UsbProductId string `json:"usb_product_id"`
|
ProductId string `json:"product_id"`
|
||||||
UsbSerialNumber string `json:"usb_serial_number"`
|
SerialNumber string `json:"serial_number"`
|
||||||
UsbManufacturer string `json:"usb_manufacturer"`
|
Manufacturer string `json:"manufacturer"`
|
||||||
UsbProduct string `json:"usb_product"`
|
Product string `json:"product"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
|
@ -39,11 +39,11 @@ var defaultConfig = &Config{
|
||||||
CloudURL: "https://api.jetkvm.com",
|
CloudURL: "https://api.jetkvm.com",
|
||||||
AutoUpdateEnabled: true, // Set a default value
|
AutoUpdateEnabled: true, // Set a default value
|
||||||
UsbConfig: UsbConfig{
|
UsbConfig: UsbConfig{
|
||||||
UsbVendorId: "0x1d6b", //The Linux Foundation
|
VendorId: "0x1d6b", //The Linux Foundation
|
||||||
UsbProductId: "0x0104", //Multifunction Composite Gadget¬
|
ProductId: "0x0104", //Multifunction Composite Gadget¬
|
||||||
UsbSerialNumber: "",
|
SerialNumber: "",
|
||||||
UsbManufacturer: "JetKVM",
|
Manufacturer: "JetKVM",
|
||||||
UsbProduct: "JetKVM USB Emulation Device",
|
Product: "JetKVM USB Emulation Device",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -79,11 +79,11 @@ function UpdateUsbConfigModal({
|
||||||
error: string | null;
|
error: string | null;
|
||||||
}) {
|
}) {
|
||||||
const [usbConfig, setUsbConfig] = useState({
|
const [usbConfig, setUsbConfig] = useState({
|
||||||
usb_vendor_id: '',
|
vendor_id: '',
|
||||||
usb_product_id: '',
|
product_id: '',
|
||||||
usb_serial_number: '',
|
serial_number: '',
|
||||||
usb_manufacturer: '',
|
manufacturer: '',
|
||||||
usb_product: '',
|
product: '',
|
||||||
})
|
})
|
||||||
|
|
||||||
const [usbConfigState, setUsbConfigState] = useState<UsbConfigState>();
|
const [usbConfigState, setUsbConfigState] = useState<UsbConfigState>();
|
||||||
|
@ -91,11 +91,11 @@ function UpdateUsbConfigModal({
|
||||||
|
|
||||||
const syncUsbConfig = useCallback(() => {
|
const syncUsbConfig = useCallback(() => {
|
||||||
send("getUsbConfig", {}, resp => {
|
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);
|
console.info("Successfully synced USB Config: ", resp.result);
|
||||||
setUsbConfigState(resp.result as UsbConfigState);
|
setUsbConfigState(resp.result as UsbConfigState);
|
||||||
} else {
|
|
||||||
console.error("Failed to load USB Config:", resp.error);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, [send, setUsbConfigState]);
|
}, [send, setUsbConfigState]);
|
||||||
|
@ -106,23 +106,23 @@ function UpdateUsbConfigModal({
|
||||||
}, [syncUsbConfig]);
|
}, [syncUsbConfig]);
|
||||||
|
|
||||||
const handleUsbVendorIdChange = (vendorId: string) => {
|
const handleUsbVendorIdChange = (vendorId: string) => {
|
||||||
setUsbConfig({... usbConfig, usb_vendor_id: vendorId})
|
setUsbConfig({... usbConfig, vendor_id: vendorId})
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleUsbProductIdChange = (productId: string) => {
|
const handleUsbProductIdChange = (productId: string) => {
|
||||||
setUsbConfig({... usbConfig, usb_product_id: productId})
|
setUsbConfig({... usbConfig, product_id: productId})
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleUsbSerialChange = (serialNumber: string) => {
|
const handleUsbSerialChange = (serialNumber: string) => {
|
||||||
setUsbConfig({... usbConfig, usb_serial_number: serialNumber})
|
setUsbConfig({... usbConfig, serial_number: serialNumber})
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleUsbManufacturer = (manufacturer: string) => {
|
const handleUsbManufacturer = (manufacturer: string) => {
|
||||||
setUsbConfig({... usbConfig, usb_manufacturer: manufacturer})
|
setUsbConfig({... usbConfig, manufacturer: manufacturer})
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleUsbProduct = (name: string) => {
|
const handleUsbProduct = (name: string) => {
|
||||||
setUsbConfig({... usbConfig, usb_product: name})
|
setUsbConfig({... usbConfig, product: name})
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
18
usb.go
18
usb.go
|
@ -61,8 +61,8 @@ func init() {
|
||||||
func UpdateGadgetConfig() error {
|
func UpdateGadgetConfig() error {
|
||||||
LoadConfig()
|
LoadConfig()
|
||||||
gadgetAttrs := [][]string{
|
gadgetAttrs := [][]string{
|
||||||
{"idVendor", config.UsbConfig.UsbVendorId},
|
{"idVendor", config.UsbConfig.VendorId},
|
||||||
{"idProduct", config.UsbConfig.UsbProductId},
|
{"idProduct", config.UsbConfig.ProductId},
|
||||||
}
|
}
|
||||||
err := writeGadgetAttrs(kvmGadgetPath, gadgetAttrs)
|
err := writeGadgetAttrs(kvmGadgetPath, gadgetAttrs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -72,9 +72,9 @@ func UpdateGadgetConfig() error {
|
||||||
log.Printf("Successfully updated usb gadget attributes: %v", gadgetAttrs)
|
log.Printf("Successfully updated usb gadget attributes: %v", gadgetAttrs)
|
||||||
|
|
||||||
strAttrs := [][]string{
|
strAttrs := [][]string{
|
||||||
{"serialnumber", config.UsbConfig.UsbSerialNumber},
|
{"serialnumber", config.UsbConfig.SerialNumber},
|
||||||
{"manufacturer", config.UsbConfig.UsbManufacturer},
|
{"manufacturer", config.UsbConfig.Manufacturer},
|
||||||
{"product", config.UsbConfig.UsbProduct},
|
{"product", config.UsbConfig.Product},
|
||||||
}
|
}
|
||||||
gadgetStringsPath := filepath.Join(kvmGadgetPath, "strings", "0x409")
|
gadgetStringsPath := filepath.Join(kvmGadgetPath, "strings", "0x409")
|
||||||
err = os.MkdirAll(gadgetStringsPath, 0755)
|
err = os.MkdirAll(gadgetStringsPath, 0755)
|
||||||
|
@ -120,8 +120,8 @@ func writeGadgetConfig() error {
|
||||||
LoadConfig()
|
LoadConfig()
|
||||||
err = writeGadgetAttrs(kvmGadgetPath, [][]string{
|
err = writeGadgetAttrs(kvmGadgetPath, [][]string{
|
||||||
{"bcdUSB", "0x0200"}, //USB 2.0
|
{"bcdUSB", "0x0200"}, //USB 2.0
|
||||||
{"idVendor", config.UsbConfig.UsbVendorId},
|
{"idVendor", config.UsbConfig.VendorId},
|
||||||
{"idProduct", config.UsbConfig.UsbProductId},
|
{"idProduct", config.UsbConfig.ProductId},
|
||||||
{"bcdDevice", "0100"},
|
{"bcdDevice", "0100"},
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -136,8 +136,8 @@ func writeGadgetConfig() error {
|
||||||
|
|
||||||
err = writeGadgetAttrs(gadgetStringsPath, [][]string{
|
err = writeGadgetAttrs(gadgetStringsPath, [][]string{
|
||||||
{"serialnumber", GetDeviceID()},
|
{"serialnumber", GetDeviceID()},
|
||||||
{"manufacturer", config.UsbConfig.UsbManufacturer},
|
{"manufacturer", config.UsbConfig.Manufacturer},
|
||||||
{"product", config.UsbConfig.UsbProduct},
|
{"product", config.UsbConfig.Product},
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in New Issue