@@ -3,6 +3,7 @@ package kvm
3
3
import (
4
4
"encoding/json"
5
5
"fmt"
6
+ "kvm/internal/usbgadget"
6
7
"os"
7
8
"sync"
8
9
)
@@ -12,32 +13,26 @@ type WakeOnLanDevice struct {
12
13
MacAddress string `json:"macAddress"`
13
14
}
14
15
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
16
type Config struct {
24
- CloudURL string `json:"cloud_url"`
25
- CloudAppURL string `json:"cloud_app_url"`
26
- CloudToken string `json:"cloud_token"`
27
- GoogleIdentity string `json:"google_identity"`
28
- JigglerEnabled bool `json:"jiggler_enabled"`
29
- AutoUpdateEnabled bool `json:"auto_update_enabled"`
30
- IncludePreRelease bool `json:"include_pre_release"`
31
- HashedPassword string `json:"hashed_password"`
32
- LocalAuthToken string `json:"local_auth_token"`
33
- LocalAuthMode string `json:"localAuthMode"` //TODO: fix it with migration
34
- WakeOnLanDevices []WakeOnLanDevice `json:"wake_on_lan_devices"`
35
- EdidString string `json:"hdmi_edid_string"`
36
- ActiveExtension string `json:"active_extension"`
37
- DisplayMaxBrightness int `json:"display_max_brightness"`
38
- DisplayDimAfterSec int `json:"display_dim_after_sec"`
39
- DisplayOffAfterSec int `json:"display_off_after_sec"`
40
- UsbConfig * UsbConfig `json:"usb_config"`
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"`
41
36
}
42
37
43
38
const configPath = "/userdata/kvm_config.json"
@@ -50,13 +45,20 @@ var defaultConfig = &Config{
50
45
DisplayMaxBrightness : 64 ,
51
46
DisplayDimAfterSec : 120 , // 2 minutes
52
47
DisplayOffAfterSec : 1800 , // 30 minutes
53
- UsbConfig : & UsbConfig {
48
+ TLSMode : "" ,
49
+ UsbConfig : & usbgadget.Config {
54
50
VendorId : "0x1d6b" , //The Linux Foundation
55
51
ProductId : "0x0104" , //Multifunction Composite Gadget
56
52
SerialNumber : "" ,
57
53
Manufacturer : "JetKVM" ,
58
54
Product : "USB Emulation Device" ,
59
55
},
56
+ UsbDevices : & usbgadget.Devices {
57
+ AbsoluteMouse : true ,
58
+ RelativeMouse : true ,
59
+ Keyboard : true ,
60
+ MassStorage : true ,
61
+ },
60
62
}
61
63
62
64
var (
@@ -95,6 +97,10 @@ func LoadConfig() {
95
97
loadedConfig .UsbConfig = defaultConfig .UsbConfig
96
98
}
97
99
100
+ if loadedConfig .UsbDevices == nil {
101
+ loadedConfig .UsbDevices = defaultConfig .UsbDevices
102
+ }
103
+
98
104
config = & loadedConfig
99
105
}
100
106
0 commit comments