feat: add ftp root path setting
This commit is contained in:
@@ -83,6 +83,10 @@ type SSHConfig struct {
|
||||
// reuses the local ssh-agent and ~/.ssh/id_* discovery used by SSH/SCP.
|
||||
// - PathPrefix is relative to the account's login root. The application
|
||||
// rejects absolute paths and traversal segments before uploading.
|
||||
// - RootDirectory is only used to build the path copied to the clipboard.
|
||||
// Keeping it separate from PathPrefix lets the server expose a login root
|
||||
// such as "~/ftp/" while uploads still target a relative directory such
|
||||
// as "snapgo/".
|
||||
// - StrictHostKey and KnownHostsPath apply only to SFTP. Plain FTP has no
|
||||
// host-key mechanism and sends credentials and data without encryption.
|
||||
type FTPConfig struct {
|
||||
@@ -92,6 +96,7 @@ type FTPConfig struct {
|
||||
User string `json:"user"`
|
||||
AuthMethod string `json:"authMethod"`
|
||||
Password string `json:"password"`
|
||||
RootDirectory string `json:"rootDirectory"`
|
||||
PathPrefix string `json:"pathPrefix"`
|
||||
StrictHostKey bool `json:"strictHostKey"`
|
||||
KnownHostsPath string `json:"knownHostsPath"`
|
||||
@@ -260,6 +265,7 @@ func DefaultAppConfig() AppConfig {
|
||||
Protocol: FTPProtocolFTP,
|
||||
Port: 21,
|
||||
AuthMethod: SSHAuthPassword,
|
||||
RootDirectory: "/",
|
||||
PathPrefix: "snapgo/",
|
||||
ConnectTimeoutSecs: 10,
|
||||
StrictHostKey: false,
|
||||
@@ -371,6 +377,13 @@ func (c *AppConfig) Normalize() {
|
||||
if c.FTP.AuthMethod != SSHAuthPassword && c.FTP.AuthMethod != SSHAuthKey {
|
||||
c.FTP.AuthMethod = SSHAuthPassword
|
||||
}
|
||||
if c.FTP.RootDirectory == "" {
|
||||
if c.FTP.Protocol == FTPProtocolSFTP {
|
||||
c.FTP.RootDirectory = "~/"
|
||||
} else {
|
||||
c.FTP.RootDirectory = "/"
|
||||
}
|
||||
}
|
||||
if c.FTP.PathPrefix == "" {
|
||||
c.FTP.PathPrefix = "snapgo/"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user