Skip to content

Commit 7822350

Browse files
fix: share config key error
1 parent 3d215d5 commit 7822350

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/mcpm/commands/router.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -451,12 +451,12 @@ def try_clear_share():
451451
console.print("[bold yellow]Clearing share config...[/]")
452452
config_manager = ConfigManager()
453453
share_config = config_manager.read_share_config()
454-
if share_config["url"]:
454+
if share_config.get("url"):
455455
try:
456456
console.print("[bold yellow]Disabling share link...[/]")
457457
config_manager.save_share_config(share_url=None, share_pid=None)
458458
console.print("[bold green]Share link disabled[/]")
459-
if share_config["pid"]:
459+
if share_config.get("pid"):
460460
os.kill(share_config["pid"], signal.SIGTERM)
461461
except OSError as e:
462462
if e.errno == 3: # "No such process"
@@ -473,11 +473,11 @@ def stop_share():
473473
# check if there is a share link already running
474474
config_manager = ConfigManager()
475475
share_config = config_manager.read_share_config()
476-
if not share_config["url"]:
476+
if not share_config.get("url"):
477477
console.print("[yellow]No share link is active.[/]")
478478
return
479479

480-
pid = share_config["pid"]
480+
pid = share_config.get("pid")
481481
if not pid:
482482
console.print("[yellow]No share link is active.[/]")
483483
return

src/mcpm/router/transport.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ def _validate_api_key(self, scope: Scope, api_key: str | None) -> bool:
258258
share_config = config_manager.read_share_config()
259259
router_config = config_manager.get_router_config()
260260
host_name = urlsplit(host).hostname
261-
if share_config["url"] and host_name != router_config["host"]:
261+
if share_config.get("url") and host_name != router_config["host"]:
262262
if api_key != self.api_key:
263263
return False
264264
except Exception as e:

0 commit comments

Comments
 (0)