Skip to content

Commit 2daa7cb

Browse files
committed
-Update...
1 parent 0522d02 commit 2daa7cb

30 files changed

+3211
-171
lines changed

ssh-vpn.v12.suo

-14.5 KB
Binary file not shown.

ssh-vpn/App.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
<configuration>
33
<startup>
44

5-
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/></startup>
5+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup>
66
</configuration>

ssh-vpn/Form1.Designer.cs

Lines changed: 13 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ssh-vpn/Form1.cs

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -82,28 +82,19 @@ void Disconnect()
8282
{
8383
btnToggle.Text = "Disconnecting...";
8484

85-
ThreadPool.QueueUserWorkItem(new WaitCallback((state) =>
86-
{
87-
portForwarded.Stop();
88-
sshClient.Disconnect();
89-
unset_windows_proxy();
85+
portForwarded.Stop();
86+
sshClient.Disconnect();
87+
unset_windows_proxy();
9088

91-
Invoke((MethodInvoker)delegate
92-
{
93-
btnToggle.Text = "Connect";
94-
lblStatus.BackColor = Color.Red;
95-
lblStatus.Text = "Not Connected";
89+
btnToggle.Text = "Connect";
90+
lblStatus.BackColor = Color.Red;
91+
lblStatus.Text = "Not Connected";
9692

97-
timer_check_status.Enabled = false;
98-
timer_check_status.Stop();
99-
seconds = 0;
100-
101-
btnToggle.Enabled = true;
102-
});
103-
104-
105-
}));
93+
timer_check_status.Enabled = false;
94+
timer_check_status.Stop();
95+
seconds = 0;
10696

97+
btnToggle.Enabled = true;
10798
}
10899

109100

@@ -118,7 +109,6 @@ private void btnToggle_Click(object sender, EventArgs e)
118109
else Connect();
119110

120111
Cursor.Current = Cursors.Default;
121-
122112
}
123113

124114

@@ -130,15 +120,14 @@ private void Form1_FormClosing(object sender, FormClosingEventArgs e)
130120
if (result == DialogResult.No)
131121
e.Cancel = true;
132122
else
133-
btnToggle_Click(null, null);
123+
Disconnect();
134124

135125
}
136126
private void SystemEvents_SessionEnding(object sender, SessionEndingEventArgs e)
137127
{
138128
if (sshClient.IsConnected)
139129
btnToggle_Click(null, null);
140130

141-
142131
Application.Exit();
143132
}
144133

@@ -148,15 +137,33 @@ private void btnOpenSettings_Click(object sender, EventArgs e)
148137
settingsForm.ShowDialog();
149138
}
150139

140+
bool back_status = false;
151141
int seconds = 0;
152142
private void timer_check_status_Tick(object sender, EventArgs e)
153143
{
154-
seconds++;
144+
if (!sshClient.IsConnected && sshClient.IsConnected != back_status)
145+
{
146+
Disconnect();
147+
148+
notifyIcon1.Icon = SystemIcons.Warning;
149+
notifyIcon1.ShowBalloonTip(10);
150+
}
151+
else if (sshClient.IsConnected && sshClient.IsConnected != back_status)
152+
{
153+
seconds = 0;
154+
lblStatus.Text = "Connected 00:00:00";
155+
}
156+
else if (sshClient.IsConnected)
157+
{
158+
seconds++;
159+
160+
int hours = seconds / 3600;
161+
int minutes = (seconds % 3600) / 60;
162+
int remainingSeconds = seconds % 60;
163+
lblStatus.Text = "Connected " + hours.ToString("D2") + ":" + minutes.ToString("D2") + ":" + remainingSeconds.ToString("D2");
164+
}
155165

156-
int hours = seconds / 3600;
157-
int minutes = (seconds % 3600) / 60;
158-
int remainingSeconds = seconds % 60;
159-
lblStatus.Text = "Connected " + hours.ToString("D2") + ":" + minutes.ToString("D2") + ":" + remainingSeconds.ToString("D2");
166+
back_status = sshClient.IsConnected;
160167
}
161168

162169
private void set_windows_proxy()

0 commit comments

Comments
 (0)