Skip to content

Commit d1948ad

Browse files
committed
refactor(usb): move usbconfig to a seperated package
1 parent c088534 commit d1948ad

File tree

16 files changed

+1045
-604
lines changed

16 files changed

+1045
-604
lines changed

config.go

Lines changed: 23 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package kvm
33
import (
44
"encoding/json"
55
"fmt"
6+
"kvm/internal/usbgadget"
67
"os"
78
"sync"
89
)
@@ -12,40 +13,26 @@ type WakeOnLanDevice struct {
1213
MacAddress string `json:"macAddress"`
1314
}
1415

15-
type UsbConfig struct {
16-
VendorId string `json:"vendor_id"`
17-
ProductId string `json:"product_id"`
18-
SerialNumber string `json:"serial_number"`
19-
Manufacturer string `json:"manufacturer"`
20-
Product string `json:"product"`
21-
}
22-
23-
type UsbDevicesConfig struct {
24-
AbsoluteMouse bool `json:"absolute_mouse"`
25-
RelativeMouse bool `json:"relative_mouse"`
26-
Keyboard bool `json:"keyboard"`
27-
MassStorage bool `json:"mass_storage"`
28-
}
29-
3016
type Config struct {
31-
CloudURL string `json:"cloud_url"`
32-
CloudAppURL string `json:"cloud_app_url"`
33-
CloudToken string `json:"cloud_token"`
34-
GoogleIdentity string `json:"google_identity"`
35-
JigglerEnabled bool `json:"jiggler_enabled"`
36-
AutoUpdateEnabled bool `json:"auto_update_enabled"`
37-
IncludePreRelease bool `json:"include_pre_release"`
38-
HashedPassword string `json:"hashed_password"`
39-
LocalAuthToken string `json:"local_auth_token"`
40-
LocalAuthMode string `json:"localAuthMode"` //TODO: fix it with migration
41-
WakeOnLanDevices []WakeOnLanDevice `json:"wake_on_lan_devices"`
42-
EdidString string `json:"hdmi_edid_string"`
43-
ActiveExtension string `json:"active_extension"`
44-
DisplayMaxBrightness int `json:"display_max_brightness"`
45-
DisplayDimAfterSec int `json:"display_dim_after_sec"`
46-
DisplayOffAfterSec int `json:"display_off_after_sec"`
47-
UsbConfig *UsbConfig `json:"usb_config"`
48-
UsbDevices *UsbDevicesConfig `json:"usb_devices"`
17+
CloudURL string `json:"cloud_url"`
18+
CloudAppURL string `json:"cloud_app_url"`
19+
CloudToken string `json:"cloud_token"`
20+
GoogleIdentity string `json:"google_identity"`
21+
JigglerEnabled bool `json:"jiggler_enabled"`
22+
AutoUpdateEnabled bool `json:"auto_update_enabled"`
23+
IncludePreRelease bool `json:"include_pre_release"`
24+
HashedPassword string `json:"hashed_password"`
25+
LocalAuthToken string `json:"local_auth_token"`
26+
LocalAuthMode string `json:"localAuthMode"` //TODO: fix it with migration
27+
WakeOnLanDevices []WakeOnLanDevice `json:"wake_on_lan_devices"`
28+
EdidString string `json:"hdmi_edid_string"`
29+
ActiveExtension string `json:"active_extension"`
30+
DisplayMaxBrightness int `json:"display_max_brightness"`
31+
DisplayDimAfterSec int `json:"display_dim_after_sec"`
32+
DisplayOffAfterSec int `json:"display_off_after_sec"`
33+
TLSMode string `json:"tls_mode"`
34+
UsbConfig *usbgadget.Config `json:"usb_config"`
35+
UsbDevices *usbgadget.Devices `json:"usb_devices"`
4936
}
5037

5138
const configPath = "/userdata/kvm_config.json"
@@ -58,14 +45,15 @@ var defaultConfig = &Config{
5845
DisplayMaxBrightness: 64,
5946
DisplayDimAfterSec: 120, // 2 minutes
6047
DisplayOffAfterSec: 1800, // 30 minutes
61-
UsbConfig: &UsbConfig{
48+
TLSMode: "",
49+
UsbConfig: &usbgadget.Config{
6250
VendorId: "0x1d6b", //The Linux Foundation
6351
ProductId: "0x0104", //Multifunction Composite Gadget
6452
SerialNumber: "",
6553
Manufacturer: "JetKVM",
6654
Product: "USB Emulation Device",
6755
},
68-
UsbDevices: &UsbDevicesConfig{
56+
UsbDevices: &usbgadget.Devices{
6957
AbsoluteMouse: true,
7058
RelativeMouse: true,
7159
Keyboard: true,

0 commit comments

Comments
 (0)