mirror of https://github.com/Xhofe/alist
🔥 delete proxy interface
parent
6f14d0eb5c
commit
feb42f1f4b
|
@ -15,7 +15,6 @@ import (
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
@ -197,9 +196,9 @@ func (driver Pan123) Path(path string, account *model.Account) (*model.File, []m
|
||||||
return nil, files, nil
|
return nil, files, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (driver Pan123) Proxy(r *http.Request, account *model.Account) {
|
//func (driver Pan123) Proxy(r *http.Request, account *model.Account) {
|
||||||
r.Header.Del("origin")
|
// r.Header.Del("origin")
|
||||||
}
|
//}
|
||||||
|
|
||||||
func (driver Pan123) Preview(path string, account *model.Account) (interface{}, error) {
|
func (driver Pan123) Preview(path string, account *model.Account) (interface{}, error) {
|
||||||
return nil, base.ErrNotSupport
|
return nil, base.ErrNotSupport
|
||||||
|
|
|
@ -162,9 +162,9 @@ func (driver Cloud139) Path(path string, account *model.Account) (*model.File, [
|
||||||
return nil, files, nil
|
return nil, files, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (driver Cloud139) Proxy(r *http.Request, account *model.Account) {
|
//func (driver Cloud139) Proxy(r *http.Request, account *model.Account) {
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
|
||||||
func (driver Cloud139) Preview(path string, account *model.Account) (interface{}, error) {
|
func (driver Cloud139) Preview(path string, account *model.Account) (interface{}, error) {
|
||||||
return nil, base.ErrNotSupport
|
return nil, base.ErrNotSupport
|
||||||
|
|
|
@ -7,7 +7,6 @@ import (
|
||||||
"github.com/Xhofe/alist/model"
|
"github.com/Xhofe/alist/model"
|
||||||
"github.com/Xhofe/alist/utils"
|
"github.com/Xhofe/alist/utils"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"net/http"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -198,9 +197,9 @@ func (driver Cloud189) Path(path string, account *model.Account) (*model.File, [
|
||||||
return nil, files, nil
|
return nil, files, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (driver Cloud189) Proxy(r *http.Request, account *model.Account) {
|
//func (driver Cloud189) Proxy(r *http.Request, account *model.Account) {
|
||||||
r.Header.Del("Origin")
|
// r.Header.Del("Origin")
|
||||||
}
|
//}
|
||||||
|
|
||||||
func (driver Cloud189) Preview(path string, account *model.Account) (interface{}, error) {
|
func (driver Cloud189) Preview(path string, account *model.Account) (interface{}, error) {
|
||||||
return nil, base.ErrNotSupport
|
return nil, base.ErrNotSupport
|
||||||
|
|
|
@ -190,6 +190,12 @@ func (driver AliDrive) Link(args base.Args, account *model.Account) (*base.Link,
|
||||||
return nil, fmt.Errorf("%s", e.Message)
|
return nil, fmt.Errorf("%s", e.Message)
|
||||||
}
|
}
|
||||||
return &base.Link{
|
return &base.Link{
|
||||||
|
Headers: []base.Header{
|
||||||
|
{
|
||||||
|
Name: "Referer",
|
||||||
|
Value: "https://www.aliyundrive.com/",
|
||||||
|
},
|
||||||
|
},
|
||||||
Url: resp["url"].(string),
|
Url: resp["url"].(string),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
@ -211,10 +217,10 @@ func (driver AliDrive) Path(path string, account *model.Account) (*model.File, [
|
||||||
return nil, files, nil
|
return nil, files, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (driver AliDrive) Proxy(r *http.Request, account *model.Account) {
|
//func (driver AliDrive) Proxy(r *http.Request, account *model.Account) {
|
||||||
r.Header.Del("Origin")
|
// r.Header.Del("Origin")
|
||||||
r.Header.Set("Referer", "https://www.aliyundrive.com/")
|
// r.Header.Set("Referer", "https://www.aliyundrive.com/")
|
||||||
}
|
//}
|
||||||
|
|
||||||
func (driver AliDrive) Preview(path string, account *model.Account) (interface{}, error) {
|
func (driver AliDrive) Preview(path string, account *model.Account) (interface{}, error) {
|
||||||
file, err := driver.GetFile(path, account)
|
file, err := driver.GetFile(path, account)
|
||||||
|
|
|
@ -7,7 +7,6 @@ import (
|
||||||
"github.com/Xhofe/alist/drivers/base"
|
"github.com/Xhofe/alist/drivers/base"
|
||||||
"github.com/Xhofe/alist/model"
|
"github.com/Xhofe/alist/model"
|
||||||
"github.com/Xhofe/alist/utils"
|
"github.com/Xhofe/alist/utils"
|
||||||
"net/http"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
@ -148,7 +147,7 @@ func (driver Alist) Path(path string, account *model.Account) (*model.File, []mo
|
||||||
return nil, resp.Data.Files, nil
|
return nil, resp.Data.Files, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (driver Alist) Proxy(r *http.Request, account *model.Account) {}
|
//func (driver Alist) Proxy(r *http.Request, account *model.Account) {}
|
||||||
|
|
||||||
func (driver Alist) Preview(path string, account *model.Account) (interface{}, error) {
|
func (driver Alist) Preview(path string, account *model.Account) (interface{}, error) {
|
||||||
var resp PathResp
|
var resp PathResp
|
||||||
|
|
|
@ -13,7 +13,6 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"math"
|
"math"
|
||||||
"net/http"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -170,9 +169,9 @@ func (driver Baidu) Path(path string, account *model.Account) (*model.File, []mo
|
||||||
return nil, files, nil
|
return nil, files, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (driver Baidu) Proxy(r *http.Request, account *model.Account) {
|
//func (driver Baidu) Proxy(r *http.Request, account *model.Account) {
|
||||||
r.Header.Set("User-Agent", "pan.baidu.com")
|
// r.Header.Set("User-Agent", "pan.baidu.com")
|
||||||
}
|
//}
|
||||||
|
|
||||||
func (driver Baidu) Preview(path string, account *model.Account) (interface{}, error) {
|
func (driver Baidu) Preview(path string, account *model.Account) (interface{}, error) {
|
||||||
return nil, base.ErrNotSupport
|
return nil, base.ErrNotSupport
|
||||||
|
|
|
@ -37,8 +37,8 @@ type Driver interface {
|
||||||
Link(args Args, account *model.Account) (*Link, error)
|
Link(args Args, account *model.Account) (*Link, error)
|
||||||
// Path 取路径(文件或文件夹)
|
// Path 取路径(文件或文件夹)
|
||||||
Path(path string, account *model.Account) (*model.File, []model.File, error)
|
Path(path string, account *model.Account) (*model.File, []model.File, error)
|
||||||
// Proxy 代理处理
|
// Deprecated Proxy 代理处理
|
||||||
Proxy(r *http.Request, account *model.Account)
|
//Proxy(r *http.Request, account *model.Account)
|
||||||
// Preview 预览
|
// Preview 预览
|
||||||
Preview(path string, account *model.Account) (interface{}, error)
|
Preview(path string, account *model.Account) (interface{}, error)
|
||||||
// MakeDir 创建文件夹
|
// MakeDir 创建文件夹
|
||||||
|
|
|
@ -7,7 +7,6 @@ import (
|
||||||
"github.com/Xhofe/alist/utils"
|
"github.com/Xhofe/alist/utils"
|
||||||
"github.com/jlaffaye/ftp"
|
"github.com/jlaffaye/ftp"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"net/http"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -186,9 +185,9 @@ func (driver FTP) Path(path string, account *model.Account) (*model.File, []mode
|
||||||
return nil, files, nil
|
return nil, files, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (driver FTP) Proxy(r *http.Request, account *model.Account) {
|
//func (driver FTP) Proxy(r *http.Request, account *model.Account) {
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
|
||||||
func (driver FTP) Preview(path string, account *model.Account) (interface{}, error) {
|
func (driver FTP) Preview(path string, account *model.Account) (interface{}, error) {
|
||||||
return nil, base.ErrNotSupport
|
return nil, base.ErrNotSupport
|
||||||
|
|
|
@ -8,7 +8,6 @@ import (
|
||||||
"github.com/Xhofe/alist/utils"
|
"github.com/Xhofe/alist/utils"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -178,9 +177,9 @@ func (driver GoogleDrive) Path(path string, account *model.Account) (*model.File
|
||||||
return nil, files, nil
|
return nil, files, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (driver GoogleDrive) Proxy(r *http.Request, account *model.Account) {
|
//func (driver GoogleDrive) Proxy(r *http.Request, account *model.Account) {
|
||||||
r.Header.Add("Authorization", "Bearer "+account.AccessToken)
|
// r.Header.Add("Authorization", "Bearer "+account.AccessToken)
|
||||||
}
|
//}
|
||||||
|
|
||||||
func (driver GoogleDrive) Preview(path string, account *model.Account) (interface{}, error) {
|
func (driver GoogleDrive) Preview(path string, account *model.Account) (interface{}, error) {
|
||||||
return nil, base.ErrNotSupport
|
return nil, base.ErrNotSupport
|
||||||
|
|
|
@ -6,7 +6,6 @@ import (
|
||||||
"github.com/Xhofe/alist/model"
|
"github.com/Xhofe/alist/model"
|
||||||
"github.com/Xhofe/alist/utils"
|
"github.com/Xhofe/alist/utils"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"net/http"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -159,9 +158,9 @@ func (driver Lanzou) Path(path string, account *model.Account) (*model.File, []m
|
||||||
return nil, files, nil
|
return nil, files, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (driver Lanzou) Proxy(r *http.Request, account *model.Account) {
|
//func (driver Lanzou) Proxy(r *http.Request, account *model.Account) {
|
||||||
r.Header.Del("Origin")
|
// r.Header.Del("Origin")
|
||||||
}
|
//}
|
||||||
|
|
||||||
func (driver Lanzou) Preview(path string, account *model.Account) (interface{}, error) {
|
func (driver Lanzou) Preview(path string, account *model.Account) (interface{}, error) {
|
||||||
return nil, base.ErrNotSupport
|
return nil, base.ErrNotSupport
|
||||||
|
|
|
@ -17,7 +17,6 @@ import (
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
@ -148,9 +147,9 @@ func (driver MediaTrack) Path(path string, account *model.Account) (*model.File,
|
||||||
return nil, files, nil
|
return nil, files, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (driver MediaTrack) Proxy(r *http.Request, account *model.Account) {
|
//func (driver MediaTrack) Proxy(r *http.Request, account *model.Account) {
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
|
||||||
func (driver MediaTrack) Preview(path string, account *model.Account) (interface{}, error) {
|
func (driver MediaTrack) Preview(path string, account *model.Account) (interface{}, error) {
|
||||||
return nil, base.ErrNotImplement
|
return nil, base.ErrNotImplement
|
||||||
|
|
|
@ -9,7 +9,6 @@ import (
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -156,9 +155,9 @@ func (driver Native) Path(path string, account *model.Account) (*model.File, []m
|
||||||
return nil, files, nil
|
return nil, files, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (driver Native) Proxy(r *http.Request, account *model.Account) {
|
//func (driver Native) Proxy(r *http.Request, account *model.Account) {
|
||||||
// unnecessary
|
// // unnecessary
|
||||||
}
|
//}
|
||||||
|
|
||||||
func (driver Native) Preview(path string, account *model.Account) (interface{}, error) {
|
func (driver Native) Preview(path string, account *model.Account) (interface{}, error) {
|
||||||
return nil, base.ErrNotSupport
|
return nil, base.ErrNotSupport
|
||||||
|
|
|
@ -7,7 +7,6 @@ import (
|
||||||
"github.com/Xhofe/alist/model"
|
"github.com/Xhofe/alist/model"
|
||||||
"github.com/Xhofe/alist/utils"
|
"github.com/Xhofe/alist/utils"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"net/http"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -201,9 +200,9 @@ func (driver Onedrive) Path(path string, account *model.Account) (*model.File, [
|
||||||
return nil, files, nil
|
return nil, files, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (driver Onedrive) Proxy(r *http.Request, account *model.Account) {
|
//func (driver Onedrive) Proxy(r *http.Request, account *model.Account) {
|
||||||
r.Header.Del("Origin")
|
// r.Header.Del("Origin")
|
||||||
}
|
//}
|
||||||
|
|
||||||
func (driver Onedrive) Preview(path string, account *model.Account) (interface{}, error) {
|
func (driver Onedrive) Preview(path string, account *model.Account) (interface{}, error) {
|
||||||
return nil, base.ErrNotSupport
|
return nil, base.ErrNotSupport
|
||||||
|
|
|
@ -12,7 +12,6 @@ import (
|
||||||
"github.com/aws/aws-sdk-go/service/s3/s3manager"
|
"github.com/aws/aws-sdk-go/service/s3/s3manager"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"net/http"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
@ -142,9 +141,9 @@ func (driver PikPak) Path(path string, account *model.Account) (*model.File, []m
|
||||||
return nil, files, nil
|
return nil, files, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (driver PikPak) Proxy(r *http.Request, account *model.Account) {
|
//func (driver PikPak) Proxy(r *http.Request, account *model.Account) {
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
|
||||||
func (driver PikPak) Preview(path string, account *model.Account) (interface{}, error) {
|
func (driver PikPak) Preview(path string, account *model.Account) (interface{}, error) {
|
||||||
return nil, base.ErrNotSupport
|
return nil, base.ErrNotSupport
|
||||||
|
|
|
@ -9,7 +9,6 @@ import (
|
||||||
"github.com/aws/aws-sdk-go/service/s3"
|
"github.com/aws/aws-sdk-go/service/s3"
|
||||||
"github.com/aws/aws-sdk-go/service/s3/s3manager"
|
"github.com/aws/aws-sdk-go/service/s3/s3manager"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"net/http"
|
|
||||||
"net/url"
|
"net/url"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
|
@ -189,9 +188,9 @@ func (driver S3) Path(path string, account *model.Account) (*model.File, []model
|
||||||
return nil, files, nil
|
return nil, files, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (driver S3) Proxy(r *http.Request, account *model.Account) {
|
//func (driver S3) Proxy(r *http.Request, account *model.Account) {
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
|
||||||
func (driver S3) Preview(path string, account *model.Account) (interface{}, error) {
|
func (driver S3) Preview(path string, account *model.Account) (interface{}, error) {
|
||||||
return nil, base.ErrNotSupport
|
return nil, base.ErrNotSupport
|
||||||
|
|
|
@ -7,7 +7,6 @@ import (
|
||||||
"github.com/Xhofe/alist/model"
|
"github.com/Xhofe/alist/model"
|
||||||
"github.com/Xhofe/alist/utils"
|
"github.com/Xhofe/alist/utils"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"net/http"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
|
@ -154,9 +153,9 @@ func (driver Shandian) Path(path string, account *model.Account) (*model.File, [
|
||||||
return nil, files, nil
|
return nil, files, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (driver Shandian) Proxy(r *http.Request, account *model.Account) {
|
//func (driver Shandian) Proxy(r *http.Request, account *model.Account) {
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
|
||||||
func (driver Shandian) Preview(path string, account *model.Account) (interface{}, error) {
|
func (driver Shandian) Preview(path string, account *model.Account) (interface{}, error) {
|
||||||
return nil, base.ErrNotSupport
|
return nil, base.ErrNotSupport
|
||||||
|
|
|
@ -6,7 +6,6 @@ import (
|
||||||
"github.com/Xhofe/alist/model"
|
"github.com/Xhofe/alist/model"
|
||||||
"github.com/Xhofe/alist/utils"
|
"github.com/Xhofe/alist/utils"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"net/http"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -149,9 +148,9 @@ func (driver Teambition) Path(path string, account *model.Account) (*model.File,
|
||||||
return nil, files, nil
|
return nil, files, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (driver Teambition) Proxy(r *http.Request, account *model.Account) {
|
//func (driver Teambition) Proxy(r *http.Request, account *model.Account) {
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
|
||||||
func (driver Teambition) Preview(path string, account *model.Account) (interface{}, error) {
|
func (driver Teambition) Preview(path string, account *model.Account) (interface{}, error) {
|
||||||
return nil, base.ErrNotSupport
|
return nil, base.ErrNotSupport
|
||||||
|
|
|
@ -5,7 +5,6 @@ import (
|
||||||
"github.com/Xhofe/alist/drivers/base"
|
"github.com/Xhofe/alist/drivers/base"
|
||||||
"github.com/Xhofe/alist/model"
|
"github.com/Xhofe/alist/model"
|
||||||
"github.com/Xhofe/alist/utils"
|
"github.com/Xhofe/alist/utils"
|
||||||
"net/http"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -137,9 +136,9 @@ func (driver WebDav) Path(path string, account *model.Account) (*model.File, []m
|
||||||
return nil, files, nil
|
return nil, files, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (driver WebDav) Proxy(r *http.Request, account *model.Account) {
|
//func (driver WebDav) Proxy(r *http.Request, account *model.Account) {
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
|
||||||
func (driver WebDav) Preview(path string, account *model.Account) (interface{}, error) {
|
func (driver WebDav) Preview(path string, account *model.Account) (interface{}, error) {
|
||||||
return nil, base.ErrNotSupport
|
return nil, base.ErrNotSupport
|
||||||
|
|
|
@ -144,9 +144,9 @@ func (driver Yandex) Path(path string, account *model.Account) (*model.File, []m
|
||||||
return nil, files, nil
|
return nil, files, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (driver Yandex) Proxy(r *http.Request, account *model.Account) {
|
//func (driver Yandex) Proxy(r *http.Request, account *model.Account) {
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
|
||||||
func (driver Yandex) Preview(path string, account *model.Account) (interface{}, error) {
|
func (driver Yandex) Preview(path string, account *model.Account) (interface{}, error) {
|
||||||
return nil, base.ErrNotSupport
|
return nil, base.ErrNotSupport
|
||||||
|
|
|
@ -120,7 +120,9 @@ func Proxy(c *gin.Context) {
|
||||||
for h, val := range r.Header {
|
for h, val := range r.Header {
|
||||||
req.Header[h] = val
|
req.Header[h] = val
|
||||||
}
|
}
|
||||||
driver.Proxy(req, account)
|
for _, header := range link.Headers {
|
||||||
|
req.Header.Set(header.Name, header.Value)
|
||||||
|
}
|
||||||
res, err := HttpClient.Do(req)
|
res, err := HttpClient.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
common.ErrorResp(c, err, 500)
|
common.ErrorResp(c, err, 500)
|
||||||
|
|
Loading…
Reference in New Issue