简介
GoIndex 是一个部署在 CloudFlare Workers 小程序。可以将 Google Drive 文件以目录形式列出,并直连下载。流量走 CloudFlare ,网速由 CloudFlare 决定。
安装部署
方案1
- 打开 https://install.gd.workers.dev/ ,点击获取认证码。
- 登录成功后,获得一串代码,复制保存。
- 打开:https://drive.google.com/ ,并登录 Google 账户。
- 新建一个文件夹,右击共享出来。
- 回到GoIndex安装界面,在这里输入 Auth 认证码(通过认证连接获取认证码)、目录id(即
https://drive.google.com/drive/folders/{这后面代码就是id})
以及想要加密访问的话可以设置一个密码,最后点击生成代码。 - 打开 cloudflare,然后添加域名
- 点击wokers,然后点击进入新的控制面板。
- 可以先绑定一个二级域名,免费的二级域名,后期不能更改。
- 绑定成功后,点击进入到应用代码部署页面,将上面生成的代码复制粘贴进去
- 如果想绑定自己的域名,就需要先将自己的域名转到cloudflare,然后点自己的域名,解析一个A记录,IP地址随意。
- 然后在上方找到
Workers
,选择后,点击页面下的Add route
,进行如下设置。 - 按照图中的格式,填上自己的域名,并选择对应的
Workers
程序即可。
方案2
- 获取GDrive客户端
先启用Google Drive API,启用地址:点击进入,注意这里使用个人账号操作。 - 创建一个OAuth client ID,创建地址:点击进入。应用类型选择其他(Other),名称自己填,这里示例为 GoIndex 。
- 然后你会获得自己的客户端ID和客户端密钥,再复制下来。
使用 Rclone 来获取
refresh_token
,先登录VPS,先安装依赖,使用命令:#CentOS系统 yum install p7zip unzip -y #Debian/Ubuntu系统 apt install -y p7zip-full
再安装Rclone,使用命令:
curl https://rclone.org/install.sh | bash
开始配置,使用命令:
rclone config
- 会出现以下信息:
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n
name> Rats #配置名称,随便填
Type of storage to configure.
Enter a string value. Press Enter for the default ("").
Choose a number from below, or type in your own value
1 / 1Fichier
\ "fichier"
2 / Alias for an existing remote
\ "alias"
3 / Amazon Drive
\ "amazon cloud drive"
4 / Amazon S3 Compliant Storage Provider (AWS, Alibaba, Ceph, Digital Ocean, Dreamhost, IBM COS, Minio, etc)
\ "s3"
5 / Backblaze B2
\ "b2"
6 / Box
\ "box"
7 / Cache a remote
\ "cache"
8 / Dropbox
\ "dropbox"
9 / Encrypt/Decrypt a remote
\ "crypt"
10 / FTP Connection
\ "ftp"
11 / Google Cloud Storage (this is not Google Drive)
\ "google cloud storage"
12 / Google Drive
\ "drive"
13 / Google Photos
\ "google photos"
14 / Hubic
\ "hubic"
15 / JottaCloud
\ "jottacloud"
16 / Koofr
\ "koofr"
17 / Local Disk
\ "local"
18 / Mega
\ "mega"
19 / Microsoft Azure Blob Storage
\ "azureblob"
20 / Microsoft OneDrive
\ "onedrive"
21 / OpenDrive
\ "opendrive"
22 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
\ "swift"
23 / Pcloud
\ "pcloud"
24 / Put.io
\ "putio"
25 / QingCloud Object Storage
\ "qingstor"
26 / SSH/SFTP Connection
\ "sftp"
27 / Union merges the contents of several remotes
\ "union"
28 / Webdav
\ "webdav"
29 / Yandex Disk
\ "yandex"
30 / http Connection
\ "http"
31 / premiumize.me
\ "premiumizeme"
Storage> 12 #选择12,Google Drive
client_id> 850428 #填上你的Google Drive客户端ID
client_secret> D72gPc #填上你的Google Drive客户端密匙
Choose a number from below, or type in your own value
1 / Full access all files, excluding Application Data Folder.
\ "drive"
2 / Read-only access to file metadata and file contents.
\ "drive.readonly"
/ Access to files created by rclone only.
3 | These are visible in the drive website.
| File authorization is revoked when the user deauthorizes the app.
\ "drive.file"
/ Allows read and write access to the Application Data folder.
4 | This is not visible in the drive website.
\ "drive.appfolder"
/ Allows read-only access to file metadata but
5 | does not allow any access to read or download file content.
\ "drive.metadata.readonly"
scope> 1
ID of the root folder
Leave blank normally.
Fill in to access "Computers" folders. (see docs).
Enter a string value. Press Enter for the default ("").
root_folder_id>
Service Account Credentials JSON file path
Leave blank normally.
Needed only if you want use SA instead of interactive login.
Enter a string value. Press Enter for the default ("").
service_account_file>
Edit advanced config? (y/n)
y) Yes
n) No
y/n> n #输入n
Remote config
Use auto config?
* Say Y if not sure
* Say N if you are working on a remote or headless machine
y) Yes
n) No
y/n> n #输入n
If your browser doesn't open automatically go to the following link: https://accounts.google.com/o/ #打开该地址获取code
Log in and authorize rclone for access
Enter verification code>hjdd #输入你获取到的code
Configure this as a team drive?
y) Yes
n) No
y/n> n #输入n
--------------------
[Rats]
type = drive
client_id = 85042871
client_secret = D72gPc
scope = drive
token = {"access_token":"y902Z"} #记住里面的refresh_token参数
--------------------
y) Yes this is OK
e) Edit this remote
d) Delete this remote
y/e/d> y #输入y
Current remotes:
Name Type
==== ====
Rats drive
e) Edit existing remote
n) New remote
d) Delete remote
r) Rename remote
c) Copy remote
s) Set configuration password
q) Quit config
e/n/d/r/c/s/q> q #输入q保存退出
此时我们在配置过程中就获取到了 refresh_token
参数,如果忘了的可以查看配置文件。不知道配置文件在哪的,可以使用命令:
rclone config file | grep rclone.conf
Workers 代码可以点击该地址查看→传送门,先复制代码,部分修改可参考上面,不同的是,需要填上自己的api信息,如下:
#填上自己的api客户端,密匙和获取到的refresh_token “client_id”:“20226481”, “client_secret”:“X4Z3ca8”, “refresh_token”:“”,
最后就可以部署Workers代码了,方法参考上面的快速部署。
整理转载自:Rat's Blog、挖站否
Comment here is closed