mirror of
https://github.com/Li4n0/revsuit.git
synced 2026-09-24 23:51:54 +08:00
feat(ftp): support upload, download and PASV rebind (#13)
Co-authored-by: E99p1ant <[email protected]>
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/li4n0/revsuit/frontend"
|
||||
"github.com/li4n0/revsuit/internal/file"
|
||||
"github.com/li4n0/revsuit/pkg/dns"
|
||||
"github.com/li4n0/revsuit/pkg/ftp"
|
||||
"github.com/li4n0/revsuit/pkg/mysql"
|
||||
@@ -101,6 +102,6 @@ func (revsuit *Revsuit) registerHttpRouter() {
|
||||
|
||||
// init file router group
|
||||
fileGroup := revsuit.http.ApiGroup.Group("/file")
|
||||
fileGroup.GET("/mysql/:id", mysql.GetFile)
|
||||
fileGroup.GET("/:record_type/:id", file.GetFile)
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package server
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/li4n0/revsuit/internal/database"
|
||||
"github.com/li4n0/revsuit/internal/file"
|
||||
"github.com/li4n0/revsuit/internal/notice"
|
||||
"github.com/li4n0/revsuit/pkg/dns"
|
||||
"github.com/li4n0/revsuit/pkg/ftp"
|
||||
@@ -53,7 +54,7 @@ func initDatabase(dsn string) {
|
||||
if err != nil {
|
||||
log.Fatal(err.Error())
|
||||
}
|
||||
err = database.DB.AutoMigrate(&mysql.File{})
|
||||
err = database.DB.AutoMigrate(&file.MySQLFile{})
|
||||
if err != nil {
|
||||
log.Fatal(err.Error())
|
||||
}
|
||||
@@ -73,13 +74,17 @@ func initDatabase(dsn string) {
|
||||
if err != nil {
|
||||
log.Fatal(err.Error())
|
||||
}
|
||||
err = database.DB.AutoMigrate(&file.FTPFile{})
|
||||
if err != nil {
|
||||
log.Fatal(err.Error())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func initLog(level string) (logLevel log.Level) {
|
||||
|
||||
switch level {
|
||||
case "debug":
|
||||
case "debug", "trace":
|
||||
gin.SetMode(gin.DebugMode)
|
||||
database.DB.Logger.LogMode(logger.Info)
|
||||
logLevel = log.LevelTrace
|
||||
@@ -87,7 +92,7 @@ func initLog(level string) (logLevel log.Level) {
|
||||
gin.SetMode(gin.DebugMode)
|
||||
database.DB.Logger.LogMode(logger.Info)
|
||||
logLevel = log.LevelInfo
|
||||
case "warning":
|
||||
case "warning", "warn":
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
database.DB.Logger.LogMode(logger.Warn)
|
||||
logLevel = log.LevelWarn
|
||||
@@ -133,8 +138,8 @@ func initNotice(nc noticeConfig) {
|
||||
|
||||
func New(c *Config) *Revsuit {
|
||||
|
||||
initDatabase(c.Database)
|
||||
logLevel := initLog(c.LogLevel)
|
||||
initDatabase(c.Database)
|
||||
initNotice(c.Notice)
|
||||
|
||||
s := &Revsuit{
|
||||
|
||||
Reference in New Issue
Block a user