Skip to content

Commit 32ddb9e

Browse files
committed
remove the ability to turn off the API
1 parent 3fcd629 commit 32ddb9e

File tree

2 files changed

+41
-55
lines changed

2 files changed

+41
-55
lines changed

src/hhd/__main__.py

Lines changed: 41 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -456,46 +456,46 @@ def main():
456456
prev_http_cfg = http_cfg
457457
if https:
458458
https.close()
459-
if http_cfg["enable"].to(bool):
460-
from .http import HHDHTTPServer
461-
462-
port = http_cfg["port"].to(int)
463-
localhost = http_cfg["localhost"].to(bool)
464-
use_token = http_cfg["token"].to(bool)
465-
466-
# Generate security token
467-
if use_token:
468-
if not os.path.isfile(token_fn):
469-
import hashlib
470-
import random
471-
472-
token = hashlib.sha256(
473-
str(random.random()).encode()
474-
).hexdigest()[:12]
475-
with open(token_fn, "w") as f:
476-
os.chmod(token_fn, 0o600)
477-
f.write(token)
478-
fix_perms(token_fn, ctx)
479-
else:
480-
with open(token_fn, "r") as f:
481-
token = f.read().strip()
459+
460+
from .http import HHDHTTPServer
461+
462+
port = 5335
463+
localhost = http_cfg["localhost"].to(bool)
464+
use_token = http_cfg["token"].to(bool)
465+
466+
# Generate security token
467+
if use_token:
468+
if not os.path.isfile(token_fn):
469+
import hashlib
470+
import random
471+
472+
token = hashlib.sha256(
473+
str(random.random()).encode()
474+
).hexdigest()[:12]
475+
with open(token_fn, "w") as f:
476+
os.chmod(token_fn, 0o600)
477+
f.write(token)
478+
fix_perms(token_fn, ctx)
482479
else:
483-
token = None
480+
with open(token_fn, "r") as f:
481+
token = f.read().strip()
482+
else:
483+
token = None
484484

485-
set_log_plugin("rest")
486-
https = HHDHTTPServer(localhost, port, token)
487-
https.update(settings, conf, info, profiles, emit, locales, ctx)
488-
try:
489-
https.open()
490-
except Exception as e:
491-
logger.error(
492-
f"Could not start http API on port {port}.\n"
493-
+ "Is another version of Handheld Daemon open?\n"
494-
+ "Closing."
495-
)
496-
return
497-
update_log_plugins()
498-
set_log_plugin("main")
485+
set_log_plugin("rest")
486+
https = HHDHTTPServer(localhost, port, token)
487+
https.update(settings, conf, info, profiles, emit, locales, ctx)
488+
try:
489+
https.open()
490+
except Exception as e:
491+
logger.error(
492+
f"Could not start http API on port {port}.\n"
493+
+ "Is another version of Handheld Daemon open?\n"
494+
+ "Closing."
495+
)
496+
return
497+
update_log_plugins()
498+
set_log_plugin("main")
499499

500500
#
501501
# Plugin loop
@@ -584,7 +584,9 @@ def main():
584584
logger.info(f"Reloading settings.")
585585

586586
# Settings
587-
settings_base = {k: {} for k in load_relative_yaml("sections.yml")['sections']}
587+
settings_base = {
588+
k: {} for k in load_relative_yaml("sections.yml")["sections"]
589+
}
588590
hhd_settings = {"hhd": load_relative_yaml("settings.yml")}
589591
# TODO: Improve check
590592
try:

src/hhd/settings.yml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -87,22 +87,6 @@ http:
8787
Settings for configuring the http endpoint of HHD.
8888
8989
children:
90-
enable:
91-
type: bool
92-
title: Enable the API
93-
tags: [advanced]
94-
hint: >-
95-
Enables the API of Handheld Daemon (required for decky and ui).
96-
default: True
97-
port:
98-
type: int
99-
title: API Port
100-
tags: [advanced, hhd-port, port, dropdown]
101-
hint: >-
102-
Which port should the API be on?
103-
min: 1024
104-
max: 49151
105-
default: 5335
10690
localhost:
10791
type: bool
10892
title: Limit Access to localhost

0 commit comments

Comments
 (0)