From 3d44681d41617f866aa2cac078671d9501fdea6e Mon Sep 17 00:00:00 2001 From: seo Date: Tue, 21 Jul 2026 19:37:32 +0900 Subject: [PATCH] =?UTF-8?q?=EC=98=A8=EB=9D=BC=EC=9D=B8=20LAN=20=EA=B8=B0?= =?UTF-8?q?=EA=B8=B0=20WOL=20=EC=B0=A8=EB=8B=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/api.php | 9 +++++++-- public/assets/app.js | 11 ++++++++++- public/index.php | 2 +- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/public/api.php b/public/api.php index 03fb1e8..4f6cbb9 100644 --- a/public/api.php +++ b/public/api.php @@ -2798,7 +2798,7 @@ function lan_client_rows(array $leases, array $aliases, array $wifiMacs = [], st 'connected_time' => $isFdbVisible ? 'N/A' : '-', 'inactive_time' => '-', 'presence' => $isFdbVisible ? 'fdb' : 'lease', - 'wol_available' => true, + 'wol_available' => !$isFdbVisible, 'rx_bytes' => 0, 'tx_bytes' => 0, 'rx_packets' => 0, @@ -2822,7 +2822,12 @@ function send_wake_on_lan(string $mac, string $broadcast = '192.168.50.255', int throw new InvalidArgumentException('unknown_dhcp_client'); } - $lanMacs = array_fill_keys(array_merge(lan_fdb_macs(), observed_lan_macs($leases)), true); + $activeLanMacs = array_fill_keys(lan_fdb_macs(), true); + if (isset($activeLanMacs[$mac])) { + throw new InvalidArgumentException('device_already_online'); + } + + $lanMacs = array_fill_keys(array_merge(array_keys($activeLanMacs), observed_lan_macs($leases)), true); if (!isset($lanMacs[$mac])) { throw new InvalidArgumentException('not_lan_client'); } diff --git a/public/assets/app.js b/public/assets/app.js index 594f6d3..0f59ec6 100644 --- a/public/assets/app.js +++ b/public/assets/app.js @@ -187,6 +187,7 @@ wolConfirm: ({ hostname, mac }) => `Send one Wake-on-LAN request to ${hostname || mac}?`, wolSent: 'Wake-on-LAN request sent.', wolFailed: 'Wake-on-LAN request failed', + wolAlreadyOnline: 'LAN device is already online.', show: 'Show', hide: 'Hide', translateButton: 'Translate', @@ -338,6 +339,7 @@ wolConfirm: ({ hostname, mac }) => `${hostname || mac} 기기에 WOL 요청을 1회 보낼까요?`, wolSent: 'WOL 요청을 보냈습니다.', wolFailed: 'WOL 요청 실패', + wolAlreadyOnline: 'LAN 기기가 이미 켜져 있습니다.', show: '보기', hide: '숨기기', translateButton: '번역', @@ -603,6 +605,13 @@ message, }, options)); + function apiErrorMessage(message) { + const map = { + device_already_online: t('wolAlreadyOnline'), + }; + return map[message] || message; + } + async function api(action, body = null) { const opts = { method: body ? 'POST' : 'GET', @@ -627,7 +636,7 @@ const res = await fetch(url, opts); const json = await res.json(); if (!res.ok || !json.ok) { - throw new Error(json?.message || json?.error || 'API error'); + throw new Error(apiErrorMessage(json?.message || json?.error || 'API error')); } return json.data; } diff --git a/public/index.php b/public/index.php index b955831..e91701b 100644 --- a/public/index.php +++ b/public/index.php @@ -363,7 +363,7 @@ html[data-theme="light"] .details-panel{background:#edf3fa;border-color:#b8c7da} - +