Skip to content

Commit

Permalink
tweaks change
Browse files Browse the repository at this point in the history
  • Loading branch information
qiuhaotc committed Dec 24, 2020
1 parent f2dbdd6 commit 55d9f3e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/WebSSH/Client/Pages/RemoteShell.razor
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
}
else
{
StaticUtils.AddOutputString(UniqueId, Environment.NewLine + "Not conneted");
StaticUtils.AddOutputString(UniqueId, Environment.NewLine + "Not connected");
}
}
catch (Exception ex)
Expand Down
4 changes: 3 additions & 1 deletion src/WebSSH/Server/Common/ServerActiveSessionsModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ namespace WebSSH.Server
{
public class ServerActiveSessionsModel
{
public ServerActiveSessionModel Connected(ActiveSessionModel activeSessionModel)
public ServerActiveSessionModel Connected(ActiveSessionModel activeSessionModel, ShellConfiguration shellConfiguration)
{
SshClient sshClient = null;
ShellStream shellStream = null;
try
{
var timeOutMinutes = shellConfiguration.MaxIdleMinutes < 1 ? 1 : shellConfiguration.MaxIdleMinutes > 20 ? 20 : shellConfiguration.MaxIdleMinutes;
var clientStoredSessionModel = activeSessionModel.StoredSessionModel;
sshClient = new SshClient(clientStoredSessionModel.Host, clientStoredSessionModel.Port, clientStoredSessionModel.UserName, clientStoredSessionModel.PasswordDecryped);
sshClient.ConnectionInfo.Timeout = TimeSpan.FromMinutes(timeOutMinutes);
sshClient.Connect();
shellStream = sshClient.CreateShellStream("Terminal", 80, 30, 800, 400, 1000);
var outputQueue = new ConcurrentQueue<string>();
Expand Down
5 changes: 4 additions & 1 deletion src/WebSSH/Server/Common/ShellPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,12 @@ public ShellPool(ShellConfiguration shellConfiguration)
}
}
});

ShellConfiguration = shellConfiguration;
}

static ConcurrentDictionary<string, ServerActiveSessionsModel> ShellPoolDictionary { get; set; } = new ConcurrentDictionary<string, ServerActiveSessionsModel>();
public ShellConfiguration ShellConfiguration { get; }

public void AddShellToPool(string sessionId, ActiveSessionModel activeSessionModel)
{
Expand All @@ -50,7 +53,7 @@ public void AddShellToPool(string sessionId, ActiveSessionModel activeSessionMod
ShellPoolDictionary.TryAdd(sessionId, sessionsModel);
}

sessionsModel.Connected(activeSessionModel);
sessionsModel.Connected(activeSessionModel, ShellConfiguration);
}

public void RunShellCommand(string sessionId, Guid uniqueId, string command)
Expand Down

0 comments on commit 55d9f3e

Please sign in to comment.