-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: logic for listing folder content
Before, we use `HEAD` request to check for `Link` headers for folder content. However, there are limits on how big the headers are, and how many `Link` headers can be returned. This is a problem for folders with many files. Therefore, we refactor the code to use `GET` request to list folder by returing a HTML index page using `<table>` with some conventions. Not only this lets individual remote backend to be run standalone, listing contents as HTML, it also lets us parse the response for structured data listing. All remote backends are refactored to the new convention. Refactored `lsjson` to parse HTML response from remote backend to list items from it. Also let `lsjson` returns each item as a chunk. Similarly, `lsf`, which uses `lsjson`, returns each item as a chunk. Added `http` backend to use similar logic to `lsjson` to handle many HTML index pages. Added `serve` command to serve a remote from config. Only `http` is supported for now.
- Loading branch information
Showing
33 changed files
with
1,765 additions
and
659 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
node_modules | ||
package.json | ||
package-lock.json | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,27 @@ | ||
import { join } from "../../deps.ts"; | ||
import { assert } from "../../dev_deps.ts"; | ||
|
||
import { fetch } from "./main.ts"; | ||
import backend from "./main.ts"; | ||
|
||
Deno.test("local path", async () => { | ||
const requestInit = { | ||
method: "HEAD", | ||
method: "GET", | ||
}; | ||
|
||
const files: string[] = []; | ||
|
||
const cwd = Deno.cwd(); | ||
const url = new URL(`/backend?remote=${cwd}`, import.meta.url); | ||
const url = new URL(`/backend/?remote=.`, import.meta.url); | ||
|
||
const request = new Request(url, requestInit); | ||
const { headers, body } = await fetch(request); | ||
|
||
assert(!body, "should not have body"); | ||
const response = await backend.fetch(request); | ||
const html = await response.text(); | ||
|
||
const links = headers.get("Link")?.split(","); | ||
assert(Array.isArray(links), "should have Link headers"); | ||
|
||
let index = 0; | ||
for await (let { name, isDirectory } of Deno.readDir(join(cwd, "backend"))) { | ||
if (isDirectory) { | ||
name += "/"; | ||
} | ||
const link = links![index++]; | ||
assert( | ||
link.includes(`<${encodeURIComponent(name)}>`), | ||
`should have ${name} enclosed between < and > and percent encoded`, | ||
html.includes(` href="${name}`), | ||
`should have link to ${name}`, | ||
); | ||
|
||
const [_, uri] = link.match(/<(.*)>/) || []; | ||
files.push(decodeURIComponent(uri)); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
# Crypt | ||
|
||
`crypt` remotes encrypt and decrypt other remotes. | ||
|
||
A remote of type crypt does not access a storage system directly, but instead | ||
wraps another remote, which in turn accesses the storage system. This is similar | ||
to how alias, union, chunker and a few others work. It makes the usage very | ||
flexible, as you can add a layer, in this case an encryption layer, on top of | ||
any other backend, even in multiple layers. Rclone's functionality can be used | ||
as with any other remote, for example you can mount a crypt remote. | ||
|
||
Accessing a storage system through a crypt remote realizes client-side | ||
encryption, which makes it safe to keep your data in a location you do not trust | ||
will not get compromised. When working against the crypt remote, rclone will | ||
automatically encrypt (before uploading) and decrypt (after downloading) on your | ||
local system as needed on the fly, leaving the data encrypted at rest in the | ||
wrapped remote. If you access the storage system using an application other than | ||
rclone, or access the wrapped remote directly using rclone, there will not be | ||
any encryption/decryption: Downloading existing content will just give you the | ||
encrypted (scrambled) format, and anything you upload will not become encrypted. | ||
|
||
The encryption is a secret-key encryption (also called symmetric key encryption) | ||
algorithm, where a password (or pass phrase) is used to generate real encryption | ||
key. The password can be supplied by user, or you may chose to let rclone | ||
generate one. It will be stored in the configuration file, in a lightly obscured | ||
form. If you are in an environment where you are not able to keep your | ||
configuration secured, you should add configuration encryption as protection. As | ||
long as you have this configuration file, you will be able to decrypt your data. | ||
Without the configuration file, as long as you remember the password (or keep it | ||
in a safe place), you can re-create the configuration and gain access to the | ||
existing data. You may also configure a corresponding remote in a different | ||
installation to access the same data. See below for guidance to changing | ||
password. | ||
|
||
Encryption uses cryptographic salt, to permute the encryption key so that the | ||
same string may be encrypted in different ways. When configuring the crypt | ||
remote it is optional to enter a salt, or to let rclone generate a unique salt. | ||
If omitted, rclone uses a built-in unique string. Normally in cryptography, the | ||
salt is stored together with the encrypted content, and do not have to be | ||
memorized by the user. This is not the case in rclone, because rclone does not | ||
store any additional information on the remotes. Use of custom salt is | ||
effectively a second password that must be memorized. | ||
|
||
File content encryption is performed using NaCl SecretBox, based on XSalsa20 | ||
cipher and Poly1305 for integrity. Names (file- and directory names) are also | ||
encrypted by default, but this has some implications and is therefore possible | ||
to be turned off. | ||
|
||
### Standard options | ||
|
||
Here are the Standard options specific to crypt (Encrypt/Decrypt a remote). | ||
|
||
#### --crypt-remote | ||
|
||
Remote to encrypt/decrypt. | ||
|
||
Normally should contain a ':' and a path, e.g. "myremote:path/to/dir", | ||
"myremote:bucket" or maybe "myremote:" (not recommended). | ||
|
||
Properties: | ||
|
||
- Config: remote | ||
- Env Var: RCLONE_CRYPT_REMOTE | ||
- Type: string | ||
- Required: true | ||
|
||
#### --crypt-password | ||
|
||
Password or pass phrase for encryption. | ||
|
||
**NB** Input to this must be obscured - see [obscure](/cmd/obscure/). | ||
|
||
Properties: | ||
|
||
- Config: password | ||
- Env Var: RCLONE_CRYPT_PASSWORD | ||
- Type: string | ||
- Required: true | ||
|
||
#### --crypt-password2 | ||
|
||
Password or pass phrase for salt. | ||
|
||
Optional but recommended. Should be different to the previous password. | ||
|
||
**NB** Input to this must be obscured - see [obscure](/cmd/obscure/). | ||
|
||
Properties: | ||
|
||
- Config: password2 | ||
- Env Var: RCLONE_CRYPT_PASSWORD2 | ||
- Type: string | ||
- Required: false |
Oops, something went wrong.