Passive 대상 제목에 (Passive) 표시, 연결됨 로그 중복 수정

- Passive 대상 PC 묶음 제목/서비스 앞 표시: "IP / hostname (Passive)"
- 연결 상태 변경을 이벤트 시점 값으로 UI에 전달 (연속 변경 시 "연결됨"이 여러 번 기록되던 문제)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013U497kUNL8ArhV7jkzCpKa
main
Claude 2026-10-27 05:31:54 +00:00
parent 39a8f03b59
commit 07c1b423a8
No known key found for this signature in database
2 changed files with 22 additions and 12 deletions

View File

@ -95,10 +95,14 @@ namespace JJServiceManager
{ {
get get
{ {
var addr = Direction == ConnectDirection.Passive if (Direction == ConnectDirection.Passive)
? (string.IsNullOrWhiteSpace(LastAddress) ? "Passive " + AccessCode : LastAddress) {
: Address; // 아직 한 번도 접속하지 않았으면 코드로 표시
return string.IsNullOrWhiteSpace(Hostname) ? addr : $"{addr} / {Hostname}"; if (string.IsNullOrWhiteSpace(LastAddress)) return "Passive " + AccessCode;
var p = string.IsNullOrWhiteSpace(Hostname) ? LastAddress : $"{LastAddress} / {Hostname}";
return p + " (Passive)";
}
return string.IsNullOrWhiteSpace(Hostname) ? Address : $"{Address} / {Hostname}";
} }
} }

View File

@ -794,7 +794,13 @@ namespace JJServiceManager
StatusBrush = Brushes2.Pending, StatusBrush = Brushes2.Pending,
EmptyText = "연결 중…" EmptyText = "연결 중…"
}; };
client.StateChanged += c => Dispatcher.BeginInvoke(new Action(() => OnRemoteState(g, c))); client.StateChanged += c =>
{
// 상태는 이벤트 시점 값으로 넘김 (UI에서 나중에 읽으면 연속 변경이 모두 같은 값으로 보임)
var st = c.State;
var stMsg = c.StateMessage;
Dispatcher.BeginInvoke(new Action(() => OnRemoteState(g, st, stMsg)));
};
client.ServicesChanged += c => Dispatcher.BeginInvoke(new Action(() => OnRemoteServices(g, c))); client.ServicesChanged += c => Dispatcher.BeginInvoke(new Action(() => OnRemoteServices(g, c)));
client.HostnameDiscovered += (c, host) => Dispatcher.BeginInvoke(new Action(() => OnHostname(g, c, host))); client.HostnameDiscovered += (c, host) => Dispatcher.BeginInvoke(new Action(() => OnHostname(g, c, host)));
client.PeerAddressDiscovered += (c, addr) => Dispatcher.BeginInvoke(new Action(() => OnPeerAddress(g, addr))); client.PeerAddressDiscovered += (c, addr) => Dispatcher.BeginInvoke(new Action(() => OnPeerAddress(g, addr)));
@ -851,10 +857,10 @@ namespace JJServiceManager
_logWindows.ChoicesChanged(); _logWindows.ChoicesChanged();
} }
private void OnRemoteState(HostGroup g, RemoteClient c) private void OnRemoteState(HostGroup g, RemoteState state, string stateMessage)
{ {
if (!_groups.Contains(g)) return; if (!_groups.Contains(g)) return;
switch (c.State) switch (state)
{ {
case RemoteState.Connected: case RemoteState.Connected:
g.StatusText = "연결됨"; g.StatusText = "연결됨";
@ -868,17 +874,17 @@ namespace JJServiceManager
break; break;
default: default:
bool wasConnected = g.Rows.Any(r => r.StatusKnown); bool wasConnected = g.Rows.Any(r => r.StatusKnown);
g.StatusText = (c.State == RemoteState.AuthFailed ? "인증 실패: " : "연결 안 됨: ") + c.StateMessage; g.StatusText = (state == RemoteState.AuthFailed ? "인증 실패: " : "연결 안 됨: ") + stateMessage;
g.StatusBrush = Brushes2.Stopped; g.StatusBrush = Brushes2.Stopped;
g.EmptyText = g.StatusText; g.EmptyText = g.StatusText;
foreach (var r in g.Rows) r.MarkUnknown(); foreach (var r in g.Rows) r.MarkUnknown();
// 같은 실패 메시지는 처음 한 번만 기록 // 같은 실패 메시지는 처음 한 번만 기록
if (wasConnected || g.Tag != c.StateMessage) if (wasConnected || g.Tag != stateMessage)
Log($"[{g.Prefix}] {g.StatusText}", c.State == RemoteState.AuthFailed ? LogLevel.Error : LogLevel.Warning); Log($"[{g.Prefix}] {g.StatusText}", state == RemoteState.AuthFailed ? LogLevel.Error : LogLevel.Warning);
g.Tag = c.StateMessage; g.Tag = stateMessage;
break; break;
} }
if (c.State == RemoteState.Connected) g.Tag = null; if (state == RemoteState.Connected) g.Tag = null;
UpdateCounts(); UpdateCounts();
} }