Publish Zonghengjia Windows 0.4.0 client source
This commit is contained in:
@@ -328,8 +328,6 @@ internal sealed partial class MainForm
|
||||
private readonly NodeTrafficPanel _nodeTrafficPanel = new();
|
||||
private readonly System.Windows.Forms.Timer _nodeTrafficTimer = new() { Interval = 5_000 };
|
||||
private bool _canViewNodeTraffic, _nodeTrafficReading;
|
||||
private bool _nodeTrafficDiscovery;
|
||||
private long _nodeTrafficDiscoveryRevision=long.MinValue;
|
||||
private DateTimeOffset? _nodeTrafficSince;
|
||||
private string? _nodeTrafficSlugs;
|
||||
private DateTimeOffset _nextNodeTrafficAttempt;
|
||||
@@ -342,7 +340,9 @@ internal sealed partial class MainForm
|
||||
}
|
||||
private void SetNodeTrafficPermission(bool allowed)
|
||||
{
|
||||
_nodeTrafficDiscovery=false;
|
||||
// v0.4.0 deliberately removes server-interface sampling from the
|
||||
// client. Local proxy counters remain available without polling hosts.
|
||||
allowed = false;
|
||||
if(!allowed) { _nodeTrafficSince=null; _nodeTrafficSlugs=null; }
|
||||
if (_canViewNodeTraffic != allowed) _nodeTrafficPanel.Unavailable("等待服务器采样", clear: true);
|
||||
_canViewNodeTraffic = allowed;
|
||||
@@ -353,23 +353,16 @@ internal sealed partial class MainForm
|
||||
}
|
||||
private void ConfigureNodeTrafficMonitor(Profile profile)
|
||||
{
|
||||
if(_preview||_uiOnly) { SetNodeTrafficPermission(profile.CanViewNodeTraffic); return; }
|
||||
// Legacy profiles have no staff/monitor flag. Probe the read-only staff
|
||||
// endpoint once per login; only a successful server authorization shows
|
||||
// the panel. A 403 hides it and stops polling for that session.
|
||||
if(_nodeTrafficDiscoveryRevision!=_sessionRevision)
|
||||
{ _nodeTrafficDiscoveryRevision=_sessionRevision; _nodeTrafficDiscovery=true; _nextNodeTrafficAttempt=DateTimeOffset.MinValue; }
|
||||
if((_canViewNodeTraffic||_nodeTrafficDiscovery)&&!_exiting)
|
||||
{ _nodeTrafficTimer.Start(); _=RefreshNodeTrafficAsync(); }
|
||||
SetNodeTrafficPermission(false);
|
||||
}
|
||||
private async Task RefreshNodeTrafficAsync()
|
||||
{
|
||||
_nodeTrafficPanel.Invalidate();
|
||||
if (!(_canViewNodeTraffic||_nodeTrafficDiscovery) || _nodeTrafficReading || _preview || _uiOnly || _exiting
|
||||
if (!_canViewNodeTraffic || _nodeTrafficReading || _preview || _uiOnly || _exiting
|
||||
|| string.IsNullOrWhiteSpace(_accessToken) || DateTimeOffset.UtcNow < _nextNodeTrafficAttempt) return;
|
||||
var token = _accessToken;
|
||||
var revision = _sessionRevision;
|
||||
bool Current() => !_exiting && !IsDisposed && (_canViewNodeTraffic||_nodeTrafficDiscovery) && _sessionRevision == revision && _accessToken == token;
|
||||
bool Current() => !_exiting && !IsDisposed && _canViewNodeTraffic && _sessionRevision == revision && _accessToken == token;
|
||||
_nodeTrafficReading = true;
|
||||
try
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user