mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 09:10:30 +08:00
refactoring
This commit is contained in:
parent
27f04a0967
commit
977c8a1ade
@ -352,7 +352,7 @@ def _get_config_scheme() -> Dict:
|
|||||||
"enabled": Option(True, type=valid_bool),
|
"enabled": Option(True, type=valid_bool),
|
||||||
|
|
||||||
"internal": {
|
"internal": {
|
||||||
"type": Option("htpasswd"),
|
"type": Option("htpasswd"),
|
||||||
"force_users": Option([], type=valid_users_list),
|
"force_users": Option([], type=valid_users_list),
|
||||||
# Dynamic content
|
# Dynamic content
|
||||||
},
|
},
|
||||||
@ -375,7 +375,7 @@ def _get_config_scheme() -> Dict:
|
|||||||
"hid": {
|
"hid": {
|
||||||
"type": Option("", type=valid_stripped_string_not_empty),
|
"type": Option("", type=valid_stripped_string_not_empty),
|
||||||
|
|
||||||
"keymap": Option("/usr/share/kvmd/keymaps/en-us", type=valid_abs_file),
|
"keymap": Option("/usr/share/kvmd/keymaps/en-us", type=valid_abs_file),
|
||||||
"ignore_keys": Option([], type=functools.partial(valid_string_list, subval=valid_hid_key)),
|
"ignore_keys": Option([], type=functools.partial(valid_string_list, subval=valid_hid_key)),
|
||||||
|
|
||||||
"mouse_x_range": {
|
"mouse_x_range": {
|
||||||
@ -474,13 +474,13 @@ def _get_config_scheme() -> Dict:
|
|||||||
},
|
},
|
||||||
|
|
||||||
"otg": {
|
"otg": {
|
||||||
"vendor_id": Option(0x1D6B, type=valid_otg_id), # Linux Foundation
|
"vendor_id": Option(0x1D6B, type=valid_otg_id), # Linux Foundation
|
||||||
"product_id": Option(0x0104, type=valid_otg_id), # Multifunction Composite Gadget
|
"product_id": Option(0x0104, type=valid_otg_id), # Multifunction Composite Gadget
|
||||||
"manufacturer": Option("PiKVM"),
|
"manufacturer": Option("PiKVM"),
|
||||||
"product": Option("Composite KVM Device"),
|
"product": Option("Composite KVM Device"),
|
||||||
"serial": Option("CAFEBABE"),
|
"serial": Option("CAFEBABE"),
|
||||||
"usb_version": Option(0x0200, type=valid_otg_id),
|
"usb_version": Option(0x0200, type=valid_otg_id),
|
||||||
"remote_wakeup": Option(False, type=valid_bool),
|
"remote_wakeup": Option(False, type=valid_bool),
|
||||||
|
|
||||||
"gadget": Option("kvmd", type=valid_otg_gadget),
|
"gadget": Option("kvmd", type=valid_otg_gadget),
|
||||||
"config": Option("PiKVM device", type=valid_stripped_string_not_empty),
|
"config": Option("PiKVM device", type=valid_stripped_string_not_empty),
|
||||||
@ -507,8 +507,8 @@ def _get_config_scheme() -> Dict:
|
|||||||
"ethernet": {
|
"ethernet": {
|
||||||
"enabled": Option(False, type=valid_bool),
|
"enabled": Option(False, type=valid_bool),
|
||||||
"driver": Option("ecm", type=valid_otg_ethernet),
|
"driver": Option("ecm", type=valid_otg_ethernet),
|
||||||
"host_mac": Option("", type=valid_mac, if_empty=""),
|
"host_mac": Option("", type=valid_mac, if_empty=""),
|
||||||
"kvm_mac": Option("", type=valid_mac, if_empty=""),
|
"kvm_mac": Option("", type=valid_mac, if_empty=""),
|
||||||
},
|
},
|
||||||
|
|
||||||
"drives": {
|
"drives": {
|
||||||
@ -528,14 +528,14 @@ def _get_config_scheme() -> Dict:
|
|||||||
"otgnet": {
|
"otgnet": {
|
||||||
"iface": {
|
"iface": {
|
||||||
"net": Option("169.254.0.0/28", type=functools.partial(valid_net, v6=False)),
|
"net": Option("169.254.0.0/28", type=functools.partial(valid_net, v6=False)),
|
||||||
"ip_cmd": Option(["/usr/bin/ip"], type=valid_command),
|
"ip_cmd": Option(["/usr/bin/ip"], type=valid_command),
|
||||||
},
|
},
|
||||||
|
|
||||||
"firewall": {
|
"firewall": {
|
||||||
"allow_icmp": Option(True, type=valid_bool),
|
"allow_icmp": Option(True, type=valid_bool),
|
||||||
"allow_tcp": Option([], type=valid_ports_list),
|
"allow_tcp": Option([], type=valid_ports_list),
|
||||||
"allow_udp": Option([67], type=valid_ports_list),
|
"allow_udp": Option([67], type=valid_ports_list),
|
||||||
"forward_iface": Option("", type=valid_stripped_string),
|
"forward_iface": Option("", type=valid_stripped_string),
|
||||||
"iptables_cmd": Option(["/usr/sbin/iptables", "--wait=5"], type=valid_command),
|
"iptables_cmd": Option(["/usr/sbin/iptables", "--wait=5"], type=valid_command),
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -614,9 +614,9 @@ def _get_config_scheme() -> Dict:
|
|||||||
"no_delay": Option(True, type=valid_bool),
|
"no_delay": Option(True, type=valid_bool),
|
||||||
"keepalive": {
|
"keepalive": {
|
||||||
"enabled": Option(True, type=valid_bool, unpack_as="keepalive_enabled"),
|
"enabled": Option(True, type=valid_bool, unpack_as="keepalive_enabled"),
|
||||||
"idle": Option(10, type=functools.partial(valid_number, min=1, max=3600), unpack_as="keepalive_idle"),
|
"idle": Option(10, type=functools.partial(valid_number, min=1, max=3600), unpack_as="keepalive_idle"),
|
||||||
"interval": Option(3, type=functools.partial(valid_number, min=1, max=60), unpack_as="keepalive_interval"),
|
"interval": Option(3, type=functools.partial(valid_number, min=1, max=60), unpack_as="keepalive_interval"),
|
||||||
"count": Option(3, type=functools.partial(valid_number, min=1, max=10), unpack_as="keepalive_count"),
|
"count": Option(3, type=functools.partial(valid_number, min=1, max=10), unpack_as="keepalive_count"),
|
||||||
},
|
},
|
||||||
|
|
||||||
"tls": {
|
"tls": {
|
||||||
|
|||||||
@ -63,7 +63,7 @@ class Plugin(BaseAuthService):
|
|||||||
"service": Option("login"),
|
"service": Option("login"),
|
||||||
"allow_users": Option([], type=valid_users_list),
|
"allow_users": Option([], type=valid_users_list),
|
||||||
"deny_users": Option([], type=valid_users_list),
|
"deny_users": Option([], type=valid_users_list),
|
||||||
"allow_uids_at": Option(0, type=valid_int_f0),
|
"allow_uids_at": Option(0, type=valid_int_f0),
|
||||||
}
|
}
|
||||||
|
|
||||||
async def authorize(self, user: str, passwd: str) -> bool:
|
async def authorize(self, user: str, passwd: str) -> bool:
|
||||||
|
|||||||
@ -151,11 +151,11 @@ class BaseMcuHid(BaseHid, multiprocessing.Process): # pylint: disable=too-many-
|
|||||||
"reset_inverted": Option(False, type=valid_bool),
|
"reset_inverted": Option(False, type=valid_bool),
|
||||||
"reset_delay": Option(0.1, type=valid_float_f01),
|
"reset_delay": Option(0.1, type=valid_float_f01),
|
||||||
|
|
||||||
"read_retries": Option(5, type=valid_int_f1),
|
"read_retries": Option(5, type=valid_int_f1),
|
||||||
"common_retries": Option(5, type=valid_int_f1),
|
"common_retries": Option(5, type=valid_int_f1),
|
||||||
"retries_delay": Option(0.5, type=valid_float_f01),
|
"retries_delay": Option(0.5, type=valid_float_f01),
|
||||||
"errors_threshold": Option(5, type=valid_int_f0),
|
"errors_threshold": Option(5, type=valid_int_f0),
|
||||||
"noop": Option(False, type=valid_bool),
|
"noop": Option(False, type=valid_bool),
|
||||||
}
|
}
|
||||||
|
|
||||||
def sysprep(self) -> None:
|
def sysprep(self) -> None:
|
||||||
|
|||||||
@ -110,17 +110,17 @@ class Plugin(BaseHid): # pylint: disable=too-many-instance-attributes
|
|||||||
"product": Option("HID Device"),
|
"product": Option("HID Device"),
|
||||||
"description": Option("Bluetooth Keyboard & Mouse"),
|
"description": Option("Bluetooth Keyboard & Mouse"),
|
||||||
|
|
||||||
"iface": Option("hci0", type=valid_stripped_string_not_empty),
|
"iface": Option("hci0", type=valid_stripped_string_not_empty),
|
||||||
"alias": Option("PiKVM HID"),
|
"alias": Option("PiKVM HID"),
|
||||||
|
|
||||||
"pairing_required": Option(True, type=valid_bool),
|
"pairing_required": Option(True, type=valid_bool),
|
||||||
"auth_required": Option(False, type=valid_bool),
|
"auth_required": Option(False, type=valid_bool),
|
||||||
"control_public": Option(True, type=valid_bool),
|
"control_public": Option(True, type=valid_bool),
|
||||||
"unpair_on_close": Option(True, type=valid_bool),
|
"unpair_on_close": Option(True, type=valid_bool),
|
||||||
|
|
||||||
"max_clients": Option(1, type=valid_int_f1),
|
"max_clients": Option(1, type=valid_int_f1),
|
||||||
"socket_timeout": Option(5.0, type=valid_float_f01),
|
"socket_timeout": Option(5.0, type=valid_float_f01),
|
||||||
"select_timeout": Option(1.0, type=valid_float_f01),
|
"select_timeout": Option(1.0, type=valid_float_f01),
|
||||||
}
|
}
|
||||||
|
|
||||||
def sysprep(self) -> None:
|
def sysprep(self) -> None:
|
||||||
|
|||||||
@ -94,13 +94,13 @@ class Plugin(BaseHid): # pylint: disable=too-many-instance-attributes
|
|||||||
"write_retries": Option(150, type=valid_int_f1),
|
"write_retries": Option(150, type=valid_int_f1),
|
||||||
},
|
},
|
||||||
"mouse": {
|
"mouse": {
|
||||||
"device": Option("", type=valid_abs_path, unpack_as="device_path"),
|
"device": Option("", type=valid_abs_path, unpack_as="device_path"),
|
||||||
"select_timeout": Option(0.1, type=valid_float_f01),
|
"select_timeout": Option(0.1, type=valid_float_f01),
|
||||||
"queue_timeout": Option(0.1, type=valid_float_f01),
|
"queue_timeout": Option(0.1, type=valid_float_f01),
|
||||||
"write_retries": Option(150, type=valid_int_f1),
|
"write_retries": Option(150, type=valid_int_f1),
|
||||||
"absolute": Option(True, type=valid_bool),
|
"absolute": Option(True, type=valid_bool),
|
||||||
"absolute_win98_fix": Option(False, type=valid_bool),
|
"absolute_win98_fix": Option(False, type=valid_bool),
|
||||||
"horizontal_wheel": Option(True, type=valid_bool),
|
"horizontal_wheel": Option(True, type=valid_bool),
|
||||||
},
|
},
|
||||||
"mouse_alt": {
|
"mouse_alt": {
|
||||||
"device": Option("", type=valid_abs_path, if_empty="", unpack_as="device_path"),
|
"device": Option("", type=valid_abs_path, if_empty="", unpack_as="device_path"),
|
||||||
|
|||||||
@ -99,8 +99,8 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes
|
|||||||
"sync_chunk_size": Option(4194304, type=functools.partial(valid_number, min=1024)),
|
"sync_chunk_size": Option(4194304, type=functools.partial(valid_number, min=1024)),
|
||||||
|
|
||||||
"gpio_device": Option("/dev/gpiochip0", type=valid_abs_path, unpack_as="gpio_device_path"),
|
"gpio_device": Option("/dev/gpiochip0", type=valid_abs_path, unpack_as="gpio_device_path"),
|
||||||
"target_pin": Option(-1, type=valid_gpio_pin),
|
"target_pin": Option(-1, type=valid_gpio_pin),
|
||||||
"reset_pin": Option(-1, type=valid_gpio_pin),
|
"reset_pin": Option(-1, type=valid_gpio_pin),
|
||||||
"reset_inverted": Option(False, type=valid_bool),
|
"reset_inverted": Option(False, type=valid_bool),
|
||||||
|
|
||||||
"device": Option("", type=valid_abs_path, unpack_as="device_path"),
|
"device": Option("", type=valid_abs_path, unpack_as="device_path"),
|
||||||
|
|||||||
@ -75,7 +75,7 @@ class Plugin(BaseUserGpioDriver):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def get_plugin_options(cls) -> Dict:
|
def get_plugin_options(cls) -> Dict:
|
||||||
return {
|
return {
|
||||||
"device": Option("", type=valid_abs_path, unpack_as="device_path"),
|
"device": Option("", type=valid_abs_path, unpack_as="device_path"),
|
||||||
"state_poll": Option(5.0, type=valid_float_f01),
|
"state_poll": Option(5.0, type=valid_float_f01),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -64,7 +64,7 @@ class Plugin(BaseUserGpioDriver): # pylint: disable=too-many-instance-attribute
|
|||||||
def get_plugin_options(cls) -> Dict:
|
def get_plugin_options(cls) -> Dict:
|
||||||
return {
|
return {
|
||||||
"ip": Option("255.255.255.255", type=functools.partial(valid_ip, v6=False)),
|
"ip": Option("255.255.255.255", type=functools.partial(valid_ip, v6=False)),
|
||||||
"port": Option(9, type=valid_port),
|
"port": Option(9, type=valid_port),
|
||||||
"mac": Option("", type=valid_mac, if_empty=""),
|
"mac": Option("", type=valid_mac, if_empty=""),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user