mirror of https://github.com/Xhofe/alist
parent
e7c0d94b44
commit
37dffd0fce
|
@ -54,6 +54,8 @@ func (d *Crypt) Init(ctx context.Context) error {
|
||||||
if !isCryptExt(d.EncryptedSuffix) {
|
if !isCryptExt(d.EncryptedSuffix) {
|
||||||
return fmt.Errorf("EncryptedSuffix is Illegal")
|
return fmt.Errorf("EncryptedSuffix is Illegal")
|
||||||
}
|
}
|
||||||
|
d.FileNameEncoding = utils.GetNoneEmpty(d.FileNameEncoding, "base64")
|
||||||
|
d.EncryptedSuffix = utils.GetNoneEmpty(d.EncryptedSuffix, ".bin")
|
||||||
|
|
||||||
op.MustSaveDriverStorage(d)
|
op.MustSaveDriverStorage(d)
|
||||||
|
|
||||||
|
@ -71,7 +73,7 @@ func (d *Crypt) Init(ctx context.Context) error {
|
||||||
"password2": p2,
|
"password2": p2,
|
||||||
"filename_encryption": d.FileNameEnc,
|
"filename_encryption": d.FileNameEnc,
|
||||||
"directory_name_encryption": d.DirNameEnc,
|
"directory_name_encryption": d.DirNameEnc,
|
||||||
"filename_encoding": "base64",
|
"filename_encoding": d.FileNameEncoding,
|
||||||
"suffix": d.EncryptedSuffix,
|
"suffix": d.EncryptedSuffix,
|
||||||
"pass_bad_blocks": "",
|
"pass_bad_blocks": "",
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,17 +15,12 @@ type Addition struct {
|
||||||
DirNameEnc string `json:"directory_name_encryption" type:"select" required:"true" options:"false,true" default:"false"`
|
DirNameEnc string `json:"directory_name_encryption" type:"select" required:"true" options:"false,true" default:"false"`
|
||||||
RemotePath string `json:"remote_path" required:"true" help:"This is where the encrypted data stores"`
|
RemotePath string `json:"remote_path" required:"true" help:"This is where the encrypted data stores"`
|
||||||
|
|
||||||
Password string `json:"password" required:"true" confidential:"true" help:"the main password"`
|
Password string `json:"password" required:"true" confidential:"true" help:"the main password"`
|
||||||
Salt string `json:"salt" confidential:"true" help:"If you don't know what is salt, treat it as a second password'. Optional but recommended"`
|
Salt string `json:"salt" confidential:"true" help:"If you don't know what is salt, treat it as a second password. Optional but recommended"`
|
||||||
EncryptedSuffix string `json:"encrypted_suffix" required:"true" default:".bin" help:"encrypted files will have this suffix"`
|
EncryptedSuffix string `json:"encrypted_suffix" required:"true" default:".bin" help:"for advanced user only! encrypted files will have this suffix"`
|
||||||
|
FileNameEncoding string `json:"filename_encoding" type:"select" required:"true" options:"base64,base32,base32768" default:"base64" help:"for advanced user only!"`
|
||||||
}
|
}
|
||||||
|
|
||||||
/*// inMemory contains decrypted confidential info and other temp data. will not persist these info anywhere
|
|
||||||
type inMemory struct {
|
|
||||||
password string
|
|
||||||
salt string
|
|
||||||
}*/
|
|
||||||
|
|
||||||
var config = driver.Config{
|
var config = driver.Config{
|
||||||
Name: "Crypt",
|
Name: "Crypt",
|
||||||
LocalSort: true,
|
LocalSort: true,
|
||||||
|
|
|
@ -30,3 +30,13 @@ func SafeAtob(data string) (string, error) {
|
||||||
}
|
}
|
||||||
return string(bytes), err
|
return string(bytes), err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetNoneEmpty returns the first non-empty string, return empty if all empty
|
||||||
|
func GetNoneEmpty(strArr ...string) string {
|
||||||
|
for _, s := range strArr {
|
||||||
|
if len(s) > 0 {
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue