2022-09-03 22:07:08 +08:00
|
|
|
package ftp
|
|
|
|
|
|
|
|
import (
|
2025-07-01 09:54:50 +08:00
|
|
|
"github.com/OpenListTeam/OpenList/v4/internal/driver"
|
|
|
|
"github.com/OpenListTeam/OpenList/v4/internal/op"
|
2024-06-16 16:58:02 +08:00
|
|
|
"github.com/axgle/mahonia"
|
2022-09-03 22:07:08 +08:00
|
|
|
)
|
|
|
|
|
2024-06-16 16:58:02 +08:00
|
|
|
func encode(str string, encoding string) string {
|
|
|
|
if encoding == "" {
|
|
|
|
return str
|
|
|
|
}
|
|
|
|
encoder := mahonia.NewEncoder(encoding)
|
|
|
|
return encoder.ConvertString(str)
|
|
|
|
}
|
|
|
|
|
|
|
|
func decode(str string, encoding string) string {
|
|
|
|
if encoding == "" {
|
|
|
|
return str
|
|
|
|
}
|
|
|
|
decoder := mahonia.NewDecoder(encoding)
|
|
|
|
return decoder.ConvertString(str)
|
|
|
|
}
|
|
|
|
|
2022-09-03 22:07:08 +08:00
|
|
|
type Addition struct {
|
|
|
|
Address string `json:"address" required:"true"`
|
2024-06-16 16:58:02 +08:00
|
|
|
Encoding string `json:"encoding" required:"true"`
|
2022-09-03 22:07:08 +08:00
|
|
|
Username string `json:"username" required:"true"`
|
|
|
|
Password string `json:"password" required:"true"`
|
2022-09-04 13:07:53 +08:00
|
|
|
driver.RootPath
|
2022-09-03 22:07:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
var config = driver.Config{
|
2025-07-12 17:57:54 +08:00
|
|
|
Name: "FTP",
|
|
|
|
LocalSort: true,
|
|
|
|
OnlyLinkMFile: true,
|
|
|
|
DefaultRoot: "/",
|
|
|
|
NoLinkURL: true,
|
2022-09-03 22:07:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
2022-12-13 18:03:30 +08:00
|
|
|
op.RegisterDriver(func() driver.Driver {
|
|
|
|
return &FTP{}
|
|
|
|
})
|
2022-09-03 22:07:08 +08:00
|
|
|
}
|