2022-09-03 14:07:08 +00:00
|
|
|
package ftp
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/alist-org/alist/v3/internal/driver"
|
|
|
|
"github.com/alist-org/alist/v3/internal/op"
|
2024-06-16 08:58:02 +00:00
|
|
|
"github.com/axgle/mahonia"
|
2022-09-03 14:07:08 +00:00
|
|
|
)
|
|
|
|
|
2024-06-16 08:58:02 +00: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 14:07:08 +00:00
|
|
|
type Addition struct {
|
|
|
|
Address string `json:"address" required:"true"`
|
2024-06-16 08:58:02 +00:00
|
|
|
Encoding string `json:"encoding" required:"true"`
|
2022-09-03 14:07:08 +00:00
|
|
|
Username string `json:"username" required:"true"`
|
|
|
|
Password string `json:"password" required:"true"`
|
2022-09-04 05:07:53 +00:00
|
|
|
driver.RootPath
|
2022-09-03 14:07:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var config = driver.Config{
|
|
|
|
Name: "FTP",
|
2022-09-04 04:43:52 +00:00
|
|
|
LocalSort: true,
|
|
|
|
OnlyLocal: true,
|
|
|
|
DefaultRoot: "/",
|
2022-09-03 14:07:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
2022-12-13 10:03:30 +00:00
|
|
|
op.RegisterDriver(func() driver.Driver {
|
|
|
|
return &FTP{}
|
|
|
|
})
|
2022-09-03 14:07:08 +00:00
|
|
|
}
|