mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-02-01 10:31:54 +08:00
refactoring
This commit is contained in:
@@ -298,6 +298,10 @@ def _dump_config(config: Section) -> None:
|
|||||||
print(dump)
|
print(dump)
|
||||||
|
|
||||||
|
|
||||||
|
def _make_ifarg(validator, unless): # type: ignore
|
||||||
|
return (lambda arg: (validator(arg) if arg else unless))
|
||||||
|
|
||||||
|
|
||||||
def _get_config_scheme() -> Dict:
|
def _get_config_scheme() -> Dict:
|
||||||
return {
|
return {
|
||||||
"logging": Option({}),
|
"logging": Option({}),
|
||||||
@@ -342,7 +346,7 @@ def _get_config_scheme() -> Dict:
|
|||||||
"wol": {
|
"wol": {
|
||||||
"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=(lambda arg: (valid_mac(arg) if arg else ""))),
|
"mac": Option("", type=_make_ifarg(valid_mac, "")),
|
||||||
},
|
},
|
||||||
|
|
||||||
"hid": {
|
"hid": {
|
||||||
@@ -368,8 +372,8 @@ def _get_config_scheme() -> Dict:
|
|||||||
"shutdown_delay": Option(10.0, type=valid_float_f01),
|
"shutdown_delay": Option(10.0, type=valid_float_f01),
|
||||||
"state_poll": Option(1.0, type=valid_float_f01),
|
"state_poll": Option(1.0, type=valid_float_f01),
|
||||||
|
|
||||||
"quality": Option(80, type=(lambda arg: (valid_stream_quality(arg) if arg else 0))), # 0 for disabled feature
|
"quality": Option(80, type=_make_ifarg(valid_stream_quality, 0)),
|
||||||
"resolution": Option("", type=(lambda arg: (valid_stream_resolution(arg) if arg else ""))),
|
"resolution": Option("", type=_make_ifarg(valid_stream_resolution, "")),
|
||||||
"available_resolutions": Option([], type=functools.partial(valid_string_list, subval=valid_stream_resolution)),
|
"available_resolutions": Option([], type=functools.partial(valid_string_list, subval=valid_stream_resolution)),
|
||||||
|
|
||||||
"desired_fps": {
|
"desired_fps": {
|
||||||
@@ -379,7 +383,7 @@ def _get_config_scheme() -> Dict:
|
|||||||
},
|
},
|
||||||
|
|
||||||
"h264_bitrate": {
|
"h264_bitrate": {
|
||||||
"default": Option(0, type=(lambda arg: (valid_stream_h264_bitrate(arg) if arg else 0)), unpack_as="h264_bitrate"),
|
"default": Option(0, type=_make_ifarg(valid_stream_h264_bitrate, 0), unpack_as="h264_bitrate"),
|
||||||
"min": Option(100, type=valid_stream_h264_bitrate, unpack_as="h264_bitrate_min"),
|
"min": Option(100, type=valid_stream_h264_bitrate, unpack_as="h264_bitrate_min"),
|
||||||
"max": Option(16000, type=valid_stream_h264_bitrate, unpack_as="h264_bitrate_max"),
|
"max": Option(16000, type=valid_stream_h264_bitrate, unpack_as="h264_bitrate_max"),
|
||||||
},
|
},
|
||||||
@@ -406,7 +410,7 @@ def _get_config_scheme() -> Dict:
|
|||||||
"idle_interval": Option(0.0, type=valid_float_f0),
|
"idle_interval": Option(0.0, type=valid_float_f0),
|
||||||
"live_interval": Option(0.0, type=valid_float_f0),
|
"live_interval": Option(0.0, type=valid_float_f0),
|
||||||
|
|
||||||
"wakeup_key": Option("", type=(lambda arg: (valid_hid_key(arg) if arg else ""))),
|
"wakeup_key": Option("", type=_make_ifarg(valid_hid_key, "")),
|
||||||
"wakeup_move": Option(0, type=valid_hid_mouse_move),
|
"wakeup_move": Option(0, type=valid_hid_mouse_move),
|
||||||
|
|
||||||
"online_delay": Option(5.0, type=valid_float_f0),
|
"online_delay": Option(5.0, type=valid_float_f0),
|
||||||
@@ -460,8 +464,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=(lambda arg: (valid_mac(arg) if arg else ""))),
|
"host_mac": Option("", type=_make_ifarg(valid_mac, "")),
|
||||||
"kvm_mac": Option("", type=(lambda arg: (valid_mac(arg) if arg else ""))),
|
"kvm_mac": Option("", type=_make_ifarg(valid_mac, "")),
|
||||||
},
|
},
|
||||||
|
|
||||||
"drives": {
|
"drives": {
|
||||||
@@ -536,7 +540,7 @@ def _get_config_scheme() -> Dict:
|
|||||||
},
|
},
|
||||||
|
|
||||||
"sol": {
|
"sol": {
|
||||||
"device": Option("", type=(lambda arg: (valid_abs_path(arg) if arg else "")), unpack_as="sol_device_path"),
|
"device": Option("", type=_make_ifarg(valid_abs_path, ""), unpack_as="sol_device_path"),
|
||||||
"speed": Option(115200, type=valid_tty_speed, unpack_as="sol_speed"),
|
"speed": Option(115200, type=valid_tty_speed, unpack_as="sol_speed"),
|
||||||
"select_timeout": Option(0.1, type=valid_float_f01, unpack_as="sol_select_timeout"),
|
"select_timeout": Option(0.1, type=valid_float_f01, unpack_as="sol_select_timeout"),
|
||||||
"proxy_port": Option(0, type=valid_port, unpack_as="sol_proxy_port"),
|
"proxy_port": Option(0, type=valid_port, unpack_as="sol_proxy_port"),
|
||||||
@@ -561,7 +565,7 @@ def _get_config_scheme() -> Dict:
|
|||||||
},
|
},
|
||||||
|
|
||||||
"tls": {
|
"tls": {
|
||||||
"ciphers": Option("ALL:@SECLEVEL=0", type=(lambda arg: valid_ssl_ciphers(arg) if arg else "")),
|
"ciphers": Option("ALL:@SECLEVEL=0", type=_make_ifarg(valid_ssl_ciphers, "")),
|
||||||
"timeout": Option(5.0, type=valid_float_f01),
|
"timeout": Option(5.0, type=valid_float_f01),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user