feat(ftp): support upload, download and PASV rebind (#13)

Co-authored-by: E99p1ant <[email protected]>
This commit is contained in:
Li4n0
2021-05-05 12:59:50 +08:00
committed by GitHub
co-authored by E99p1ant
parent 3d8507e682
commit b39ee101f9
15 changed files with 374 additions and 146 deletions
+2 -1
View File
@@ -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)
}
+9 -4
View File
@@ -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{