commit
712687370a
2
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
2
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
@ -29,7 +29,7 @@ body:
|
|||||||
Please provide a link to a repo that can reproduce the problem you ran into.
|
Please provide a link to a repo that can reproduce the problem you ran into.
|
||||||
请提供能复现此问题的链接
|
请提供能复现此问题的链接
|
||||||
validations:
|
validations:
|
||||||
required: false
|
required: true
|
||||||
- type: textarea
|
- type: textarea
|
||||||
id: logs
|
id: logs
|
||||||
attributes:
|
attributes:
|
||||||
|
25
.github/workflows/issue_invalid.yml
vendored
Normal file
25
.github/workflows/issue_invalid.yml
vendored
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
name: Issue Invalid
|
||||||
|
|
||||||
|
on:
|
||||||
|
issues:
|
||||||
|
types: [labeled]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
create-comment:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: github.event.label.name == 'invalid'
|
||||||
|
steps:
|
||||||
|
- name: Create comment
|
||||||
|
uses: actions-cool/issues-helper@v2
|
||||||
|
with:
|
||||||
|
actions: 'create-comment'
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
issue-number: ${{ github.event.issue.number }}
|
||||||
|
body: |
|
||||||
|
Hello @${{ github.event.issue.user.login }}, your issue is invalid and will be closed.
|
||||||
|
你好 @${{ github.event.issue.user.login }},你的issue无效,将被关闭。
|
||||||
|
- name: Close issue
|
||||||
|
uses: actions-cool/issues-helper@v2
|
||||||
|
with:
|
||||||
|
actions: 'close-issue'
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
2
.github/workflows/issue_question.yml
vendored
2
.github/workflows/issue_question.yml
vendored
@ -17,4 +17,4 @@ jobs:
|
|||||||
issue-number: ${{ github.event.issue.number }}
|
issue-number: ${{ github.event.issue.number }}
|
||||||
body: |
|
body: |
|
||||||
Hello @${{ github.event.issue.user.login }}, please input issue by template and add detail. Issues labeled by `question` will be closed if no activities in 7 days.
|
Hello @${{ github.event.issue.user.login }}, please input issue by template and add detail. Issues labeled by `question` will be closed if no activities in 7 days.
|
||||||
你好 @${{ github.event.issue.user.login }},请按照issue模板填写, 并详细说明问题/复现步骤/实现思路或提供更多信息等, 7天内未回复issue自动关闭。
|
你好 @${{ github.event.issue.user.login }},请按照issue模板填写, 并详细说明问题/复现步骤/复现链接/实现思路或提供更多信息等, 7天内未回复issue自动关闭。
|
@ -73,6 +73,20 @@ func InitSettings() {
|
|||||||
Description: "text type extensions",
|
Description: "text type extensions",
|
||||||
Group: model.FRONT,
|
Group: model.FRONT,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Key: "audio types",
|
||||||
|
Value: strings.Join(conf.AudioTypes, ","),
|
||||||
|
Type: "string",
|
||||||
|
Description: "audio type extensions",
|
||||||
|
Group: model.FRONT,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Key: "video types",
|
||||||
|
Value: strings.Join(conf.VideoTypes, ","),
|
||||||
|
Type: "string",
|
||||||
|
Description: "video type extensions",
|
||||||
|
Group: model.FRONT,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Key: "d_proxy types",
|
Key: "d_proxy types",
|
||||||
Value: strings.Join(conf.DProxyTypes, ","),
|
Value: strings.Join(conf.DProxyTypes, ","),
|
||||||
|
@ -10,6 +10,7 @@ import (
|
|||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"net/http"
|
"net/http"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Cloud189 struct{}
|
type Cloud189 struct{}
|
||||||
@ -198,6 +199,7 @@ func (driver Cloud189) Link(args base.Args, account *model.Account) (*base.Link,
|
|||||||
} else {
|
} else {
|
||||||
link.Url = resp.FileDownloadUrl
|
link.Url = resp.FileDownloadUrl
|
||||||
}
|
}
|
||||||
|
link.Url = strings.Replace(link.Url, "http://", "https://", 1)
|
||||||
return &link, nil
|
return &link, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -638,7 +638,7 @@ func (driver Cloud189) uploadPerson(file *model.FileStream, parentFile *model.Fi
|
|||||||
r.SetQueryParams(clientSuffix())
|
r.SetQueryParams(clientSuffix())
|
||||||
r.SetFormData(map[string]string{
|
r.SetFormData(map[string]string{
|
||||||
"uploadFileId": fmt.Sprint(createUpload.UploadFileId),
|
"uploadFileId": fmt.Sprint(createUpload.UploadFileId),
|
||||||
"opertype": "1", //5 覆盖
|
"opertype": "5", //5 覆盖 1 重命名
|
||||||
"ResumePolicy": "1",
|
"ResumePolicy": "1",
|
||||||
"isLog": "0",
|
"isLog": "0",
|
||||||
})
|
})
|
||||||
|
@ -121,7 +121,7 @@ func GetDrivers() map[string][]Item {
|
|||||||
{
|
{
|
||||||
Name: "down_proxy_url",
|
Name: "down_proxy_url",
|
||||||
Label: "down_proxy_url",
|
Label: "down_proxy_url",
|
||||||
Type: TypeString,
|
Type: TypeText,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "extract_folder",
|
Name: "extract_folder",
|
||||||
|
@ -21,6 +21,7 @@ const (
|
|||||||
TypeSelect = "select"
|
TypeSelect = "select"
|
||||||
TypeBool = "bool"
|
TypeBool = "bool"
|
||||||
TypeNumber = "number"
|
TypeNumber = "number"
|
||||||
|
TypeText = "text"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -73,8 +73,8 @@ func (driver GoogleDrive) FormatFile(file *File, account *model.Account) *model.
|
|||||||
f.Type = utils.GetFileType(filepath.Ext(file.Name))
|
f.Type = utils.GetFileType(filepath.Ext(file.Name))
|
||||||
}
|
}
|
||||||
if file.ThumbnailLink != "" {
|
if file.ThumbnailLink != "" {
|
||||||
if account.DownProxyUrl != "" {
|
if account.APIProxyUrl != "" {
|
||||||
f.Thumbnail = fmt.Sprintf("%s/%s", account.DownProxyUrl, file.ThumbnailLink)
|
f.Thumbnail = fmt.Sprintf("%s/%s", account.APIProxyUrl, file.ThumbnailLink)
|
||||||
} else {
|
} else {
|
||||||
f.Thumbnail = file.ThumbnailLink
|
f.Thumbnail = file.ThumbnailLink
|
||||||
}
|
}
|
||||||
|
@ -159,7 +159,7 @@ func GetAccountById(id uint) (*Account, error) {
|
|||||||
func GetAccountFiles() ([]File, error) {
|
func GetAccountFiles() ([]File, error) {
|
||||||
files := make([]File, 0)
|
files := make([]File, 0)
|
||||||
var accounts []Account
|
var accounts []Account
|
||||||
if err := conf.DB.Order("`index`").Find(&accounts).Error; err != nil {
|
if err := conf.DB.Order(columnName("index")).Find(&accounts).Error; err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
for _, v := range accounts {
|
for _, v := range accounts {
|
||||||
@ -179,7 +179,7 @@ func GetAccountFiles() ([]File, error) {
|
|||||||
|
|
||||||
func GetAccounts() ([]Account, error) {
|
func GetAccounts() ([]Account, error) {
|
||||||
var accounts []Account
|
var accounts []Account
|
||||||
if err := conf.DB.Order("`index`").Find(&accounts).Error; err != nil {
|
if err := conf.DB.Order(columnName("index")).Find(&accounts).Error; err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return accounts, nil
|
return accounts, nil
|
||||||
|
@ -50,7 +50,7 @@ func SaveSetting(item SettingItem) error {
|
|||||||
|
|
||||||
func GetSettingsPublic() ([]SettingItem, error) {
|
func GetSettingsPublic() ([]SettingItem, error) {
|
||||||
var items []SettingItem
|
var items []SettingItem
|
||||||
if err := conf.DB.Where("`access` <> ?", 1).Find(&items).Error; err != nil {
|
if err := conf.DB.Where(fmt.Sprintf("%s <> ?", columnName("access")), 1).Find(&items).Error; err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return items, nil
|
return items, nil
|
||||||
@ -58,7 +58,7 @@ func GetSettingsPublic() ([]SettingItem, error) {
|
|||||||
|
|
||||||
func GetSettingsByGroup(group int) ([]SettingItem, error) {
|
func GetSettingsByGroup(group int) ([]SettingItem, error) {
|
||||||
var items []SettingItem
|
var items []SettingItem
|
||||||
if err := conf.DB.Where("`group` = ?", group).Find(&items).Error; err != nil {
|
if err := conf.DB.Where(fmt.Sprintf("%s = ?", columnName("group")), group).Find(&items).Error; err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
items = append([]SettingItem{Version}, items...)
|
items = append([]SettingItem{Version}, items...)
|
||||||
@ -82,7 +82,7 @@ func DeleteSetting(key string) error {
|
|||||||
|
|
||||||
func GetSettingByKey(key string) (*SettingItem, error) {
|
func GetSettingByKey(key string) (*SettingItem, error) {
|
||||||
var items SettingItem
|
var items SettingItem
|
||||||
if err := conf.DB.Where("`key` = ?", key).First(&items).Error; err != nil {
|
if err := conf.DB.Where(fmt.Sprintf("%s = ?", columnName("key")), key).First(&items).Error; err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &items, nil
|
return &items, nil
|
||||||
@ -93,6 +93,14 @@ func LoadSettings() {
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
conf.TextTypes = strings.Split(textTypes.Value, ",")
|
conf.TextTypes = strings.Split(textTypes.Value, ",")
|
||||||
}
|
}
|
||||||
|
audioTypes, err := GetSettingByKey("text types")
|
||||||
|
if err == nil {
|
||||||
|
conf.AudioTypes = strings.Split(audioTypes.Value, ",")
|
||||||
|
}
|
||||||
|
videoTypes, err := GetSettingByKey("text types")
|
||||||
|
if err == nil {
|
||||||
|
conf.VideoTypes = strings.Split(videoTypes.Value, ",")
|
||||||
|
}
|
||||||
dProxyTypes, err := GetSettingByKey("d_proxy types")
|
dProxyTypes, err := GetSettingByKey("d_proxy types")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
conf.DProxyTypes = strings.Split(dProxyTypes.Value, ",")
|
conf.DProxyTypes = strings.Split(dProxyTypes.Value, ",")
|
||||||
|
13
model/util.go
Normal file
13
model/util.go
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/Xhofe/alist/conf"
|
||||||
|
)
|
||||||
|
|
||||||
|
func columnName(name string) string {
|
||||||
|
if conf.Conf.Database.Type == "postgres" {
|
||||||
|
return fmt.Sprintf(`"%s"`, name)
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("`%s`", name)
|
||||||
|
}
|
@ -7,7 +7,6 @@ import (
|
|||||||
"github.com/Xhofe/alist/utils"
|
"github.com/Xhofe/alist/utils"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"path"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func Down(c *gin.Context) {
|
func Down(c *gin.Context) {
|
||||||
@ -19,7 +18,7 @@ func Down(c *gin.Context) {
|
|||||||
common.ErrorResp(c, err, 500)
|
common.ErrorResp(c, err, 500)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if driver.Config().OnlyProxy || account.Proxy || utils.IsContain(conf.DProxyTypes, path.Ext(rawPath)) {
|
if driver.Config().OnlyProxy || account.Proxy || utils.IsContain(conf.DProxyTypes, utils.Ext(rawPath)) {
|
||||||
Proxy(c)
|
Proxy(c)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
"github.com/Xhofe/alist/utils"
|
"github.com/Xhofe/alist/utils"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Pagination(files []model.File, req *common.PathReq) (int, []model.File) {
|
func Pagination(files []model.File, req *common.PathReq) (int, []model.File) {
|
||||||
@ -119,7 +120,7 @@ func Path(c *gin.Context) {
|
|||||||
// 对于中转文件或只能中转,将链接修改为中转链接
|
// 对于中转文件或只能中转,将链接修改为中转链接
|
||||||
if driver.Config().OnlyProxy || account.Proxy {
|
if driver.Config().OnlyProxy || account.Proxy {
|
||||||
if account.DownProxyUrl != "" {
|
if account.DownProxyUrl != "" {
|
||||||
file.Url = fmt.Sprintf("%s%s?sign=%s", account.DownProxyUrl, req.Path, utils.SignWithToken(file.Name, conf.Token))
|
file.Url = fmt.Sprintf("%s%s?sign=%s", strings.Split(account.DownProxyUrl, "\n")[0], req.Path, utils.SignWithToken(file.Name, conf.Token))
|
||||||
} else {
|
} else {
|
||||||
file.Url = fmt.Sprintf("//%s/p%s?sign=%s", c.Request.Host, req.Path, utils.SignWithToken(file.Name, conf.Token))
|
file.Url = fmt.Sprintf("//%s/p%s?sign=%s", c.Request.Host, req.Path, utils.SignWithToken(file.Name, conf.Token))
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
"github.com/go-resty/resty/v2"
|
"github.com/go-resty/resty/v2"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Proxy(c *gin.Context) {
|
func Proxy(c *gin.Context) {
|
||||||
@ -29,7 +30,7 @@ func Proxy(c *gin.Context) {
|
|||||||
// 4. 开启webdav中转(需要验证sign)
|
// 4. 开启webdav中转(需要验证sign)
|
||||||
if !account.Proxy && !driver.Config().OnlyProxy &&
|
if !account.Proxy && !driver.Config().OnlyProxy &&
|
||||||
utils.GetFileType(filepath.Ext(rawPath)) != conf.TEXT &&
|
utils.GetFileType(filepath.Ext(rawPath)) != conf.TEXT &&
|
||||||
!utils.IsContain(conf.DProxyTypes, filepath.Ext(rawPath)) {
|
!utils.IsContain(conf.DProxyTypes, utils.Ext(rawPath)) {
|
||||||
// 只开启了webdav中转,验证sign
|
// 只开启了webdav中转,验证sign
|
||||||
ok := false
|
ok := false
|
||||||
if account.WebdavProxy {
|
if account.WebdavProxy {
|
||||||
@ -43,7 +44,7 @@ func Proxy(c *gin.Context) {
|
|||||||
// 中转时有中转机器使用中转机器,若携带标志位则表明不能再走中转机器了
|
// 中转时有中转机器使用中转机器,若携带标志位则表明不能再走中转机器了
|
||||||
if account.DownProxyUrl != "" && c.Query("d") != "1" {
|
if account.DownProxyUrl != "" && c.Query("d") != "1" {
|
||||||
name := utils.Base(rawPath)
|
name := utils.Base(rawPath)
|
||||||
link := fmt.Sprintf("%s%s?sign=%s", account.DownProxyUrl, rawPath, utils.SignWithToken(name, conf.Token))
|
link := fmt.Sprintf("%s%s?sign=%s", strings.Split(account.DownProxyUrl, "\n")[0], rawPath, utils.SignWithToken(name, conf.Token))
|
||||||
c.Redirect(302, link)
|
c.Redirect(302, link)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ func GetFileType(ext string) int {
|
|||||||
if ext == "" {
|
if ext == "" {
|
||||||
return conf.UNKNOWN
|
return conf.UNKNOWN
|
||||||
}
|
}
|
||||||
ext = strings.ToLower(strings.TrimLeft(ext, "."))
|
ext = strings.ToLower(strings.TrimPrefix(ext, "."))
|
||||||
if IsContain(conf.OfficeTypes, ext) {
|
if IsContain(conf.OfficeTypes, ext) {
|
||||||
return conf.OFFICE
|
return conf.OFFICE
|
||||||
}
|
}
|
||||||
@ -128,10 +128,6 @@ func Split(p string) (string, string) {
|
|||||||
return path.Split(p)
|
return path.Split(p)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FormatName TODO
|
func Ext(name string) string {
|
||||||
func FormatName(name string) string {
|
return strings.TrimPrefix(path.Ext(name), ".")
|
||||||
name = strings.ReplaceAll(name, "/", " ")
|
|
||||||
name = strings.ReplaceAll(name, "#", " ")
|
|
||||||
name = strings.ReplaceAll(name, "?", " ")
|
|
||||||
return name
|
|
||||||
}
|
}
|
||||||
|
@ -13,14 +13,12 @@ func GetSHA1Encode(data string) string {
|
|||||||
return hex.EncodeToString(h.Sum(nil))
|
return hex.EncodeToString(h.Sum(nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetMD5Encode
|
|
||||||
func GetMD5Encode(data string) string {
|
func GetMD5Encode(data string) string {
|
||||||
h := md5.New()
|
h := md5.New()
|
||||||
h.Write([]byte(data))
|
h.Write([]byte(data))
|
||||||
return hex.EncodeToString(h.Sum(nil))
|
return hex.EncodeToString(h.Sum(nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get16MD5Encode
|
|
||||||
func Get16MD5Encode(data string) string {
|
func Get16MD5Encode(data string) string {
|
||||||
return GetMD5Encode(data)[8:24]
|
return GetMD5Encode(data)[8:24]
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user