mirror of
https://github.com/openziti/desktop-edge-win.git
synced 2026-10-15 09:01:27 +00:00
Changed to fully manual setting of timeouts and countdowns
This commit is contained in:
@@ -136,8 +136,9 @@ namespace ZitiDesktopEdge {
|
||||
for (int i=0; i<identities.Count; i++) {
|
||||
if (identities[i].Fingerprint==mfa.Fingerprint) {
|
||||
identities[i].WasNotified = false;
|
||||
identities[i].MFAInfo.IsAuthenticated = mfa.Successful;
|
||||
for (int j=0; j<identities[i].Services.Count; j++) {
|
||||
identities[i].Services[j].TimeoutRemaining = -1;
|
||||
identities[i].Services[j].TimeoutRemaining = identities[i].Services[j].Timeout;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -630,10 +631,14 @@ namespace ZitiDesktopEdge {
|
||||
found.TimeoutMessage = notification.Message;
|
||||
found.MaxTimeout = notification.MfaMaximumTimeout;
|
||||
found.MinTimeout = notification.MfaMinimumTimeout;
|
||||
if (!found.WasNotified) {
|
||||
found.WasNotified = true;
|
||||
ShowMFAToast(found.TimeoutMessage, found);
|
||||
|
||||
if (found.MinTimeout<1200) {
|
||||
if (!found.WasNotified) {
|
||||
found.WasNotified = true;
|
||||
ShowMFAToast(found.TimeoutMessage, found);
|
||||
}
|
||||
}
|
||||
|
||||
// Send Notification
|
||||
if (notification.MfaMinimumTimeout == 0) {
|
||||
found.MFAInfo.IsAuthenticated = false;
|
||||
@@ -1159,7 +1164,7 @@ namespace ZitiDesktopEdge {
|
||||
idItem.Authenticate += IdItem_Authenticate;
|
||||
idItem.OnStatusChanged += Id_OnStatusChanged;
|
||||
idItem.Identity = id;
|
||||
if (!id.MFAInfo.IsAuthenticated) idItem.RefreshUI();
|
||||
if (repaint) idItem.RefreshUI();
|
||||
|
||||
IdList.Children.Add(idItem);
|
||||
|
||||
|
||||
@@ -26,6 +26,8 @@ namespace ZitiDesktopEdge {
|
||||
public delegate void OnAuthenticate(ZitiIdentity identity);
|
||||
public event OnAuthenticate Authenticate;
|
||||
private System.Windows.Forms.Timer _timer;
|
||||
private System.Windows.Forms.Timer _timingTimer;
|
||||
private int countdown = -1;
|
||||
|
||||
public ZitiIdentity _identity;
|
||||
public ZitiIdentity Identity {
|
||||
@@ -49,10 +51,18 @@ namespace ZitiDesktopEdge {
|
||||
if (_identity.MaxTimeout>0) {
|
||||
if (_timer != null) _timer.Stop();
|
||||
_timer = new System.Windows.Forms.Timer();
|
||||
_timer.Interval = _identity.MaxTimeout;
|
||||
_timer.Interval = _identity.MaxTimeout*1000;
|
||||
_timer.Tick += TimerTicked;
|
||||
_timer.Start();
|
||||
}
|
||||
if (_identity.MinTimeout > 0) {
|
||||
if (_timingTimer != null) _timingTimer.Stop();
|
||||
countdown = _identity.MinTimeout;
|
||||
_timingTimer = new System.Windows.Forms.Timer();
|
||||
_timingTimer.Interval = 1000;
|
||||
_timingTimer.Tick += TimingTimerTick; ;
|
||||
_timingTimer.Start();
|
||||
}
|
||||
} else {
|
||||
ServiceCountArea.Visibility = Visibility.Collapsed;
|
||||
MfaRequired.Visibility = Visibility.Visible;
|
||||
@@ -82,6 +92,18 @@ namespace ZitiDesktopEdge {
|
||||
}
|
||||
}
|
||||
|
||||
private void TimingTimerTick(object sender, EventArgs e) {
|
||||
if (countdown>-1) {
|
||||
countdown--;
|
||||
if (countdown<1260) {
|
||||
_identity.IsTimingOut = true;
|
||||
TimerCountdown.ToolTip = _identity.TimeoutMessage;
|
||||
if (TimerCountdown.ToolTip.ToString().Length == 0) TimerCountdown.ToolTip = "Timing Out";
|
||||
TimerCountdown.Visibility = _identity.IsTimingOut ? Visibility.Visible : Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void TimerTicked(object sender, EventArgs e) {
|
||||
_identity.MFAInfo.IsAuthenticated = false;
|
||||
RefreshUI();
|
||||
|
||||
@@ -40,6 +40,7 @@ namespace ZitiDesktopEdge {
|
||||
public event OnRecovery Recovery;
|
||||
public delegate void LoadingEvent(bool isComplete);
|
||||
public event LoadingEvent OnLoading;
|
||||
private System.Windows.Forms.Timer _timer;
|
||||
|
||||
public int Page = 1;
|
||||
public int PerPage = 50;
|
||||
@@ -50,6 +51,7 @@ namespace ZitiDesktopEdge {
|
||||
private double scrolledTo = 0;
|
||||
public int totalServices = 0;
|
||||
private ScrollViewer _scroller;
|
||||
private ZitiService _info;
|
||||
|
||||
public ObservableCollection<ZitiService> _services = new ObservableCollection<ZitiService>();
|
||||
public ObservableCollection<ZitiService> ZitiServices { get { return _services; } }
|
||||
@@ -212,27 +214,52 @@ namespace ZitiDesktopEdge {
|
||||
}
|
||||
|
||||
private void ShowDetails(ZitiService info) {
|
||||
_info = info;
|
||||
DetailName.Text = info.Name;
|
||||
DetailProtocols.Text = info.ProtocolString;
|
||||
DetailAddress.Text = info.AddressString;
|
||||
DetailPorts.Text = info.PortString;
|
||||
DetailUrl.Text = info.ToString();
|
||||
|
||||
UpdateClock(info);
|
||||
if (_identity.IsMFAEnabled) {
|
||||
if (_timer != null) _timer.Stop();
|
||||
_timer = new System.Windows.Forms.Timer();
|
||||
_timer.Interval = 1000;
|
||||
_timer.Tick += Ticked; ;
|
||||
_timer.Start();
|
||||
}
|
||||
|
||||
DetailsArea.Visibility = Visibility.Visible;
|
||||
DetailsArea.Opacity = 0;
|
||||
DetailsArea.Margin = new Thickness(0, 0, 0, 0);
|
||||
DoubleAnimation animation = new DoubleAnimation(1, TimeSpan.FromSeconds(.3));
|
||||
animation.Completed += ShowCompleted;
|
||||
DetailsArea.BeginAnimation(Grid.OpacityProperty, animation);
|
||||
DetailsArea.BeginAnimation(Grid.MarginProperty, new ThicknessAnimation(new Thickness(30, 30, 30, 30), TimeSpan.FromSeconds(.3)));
|
||||
|
||||
ShowModal();
|
||||
}
|
||||
|
||||
private void Ticked(object sender, EventArgs e) {
|
||||
UpdateClock(_info);
|
||||
}
|
||||
|
||||
private void UpdateClock(ZitiService info) {
|
||||
try {
|
||||
if (_identity.IsMFAEnabled) {
|
||||
if (info.TimeoutRemaining > 0) {
|
||||
// t = TimeSpan.FromSeconds(info.TimeoutRemaining);
|
||||
TimeSpan t = (DateTime.Now - info.TimeUpdated);
|
||||
int timeout = info.Timeout - (int)Math.Floor(t.TotalSeconds);
|
||||
|
||||
if (timeout>0) {
|
||||
if (timeout > 0) {
|
||||
t = TimeSpan.FromSeconds(timeout);
|
||||
string answer = t.Seconds + " seconds";
|
||||
if (t.Days > 0) answer = t.Days + " days " + t.Hours + " hours " + t.Minutes + " minutes " + t.Seconds + " seconds";
|
||||
else {
|
||||
if (t.Hours > 0) answer = t.Hours + " hours " + t.Minutes + " minutes " + t.Seconds + " seconds";
|
||||
else {
|
||||
if (t.Minutes>0) answer = t.Minutes + " minutes " + t.Seconds + " seconds";
|
||||
if (t.Minutes > 0) answer = t.Minutes + " minutes " + t.Seconds + " seconds";
|
||||
}
|
||||
}
|
||||
TimeoutDetails.Text = answer;
|
||||
@@ -249,18 +276,8 @@ namespace ZitiDesktopEdge {
|
||||
}
|
||||
} catch (Exception e) {
|
||||
TimeoutDetails.Text = "Never";
|
||||
Console.WriteLine("Error: "+e.ToString());
|
||||
Console.WriteLine("Error: " + e.ToString());
|
||||
}
|
||||
|
||||
DetailsArea.Visibility = Visibility.Visible;
|
||||
DetailsArea.Opacity = 0;
|
||||
DetailsArea.Margin = new Thickness(0, 0, 0, 0);
|
||||
DoubleAnimation animation = new DoubleAnimation(1, TimeSpan.FromSeconds(.3));
|
||||
animation.Completed += ShowCompleted;
|
||||
DetailsArea.BeginAnimation(Grid.OpacityProperty, animation);
|
||||
DetailsArea.BeginAnimation(Grid.MarginProperty, new ThicknessAnimation(new Thickness(30, 30, 30, 30), TimeSpan.FromSeconds(.3)));
|
||||
|
||||
ShowModal();
|
||||
}
|
||||
|
||||
private void ShowCompleted(object sender, EventArgs e) {
|
||||
|
||||
Reference in New Issue
Block a user