LiterMC / go-openbmclapi

OpenBMCLAPI written in Golang
GNU Affero General Public License v3.0
47 stars 22 forks source link

oss模式能否改成302模式-直接跳转 #11

Closed 8MiYile closed 8 months ago

8MiYile commented 9 months ago

因为93哥做了个从webdav内读取 叫做 302模式-来自DAV Screenshot_20240205_235108_com tencent mobileqq 因为93哥走的是第二个模式 他们想要

zyxkad commented 9 months ago

能详细描述一下需求吗,没看懂

8MiYile commented 9 months ago

是这样的,93哥的节点端是写了一个连接到webdav的方案,他就是直接负责上传下载, 上传指的是直接把文件复制上去,和我们用的这个方案差不多,但也有一点差,因为他的方案并不需要用户额外用其他软件挂载 但他那个下载指的是,通过webdav请求一个文件,他会返回一个下载地址,这个下载地址的域名是来自于网盘平台的,然后他就把这个下载地址,挂缓存表并且302出去

来自DAV,这个方法,我明天会给你写一个配置样例

93哥的实现方法在这 https://github.com/bangbang93/openbmclapi/tree/webdav https://github.com/bangbang93/openbmclapi/blob/webdav/src/storage/alist-webdav.storage.ts

zyxkad commented 9 months ago

好,懂了

8MiYile commented 9 months ago

这是一份json配置样例,redir模式和webdav模式

{
    "302-mode": {
        "enable": false,
        "redir": {
            "enable": false,
            "list": [
                {
                    "folder_path": "",
                    "redirect_base": "",
                    "pre-create-measures": false,
                    "possibility": 0
                },
                {
                    "folder_path": "",
                    "redirect_base": "",
                    "pre-create-measures": false,
                    "possibility": 0
                }
            ]
        },
        "webdav": {
            "enable": false,
            "servers": [
                {
                    "name": "alist",
                    "url": "http://127.0.0.1:5244/dav",
                    "user": "",
                    "pass": "",
                    "list": [
                        {
                            "folder_path": "",
                            "pre-create-measures": false,
                            "possibility": 0,
                            "url_cahce_time": "1h"
                        },
                        {
                            "folder_path": "",
                            "pre-create-measures": false,
                            "possibility": 0,
                            "url_cahce_time": "1h"
                        }
                    ]
                },
                {
                    "name": "alist",
                    "url": "http://127.0.0.1:5244/dav",
                    "user": "",
                    "pass": "",
                    "list": [
                        {
                            "folder_path": "",
                            "pre-create-measures": false,
                            "possibility": 0,
                            "url_cahce_time": "1h"
                        },
                        {
                            "folder_path": "",
                            "pre-create-measures": false,
                            "possibility": 0,
                            "url_cahce_time": "1h"
                        }
                    ]
                }
            ]
        }
    }
}

webdav模式的folder_path是指dav内的路径 例如登录我自己的号,挂载路径则是指向 /189Cloud-Family/BMCLAPI-Mirrors 不是指Linux的路径 而是dav地址的 93哥说,这样就省得给alist上公网

8MiYile commented 9 months ago

如果是我自己用的话,我会这样写,这里还是以json为例

{
    "302-mode": {
        "enable": true,
        "webdav": {
            "enable": true,
            "servers": [
                {
                    "name": "8Mi-HomeWLAN_AList",
                    "url": "http://10.0.0.1:5244/dav",
                    "user": "",
                    "pass": "",
                    "list": [
                        {
                            "folder_path": "/189Cloud-Family/BMCLAPI-Mirrors",
                            "pre-create-measures": false,
                            "possibility": 0,
                            "url_cahce_time": "2h55m"
                        },
                        {
                            "folder_path": "/139Cloud/BMCLAPI-Mirrors",
                            "pre-create-measures": false,
                            "possibility": 0,
                            "url_cahce_time": "2h"
                        },
                        {
                            "folder_path": "/WooCloud/BMCLAPI-Mirrors",
                            "pre-create-measures": false,
                            "possibility": 0,
                            "url_cahce_time": "2h"
                        }
                    ]
                }
            ]
        }
    }
}
8MiYile commented 9 months ago

对了 启动检查的时候 dav要做并发扫描

zyxkad commented 9 months ago

如果是我自己用的话,我会这样写,这里还是以json为例

{
    "302-mode": {
        "enable": true,
        "webdav": {
            "enable": true,
            "servers": [
                {
                    "name": "8Mi-HomeWLAN_AList",
                    "url": "http://10.0.0.1:5244/dav",
                    "user": "",
                    "pass": "",
                    "list": [
                        {
                            "folder_path": "/189Cloud-Family/BMCLAPI-Mirrors",
                            "pre-create-measures": false,
                            "possibility": 0,
                            "url_cahce_time": "2h55m"
                        },
                        {
                            "folder_path": "/139Cloud/BMCLAPI-Mirrors",
                            "pre-create-measures": false,
                            "possibility": 0,
                            "url_cahce_time": "2h"
                        },
                        {
                            "folder_path": "/WooCloud/BMCLAPI-Mirrors",
                            "pre-create-measures": false,
                            "possibility": 0,
                            "url_cahce_time": "2h"
                        }
                    ]
                }
            ]
        }
    }
}

话说,一个webdav多个文件夹也可以分流么

zyxkad commented 9 months ago

嵌套太多了,我打算只加一层,如果真的可以这么搞你多copy几次password吧 😅

8MiYile commented 9 months ago

不可以这样,这么多password我要累死啊

8MiYile commented 9 months ago

也能分流的 因为是alist-dav是直出网盘地址

zyxkad commented 9 months ago

啊,如果我没理解错,alist就是在webdav上面套了一层,webdav不会分流,但是子分支alist可以分流?

8MiYile commented 9 months ago

webdav本身不会 但是alist是多网盘架构,只要在alist页面设置了302,webdav工作下,alist是直接返回网盘域名的链接 这个实验是93哥那边总结的

8MiYile commented 9 months ago

果然要铺开测试才能发现很多弊端啊 因为有人跟我报告说扫描rclone挂载的路径很慢(1-10分钟不等),但是93直接对接dav却很快

8MiYile commented 9 months ago

网盘url缓存方面,如果你觉得搓个轮子不好搓的话,可以对接redis

zyxkad commented 9 months ago

@8MiYile 如果有时间先测试一下 https://github.com/LiterMC/go-openbmclapi/releases/v1.7.3-9.rc-1 没有加新功能,但是重写了一大坨代码

另: 该版本缺少自动下载缺失文件的功能,所以如果 run 一个小时没问题就换回1.7.3-8

8MiYile commented 9 months ago

那dav何时安排呢

zyxkad commented 9 months ago

这周会做完的

zyxkad commented 9 months ago

@8MiYile 我看了一下,nodejs的实现是把用户名和密码public出去了,这样真的好么

https://github.com/perry-mitchell/webdav-client/blob/master/source/operations/getFileContents.ts#L94

zyxkad commented 9 months ago

嗯不过alist-webdav不是这样的实现

8MiYile commented 9 months ago

有没有一种可能?这个连接是在内网连接的 就算他的用户名和密码都是明文,但IP地址是内网地址,有什么区别吗? 就算是走公网连接,难道不会套SSL吗?

zyxkad commented 9 months ago

https://github.com/bangbang93/openbmclapi/blob/master/src/storage/webdav.storage.ts#L128

8MiYile commented 9 months ago

没事,我们都在等你更新

zyxkad commented 9 months ago

但IP地址是内网地址,有什么区别吗?

🤔难道webdav不应该是公网的么

zyxkad commented 9 months ago

没事,我们都在等你更新

开学了,更新可能会比较慢 😓

8MiYile commented 9 months ago

webdav本质是http或者https,你说呢,我的那个配置文件写的就是真的

8MiYile commented 9 months ago

啊,你们那个是什么开学时间啊?

zyxkad commented 9 months ago

webdav本质是http或者https,你说呢,我的那个配置文件写的就是真的

啊问题不是这个,问题是纯webdav的选项似乎直接把webdav的用户名&密码直接302返回给最终用户了

zyxkad commented 9 months ago

啊,你们那个是什么开学时间啊?

上周刚开学(

zyxkad commented 9 months ago

@8MiYile 试一下 https://github.com/LiterMC/go-openbmclapi/releases/tag/v1.7.3-9.rc-3

8MiYile commented 9 months ago

你看看你文档内是怎么写的webdav的? 然后调用号密配置后 不应该是直接到路径吗?

8MiYile commented 9 months ago

image 第一步啥情况就405了? image

zyxkad commented 9 months ago

你确定你输入的endpoint支持Webdav格式么?第一个请求是创建文件夹,使用MKCOL方法

8MiYile commented 9 months ago

image 我也在我的RClone确认我的这个写法 是没有问题的

zyxkad commented 9 months ago

不过不重要,如果你的webdav不支持创建文件夹,后面也会接着写入文件的,大概

zyxkad commented 9 months ago

尝试开一下 pre-gen-measure, 然后看看measure文件会不会生成

8MiYile commented 9 months ago

image

8MiYile commented 9 months ago

image 啊? 你这告诉我measure咋生成 文件全写在download外边

zyxkad commented 8 months ago

尝试 https://github.com/LiterMC/go-openbmclapi/releases/tag/v1.8.2-3

zyxkad commented 8 months ago

目前看来没啥问题了