mirror of
https://github.com/OpenListTeam/OpenList.git
synced 2025-09-20 20:56:20 +08:00
Compare commits
14 Commits
v2.0.0-bet
...
v2.0.0-bet
Author | SHA1 | Date | |
---|---|---|---|
f4affb2c69 | |||
17af21079f | |||
f7d35ec925 | |||
a8730e82b5 | |||
6275e27d1b | |||
e70353704f | |||
be5b1e42d4 | |||
7d08cbc4a9 | |||
1542878d66 | |||
ac8f5d5737 | |||
9ed5b6e581 | |||
db7bff2d61 | |||
7970e737f0 | |||
d4523d52ee |
48
.github/workflows/docker.yml
vendored
Normal file
48
.github/workflows/docker.yml
vendored
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
name: docker
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- 'v2'
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- 'v2'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
docker:
|
||||||
|
name: Docker
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Docker meta
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v3
|
||||||
|
with:
|
||||||
|
images: xhofe/alist
|
||||||
|
- name: Set up Node
|
||||||
|
uses: actions/setup-node@v2
|
||||||
|
with:
|
||||||
|
node-version: '16'
|
||||||
|
- name: Build web
|
||||||
|
run: bash build.sh web
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v1
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
- name: Login to DockerHub
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
username: xhofe
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
- name: Build and push
|
||||||
|
id: docker_build
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/386,linux/arm/v6,linux/ppc64le,linux/s390x
|
13
Dockerfile
Normal file
13
Dockerfile
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
FROM alpine:edge as builder
|
||||||
|
LABEL stage=go-builder
|
||||||
|
WORKDIR /app/
|
||||||
|
COPY ./ ./
|
||||||
|
RUN apk add --no-cache bash git go gcc musl-dev; \
|
||||||
|
sh build.sh docker
|
||||||
|
|
||||||
|
FROM alpine:edge
|
||||||
|
LABEL MAINTAINER="i@nn.ci"
|
||||||
|
WORKDIR /opt/alist/
|
||||||
|
COPY --from=builder /app/bin/alist ./
|
||||||
|
EXPOSE 5244
|
||||||
|
CMD [ "./alist" ]
|
@ -171,6 +171,12 @@ func initSettings() {
|
|||||||
Description: "when have multiple, the readme file to show",
|
Description: "when have multiple, the readme file to show",
|
||||||
Group: model.PUBLIC,
|
Group: model.PUBLIC,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Key: "markdown theme",
|
||||||
|
Value: "vuepress",
|
||||||
|
Description: "default | github | vuepress",
|
||||||
|
Group: model.PUBLIC,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
for _, v := range settings {
|
for _, v := range settings {
|
||||||
_, err := model.GetSettingByKey(v.Key)
|
_, err := model.GetSettingByKey(v.Key)
|
||||||
|
37
build.sh
37
build.sh
@ -1,4 +1,34 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
if [ "$1" == "web" ]; then
|
||||||
|
git clone https://github.com/Xhofe/alist-web.git
|
||||||
|
cd alist-web || exit
|
||||||
|
yarn
|
||||||
|
yarn build
|
||||||
|
mv dist/* ../public
|
||||||
|
cd ..
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
go env -w GOPROXY=https://goproxy.cn,https://mirrors.aliyun.com/goproxy/,https://goproxy.io,direct
|
||||||
|
|
||||||
|
if [ "$1" == "docker" ]; then
|
||||||
|
appName="alist"
|
||||||
|
builtAt="$(date +'%F %T %z')"
|
||||||
|
goVersion=$(go version | sed 's/go version //')
|
||||||
|
gitAuthor=$(git show -s --format='format:%aN <%ae>' HEAD)
|
||||||
|
gitCommit=$(git log --pretty=format:"%h" -1)
|
||||||
|
gitTag=$(git describe --long --tags --dirty --always)
|
||||||
|
ldflags="\
|
||||||
|
-w -s \
|
||||||
|
-X 'github.com/Xhofe/alist/conf.BuiltAt=$builtAt' \
|
||||||
|
-X 'github.com/Xhofe/alist/conf.GoVersion=$goVersion' \
|
||||||
|
-X 'github.com/Xhofe/alist/conf.GitAuthor=$gitAuthor' \
|
||||||
|
-X 'github.com/Xhofe/alist/conf.GitCommit=$gitCommit' \
|
||||||
|
-X 'github.com/Xhofe/alist/conf.GitTag=$gitTag' \
|
||||||
|
"
|
||||||
|
go build -o ./bin/alist -ldflags="$ldflags" alist.go
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
cd alist-web || exit
|
cd alist-web || exit
|
||||||
webCommit=$(git log --pretty=format:"%h" -1)
|
webCommit=$(git log --pretty=format:"%h" -1)
|
||||||
@ -18,12 +48,7 @@ builtAt="$(date +'%F %T %z')"
|
|||||||
goVersion=$(go version | sed 's/go version //')
|
goVersion=$(go version | sed 's/go version //')
|
||||||
gitAuthor=$(git show -s --format='format:%aN <%ae>' HEAD)
|
gitAuthor=$(git show -s --format='format:%aN <%ae>' HEAD)
|
||||||
gitCommit=$(git log --pretty=format:"%h" -1)
|
gitCommit=$(git log --pretty=format:"%h" -1)
|
||||||
|
gitTag=$(git describe --long --tags --dirty --always)
|
||||||
if [ "$1" == "release" ]; then
|
|
||||||
gitTag=$(git describe --abbrev=0 --tags)
|
|
||||||
else
|
|
||||||
gitTag=build-next
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "build version: $gitTag"
|
echo "build version: $gitTag"
|
||||||
|
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"github.com/Xhofe/alist/conf"
|
"github.com/Xhofe/alist/conf"
|
||||||
|
"github.com/robfig/cron/v3"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -44,9 +46,11 @@ func SaveAccount(account Account) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func DeleteAccount(name string) error {
|
func DeleteAccount(name string) error {
|
||||||
account := Account{
|
account, ok := GetAccount(name)
|
||||||
Name: name,
|
if !ok {
|
||||||
|
return fmt.Errorf("no [%s] account", name)
|
||||||
}
|
}
|
||||||
|
conf.Cron.Remove(cron.EntryID(account.CronId))
|
||||||
if err := conf.DB.Delete(&account).Error; err != nil {
|
if err := conf.DB.Delete(&account).Error; err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ func GetSettings() (*[]SettingItem, 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("`key` = ?", key).First(&items).Error; err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &items, nil
|
return &items, nil
|
||||||
|
@ -12,7 +12,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func Down(ctx *fiber.Ctx) error {
|
func Down(ctx *fiber.Ctx) error {
|
||||||
rawPath, err:= url.QueryUnescape(ctx.Params("*"))
|
rawPath, err := url.PathUnescape(ctx.Params("*"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ErrorResp(ctx, err, 500)
|
return ErrorResp(ctx, err, 500)
|
||||||
}
|
}
|
||||||
@ -34,7 +34,7 @@ func Down(ctx *fiber.Ctx) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Proxy(ctx *fiber.Ctx) error {
|
func Proxy(ctx *fiber.Ctx) error {
|
||||||
rawPath, err:= url.QueryUnescape(ctx.Params("*"))
|
rawPath, err := url.PathUnescape(ctx.Params("*"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ErrorResp(ctx, err, 500)
|
return ErrorResp(ctx, err, 500)
|
||||||
}
|
}
|
||||||
@ -55,6 +55,20 @@ func Proxy(ctx *fiber.Ctx) error {
|
|||||||
return ctx.SendFile(link)
|
return ctx.SendFile(link)
|
||||||
} else {
|
} else {
|
||||||
driver.Proxy(ctx)
|
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 {
|
if err := proxy.Do(ctx, link); err != nil {
|
||||||
log.Errorf("proxy error: %s", err)
|
log.Errorf("proxy error: %s", err)
|
||||||
return ErrorResp(ctx,err,500)
|
return ErrorResp(ctx,err,500)
|
||||||
|
Reference in New Issue
Block a user