mirror of https://github.com/Xhofe/alist
🔨 switch fiber to gin
parent
65ec4e3611
commit
cf07b3921c
19
alist.go
19
alist.go
|
@ -5,12 +5,9 @@ import (
|
|||
"fmt"
|
||||
"github.com/Xhofe/alist/bootstrap"
|
||||
"github.com/Xhofe/alist/conf"
|
||||
"github.com/Xhofe/alist/public"
|
||||
"github.com/Xhofe/alist/server"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/gofiber/fiber/v2/middleware/filesystem"
|
||||
"github.com/gin-gonic/gin"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -34,14 +31,14 @@ func main() {
|
|||
return
|
||||
}
|
||||
Init()
|
||||
app := fiber.New()
|
||||
server.InitApiRouter(app)
|
||||
app.Use("/", filesystem.New(filesystem.Config{
|
||||
Root: http.FS(public.Public),
|
||||
NotFoundFile: "index.html",
|
||||
}))
|
||||
if !conf.Debug {
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
}
|
||||
r := gin.Default()
|
||||
server.InitApiRouter(r)
|
||||
|
||||
log.Info("starting server")
|
||||
err := app.Listen(fmt.Sprintf(":%d", conf.Conf.Port))
|
||||
err := r.Run(fmt.Sprintf("%s:%d", conf.Conf.Address, conf.Conf.Port))
|
||||
if err != nil {
|
||||
log.Errorf("failed to start: %s", err.Error())
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@ import (
|
|||
"github.com/Xhofe/alist/conf"
|
||||
"github.com/Xhofe/alist/model"
|
||||
"github.com/Xhofe/alist/utils"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-resty/resty/v2"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/robfig/cron/v3"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"path/filepath"
|
||||
|
@ -103,9 +103,9 @@ func (a AliDrive) Items() []Item {
|
|||
}
|
||||
}
|
||||
|
||||
func (a AliDrive) Proxy(ctx *fiber.Ctx) {
|
||||
ctx.Request().Header.Del("Origin")
|
||||
ctx.Request().Header.Set("Referer", "https://www.aliyundrive.com/")
|
||||
func (a AliDrive) Proxy(c *gin.Context) {
|
||||
c.Request.Header.Del("Origin")
|
||||
c.Request.Header.Set("Referer", "https://www.aliyundrive.com/")
|
||||
}
|
||||
|
||||
type AliRespError struct {
|
||||
|
|
|
@ -2,7 +2,7 @@ package drivers
|
|||
|
||||
import (
|
||||
"github.com/Xhofe/alist/model"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type Driver interface {
|
||||
|
@ -10,7 +10,7 @@ type Driver interface {
|
|||
Path(path string, account *model.Account) (*model.File, []*model.File, error)
|
||||
Link(path string, account *model.Account) (string, error)
|
||||
Save(account *model.Account, old *model.Account) error
|
||||
Proxy(ctx *fiber.Ctx)
|
||||
Proxy(c *gin.Context)
|
||||
Preview(path string, account *model.Account) (interface{}, error)
|
||||
// TODO
|
||||
//MakeDir(path string, account *model.Account) error
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"github.com/Xhofe/alist/conf"
|
||||
"github.com/Xhofe/alist/model"
|
||||
"github.com/Xhofe/alist/utils"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/gin-gonic/gin"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
@ -31,7 +31,7 @@ func (n Native) Items() []Item {
|
|||
}
|
||||
}
|
||||
|
||||
func (n Native) Proxy(ctx *fiber.Ctx) {
|
||||
func (n Native) Proxy(c *gin.Context) {
|
||||
// unnecessary
|
||||
}
|
||||
|
||||
|
|
|
@ -5,8 +5,8 @@ import (
|
|||
"github.com/Xhofe/alist/conf"
|
||||
"github.com/Xhofe/alist/model"
|
||||
"github.com/Xhofe/alist/utils"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-resty/resty/v2"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/robfig/cron/v3"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
@ -295,7 +295,7 @@ func (o Onedrive) Save(account *model.Account, old *model.Account) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (o Onedrive) Proxy(ctx *fiber.Ctx) {
|
||||
func (o Onedrive) Proxy(c *gin.Context) {
|
||||
|
||||
}
|
||||
|
||||
|
|
19
go.mod
19
go.mod
|
@ -4,9 +4,9 @@ go 1.17
|
|||
|
||||
require (
|
||||
github.com/eko/gocache/v2 v2.1.0
|
||||
github.com/gin-gonic/gin v1.7.4
|
||||
github.com/go-playground/validator/v10 v10.9.0
|
||||
github.com/go-resty/resty/v2 v2.6.0
|
||||
github.com/gofiber/fiber/v2 v2.20.2
|
||||
github.com/patrickmn/go-cache v2.1.0+incompatible
|
||||
github.com/robfig/cron/v3 v3.0.0
|
||||
github.com/sirupsen/logrus v1.8.1
|
||||
|
@ -18,17 +18,18 @@ require (
|
|||
|
||||
require (
|
||||
github.com/XiaoMi/pegasus-go-client v0.0.0-20210427083443-f3b6b08bc4c2 // indirect
|
||||
github.com/andybalholm/brotli v1.0.3 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/bradfitz/gomemcache v0.0.0-20190913173617-a41fca850d0b // indirect
|
||||
github.com/cenkalti/backoff/v4 v4.1.0 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.1.1 // indirect
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||
github.com/gin-contrib/cors v1.3.1 // indirect
|
||||
github.com/gin-contrib/sse v0.1.0 // indirect
|
||||
github.com/go-playground/locales v0.14.0 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.0 // indirect
|
||||
github.com/go-redis/redis/v8 v8.9.0 // indirect
|
||||
github.com/go-sql-driver/mysql v1.6.0 // indirect
|
||||
github.com/golang/protobuf v1.4.3 // indirect
|
||||
github.com/golang/protobuf v1.5.2 // indirect
|
||||
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
|
||||
github.com/jackc/pgconn v1.10.0 // indirect
|
||||
github.com/jackc/pgio v1.0.0 // indirect
|
||||
|
@ -39,19 +40,20 @@ require (
|
|||
github.com/jackc/pgx/v4 v4.13.0 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/jinzhu/now v1.1.2 // indirect
|
||||
github.com/klauspost/compress v1.13.6 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/leodido/go-urn v1.2.1 // indirect
|
||||
github.com/mattn/go-isatty v0.0.14 // indirect
|
||||
github.com/mattn/go-sqlite3 v1.14.9 // indirect
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/pegasus-kv/thrift v0.13.0 // indirect
|
||||
github.com/prometheus/client_golang v1.10.0 // indirect
|
||||
github.com/prometheus/client_model v0.2.0 // indirect
|
||||
github.com/prometheus/common v0.18.0 // indirect
|
||||
github.com/prometheus/procfs v0.6.0 // indirect
|
||||
github.com/spf13/cast v1.3.1 // indirect
|
||||
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
||||
github.com/valyala/fasthttp v1.31.0 // indirect
|
||||
github.com/valyala/tcplisten v1.0.0 // indirect
|
||||
github.com/ugorji/go/codec v1.2.6 // indirect
|
||||
go.opentelemetry.io/otel v0.20.0 // indirect
|
||||
go.opentelemetry.io/otel/metric v0.20.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v0.20.0 // indirect
|
||||
|
@ -59,8 +61,9 @@ require (
|
|||
golang.org/x/net v0.0.0-20210510120150-4163338589ed // indirect
|
||||
golang.org/x/sys v0.0.0-20211023085530-d6a326fbbf70 // indirect
|
||||
golang.org/x/text v0.3.7 // indirect
|
||||
google.golang.org/protobuf v1.23.0 // indirect
|
||||
google.golang.org/protobuf v1.27.1 // indirect
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
|
||||
gopkg.in/tomb.v2 v2.0.0-20161208151619-d5d1b5820637 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
k8s.io/apimachinery v0.0.0-20191123233150-4c4803ed55e3 // indirect
|
||||
)
|
||||
|
|
68
go.sum
68
go.sum
|
@ -22,9 +22,6 @@ github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRF
|
|||
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
|
||||
github.com/allegro/bigcache/v2 v2.2.5 h1:mRc8r6GQjuJsmSKQNPsR5jQVXc8IJ1xsW5YXUYMLfqI=
|
||||
github.com/allegro/bigcache/v2 v2.2.5/go.mod h1:FppZsIO+IZk7gCuj5FiIDHGygD9xvWQcqg1uIPMb6tY=
|
||||
github.com/andybalholm/brotli v1.0.2/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y=
|
||||
github.com/andybalholm/brotli v1.0.3 h1:fpcw+r1N1h0Poc1F/pHbW40cUm/lMEQslZtCkBQ0UnM=
|
||||
github.com/andybalholm/brotli v1.0.3/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
|
||||
github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
|
||||
github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
|
||||
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
|
||||
|
@ -101,6 +98,13 @@ github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWo
|
|||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||
github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||
github.com/gin-contrib/cors v1.3.1 h1:doAsuITavI4IOcd0Y19U4B+O0dNWihRyX//nn4sEmgA=
|
||||
github.com/gin-contrib/cors v1.3.1/go.mod h1:jjEJ4268OPZUcU7k9Pm653S7lXUGcqMADzFA61xsmDk=
|
||||
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
|
||||
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
||||
github.com/gin-gonic/gin v1.5.0/go.mod h1:Nd6IXA8m5kNZdNEHMBd93KT+mdY3+bewLgRvmCsR2Do=
|
||||
github.com/gin-gonic/gin v1.7.4 h1:QmUZXrvJ9qZ3GfWvQ+2wnW/1ePrTEJqPKMYEU3lD/DM=
|
||||
github.com/gin-gonic/gin v1.7.4/go.mod h1:jD2toBW3GZUr5UMcdrwQA10I7RuaFOl/SGeDjXkfUtY=
|
||||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o=
|
||||
|
@ -115,10 +119,15 @@ github.com/go-openapi/spec v0.0.0-20160808142527-6aced65f8501/go.mod h1:J8+jY1nA
|
|||
github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87/go.mod h1:DXUve3Dpr1UfpPtxFw+EFuQ41HhCWZfha5jSVRG7C7I=
|
||||
github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A=
|
||||
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||
github.com/go-playground/locales v0.12.1/go.mod h1:IUMDtCfWo/w/mtMfIE/IG2K+Ey3ygWanZIBtBW0W2TM=
|
||||
github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8=
|
||||
github.com/go-playground/locales v0.14.0 h1:u50s323jtVGugKlcYeyzC0etD1HifMjqmJqb8WugfUU=
|
||||
github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs=
|
||||
github.com/go-playground/universal-translator v0.16.0/go.mod h1:1AnU7NaIRDWWzGEKwgtJRd2xk99HeFyHw3yid4rvQIY=
|
||||
github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA=
|
||||
github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/jYrnRPArHwAcmLoJZxyho=
|
||||
github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA=
|
||||
github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4=
|
||||
github.com/go-playground/validator/v10 v10.9.0 h1:NgTtmN58D0m8+UuxtYmGztBJB7VnPgjj221I1QHci2A=
|
||||
github.com/go-playground/validator/v10 v10.9.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXSGrTK4nAUsbPlLADvpJkos=
|
||||
github.com/go-redis/redis/v8 v8.9.0 h1:FTTbB7WqlXfVNdVv0SsxA+oVi0bAwit6bMe3IUucq2o=
|
||||
|
@ -129,8 +138,6 @@ github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG
|
|||
github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE=
|
||||
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/gofiber/fiber/v2 v2.20.2 h1:dqizbjO1pCmH6K+b+kBk7TCJK4rmgjJXvX8/MZDbK60=
|
||||
github.com/gofiber/fiber/v2 v2.20.2/go.mod h1:/LdZHMUXZvTTo7gU4+b1hclqCAdoQphNQ9bi9gutPyI=
|
||||
github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw=
|
||||
github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
|
||||
github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s=
|
||||
|
@ -148,16 +155,18 @@ github.com/golang/protobuf v0.0.0-20161109072736-4bd1920723d7/go.mod h1:6lQm79b+
|
|||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
|
||||
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
||||
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
|
||||
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
|
||||
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
||||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/golang/protobuf v1.4.3 h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM=
|
||||
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
|
||||
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||
|
@ -264,7 +273,10 @@ github.com/json-iterator/go v0.0.0-20180612202835-f2b4162afba3/go.mod h1:+SdeFBv
|
|||
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||
github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
|
||||
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
||||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||
|
@ -272,20 +284,21 @@ github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8
|
|||
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
|
||||
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/klauspost/compress v1.13.4/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg=
|
||||
github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc=
|
||||
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
||||
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
|
||||
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/leodido/go-urn v1.1.0/go.mod h1:+cyI34gQWZcE1eQU7NVgKkkzdXDQHr1dBMtdAPozLkw=
|
||||
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
|
||||
github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w=
|
||||
github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY=
|
||||
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
|
@ -304,7 +317,10 @@ github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNx
|
|||
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||
github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ=
|
||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
|
||||
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||
github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
|
||||
github.com/mattn/go-sqlite3 v1.14.8/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
|
||||
github.com/mattn/go-sqlite3 v1.14.9 h1:10HX2Td0ocZpYEjhilsuo6WWtUqttj2Kb0KtD86/KYA=
|
||||
|
@ -320,10 +336,13 @@ github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0Qu
|
|||
github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v0.0.0-20180320133207-05fbef0ca5da/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||
github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
|
@ -416,6 +435,7 @@ github.com/robfig/cron/v3 v3.0.0/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzG
|
|||
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
|
||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
|
||||
github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8=
|
||||
github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
|
||||
github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ=
|
||||
github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU=
|
||||
|
@ -463,15 +483,14 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
|
|||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
||||
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
|
||||
github.com/ugorji/go v1.2.6 h1:tGiWC9HENWE2tqYycIqFTNorMmFRVhNwCpDOpWqnk8E=
|
||||
github.com/ugorji/go v1.2.6/go.mod h1:anCg0y61KIhDlPZmnH+so+RQbysYVyDko0IMgJv0Nn0=
|
||||
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
|
||||
github.com/ugorji/go/codec v1.2.6 h1:7kbGefxLoDBuYXOms4yD7223OpNMMPNPZxXk5TvFcyQ=
|
||||
github.com/ugorji/go/codec v1.2.6/go.mod h1:V6TCNZ4PHqoHGFZuSG1W8nrCzzdgA2DozYxWFFpvxTw=
|
||||
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
|
||||
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
||||
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
||||
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
||||
github.com/valyala/fasthttp v1.29.0/go.mod h1:2rsYD01CKFrjjsvFxx75KlEUNpWNBY9JWD3K/7o2Cus=
|
||||
github.com/valyala/fasthttp v1.31.0 h1:lrauRLII19afgCs2fnWRJ4M5IkV0lo2FqA61uGkNBfE=
|
||||
github.com/valyala/fasthttp v1.31.0/go.mod h1:2rsYD01CKFrjjsvFxx75KlEUNpWNBY9JWD3K/7o2Cus=
|
||||
github.com/valyala/tcplisten v1.0.0 h1:rBHj/Xf+E1tRGZyWIWwJDiRY0zc1Js+CV5DqwacVSA8=
|
||||
github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc=
|
||||
github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
|
||||
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
|
||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
|
@ -510,7 +529,6 @@ golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8U
|
|||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
||||
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8=
|
||||
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg=
|
||||
|
@ -598,8 +616,8 @@ golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7w
|
|||
golang.org/x/sys v0.0.0-20210309074719-68d13333faf2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211023085530-d6a326fbbf70 h1:SeSEfdIxyvwGJliREIJhRPPXvW6sDlLT+UQ3B0hD0NA=
|
||||
golang.org/x/sys v0.0.0-20211023085530-d6a326fbbf70/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
|
@ -664,17 +682,23 @@ google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ
|
|||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
|
||||
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
|
||||
google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM=
|
||||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ=
|
||||
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw=
|
||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||
gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o=
|
||||
gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE=
|
||||
gopkg.in/go-playground/validator.v9 v9.29.1/go.mod h1:+c9/zcJMFNgbLvly1L1V+PpxWdVbfP1avr/N00E2vyQ=
|
||||
gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec/go.mod h1:aPpfJ7XW+gOuirDoZ8gHhLh3kZ1B08FtV2bbmy7Jv3s=
|
||||
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8=
|
||||
|
@ -690,8 +714,10 @@ gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
)
|
||||
|
||||
type Account struct {
|
||||
Name string `json:"name" gorm:"primaryKey" validate:"required"`
|
||||
Name string `json:"name" gorm:"primaryKey" binding:"required"`
|
||||
Index int `json:"index"`
|
||||
Type string `json:"type"`
|
||||
Username string `json:"username"`
|
||||
|
|
|
@ -3,7 +3,7 @@ package model
|
|||
import "github.com/Xhofe/alist/conf"
|
||||
|
||||
type Meta struct {
|
||||
Path string `json:"path" gorm:"primaryKey" validate:"required"`
|
||||
Path string `json:"path" gorm:"primaryKey" binding:"required"`
|
||||
Password string `json:"password"`
|
||||
Hide string `json:"hide"`
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ const (
|
|||
)
|
||||
|
||||
type SettingItem struct {
|
||||
Key string `json:"key" gorm:"primaryKey" validate:"required"`
|
||||
Key string `json:"key" gorm:"primaryKey" binding:"required"`
|
||||
Value string `json:"value"`
|
||||
Description string `json:"description"`
|
||||
Type string `json:"type"`
|
||||
|
|
|
@ -4,3 +4,9 @@ import "embed"
|
|||
|
||||
//go:embed *
|
||||
var Public embed.FS
|
||||
|
||||
////go:embed index.html
|
||||
//var Index embed.FS
|
||||
//
|
||||
////go:embed assets/**
|
||||
//var Assets embed.FS
|
||||
|
|
|
@ -4,35 +4,35 @@ import (
|
|||
"fmt"
|
||||
"github.com/Xhofe/alist/drivers"
|
||||
"github.com/Xhofe/alist/model"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/gin-gonic/gin"
|
||||
"time"
|
||||
)
|
||||
|
||||
func GetAccounts(ctx *fiber.Ctx) error {
|
||||
func GetAccounts(c *gin.Context) {
|
||||
accounts, err := model.GetAccounts()
|
||||
if err != nil {
|
||||
return ErrorResp(ctx, err, 500)
|
||||
ErrorResp(c, err, 500)
|
||||
return
|
||||
}
|
||||
return SuccessResp(ctx, accounts)
|
||||
SuccessResp(c, accounts)
|
||||
}
|
||||
|
||||
func SaveAccount(ctx *fiber.Ctx) error {
|
||||
func SaveAccount(c *gin.Context) {
|
||||
var req model.Account
|
||||
if err := ctx.BodyParser(&req); err != nil {
|
||||
return ErrorResp(ctx, err, 400)
|
||||
}
|
||||
if err := validate.Struct(req); err != nil {
|
||||
return ErrorResp(ctx, err, 400)
|
||||
if err := c.ShouldBind(&req); err != nil {
|
||||
ErrorResp(c, err, 400)
|
||||
return
|
||||
}
|
||||
driver, ok := drivers.GetDriver(req.Type)
|
||||
if !ok {
|
||||
return ErrorResp(ctx, fmt.Errorf("no [%s] driver", req.Type), 400)
|
||||
ErrorResp(c, fmt.Errorf("no [%s] driver", req.Type), 400)
|
||||
return
|
||||
}
|
||||
old, ok := model.GetAccount(req.Name)
|
||||
now := time.Now()
|
||||
req.UpdatedAt = &now
|
||||
if err := model.SaveAccount(req); err != nil {
|
||||
return ErrorResp(ctx, err, 500)
|
||||
ErrorResp(c, err, 500)
|
||||
} else {
|
||||
if ok {
|
||||
err = driver.Save(&req, &old)
|
||||
|
@ -40,16 +40,18 @@ func SaveAccount(ctx *fiber.Ctx) error {
|
|||
err = driver.Save(&req, nil)
|
||||
}
|
||||
if err != nil {
|
||||
return ErrorResp(ctx, err, 500)
|
||||
ErrorResp(c, err, 500)
|
||||
return
|
||||
}
|
||||
return SuccessResp(ctx)
|
||||
SuccessResp(c)
|
||||
}
|
||||
}
|
||||
|
||||
func DeleteAccount(ctx *fiber.Ctx) error {
|
||||
name := ctx.Query("name")
|
||||
func DeleteAccount(c *gin.Context) {
|
||||
name := c.Query("name")
|
||||
if err := model.DeleteAccount(name); err != nil {
|
||||
return ErrorResp(ctx, err, 500)
|
||||
ErrorResp(c, err, 500)
|
||||
return
|
||||
}
|
||||
return SuccessResp(ctx)
|
||||
SuccessResp(c)
|
||||
}
|
||||
|
|
|
@ -2,14 +2,14 @@ package server
|
|||
|
||||
import (
|
||||
"github.com/Xhofe/alist/conf"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func ClearCache(ctx *fiber.Ctx) error {
|
||||
func ClearCache(c *gin.Context) {
|
||||
err := conf.Cache.Clear(conf.Ctx)
|
||||
if err != nil {
|
||||
return ErrorResp(ctx,err,500)
|
||||
}else {
|
||||
return SuccessResp(ctx)
|
||||
ErrorResp(c, err, 500)
|
||||
} else {
|
||||
SuccessResp(c)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,37 +4,36 @@ import (
|
|||
"fmt"
|
||||
"github.com/Xhofe/alist/model"
|
||||
"github.com/Xhofe/alist/utils"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/gin-gonic/gin"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func Auth(ctx *fiber.Ctx) error {
|
||||
token := ctx.Get("Authorization")
|
||||
func Auth(c *gin.Context) {
|
||||
token := c.GetHeader("Authorization")
|
||||
password, err := model.GetSettingByKey("password")
|
||||
if err != nil {
|
||||
if err == gorm.ErrRecordNotFound {
|
||||
return ErrorResp(ctx, fmt.Errorf("password not set"), 400)
|
||||
ErrorResp(c, fmt.Errorf("password not set"), 400)
|
||||
return
|
||||
}
|
||||
return ErrorResp(ctx, err, 500)
|
||||
ErrorResp(c, err, 500)
|
||||
return
|
||||
}
|
||||
if token != utils.GetMD5Encode(password.Value) {
|
||||
return ErrorResp(ctx, fmt.Errorf("wrong password"), 401)
|
||||
ErrorResp(c, fmt.Errorf("wrong password"), 401)
|
||||
return
|
||||
}
|
||||
return ctx.Next()
|
||||
c.Next()
|
||||
}
|
||||
|
||||
func Login(ctx *fiber.Ctx) error {
|
||||
return SuccessResp(ctx)
|
||||
func Login(c *gin.Context) {
|
||||
SuccessResp(c)
|
||||
}
|
||||
|
||||
func SetSuccess(ctx *fiber.Ctx) error {
|
||||
ctx.Status(200)
|
||||
return ctx.Next()
|
||||
}
|
||||
|
||||
func CheckAccount(ctx *fiber.Ctx) error {
|
||||
func CheckAccount(c *gin.Context) {
|
||||
if model.AccountsCount() == 0 {
|
||||
return ErrorResp(ctx,fmt.Errorf("no accounts,please add one first"),1001)
|
||||
ErrorResp(c, fmt.Errorf("no accounts,please add one first"), 1001)
|
||||
return
|
||||
}
|
||||
return ctx.Next()
|
||||
}
|
||||
c.Next()
|
||||
}
|
||||
|
|
|
@ -4,62 +4,61 @@ import (
|
|||
"fmt"
|
||||
"github.com/Xhofe/alist/drivers"
|
||||
"github.com/Xhofe/alist/model"
|
||||
"github.com/go-playground/validator/v10"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/gin-gonic/gin"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var validate = validator.New()
|
||||
|
||||
type Resp struct {
|
||||
Code int `json:"code"`
|
||||
Message string `json:"message"`
|
||||
Data interface{} `json:"data"`
|
||||
Code int `json:"code"`
|
||||
Message string `json:"message"`
|
||||
Data interface{} `json:"data"`
|
||||
}
|
||||
|
||||
func ParsePath(rawPath string) (*model.Account,string,drivers.Driver,error) {
|
||||
var path,name string
|
||||
func ParsePath(rawPath string) (*model.Account, string, drivers.Driver, error) {
|
||||
var path, name string
|
||||
switch model.AccountsCount() {
|
||||
case 0:
|
||||
return nil,"",nil,fmt.Errorf("no accounts,please add one first")
|
||||
return nil, "", nil, fmt.Errorf("no accounts,please add one first")
|
||||
case 1:
|
||||
path = rawPath
|
||||
break
|
||||
default:
|
||||
paths := strings.Split(rawPath,"/")
|
||||
path = "/" + strings.Join(paths[2:],"/")
|
||||
paths := strings.Split(rawPath, "/")
|
||||
path = "/" + strings.Join(paths[2:], "/")
|
||||
name = paths[1]
|
||||
}
|
||||
account,ok := model.GetAccount(name)
|
||||
account, ok := model.GetAccount(name)
|
||||
if !ok {
|
||||
return nil,"",nil,fmt.Errorf("no [%s] account", name)
|
||||
return nil, "", nil, fmt.Errorf("no [%s] account", name)
|
||||
}
|
||||
driver,ok := drivers.GetDriver(account.Type)
|
||||
driver, ok := drivers.GetDriver(account.Type)
|
||||
if !ok {
|
||||
return nil,"",nil,fmt.Errorf("no [%s] driver",account.Type)
|
||||
return nil, "", nil, fmt.Errorf("no [%s] driver", account.Type)
|
||||
}
|
||||
return &account,path,driver,nil
|
||||
return &account, path, driver, nil
|
||||
}
|
||||
|
||||
func ErrorResp(ctx *fiber.Ctx,err error,code int) error {
|
||||
return ctx.JSON(Resp{
|
||||
Code: code,
|
||||
Message: err.Error(),
|
||||
Data: nil,
|
||||
func ErrorResp(c *gin.Context, err error, code int) {
|
||||
c.JSON(200, Resp{
|
||||
Code: code,
|
||||
Message: err.Error(),
|
||||
Data: nil,
|
||||
})
|
||||
c.Abort()
|
||||
}
|
||||
|
||||
func SuccessResp(ctx *fiber.Ctx, data ...interface{}) error {
|
||||
func SuccessResp(c *gin.Context, data ...interface{}) {
|
||||
if len(data) == 0 {
|
||||
return ctx.JSON(Resp{
|
||||
Code: 200,
|
||||
Message: "success",
|
||||
Data: nil,
|
||||
c.JSON(200, Resp{
|
||||
Code: 200,
|
||||
Message: "success",
|
||||
Data: nil,
|
||||
})
|
||||
return
|
||||
}
|
||||
return ctx.JSON(Resp{
|
||||
Code: 200,
|
||||
Message: "success",
|
||||
Data: data[0],
|
||||
c.JSON(200, Resp{
|
||||
Code: 200,
|
||||
Message: "success",
|
||||
Data: data[0],
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,79 +4,66 @@ import (
|
|||
"fmt"
|
||||
"github.com/Xhofe/alist/conf"
|
||||
"github.com/Xhofe/alist/utils"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/gofiber/fiber/v2/middleware/proxy"
|
||||
"github.com/gin-gonic/gin"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"net/url"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
func Down(ctx *fiber.Ctx) error {
|
||||
rawPath, err := url.PathUnescape(ctx.Params("*"))
|
||||
func Down(c *gin.Context) {
|
||||
rawPath, err := url.PathUnescape(c.Param("path"))
|
||||
if err != nil {
|
||||
return ErrorResp(ctx, err, 500)
|
||||
ErrorResp(c, err, 500)
|
||||
return
|
||||
}
|
||||
rawPath = utils.ParsePath(rawPath)
|
||||
log.Debugf("down: %s", rawPath)
|
||||
account, path, driver, err := ParsePath(rawPath)
|
||||
if err != nil {
|
||||
return ErrorResp(ctx, err, 500)
|
||||
ErrorResp(c, err, 500)
|
||||
return
|
||||
}
|
||||
link, err := driver.Link(path, account)
|
||||
if err != nil {
|
||||
return ErrorResp(ctx, err, 500)
|
||||
ErrorResp(c, err, 500)
|
||||
return
|
||||
}
|
||||
if account.Type == "Native" {
|
||||
return ctx.SendFile(link)
|
||||
c.File(link)
|
||||
return
|
||||
} else {
|
||||
return ctx.Redirect(link, 302)
|
||||
c.Redirect(302, link)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func Proxy(ctx *fiber.Ctx) error {
|
||||
rawPath, err := url.PathUnescape(ctx.Params("*"))
|
||||
func Proxy(c *gin.Context) {
|
||||
rawPath, err := url.PathUnescape(c.Param("path"))
|
||||
if err != nil {
|
||||
return ErrorResp(ctx, err, 500)
|
||||
ErrorResp(c, err, 500)
|
||||
return
|
||||
}
|
||||
rawPath = utils.ParsePath(rawPath)
|
||||
log.Debugf("proxy: %s", rawPath)
|
||||
account, path, driver, err := ParsePath(rawPath)
|
||||
if err != nil {
|
||||
return ErrorResp(ctx, err, 500)
|
||||
ErrorResp(c, err, 500)
|
||||
return
|
||||
}
|
||||
if !account.Proxy && utils.GetFileType(filepath.Ext(rawPath)) != conf.TEXT {
|
||||
return ErrorResp(ctx, fmt.Errorf("[%s] not allowed proxy", account.Name), 403)
|
||||
ErrorResp(c, fmt.Errorf("[%s] not allowed proxy", account.Name), 403)
|
||||
return
|
||||
}
|
||||
link, err := driver.Link(path, account)
|
||||
if err != nil {
|
||||
return ErrorResp(ctx, err, 500)
|
||||
ErrorResp(c, err, 500)
|
||||
return
|
||||
}
|
||||
if account.Type == "Native" {
|
||||
return ctx.SendFile(link)
|
||||
c.File(link)
|
||||
return
|
||||
} else {
|
||||
driver.Proxy(ctx)
|
||||
//ctx.Response().ImmediateHeaderFlush = true
|
||||
//var ProxyNetHttp = fasthttpadaptor.NewFastHTTPHandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
// target, _ := url.Parse(link)
|
||||
// protocol := "https://"
|
||||
// if strings.HasPrefix(link, "http://") {
|
||||
// protocol = "http://"
|
||||
// }
|
||||
// targetHost, _ := url.Parse(fmt.Sprintf("%s%s", protocol, target.Host))
|
||||
// proxy := httputil.NewSingleHostReverseProxy(targetHost)
|
||||
// r.URL = target
|
||||
// r.Host = target.Host
|
||||
// proxy.ServeHTTP(w, r)
|
||||
//})
|
||||
//ProxyNetHttp(ctx.Context())
|
||||
if err := proxy.Do(ctx, link); err != nil {
|
||||
log.Errorf("proxy error: %s", err)
|
||||
return ErrorResp(ctx,err,500)
|
||||
}
|
||||
// Remove Server header from response
|
||||
ctx.Response().Header.Del(fiber.HeaderServer)
|
||||
ctx.Set("Access-Control-Allow-Origin","*")
|
||||
log.Debugf("proxy hedaer: %+v", ctx.Response().Header.String())
|
||||
return nil
|
||||
driver.Proxy(c)
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,9 +2,9 @@ package server
|
|||
|
||||
import (
|
||||
"github.com/Xhofe/alist/drivers"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func GetDrivers(ctx *fiber.Ctx) error {
|
||||
return SuccessResp(ctx, drivers.GetDrivers())
|
||||
func GetDrivers(c *gin.Context) {
|
||||
SuccessResp(c, drivers.GetDrivers())
|
||||
}
|
|
@ -3,38 +3,37 @@ package server
|
|||
import (
|
||||
"github.com/Xhofe/alist/model"
|
||||
"github.com/Xhofe/alist/utils"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func GetMetas(ctx *fiber.Ctx) error {
|
||||
func GetMetas(c *gin.Context) {
|
||||
metas,err := model.GetMetas()
|
||||
if err != nil {
|
||||
return ErrorResp(ctx,err,500)
|
||||
ErrorResp(c,err,500)
|
||||
return
|
||||
}
|
||||
return SuccessResp(ctx, metas)
|
||||
SuccessResp(c, metas)
|
||||
}
|
||||
|
||||
func SaveMeta(ctx *fiber.Ctx) error {
|
||||
func SaveMeta(c *gin.Context) {
|
||||
var req model.Meta
|
||||
if err := ctx.BodyParser(&req); err != nil {
|
||||
return ErrorResp(ctx, err, 400)
|
||||
}
|
||||
if err := validate.Struct(req); err != nil {
|
||||
return ErrorResp(ctx, err, 400)
|
||||
if err := c.ShouldBind(&req); err != nil {
|
||||
ErrorResp(c, err, 400)
|
||||
return
|
||||
}
|
||||
req.Path = utils.ParsePath(req.Path)
|
||||
if err := model.SaveMeta(req); err != nil {
|
||||
return ErrorResp(ctx, err, 500)
|
||||
ErrorResp(c, err, 500)
|
||||
} else {
|
||||
return SuccessResp(ctx)
|
||||
SuccessResp(c)
|
||||
}
|
||||
}
|
||||
|
||||
func DeleteMeta(ctx *fiber.Ctx) error {
|
||||
path := ctx.Query("path")
|
||||
func DeleteMeta(c *gin.Context) {
|
||||
path := c.Query("path")
|
||||
//path = utils.ParsePath(path)
|
||||
if err := model.DeleteMeta(path); err != nil {
|
||||
return ErrorResp(ctx, err, 500)
|
||||
ErrorResp(c, err, 500)
|
||||
}
|
||||
return SuccessResp(ctx)
|
||||
SuccessResp(c)
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"fmt"
|
||||
"github.com/Xhofe/alist/model"
|
||||
"github.com/Xhofe/alist/utils"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/gin-gonic/gin"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"strings"
|
||||
)
|
||||
|
@ -14,44 +14,50 @@ type PathReq struct {
|
|||
Password string `json:"Password"`
|
||||
}
|
||||
|
||||
func Path(ctx *fiber.Ctx) error {
|
||||
func Path(c *gin.Context) {
|
||||
var req PathReq
|
||||
if err := ctx.BodyParser(&req); err != nil {
|
||||
return ErrorResp(ctx, err, 400)
|
||||
if err := c.ShouldBind(&req); err != nil {
|
||||
ErrorResp(c, err, 400)
|
||||
return
|
||||
}
|
||||
req.Path = utils.ParsePath(req.Path)
|
||||
log.Debugf("path: %s", req.Path)
|
||||
meta, err := model.GetMetaByPath(req.Path)
|
||||
if err == nil {
|
||||
if meta.Password != "" && meta.Password != req.Password {
|
||||
return ErrorResp(ctx, fmt.Errorf("wrong password"), 401)
|
||||
ErrorResp(c, fmt.Errorf("wrong password"), 401)
|
||||
return
|
||||
}
|
||||
// TODO hide or ignore?
|
||||
}
|
||||
if model.AccountsCount() > 1 && req.Path == "/" {
|
||||
files, err := model.GetAccountFiles()
|
||||
if err != nil {
|
||||
return ErrorResp(ctx, err, 500)
|
||||
ErrorResp(c, err, 500)
|
||||
return
|
||||
}
|
||||
return ctx.JSON(Resp{
|
||||
c.JSON(200, Resp{
|
||||
Code: 200,
|
||||
Message: "folder",
|
||||
Data: files,
|
||||
})
|
||||
return
|
||||
}
|
||||
account, path, driver, err := ParsePath(req.Path)
|
||||
if err != nil {
|
||||
return ErrorResp(ctx, err, 500)
|
||||
ErrorResp(c, err, 500)
|
||||
return
|
||||
}
|
||||
file, files, err := driver.Path(path, account)
|
||||
if err != nil {
|
||||
return ErrorResp(ctx, err, 500)
|
||||
ErrorResp(c, err, 500)
|
||||
return
|
||||
}
|
||||
if file != nil {
|
||||
if account.Type == "Native" {
|
||||
file.Url = fmt.Sprintf("%s://%s/p%s", ctx.Protocol(), ctx.Hostname(), req.Path)
|
||||
file.Url = fmt.Sprintf("//%s/d%s", c.Request.Host, req.Path)
|
||||
}
|
||||
return ctx.JSON(Resp{
|
||||
c.JSON(200, Resp{
|
||||
Code: 200,
|
||||
Message: "file",
|
||||
Data: []*model.File{file},
|
||||
|
@ -67,7 +73,7 @@ func Path(ctx *fiber.Ctx) error {
|
|||
}
|
||||
files = tmpFiles
|
||||
}
|
||||
return ctx.JSON(Resp{
|
||||
c.JSON(200, Resp{
|
||||
Code: 200,
|
||||
Message: "folder",
|
||||
Data: files,
|
||||
|
@ -75,49 +81,56 @@ func Path(ctx *fiber.Ctx) error {
|
|||
}
|
||||
}
|
||||
|
||||
func Link(ctx *fiber.Ctx) error {
|
||||
func Link(c *gin.Context) {
|
||||
var req PathReq
|
||||
if err := ctx.BodyParser(&req); err != nil {
|
||||
return ErrorResp(ctx, err, 400)
|
||||
if err := c.ShouldBind(&req); err != nil {
|
||||
ErrorResp(c, err, 400)
|
||||
return
|
||||
}
|
||||
rawPath := req.Path
|
||||
rawPath = utils.ParsePath(rawPath)
|
||||
log.Debugf("link: %s", rawPath)
|
||||
account, path, driver, err := ParsePath(rawPath)
|
||||
if err != nil {
|
||||
return ErrorResp(ctx, err, 500)
|
||||
ErrorResp(c, err, 500)
|
||||
return
|
||||
}
|
||||
link, err := driver.Link(path, account)
|
||||
if err != nil {
|
||||
return ErrorResp(ctx, err, 500)
|
||||
ErrorResp(c, err, 500)
|
||||
return
|
||||
}
|
||||
if account.Type == "Native" {
|
||||
return SuccessResp(ctx, fiber.Map{
|
||||
"url": fmt.Sprintf("%s://%s/p%s", ctx.Protocol(), ctx.Hostname(), rawPath),
|
||||
SuccessResp(c, gin.H{
|
||||
"url": fmt.Sprintf("//%s/d%s", c.Request.Host, req.Path),
|
||||
})
|
||||
return
|
||||
} else {
|
||||
return SuccessResp(ctx, fiber.Map{
|
||||
SuccessResp(c, gin.H{
|
||||
"url": link,
|
||||
})
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func Preview(ctx *fiber.Ctx) error {
|
||||
func Preview(c *gin.Context) {
|
||||
var req PathReq
|
||||
if err := ctx.BodyParser(&req); err != nil {
|
||||
return ErrorResp(ctx, err, 400)
|
||||
if err := c.ShouldBind(&req); err != nil {
|
||||
ErrorResp(c, err, 400)
|
||||
return
|
||||
}
|
||||
rawPath := req.Path
|
||||
rawPath = utils.ParsePath(rawPath)
|
||||
log.Debugf("preview: %s", rawPath)
|
||||
account, path, driver, err := ParsePath(rawPath)
|
||||
if err != nil {
|
||||
return ErrorResp(ctx, err, 500)
|
||||
ErrorResp(c, err, 500)
|
||||
return
|
||||
}
|
||||
data, err := driver.Preview(path, account)
|
||||
if err != nil {
|
||||
return ErrorResp(ctx, err, 500)
|
||||
ErrorResp(c, err, 500)
|
||||
} else {
|
||||
return SuccessResp(ctx, data)
|
||||
SuccessResp(c, data)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,42 +1,48 @@
|
|||
package server
|
||||
|
||||
import (
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/gofiber/fiber/v2/middleware/cors"
|
||||
"github.com/gin-contrib/cors"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func InitApiRouter(app *fiber.App) {
|
||||
func InitApiRouter(r *gin.Engine) {
|
||||
|
||||
// TODO from settings
|
||||
app.Use(cors.New())
|
||||
app.Get("/d/*", Down)
|
||||
// TODO check allow proxy?
|
||||
app.Get("/p/*", Proxy)
|
||||
Cors(r)
|
||||
r.GET("/d/*path", Down)
|
||||
r.GET("/p/*path", Proxy)
|
||||
|
||||
api := app.Group("/api")
|
||||
api.Use(SetSuccess)
|
||||
api := r.Group("/api")
|
||||
public := api.Group("/public")
|
||||
{
|
||||
public.Post("/path", CheckAccount, Path)
|
||||
public.Post("/preview", CheckAccount, Preview)
|
||||
public.Get("/settings", GetSettingsPublic)
|
||||
public.Post("/link", CheckAccount, Link)
|
||||
public.POST("/path", CheckAccount, Path)
|
||||
public.POST("/preview", CheckAccount, Preview)
|
||||
public.GET("/settings", GetSettingsPublic)
|
||||
public.POST("/link", CheckAccount, Link)
|
||||
}
|
||||
|
||||
admin := api.Group("/admin")
|
||||
{
|
||||
admin.Use(Auth)
|
||||
admin.Get("/login", Login)
|
||||
admin.Get("/settings", GetSettings)
|
||||
admin.Post("/settings", SaveSettings)
|
||||
admin.Post("/account", SaveAccount)
|
||||
admin.Get("/accounts", GetAccounts)
|
||||
admin.Delete("/account", DeleteAccount)
|
||||
admin.Get("/drivers", GetDrivers)
|
||||
admin.Get("/clear_cache",ClearCache)
|
||||
admin.GET("/login", Login)
|
||||
admin.GET("/settings", GetSettings)
|
||||
admin.POST("/settings", SaveSettings)
|
||||
admin.POST("/account", SaveAccount)
|
||||
admin.GET("/accounts", GetAccounts)
|
||||
admin.DELETE("/account", DeleteAccount)
|
||||
admin.GET("/drivers", GetDrivers)
|
||||
admin.GET("/clear_cache", ClearCache)
|
||||
|
||||
admin.Get("/metas", GetMetas)
|
||||
admin.Post("/meta", SaveMeta)
|
||||
admin.Delete("/meta", DeleteMeta)
|
||||
admin.GET("/metas", GetMetas)
|
||||
admin.POST("/meta", SaveMeta)
|
||||
admin.DELETE("/meta", DeleteMeta)
|
||||
}
|
||||
Static(r)
|
||||
}
|
||||
|
||||
func Cors(r *gin.Engine) {
|
||||
config := cors.DefaultConfig()
|
||||
config.AllowAllOrigins = true
|
||||
config.AllowHeaders = append(config.AllowHeaders, "Authorization")
|
||||
r.Use(cors.New(config))
|
||||
}
|
||||
|
|
|
@ -2,37 +2,37 @@ package server
|
|||
|
||||
import (
|
||||
"github.com/Xhofe/alist/model"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func SaveSettings(ctx *fiber.Ctx) error {
|
||||
func SaveSettings(c *gin.Context) {
|
||||
var req []model.SettingItem
|
||||
if err := ctx.BodyParser(&req); err != nil {
|
||||
return ErrorResp(ctx, err, 400)
|
||||
if err := c.ShouldBind(&req); err != nil {
|
||||
ErrorResp(c, err, 400)
|
||||
return
|
||||
}
|
||||
//if err := validate.Struct(req); err != nil {
|
||||
// return ErrorResp(ctx, err, 400)
|
||||
//}
|
||||
if err := model.SaveSettings(req); err != nil {
|
||||
return ErrorResp(ctx, err, 500)
|
||||
ErrorResp(c, err, 500)
|
||||
} else {
|
||||
model.LoadSettings()
|
||||
return SuccessResp(ctx)
|
||||
SuccessResp(c)
|
||||
}
|
||||
}
|
||||
|
||||
func GetSettings(ctx *fiber.Ctx) error {
|
||||
func GetSettings(c *gin.Context) {
|
||||
settings, err := model.GetSettings()
|
||||
if err != nil {
|
||||
return ErrorResp(ctx, err, 400)
|
||||
ErrorResp(c, err, 400)
|
||||
return
|
||||
}
|
||||
return SuccessResp(ctx, settings)
|
||||
SuccessResp(c, settings)
|
||||
}
|
||||
|
||||
func GetSettingsPublic(ctx *fiber.Ctx) error {
|
||||
func GetSettingsPublic(c *gin.Context) {
|
||||
settings, err := model.GetSettingsPublic()
|
||||
if err != nil {
|
||||
return ErrorResp(ctx, err, 400)
|
||||
ErrorResp(c, err, 400)
|
||||
return
|
||||
}
|
||||
return SuccessResp(ctx, settings)
|
||||
SuccessResp(c, settings)
|
||||
}
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
package server
|
||||
|
||||
import (
|
||||
"github.com/Xhofe/alist/public"
|
||||
"github.com/gin-gonic/gin"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"io/fs"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
var data []byte
|
||||
|
||||
func init() {
|
||||
index, _ := public.Public.Open("index.html")
|
||||
data, _ = ioutil.ReadAll(index)
|
||||
}
|
||||
|
||||
func Static(r *gin.Engine) {
|
||||
assets, err := fs.Sub(public.Public, "assets")
|
||||
if err != nil {
|
||||
log.Fatalf("can't find assets folder")
|
||||
}
|
||||
r.StaticFS("/assets/", http.FS(assets))
|
||||
r.NoRoute(func(c *gin.Context) {
|
||||
c.Status(200)
|
||||
c.Header("Content-Type", "text/html")
|
||||
_, _ = c.Writer.Write(data)
|
||||
c.Writer.Flush()
|
||||
})
|
||||
}
|
Loading…
Reference in New Issue