diff --git a/README.md b/README.md index c17a9bfb..4d7890eb 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Regularly the test cases are manually executed and pass on Windows. Other UNIX v ## Requirements - Go 1.12 or higher -- A suitable SQL server to use as data provider: PostreSQL (9+) or MySQL (4.1+) or SQLite 3.x +- A suitable SQL server to use as data provider: PostreSQL (9+) or MySQL (5.6+) or SQLite 3.x ## Installation @@ -89,7 +89,7 @@ If you don't configure any private host keys, the daemon will use `id_rsa` in th Before starting `sftpgo` a dataprovider must be configured. -Sample SQL scripts to create the required database structure can be found insite the source tree [sql](https://github.com/drakkan/sftpgo/tree/master/sql "sql") directory. The SQL scripts filename's is, by convention, the date as `YYYYMMDD` and the suffix `.sql`. You need to apply all the SQL scripts for your database ordered by name, for example `20190706.sql` must be applied before `20190728.sql` and so on. +Sample SQL scripts to create the required database structure can be found inside the source tree [sql](https://github.com/drakkan/sftpgo/tree/master/sql "sql") directory. The SQL scripts filename's is, by convention, the date as `YYYYMMDD` and the suffix `.sql`. You need to apply all the SQL scripts for your database ordered by name, for example `20190706.sql` must be applied before `20190728.sql` and so on. The `sftpgo` configuration file contains the following sections: diff --git a/api/schema/openapi.yaml b/api/schema/openapi.yaml index 5cab86fa..203eb019 100644 --- a/api/schema/openapi.yaml +++ b/api/schema/openapi.yaml @@ -602,6 +602,9 @@ components: enum: - upload - download + path: + type: string + description: SFTP file path for the upload/download start_time: type: integer format: int64 diff --git a/dataprovider/user.go b/dataprovider/user.go index b39f5a63..4722abe2 100644 --- a/dataprovider/user.go +++ b/dataprovider/user.go @@ -110,3 +110,13 @@ func (u *User) GetHomeDir() string { func (u *User) HasQuotaRestrictions() bool { return u.QuotaFiles > 0 || u.QuotaSize > 0 } + +// GetRelativePath returns the path for a file relative to the user's home dir. +// This is the path as seen by SFTP users +func (u *User) GetRelativePath(path string) string { + rel, err := filepath.Rel(u.GetHomeDir(), path) + if err != nil { + return "" + } + return "/" + filepath.ToSlash(rel) +} diff --git a/sftpd/sftpd.go b/sftpd/sftpd.go index a4ddb7aa..72fe27a5 100644 --- a/sftpd/sftpd.go +++ b/sftpd/sftpd.go @@ -50,6 +50,7 @@ type connectionTransfer struct { StartTime int64 `json:"start_time"` Size int64 `json:"size"` LastActivity int64 `json:"last_activity"` + Path string `json:"path"` } // ActiveQuotaScan defines an active quota scan @@ -210,6 +211,7 @@ func GetConnectionsStats() []ConnectionStatus { StartTime: utils.GetTimeAsMsSinceEpoch(t.start), Size: size, LastActivity: utils.GetTimeAsMsSinceEpoch(t.lastActivity), + Path: c.User.GetRelativePath(t.path), } conn.Transfers = append(conn.Transfers, connTransfer) }