Skip to content

Commit ac71517

Browse files
committed
-Update
Add custom port
1 parent 885377e commit ac71517

19 files changed

+2998
-117
lines changed

ssh-vpn.v12.suo

4.5 KB
Binary file not shown.

ssh-vpn/Form1.cs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
using System.Runtime.InteropServices;
1111
using Microsoft.Win32;
1212
using Renci.SshNet;
13-
using System.Management;
1413

1514
namespace ssh_vpn
1615
{
@@ -21,7 +20,7 @@ public Form1()
2120
InitializeComponent();
2221
}
2322

24-
SshClient sshClient = new SshClient("0.0.0.0","0000","0000");
23+
SshClient sshClient = new SshClient("0.0.0.0",22,"0000","0000");
2524
ForwardedPortDynamic portForwarded = new ForwardedPortDynamic(9000);
2625

2726
private void btnConnect_Click(object sender, EventArgs e)
@@ -33,14 +32,18 @@ private void btnConnect_Click(object sender, EventArgs e)
3332
string password = registery_get_data("password");
3433
string username = registery_get_data("username");
3534
string ip = registery_get_data("ip");
35+
int port;
3636

37-
if (password == "" || password == "" || ip == "")
37+
if (!int.TryParse(registery_get_data("port"), out port)) port = 22;
38+
39+
if (password == null || password == null || ip == null)
3840
{
3941
MessageBox.Show("Error : You should set SSH server settings...", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
42+
btnConnect.Text = "Connect";
4043
return;
41-
}
44+
}
4245

43-
sshClient = new SshClient(ip, username, password);
46+
sshClient = new SshClient(ip, port, username, password);
4447

4548
try
4649
{
@@ -96,7 +99,7 @@ private void Form1_FormClosing(object sender, FormClosingEventArgs e)
9699
}
97100
else
98101
{
99-
btnConnect_Click(null, null);
102+
btnDisconnect_Click(null, null);
100103
}
101104
}
102105
}
@@ -167,8 +170,8 @@ private void set_windows_proxy()
167170
registry.SetValue("ProxyEnable", 1);
168171
registry.SetValue("ProxyServer", "socks5://127.0.0.1:9000");
169172

170-
WinINetInterop.InternetSetOption(IntPtr.Zero, WinINetInterop.INTERNET_OPTION_SETTINGS_CHANGED, IntPtr.Zero, 0);
171-
WinINetInterop.InternetSetOption(IntPtr.Zero, WinINetInterop.INTERNET_OPTION_REFRESH, IntPtr.Zero, 0);
173+
//WinINetInterop.InternetSetOption(IntPtr.Zero, WinINetInterop.INTERNET_OPTION_SETTINGS_CHANGED, IntPtr.Zero, 0);
174+
//WinINetInterop.InternetSetOption(IntPtr.Zero, WinINetInterop.INTERNET_OPTION_REFRESH, IntPtr.Zero, 0);
172175
}
173176

174177
private void unset_windows_proxy()

ssh-vpn/Form1.resx

Lines changed: 2930 additions & 103 deletions
Large diffs are not rendered by default.

ssh-vpn/SettingsForm.Designer.cs

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

ssh-vpn/SettingsForm.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ private void btn_save_Click(object sender, EventArgs e)
2424
using (RegistryKey key = Registry.CurrentUser.CreateSubKey(keyName))
2525
{
2626
key.SetValue("ip", txt_ip.Text);
27+
key.SetValue("port", txt_port.Value);
2728
key.SetValue("username", txt_username.Text);
2829
key.SetValue("password", txt_password.Text);
2930

@@ -39,6 +40,9 @@ private void SettingsForm_Load(object sender, EventArgs e)
3940
if (key != null)
4041
{
4142
txt_ip.Text = key.GetValue("ip") as string;
43+
int port = 22;
44+
if (int.TryParse(key.GetValue("port") as string, out port))
45+
txt_port.Value = port;
4246
txt_username.Text = key.GetValue("username") as string;
4347
txt_password.Text = key.GetValue("password") as string;
4448
}

ssh-vpn/bin/Debug/ssh-vpn.exe

333 KB
Binary file not shown.

ssh-vpn/bin/Debug/ssh-vpn.pdb

0 Bytes
Binary file not shown.

ssh-vpn/bin/Debug/v1.0.0.rar

46.7 KB
Binary file not shown.

ssh-vpn/bin/Debug/v1.0.0/ssh-vpn.exe

333 KB
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)