Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
dc73c2e97d | |||
a624121095 | |||
9d9c79179b | |||
b7479651e1 | |||
2fc0ccbfe0 | |||
f86ad1dce4 |
1
.github/workflows/issue_close_inactive.yml
vendored
1
.github/workflows/issue_close_inactive.yml
vendored
@ -3,6 +3,7 @@ name: Close inactive
|
|||||||
on:
|
on:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: "0 0 */7 * *"
|
- cron: "0 0 */7 * *"
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
close-inactive:
|
close-inactive:
|
||||||
|
1
.github/workflows/issue_close_question.yml
vendored
1
.github/workflows/issue_close_question.yml
vendored
@ -3,6 +3,7 @@ name: Close need info
|
|||||||
on:
|
on:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: "0 0 */7 * *"
|
- cron: "0 0 */7 * *"
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
close-need-info:
|
close-need-info:
|
||||||
|
@ -6,11 +6,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func InitAria2() {
|
func InitAria2() {
|
||||||
go func() {
|
_, err := aria2.InitClient(2)
|
||||||
_, err := aria2.InitClient(2)
|
if err != nil {
|
||||||
if err != nil {
|
//utils.Log.Errorf("failed to init aria2 client: %+v", err)
|
||||||
//utils.Log.Errorf("failed to init aria2 client: %+v", err)
|
utils.Log.Infof("Aria2 not ready.")
|
||||||
utils.Log.Infof("Aria2 not ready.")
|
}
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package bootstrap
|
package bootstrap
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
@ -25,7 +24,7 @@ func InitConfig() {
|
|||||||
log.Fatalf("failed to create default config file")
|
log.Fatalf("failed to create default config file")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
configBytes, err := ioutil.ReadFile(flags.Config)
|
configBytes, err := os.ReadFile(flags.Config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("reading config file error: %+v", err)
|
log.Fatalf("reading config file error: %+v", err)
|
||||||
}
|
}
|
||||||
@ -39,7 +38,7 @@ func InitConfig() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("marshal config error: %+v", err)
|
log.Fatalf("marshal config error: %+v", err)
|
||||||
}
|
}
|
||||||
err = ioutil.WriteFile(flags.Config, confBody, 0777)
|
err = os.WriteFile(flags.Config, confBody, 0777)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("update config struct error: %+v", err)
|
log.Fatalf("update config struct error: %+v", err)
|
||||||
}
|
}
|
||||||
@ -59,7 +58,7 @@ func InitConfig() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorln("failed delete temp file:", err)
|
log.Errorln("failed delete temp file:", err)
|
||||||
}
|
}
|
||||||
err = os.MkdirAll(conf.Conf.TempDir, 0700)
|
err = os.MkdirAll(conf.Conf.TempDir, 0777)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("create temp dir error: %+v", err)
|
log.Fatalf("create temp dir error: %+v", err)
|
||||||
}
|
}
|
||||||
|
@ -32,32 +32,32 @@ type LogConfig struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Force bool `json:"force" env:"FORCE"`
|
Force bool `json:"force" env:"FORCE"`
|
||||||
Address string `json:"address" env:"ADDR"`
|
Address string `json:"address" env:"ADDR"`
|
||||||
Port int `json:"port" env:"PORT"`
|
Port int `json:"port" env:"PORT"`
|
||||||
SiteURL string `json:"site_url" env:"SITE_URL"`
|
SiteURL string `json:"site_url" env:"SITE_URL"`
|
||||||
Cdn string `json:"cdn" env:"CDN"`
|
Cdn string `json:"cdn" env:"CDN"`
|
||||||
JwtSecret string `json:"jwt_secret" env:"JWT_SECRET"`
|
JwtSecret string `json:"jwt_secret" env:"JWT_SECRET"`
|
||||||
Database Database `json:"database"`
|
TokenExpiresIn int `json:"token_expires_in" env:"TOKEN_EXPIRES_IN"`
|
||||||
Scheme Scheme `json:"scheme"`
|
Database Database `json:"database"`
|
||||||
TempDir string `json:"temp_dir" env:"TEMP_DIR"`
|
Scheme Scheme `json:"scheme"`
|
||||||
Log LogConfig `json:"log"`
|
TempDir string `json:"temp_dir" env:"TEMP_DIR"`
|
||||||
|
Log LogConfig `json:"log"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func DefaultConfig() *Config {
|
func DefaultConfig() *Config {
|
||||||
return &Config{
|
return &Config{
|
||||||
Address: "0.0.0.0",
|
Address: "0.0.0.0",
|
||||||
Port: 5244,
|
Port: 5244,
|
||||||
JwtSecret: random.String(16),
|
JwtSecret: random.String(16),
|
||||||
Cdn: "",
|
TokenExpiresIn: 48,
|
||||||
TempDir: "data/temp",
|
TempDir: "data/temp",
|
||||||
Database: Database{
|
Database: Database{
|
||||||
Type: "sqlite3",
|
Type: "sqlite3",
|
||||||
Port: 0,
|
Port: 0,
|
||||||
TablePrefix: "x_",
|
TablePrefix: "x_",
|
||||||
DBFile: "data/data.db",
|
DBFile: "data/data.db",
|
||||||
},
|
},
|
||||||
// CaCheExpiration: 30,
|
|
||||||
Log: LogConfig{
|
Log: LogConfig{
|
||||||
Enable: true,
|
Enable: true,
|
||||||
Name: "log/log.log",
|
Name: "log/log.log",
|
||||||
|
@ -3,6 +3,7 @@ package common
|
|||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/alist-org/alist/v3/internal/conf"
|
||||||
"github.com/golang-jwt/jwt/v4"
|
"github.com/golang-jwt/jwt/v4"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
@ -18,7 +19,7 @@ func GenerateToken(username string) (tokenString string, err error) {
|
|||||||
claim := UserClaims{
|
claim := UserClaims{
|
||||||
Username: username,
|
Username: username,
|
||||||
RegisteredClaims: jwt.RegisteredClaims{
|
RegisteredClaims: jwt.RegisteredClaims{
|
||||||
ExpiresAt: jwt.NewNumericDate(time.Now().Add(12 * time.Hour)),
|
ExpiresAt: jwt.NewNumericDate(time.Now().Add(time.Duration(conf.Conf.TokenExpiresIn) * time.Hour)),
|
||||||
IssuedAt: jwt.NewNumericDate(time.Now()),
|
IssuedAt: jwt.NewNumericDate(time.Now()),
|
||||||
NotBefore: jwt.NewNumericDate(time.Now()),
|
NotBefore: jwt.NewNumericDate(time.Now()),
|
||||||
}}
|
}}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package static
|
package static
|
||||||
|
|
||||||
import (
|
import (
|
||||||
stdpath "path"
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/alist-org/alist/v3/internal/conf"
|
"github.com/alist-org/alist/v3/internal/conf"
|
||||||
@ -16,9 +16,13 @@ type SiteConfig struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getSiteConfig() SiteConfig {
|
func getSiteConfig() SiteConfig {
|
||||||
|
u, err := url.Parse(conf.Conf.SiteURL)
|
||||||
|
if err != nil {
|
||||||
|
utils.Log.Fatalf("can't parse site_url: %+v", err)
|
||||||
|
}
|
||||||
siteConfig := SiteConfig{
|
siteConfig := SiteConfig{
|
||||||
ApiURL: conf.Conf.SiteURL,
|
ApiURL: conf.Conf.SiteURL,
|
||||||
BasePath: stdpath.Base(conf.Conf.SiteURL),
|
BasePath: u.Path,
|
||||||
Cdn: strings.ReplaceAll(strings.TrimSuffix(conf.Conf.Cdn, "/"), "$version", conf.WebVersion),
|
Cdn: strings.ReplaceAll(strings.TrimSuffix(conf.Conf.Cdn, "/"), "$version", conf.WebVersion),
|
||||||
}
|
}
|
||||||
// try to get old config
|
// try to get old config
|
||||||
|
@ -21,11 +21,19 @@ func InitIndex() {
|
|||||||
log.Fatalf("failed to read index.html: %v", err)
|
log.Fatalf("failed to read index.html: %v", err)
|
||||||
}
|
}
|
||||||
conf.RawIndexHtml = string(index)
|
conf.RawIndexHtml = string(index)
|
||||||
|
siteConfig := getSiteConfig()
|
||||||
|
replaceMap := map[string]string{
|
||||||
|
"cdn: undefined": fmt.Sprintf("cdn: '%s'", siteConfig.Cdn),
|
||||||
|
"base_path: undefined": fmt.Sprintf("base_path: '%s'", siteConfig.BasePath),
|
||||||
|
"api: undefined": fmt.Sprintf("api: '%s'", siteConfig.ApiURL),
|
||||||
|
}
|
||||||
|
for k, v := range replaceMap {
|
||||||
|
conf.RawIndexHtml = strings.Replace(conf.RawIndexHtml, k, v, 1)
|
||||||
|
}
|
||||||
UpdateIndex()
|
UpdateIndex()
|
||||||
}
|
}
|
||||||
|
|
||||||
func UpdateIndex() {
|
func UpdateIndex() {
|
||||||
siteConfig := getSiteConfig()
|
|
||||||
favicon := setting.GetStr(conf.Favicon)
|
favicon := setting.GetStr(conf.Favicon)
|
||||||
title := setting.GetStr(conf.SiteTitle)
|
title := setting.GetStr(conf.SiteTitle)
|
||||||
customizeHead := setting.GetStr(conf.CustomizeHead)
|
customizeHead := setting.GetStr(conf.CustomizeHead)
|
||||||
@ -35,9 +43,6 @@ func UpdateIndex() {
|
|||||||
replaceMap1 := map[string]string{
|
replaceMap1 := map[string]string{
|
||||||
"https://jsd.nn.ci/gh/alist-org/logo@main/logo.svg": favicon,
|
"https://jsd.nn.ci/gh/alist-org/logo@main/logo.svg": favicon,
|
||||||
"Loading...": title,
|
"Loading...": title,
|
||||||
"cdn: undefined": fmt.Sprintf("cdn: '%s'", siteConfig.Cdn),
|
|
||||||
"base_path: undefined": fmt.Sprintf("base_path: '%s'", siteConfig.BasePath),
|
|
||||||
"api: undefined": fmt.Sprintf("api: '%s'", siteConfig.ApiURL),
|
|
||||||
"main_color: undefined": fmt.Sprintf("main_color: '%s'", mainColor),
|
"main_color: undefined": fmt.Sprintf("main_color: '%s'", mainColor),
|
||||||
}
|
}
|
||||||
for k, v := range replaceMap1 {
|
for k, v := range replaceMap1 {
|
||||||
|
Reference in New Issue
Block a user