Merge pull request #117 from Moonlight-Panel/LimitFileAccessWebspace
Added website directory limit for website file manager
This commit is contained in:
@@ -11,6 +11,7 @@ public class SftpFileAccess : FileAccess
|
|||||||
private readonly string SftpPassword;
|
private readonly string SftpPassword;
|
||||||
private readonly int SftpPort;
|
private readonly int SftpPort;
|
||||||
private readonly bool ForceUserDir;
|
private readonly bool ForceUserDir;
|
||||||
|
private readonly string AdditionalPath;
|
||||||
|
|
||||||
private readonly SftpClient Client;
|
private readonly SftpClient Client;
|
||||||
|
|
||||||
@@ -19,20 +20,21 @@ public class SftpFileAccess : FileAccess
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (ForceUserDir)
|
if (ForceUserDir)
|
||||||
return $"/home/{SftpUser}{CurrentPath}";
|
return $"/home/{SftpUser}{AdditionalPath}{CurrentPath}";
|
||||||
|
|
||||||
return InternalPath;
|
return InternalPath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public SftpFileAccess(string sftpHost, string sftpUser, string sftpPassword, int sftpPort,
|
public SftpFileAccess(string sftpHost, string sftpUser, string sftpPassword, int sftpPort,
|
||||||
bool forceUserDir = false)
|
bool forceUserDir = false, string additionalPath = "")
|
||||||
{
|
{
|
||||||
SftpHost = sftpHost;
|
SftpHost = sftpHost;
|
||||||
SftpUser = sftpUser;
|
SftpUser = sftpUser;
|
||||||
SftpPassword = sftpPassword;
|
SftpPassword = sftpPassword;
|
||||||
SftpPort = sftpPort;
|
SftpPort = sftpPort;
|
||||||
ForceUserDir = forceUserDir;
|
ForceUserDir = forceUserDir;
|
||||||
|
AdditionalPath = additionalPath;
|
||||||
|
|
||||||
Client = new(
|
Client = new(
|
||||||
new ConnectionInfo(
|
new ConnectionInfo(
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ public class WebSpaceService
|
|||||||
var webspace = EnsureData(w);
|
var webspace = EnsureData(w);
|
||||||
|
|
||||||
return Task.FromResult<FileAccess>(
|
return Task.FromResult<FileAccess>(
|
||||||
new SftpFileAccess(webspace.CloudPanel.Host, webspace.UserName, webspace.Password, 22, true)
|
new SftpFileAccess(webspace.CloudPanel.Host, webspace.UserName, webspace.Password, 22, true, $"/htdocs/{webspace.Domain}")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user